Вы находитесь на странице: 1из 4

What is Paypal

PayPal is an international e-commerce business allowing payments and money transfers to be made
through the Internet. Online money transfers serve as electronic alternatives to paying with traditional
paper methods, such as cheques and money orders.
How to implement Paypal payment gateway
Step 1: Create a paypal developer account
Go to https://developer.paypal.com/ and click signup button to create paypal developer account.
Step 2: Set up PayPal sandbox seller and buyer account.
What is sandbox: Sandbox is the testing environment of PayPal. It words as real account but it is
only for testing. All the balance, transaction etc will be for testing.
Now we will create two test accounts one for seller and second one for buyer.
First of all open http://developers.paypal.com/ and login there using email id and password of main
account. Which we have created in step 1 and navigate to Applications > Sandbox Accounts.
Account type: Tick either the Personal or Business radio button.
Email address: The email address doesn't need to be a real email address; the Sandbox doesn't send
any email outside of the Sandbox environment. Emails to Sandbox accounts, generated as a result of
your test API requests, are listed on both the Notifications tab on the Developer site, as well as on the
Sandbox test site.
Password: The password must be 8-20 alpha-numeric characters in length. Use the password to log in
to the Sandbox site as the test account.
First and Last names: The optional name fields accept alpha-numeric characters.
PayPal balance: While this field is optional, it's a good idea to create test accounts with positive bank
balances. Enter an integer value between 1 and 5000.
Bank Verified Account: You should create both Verified and Unverified test accounts so you can fully
test your application.
Select Payment Card: Test payments made with different payment cards by selecting
either Discover or PayPal. (Personal accounts only.).
Credit card type: You must select a single credit card type for each test account. The Sandbox
associates a mock credit card number with the account.
Click Create Account after completing the account details.
See details in https://developer.paypal.com/docs/classic/lifecycle/sb_create-accounts/
Step 3 : Build web page and make payment using buyer account.
In this step of PHP PayPal payment gateway integration, we will develop a web page into web server and
make a payment.
Create a new php file
<form name=_xclick action=https://www.sandbox.paypal.com/webscr method=post><!--
paypal sandbox post url-->
<input type=hidden name=cmd value=_xclick>
<input type=hidden name=business value=seller@example.com> <!--Paypal sandbox seller
account email id-->
<input type=hidden name=currency_code value=USD> <!--enter your currency code-->
<input type=hidden name=item_name value=Computer Harddisk> <!--enter the item name--
>
<input type=hidden name=amount value=1><!amount of transaction needs to be credited
to your paypal account-->
<input type=image src=http://www.paypal.com/en_US/i/btn/btn_buynow_LG.gif border=0
name=submit alt=Make payments with PayPal its fast, free and secure!>
</form>

Set Return url and IPN url
What is return url: Return url is a url where paypal site back after transaction.
How to set return url: Please Go to https://www.sandbox.paypal.com/ and login using seller
account. After that go to profile > my selling tools. After that click on update of Website
preferences. And set to ON of Auto return. And type return URL. And payment data transfer to ON and
other all as per you need.
What is Instant Payment Notification (IPN)
Instant Payment Notification allows you to integrate your PayPal payments with your website's back-end operations,
so you get immediate notification and authentication of the PayPal payments you receive.
How It Works
When a customer makes a payment to you or a payment is reversed or refunded, PayPal will post a notification to
your server at the URL you specified. Included in this notification will be all of your customers payment information
(e.g. customer name, payment amount) as well as a piece of encrypted code. When your server receives a
notification, it will then post the information, including the encrypted code, back to a secure PayPal URL. PayPal will
authenticate the transaction and send confirmation of its validity back to your server.
Note: To activate Instant Payment Notification, you will need to enter the URL at which you would like to receive the
notification posts from your Profile.
After you have activated Instant Payment Notification, your server will be sent a notification every time you receive a
payment, this notification will be sent as a hidden "FORM POST" to the URL you specified, and will include all of the
payment information. Each time you receive an IPN from PayPal, you must complete the Notification Validation
process described below before fulfilling the order. Verifying the information listed will ensure that the transaction is
legitimate.
Notification Validation
To ensure that a payment has been made into your PayPal account, you must verify that the email address used as
your "receiver_email" has been registered and confirmed in your PayPal account.
Once your server has received the Instant Payment Notification, you will need to confirm it by constructing an HTTP
POST to PayPal. Your POST should be sent to https://www.paypal.com/cgi-bin/webscr
as you received them. You will also need to append a variable named "cmd" with the value "_notify-validate" (e.g.
cmd=_notify-validate) to the POST string.
PayPal will respond to the post with a single word, "VERIFIED" or "INVALID", in the body of the response. When you
receive a VERIFIED response, you need to perform several checks before fulfilling the order:
Confirm that the "payment_status" is "Completed," since IPNs are also sent for other results such as "Pending" or
"Failed"
Check that the "txn_id" is not a duplicate to prevent a fraudster from using reusing an old, completed transaction
Validate that the "receiver_email" is an email address registered in your PayPal account, to prevent the payment
from being sent to a fraudster's account
Check other transaction details such as the item number and price to confirm that the price has not been changed
Once you have completed the above checks, you may update your database with the IPN data and process the
purchase.
If you receive an "INVALID" notification, it should be treated as suspicious and be investigated.
Please see more at https://www.paypal.com/cgi-bin/webscr?cmd=p/acc/ipn-info-outside
See the sample IPN script here: https://github.com/paypal/ipn-code-samples/blob/master/paypal_ipn.php.
See About IPN on github: https://github.com/paypal/ipn-code-samples.
How to set IPN url: Please Go to https://www.sandbox.paypal.com/ and login using seller account.
After that go to profile > my selling tools. After that click on update of Instant payment
notifications. And set to Enabled of Message delivery. And type Notification URL.

Вам также может понравиться