The website USES PHP to implement the paypal integration method

  • 2020-03-31 21:18:09
  • OfStack

So today I'm going to talk about how to integrate your website with paypal.

First of all, go to paypal to apply for a number, after the information is complete, we can start to act. By the way, when applying for paypal, we should apply for an account that can accept payment from others.

Next, we really started integrating paypal with the site.

In fact, paypal offers a fool-happy way to create a payment button, but we don't usually use it because we write the customized payment button based on the actual situation of our website. Let's start with a piece of code:
 
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post"> 
<!--  Which account do you pay to? Here value Change to your account  --> 
<input type="hidden" name="business" value="recieve@gmail.com"> 
<!--  Define the type of button . --> 
<input type="hidden" name="cmd" value="_xclick"> 
<!--  define IPN Return mode of, 2 On behalf of post. --> 
<input type="hidden" name="rm" value="2"> 
<!--  Which page does the user go to after successful payment . --> 
<input type="hidden" name="return" value="http://www.sqlview.com/payment/notify.php"> 
<!--  Very important, self defined values . --> 
<input type="hidden" name="custom" value="myvalue"> 
<!--  Name of commodity . --> 
<input type="hidden" name="item_name" value=" Building a ticket "> 
<!--  Price of goods . --> 
<input type="hidden" name="amount" value="5.95"> 
<!--  The unit of price of a commodity . --> 
<input type="hidden" name="currency_code" value="USD"> 
<!--  Users can adjust the quantity of goods . --> 
<input type="hidden" name="undefined_quantity" value="1"> 
<!--  Submit buttons and pictures . --> 
<input type="image" src="https://www.sandbox.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"> 
<img alt="" border="0" src="https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1"> 
</form> 

I wrote down some of the most commonly used options for the submission form above, but of course, you can check the manual on paypal for special needs.

Mentioned in the form in front of the IPN (Instant Payment Notification), this is the key, is when the user pay after success, paypal sent us a notice, contains the transaction information variables, we specify the paypal send these variable information already set a good page to our website, we need the variable information through this page wrote in the database, page through $_POST can obtain desired information. To set up IPN, log into your paypal account, click the profile option, and set up IPN.

Ok, that sounds simple, so integrate paypal and your site can accept payments from users around the world!

Related articles: