Paypal standard integration script using PHP

Hello friends, today I will show you paypal standard integration using PHP. PayPal is an international e-commerce business that allow payments and money transfers to be made through the Internet. We are using payPal to transfer money from one account to another. If we want to buy some products from an online shop, we can make the payment through paypal if there is any option for paypal. In this application I am creating a form where user will submit his/her information, after clicking submit it will be redirected to paypal site where user put their username, password and buy the item or they can pay with credit card also. After making a payment paypal will silently post user information to our site, we will validate the data and save this into our database. At last user will see a success page if all are ok.

Step 1: Create a database table for saving user information and payment related status.

DROP TABLE IF EXISTS payment_history;
CREATE TABLE IF NOT EXISTS payment_history (
order_id varchar(255) NOT NULL,
first_name varchar(255) NOT NULL,
last_name varchar(255) NOT NULL,
email_address varchar(255) NOT NULL,
product_price varchar(255) NOT NULL,
status varchar(255) NOT NULL,
response varchar(255) NOT NULL,
all_data text NOT NULL,

Step 2: Now create a payment form for user where they put their information. I name it index.php.

Step 3: In this step I create a form.php where submitted user data will be taken and then post to paypal site.

I make it simple for understand but you can validate user information here.

Step 4: Now you are in paypal website. Pay with your paypal account information and make payment.

After hitting Pay Now button payment will send user info and all payment related information to your notify_url. For me it is callback.php

Step 5: Create success.php where user will be redirected by paypal after successful paypal.

Step 6: Create cancle.php

If user click on “Cancel and return to abhijit pal’s Test Store.” before payment they will be redirected to this page.

So now you can easily do paypal standard integration using PHP

Spread the love
  • 2