Original Address: http://www.oueasy.com/2010/0101/2108713.html
It must understand the basics:
IPN's principle is very simple when produced after a transaction, the transaction status changes, such as the user has paid, or refund, revoked, Paypal use of commonly used HTTP POST method, will trade some of the variables submitted to the site a page (called IPN Handler), when the page receives the request when the data intact would be to add a direct verification of the cmd = _notify-validate, POST interface back to Paypal address, if the data is correct, then Paypal returns the string VERIFIED, otherwise INVALID, if the result is VERIFIED, then your program can use the data to operate.
However, the debug code is a very painful thing, because as a third-party developers, it is impossible to open two accounts, transactions between each test but also some money, so Paypal Sandbox specifically developed to developers for development, first to https: / / developer.paypal.com / register a development account, well into the Sandbox after the establishment of a virtual test of the Paypal account (at least to establish a Business and a Personal's), this method of registration and the Paypal account of process, as information can be false, including bank account numbers, credit card (actually Paypal Sandbox will automatically generate a random number). Then need to activate the virtual Paypal Sandbox accounts, pay attention, no matter where you fill in the registration Paypal Sanbox what e-mail address, any mail sent to the virtual account filled messages are deposited in the Development Account in the Email management interface page ( navigation bar available). Login Virtual Sandbox
Paypal environment, also need to verify that the virtual bank account, where you can easily fill in, and then to the account through Add Funds to recharge (the number of Reclamation to fill in the number)
The detailed settings on the IPN
Log in to Paypal back into the My Account-> Profile page, click on Instant Payment Notification, as below:
Then will appear the following page, and click the Edit button, as shown:
Then the following page will appear, and the page inside the box office tick, and fill out the following Notification URL Service: http:// your website address / index.php? GOo = cGF5cGFsX3JlcGx5LnBocA & then click the Save button the following diagram:
Then the page will prompt you: "You have successfully activated Instant Payment Notification."
Then re-enter the My Account-> Profile page, click on Website Payment Preferences, as shown below:
And then will enter Website Payment Preferences page, in which to do four things:
1: Auto Return On the back of tick
2: Return URL behind the input: http:// your website address / index.php? GOo = cGF5cGFsX3JlcGx5X3JldHVybi5waHA &
3: Payment Data Transfer On the back of tick
4: above all do a good job, click on the Save button on the bottom page the following chart:
Save the page immediately after the jump to the My Account-> Profile, and prompts you to set up, which will have a bunch of identity token number, that is the private key, as shown below:
Of course, this private key (identity token) will only appear this time, after you've set up, you can still enter the Website Payment Preferences page to view it, it was in the Payment Data Transfer a block, as shown below:
Next, we tested, it should be Paypal interface address is set to https: / / www.sandbox.paypal.com / cgi-bin / webscr
Finally the basic process:
Users to choose products on our website, add to shopping cart, then check the website under the shopping cart ready to pay in goods, produce Paypal payment form (also submitted to the above with the Paypal IPN interface, address), contains the transaction some of the information (the next will be specifically looking for the opportunity to explain). And in its own database to generate an order record. Paypal in the Session in the record these transactions using Paypal account information users log Paypal (Sandbox Sandbox using the virtual account number), review details, click on the Pay button and Paypal transaction processing, if our Paypal account in the acceptance of accounts receivable does not have any problem (no particular need to Accept the place), completion of the transaction, it will send a Paypal IPN, and send prompt messages.
IPN Handler we receive information, first of all to Paypal for verification, if the information is correct, then according to the information and to compare their database, if correct, you can save payment information, and modify the order status.
Then Paypal will display an interface that completion of the transaction, then if the user clicks "Return" button, Paypal will be the user back to the designated place on our website.
Welcome back to our site users, thanks to the user, and be reminded, order number, etc. are given.
If clear text, then it and the compressed file inside paypal.htm general
<form target="paypal" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post"> <input type="image" src="/uploadfile/2010/0101/20100101125037948.gif" border="0" name="submit" alt="PayPal is the safer, easier way to pay - PayPal"> <!-- Once the purchase <input type="hidden" name="add" value="1">--> <!-- This is not an integrated shopping cart, if the code is value="_cart" Represents a PayPal shopping cart ready . --> <input type="hidden" name="cmd" value="_xclick"> <!-- The seller's PayPal account --> <input type="hidden" name="business" value="[email protected]"> <!-- This is from my Web site delivered by the trade name and order number --> <input type="hidden" name="item_name" value="BoAo International Trading 20071212s1p1u1"> <input type="hidden" name="item_number" value="20071212s1p1u1"> <!-- This is the price, how can I transfer won't say ~ --> <input type="hidden" name="amount" value="15"> <!-- Quantity --> <input type="hidden" name="quantity" value="1"> <!-- Currency type CNY: RMB ,USD: US dollar --> <input type="hidden" name="currency_code" value="USD"> <!-- Cancel the transactions and the location to return --> <input type="hidden" name="cancel_return" value=" http://www.hotweb.net.cn/?state=null"> <!-- Transactions after the returned location --> <input type="hidden" name="return" value="http://www.hotweb.net.cn/?state=OK"> <input type="hidden" name="no_shipping" value="1"> <input type="hidden" name="charset" value="UTF-8"> <input type="hidden" name="notify_url" value="http://www.hotweb.net.cn/?state=notify"> <input type="hidden" name="add" value="1"> <input type="hidden" name="no_note" value="1"> <input type="hidden" name="bn" value="PP-BuyNowBF"> </form>
Some of the folders and files a brief description: [App_Code] put a few necessary classes
[Bin] deposited the payment interface of a DLL file to decrypt the encrypted
[EWPcert] systems need to use a security certificate
CheckOut.aspx equivalent of B2C Web site shopping cart, the program from here
NotifyUrl.ashx 2 times POST security authentication page, the more important
PDTResponse.aspx page for return information, we can achieve through this page, it's a series of transactions into their own database of information used to verify whether the user has paid
---------[ App_Code ]-----------
CHECK OUT] [ButtonEncryption.cs encrypted password string button, equivalent to some of the basic parameters it expressly direct encrypted
Constants.cs global variable, used for storing settings of some basic information PAYPAL
NVPCodec.cs code conversion
Utils.cs for security authentication when used
---------[ EWPcert ]-----------
sandbox_cert_pem.txt PAYPAL public certificate
sdk-ewp.p12 a similar certificate like some of it, to not know much about this [