How to integrate paypal payment gateway using PHP

paypal-php

This post belongs to newbie PHP developer who wants to integrate paypal payment gateway in his website using PHP. This post will show you the very basic and quick method to integrate paypal using core PHP.

First of all need to create paypal developer account.
https://developer.paypal.com/developer/accounts
paypal-php

After that you’ll see two test email ids one for business type and other one for personal type. Where You’ll receive your paypal payment in your business account and you can purchase any item from your personal account. Both the account just for testing purpose you can use them for buying and selling items.

Time to start coding part.

create your project config file where you can set all configuration of your project like paypal url, paypal id etc.

config.php


// Your test paypal sandbox url, Replace it with live url after successful testing.
DEFINE('PAYPAL_URL', 'https://www.sandbox.paypal.com/cgi-bin/webscr'); 
 
// Set paypal marchent id.
DEFINE('PAYPAL_ID', 'YOUR_PAYPAL_ID');  // you can find thuis in your developer account it look like "[email protected]"
 
// Define your base currency
DEFINE('CURRENCY', 'USD')
?>

Create your payment page this is just for demonstration purpose you can change it according to your need.

index.php


 require_once('config.php');
?>






INTEGRATE PAYPAL PAYMENT GATEWAY IN PHP



Paypal Payment Gateway in PHP