PayPal Payment Gateway Integration in PHP with mysql

PayPal is an American international most popular payment gateway  allowing payments and money transfers to be made through the Internet to send and receive payment in worldwide. PayPal is a widely used payment gateway to accept payment through internet. In this post  I want to explain how to work Paypal payment system development and sending arguments while click buy now button. It’s simple and very easy to integrate in php.

Before Integration PayPal  need to create a paypal Sandbox Account

  1. First go to the PayPal Developer page and log in to your PayPal account. If you don’t have any PayPal account, sign up for a PayPal account before integration.
  2. Go to Dashboard -> Sandbox -> Accounts and create test accounts for seller and buyer by selecting Business and Personal respectively.
  3. Now login paypal sandbox with paypal business account and go to My Account ->Profile->My selling tools
  4. click on manage paypal buttons and copy the button code and paste in your page.
  5. Click on manage website preferences and turn on Auto Return and enter Return URL.
  6. Manage Instant payment notifications and select Receive IPN messages (Enabled) and enter Notification URL.

Paypal Example Source Code 

In this example I have created four files for paypal payment integration process. Files are

  1. index.php
  2. connection.php
  3. payment.php
  4. payment_cancel.php

Also need to first create a table “payment” in database with required fields which you want to store in database for future use.

Now create index.php file  and copy the below code and paste it in index.php file.

Next step to create database connection file connection.php   and copy the below code and paste in just created connection file.

Please change the connection parameter like username,password and database name in connection file.

When paypal transaction is success then return full details of transaction in array format. I have explained some variable like item_no,transaction_id,amt,currency_code,payment_status etc.

Next Step we need to create success file and display transaction details which received from paypal .

All Done!

But before go to live make sure need to change paypal url from sandbox to live

5 thoughts on “PayPal Payment Gateway Integration in PHP with mysql”

  1. I think other website proprietors should take this site as an model, very clean and excellent user genial style and design, as well as the content. You’re an expert in this topic!

  2. Magnificent beat ! I wish to apprentice at the same time as you amend your web site, how can i subscribe for a blog site? The account aided me a appropriate deal. I have been tiny bit familiar of this your broadcast provided bright transparent idea

  3. Only wanna remark on few general things, The website pattern is perfect, the subject material is rattling good. “To the artist there is never anything ugly in nature.” by Franois Auguste Ren Rodin.


Leave a Comment