How to Integrate PayPal Payment Gateway in PHP?

Now a days there are lots of the service provider of payment gateway for online website like as a ccavenue payment gateway integration in php, razorpay payment gateway integration in php, stripe payment gateway integration in php and paytm payment gateway integration in php.

Payment gateway integration in PHP With Database Connection

Payment integration in PHP is very simple. Please follow the below step by step to integrate Payment gateway in your PHP source code online website with I provided paypal payment gateway integration in php source code download.

  • EBS
  • Paytm
  • PayPal
  • Citrus
  • DirecPay
  • ccavenue
  • Payumoney
  • Fonepaisa
  • Atom Paynetz

What is Payment Gateway ?

Payment Gateway is a one type of the bridge between the credit card merchant holder and Credit card any types of the Company to establish a secure and trustable connection between them to interchange the userful data.

This Payment system securely sends your credit card details from the online website to the credit card great company for processing and then returns with your transaction information and response from the bank.

Some of the most Popular secure and trustable Payment gateway examples are: Atom Paynetz, Citrus, Fonepaisa, Paytm, ccavenue, PayPal, Payumoney, EBS, DirecPay with debit card payment gateway integration in php etc., pay pal, discover credit card, facebook sign in, loign,, pay

In this Article, You will Know

PayPal Payment Gateway integration in PHP

PayPal is an American international e-commerce company which support a virtual platform for secure, trustable and safety online money transaction on Internet.

PayPal payment Gateway is a widely used payment gateway used by different web developers for their web pages to establish secure online money transfer.

It is the best and easiest methods for web developers to implement a payment system to their online Web Applications.

PayPal gateway:-

PayPal uses its own gateway for the transaction known as Pay flow. PayPal is available for both free and paid based on merchant.

Language used in PayPal Payment gateway

PayPal Payment gateway is Front end is created on HTML source code, CSS source code, JavaScript source code and web application layer is full coded on Java as well as Node J.S.

How to Integrate ?

Here is a phase to phase full information for you to how to integrate this to your online web applications.

You need to add the following functionalities for a payment gateway.

PHP - Paypal Payment Gateway Integration
PHP – Paypal Payment Gateway Integration

  1. Create the HTML form to get a credit card details.
  2. Generate Stripe token to securely as well as transmit card details.
  3. and then Submit the form and save with card informations.
  4. Now, Verify and check the card as well as step by step process charges.
  5. last all the data Insert payment informations in the database mysql for status(Cancel, Success) to be shown to the user.

It uses two environments Like as a

  • Sandbox
  • Real-Time.

Sandbox (for test purpose) is a self-contained virtual environment all the platform testing which makes a mimic of live environment which allow developers to test purpose their transactions without any types of the affecting any live PayPal accounts.

Real-time (Live) means when your application will go online. And then coding and debugging all you PayPal API in the sandbox move your application to PayPal production environment to go live.

Steps To integrate PayPal Payment Gateway using PHP.

step : 1. Make Sandbox Account

You required to make a Sandbox Account for testing your code. For make your account please visit to this Link.


step : 2. Make Index.php file

Now you have to make a display output or index file, this file will fetch all the product records from the database and display it onto page.

step : 3. Make a success.php file

Now we have to make a success file for identify your payment when your transaction will be succeeded it will return here. Remember that in case of success transaction the gateway will return you following details.

  1. Item_number
  2. Transaction_ID

So by keeping this in your mind you have to write your source code.

step : 4. Make a Cancel.php file

I also required to make a cancel php file when the transaction will be cancel then it will redirect here.

step : 5. Going Live

here last step to Once everything is working good including step by step the payment transactions Sandbox mode processing flow after that you can go here simple live URL using your PHP source code. Just update the sandbox(testing) mode to live mode.

paypal express checkout
paypal express checkout

Also Read: Paypal Recurring Payments PHP REST API Example

payment gateway in php and mysql Example

Connection File

fetch Products from database


 Paypal Integration in PHP -



payment gateway integration in php

Also Read: Laravel 5.4 Paypal integration – Paypal Payment Gateway


Your payment has been successful.

Your payment has been successful.

Your Payment ID - .

Your payment has failed.


PayPal Transaction Cancel - 


Your PayPal transaction has been canceled.

Also Read: paypal payment Gateway Integration with laravel 5.5 -Paypal checkout Laravel

I hope you get an idea about payment gateway integration in php.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Comment