Recently, the website needs to connect to the international payment interface PayPal, and it took a few days to record the pitfalls it encountered for later use.
1. The first step is to apply for a merchant account on the official websiteThe hyperlink login is visible.I don't know the specific steps here, after all, I didn't come to apply
2. Because we are using the website here, we use the most convenient website payment standard version, and the rest can also be implemented with the API of fast checkout.
First, we configure the parameter information we need to use into the config
Then we build the page code that requires us to post, and store the values that must be filled in the hidden domain <input type="hidden" />
These parameters are more important, and you can go to the official website to find relevant documents for a more comprehensive parameter introduction
3. The initiation code is okay, let's write the code to return and notify the page
On the notification page, we can get the following key parameters
We can use item_number parameters to correspond to the database, verify according to the pay_order to prevent reuse, and judge whether the transaction is successful based on pay_status (pay_status="Completed").
One thing to note here is that PayPal does not automatically return by default, and relevant configurations are required. Steps: User information - > sales notification - > website payment habit setting
Just set the two places in the picture to on.
4. The return page is generally only used to display the recharge results, and we generally put it on the notification page to handle the relevant business logic.
The ValidateSource method is mainly verified by calling the interface after the obtained parameters + "&cmd=_notify-validate" to see if the parameters have been tampered with during the passing process.
Note the red area above, this must be indispensable, the https interface we access, if the above code is missing, will report an exception: Request aborted: Failed to create an SSL/TLS secure channel
Well, after writing the above code, we can publish it to the server for testing, PayPal's test is still relatively good, providing us with a special test address, you can arbitrarily add merchants and personal accounts to test.
First, we log in with our registered account:The hyperlink login is visible.
After logging in we find
Here we will be given two default accounts, of course, you can also make any changes, and then we can test with the accounts we set
After the test is completed, if we want to log in to our test account to view information, we need to use this URL:The hyperlink login is visible.
We log in with the merchant account here, and here we also need to operate the configuration information in step 3 again.
Here you can also check our IPN information
Official introduction:The hyperlink login is visible.
|