Integration of php and paypal

Source: Internet
Author: User
In the past few days, the boss needs to integrate paypal into the system to facilitate transactions. I am idle. therefore, this job falls into me. no clue at all. you can only google it first. I searched for it for more than half a morning and understood it at noon. fortunately, paypal provides a complete reference document. i'm dizzy. recently I used the paypal payment function for two days. Depressed.
Take a note first, write down the completed part, and forget it later.
1. Register the SandBox account and create two virtual accounts. you can select the one automatically created. One buyer and one seller. For testing during development.

2. code for quick purchase. The link is currently directed to SandBox for testing during development. It will be officially changed later.

The code is as follows:


If (! Defined ("_ f_afficherButtonPayPal "))
{Define ("_ f_afficherButtonPayPal", 1 );
Function afficherButtonPayPal ($ nbr_point, $ montant)
{

Echo" ";
Echo"

";
}
}


3. transfer the paid information back to IPN, which has not been completed yet.

Additional information:
Learn from the reference documents:
Paypal specially developed Sandbox for developers to perform development and testing.
First register a development account in https://developer.paypal.com,
Go to Sandbox and create a Paypal virtual account for testing (at least one Business account and one Personal account should be created ),
This account registration method is the same as the Paypal process. information can be fake, including bank accounts and credit cards (in fact, Paypal Sandbox will automatically generate

Some random numbers ). Activate the virtual account of the Paypal Sandbox. Note that no matter what email address you fill in when registering the Paypal Sanbox

Any emails sent to the Email address entered by the virtual account are saved on the Email page (on the navigation bar) on the management interface of the development account. Log on to Sandbox

In the virtual Paypal environment, you also need to verify the bank of the virtual account. here you can fill in as needed, and then Add Funds to recharge the account (you want to fill in more)

Less ). Then, you also need to activate the IPN option. on the Profile settings page of the Business account, click, and then click the Edit button to open

IPN. if you are using a fixed IPN Handle, you can enter the address directly.
Next, we should set the address of the Paypal interface to https://www.sandbox.paypal.com/cgi-bin/webscr during the test
The basic process is as follows:
The user selects products on our website, puts them in the shopping cart, and then checks for the preparation and payment
The website generates a payment form for Paypal based on the items in the shopping cart (which is also the address of the Paypal interface used for submission to IPN), including one of

Some information (next time I will look for a special opportunity to explain ). And generate an order record in your database.
Paypal records the transaction information in the Session.

Use a Paypal account to log on to Paypal (Sandbox's virtual account), review details, and click Pay.
Paypal handles transactions. if our Paypal account has no problems with the account to be accepted (there is no special place to Accept ),

Then, Paypal will send an IPN and send a prompt email.
When IPN Handler receives the information, it first checks the information with Paypal. if the information is correct, it compares the information with the information in its own database. if

You can save the payment information and modify the order status.
Then, Paypal will display an interface indicating that the transaction is complete. if you click "Return", Paypal will send the user back to the specified location on our website.
Our website welcomes the user back, expresses thanks to the user, reminds me, and gives the order number.
It should be my final requirement that I only need to settle the total price and do not need to join the online store. so it's much simpler. just generate the total price and put it in paypal.

Done. if the online store still needs to set a lot of parameters in paypal. it is troublesome.

The code is as follows:


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.