PayPal is an American Company Founded in 1998 by Palo Alto of California "United States". It provides services to users of online payment globally such as money transfer and traditional payment methods like checks and money orders.
In today's world PayPal has become a very popular payment gateway system to send and receive payment worldwide.
Also, It is an easiest and simplest way to the web developer for implementing payment system on the website. Hence it is true to say that PayPal is a widely used payment gateway to accept payment in the web application.
In this tutorial, we will learn to "Integrated Standard PayPal Gateway in PHP".
Step 1: First you have to create a Paypal Sandbox account.
There are two accounts in Paypal Sandbox
Personal/Buyer => This account represents the buyer or sender, When user goes for the transaction.
Business/Merchant => This account represents the merchant, or receiver, in a transaction.
Step 2: Now create products.php for payment system
Using above code your products.php page will be created for payment system on that page you will have subscribe button.
Step 3:Now you have to click on subscribe button and you will redirect to PayPal payment page, on that page you have to login with your PayPal Sandbox id "Personal/Buyer" and after that you will be able to do payment where user will find two options, one will be, proceed for payment and another one will be, cancel payment and once if you select proceed for payment you will redirect on success.php page with below data.
$item_no = $_REQUEST['item_number'];
$transaction_id = $_REQUEST['tx']; // Paypal transaction ID
$amount = $_REQUEST['amt']; // Paypal received amount
$currency_code = $_REQUEST['cc']; // Paypal received currency type
//checking the payment details
echo "<h1>Welcomem, User</h1>";
echo "<h1>Your payment has been Successful.</h1>";
echo "<h1>Error ! Payment Failed .</h1>";
Or If you select cancel payment option then you will redirect to below cancel.php page
Step 4 -> Once everything is set, after that you should test your web application payment system workflow and if it is working fine then you have to change your form action API URL to original API URLs also you have to change seller email id.
you can see below for better understanding
$paypalUrl='https://www.sandbox.paypal.com/cgi-bin/webscr'; // it is sandbox url
now here you will change your original API URLs, as below:
Well, this was fun. Isn’t it? If you have any question and wanted to share your thoughts please feel free to share in the comment section below.