PHP and PayPal integration methods

Source: Internet
Author: User
Tags copy final interface php and
I dizzy, recently this use PayPal payment function has done me 2 days, has not finished. Depressed dead.
Make a note first, write down the parts that have been taken care of, and forget about them later in the province.
1 registered sandbox account, and set up two virtual accounts, you can choose the automatically established one. A buyer, a seller. For the development of the test use.

2 Implementation of fast purchase code. Links temporarily point to sandbox for easy development testing. Change it into a formal later.
Copy CodeThe code is as follows:
if (!defined ("_f_afficherbuttonpaypal"))
{Define ("_f_afficherbuttonpaypal", 1);
function Afficherbuttonpaypal ($nbr _point, $montant)
{

echo "<td width=\" 50\ "> </td>";
echo "<td>
<form action=\ "https://www.sandbox.paypal.com/cgi-bin/webscr\" method=\ "post\" target=\ "_blank\" >
<input type=\ "hidden\" name=\ "cmd\" value=\ "_xclick\" >
<input type=\ "hidden\" name=\ "business\" value=\ "email_of_seller@emai.com\" >//This is the seller account you just established.
<input type=\ "hidden\" name=\ "item_name\" value=\ "$nbr _point points\" >
<input type=\ "hidden\" name=\ "currency_code\" value=\ "eur\" >//payment currency, I wrote the euro
<input type=\ "hidden\" name=\ "amount\" value=\ "$montant \" >//Total amount of quick payment
<input type=\ "image\" src=\ ". /src/img/x-click-but01.gif\ "name=\" submit\ "alt=\" Veuillez vous par payer ">//Show PayPal pictures
</form>
</td> ";
}
}

3 will have already paid the information back, should be used IPN, still not done, and then the next excitation

Supplementary information:
Learn from the reference documentation:
PayPal specializes in developing sandbox for developers to test
First to https://developer.paypal.com/to register a Development Account,
Enter sandbox to build the PayPal virtual account of the test (at least a business and a personal should be established),
This account registration method and PayPal process, the information can be false, including bank account number, credit card (in fact, PayPal sandbox will automatically generate

some random numbers). Then activate the PayPal sandbox virtual account, note, here, regardless of your PayPal sanbox registration when you fill in what mail

Address, any email sent to the virtual account will be stored in the email page (on the navigation bar) in the admin interface of the Development Account. Login Sandbox

Virtual PayPal environment, but also need to verify the virtual account of the bank, where you can easily fill in, and then add funds to the account recharge (want to fill in more than how many

Less). Then, you also need to activate the IPN option, in the Business Account profile Settings page, click, and then click the Edit button to open

IPN, here if you are using a fixed IPN Handle, you can directly fill in the address.
Next, when we test, we should set the address of the PayPal interface to HTTPS://WWW.SANDBOX.PAYPAL.COM/CGI-BIN/WEBSCR
The final basic process is:
Users select items on our website, put them in the shopping cart, and then check to be ready to pay
Website according to the goods in the cart, generate PayPal payment form (also submitted to the above IPN with the PayPal interface address), including the transaction of a

Some information (the next time will be a special opportunity to explain). and generate an order record in your own database.
PayPal records These transaction information in the session

User PayPal account login PayPal (sandbox with sandbox virtual account), review details, click on the Pay button
PayPal to deal with transactions, if our PayPal account number in the acceptance of the account does not have any problems (there is no special need to accept place), trading

Done, then PayPal will send an IPN and send a prompt message.
We IPN handler received information, first to PayPal for verification, if the information is correct, and then according to the information and their own database in comparison, if

Correct, you can save the payment information and modify the order status.
PayPal will then show an interface to the completion of the transaction, at this time if the user clicks the "Return" button, PayPal will send users back to our site designated location.
Our website greets the user to return, expresses thanks to the user, and carries on the reminder, gives the order number and so on.
Should be for my final demand is only a total price of the settlement, do not need to engage with the shop. So it's a lot simpler. As long as the total price generated, put in PayPal in the basic calculation

It's done. If the shop will also need to set a large pile of parameters in PayPal. More trouble.
Copy CodeThe code is as follows:
<form name= "Paypay_form" action= "HTTPS://WWW.PAYPAL.COM/CGI-BIN/WEBSCR" method= "POST" ><!--submitted address-->
<input type= "image" Src= "http://www.jb51.net/article/Styles/Compact/Images/payicon.jpg" ></p><!-- Picture of the button-->
<input type= "hidden" value= "vihaoo_1195608276_biz@gmail.com" name= "Business" ></p><!--Collection Account-->
<input type= "hidden" value= "Products" name= "Item_name" ></p><!--payment details-->
<input type= "hidden" value= "Dweeww" name= "Item_Number" ></p><!--payment details-->
<input type= "hidden" value= "http://www.xxx.xxx" name= "return" ></p><!--returns address-->
<input type= "hidden" value= "150.0" name= "Amount" ></p><!--amount-->
<input type= "hidden" name= "Currency_code" value= "USD" ><!--currency-->
</form>


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.