In the previous post, we had created a simple PHP session based shopping cart, now in this article we will integrating this shopping cart with our PayPal express checkout system. Main idea is to let users buy multiple items using PayPal, shopping cart collects the items users want to buy and then they’ll be able to pay for multiple items using their PayPal account.
View Cart Page
In viewcart.php I have added a “Pay with PayPal” button, once clicked it will redirect user to PayPal express checkout page. The express checkout page uses existing session variable from the shopping cart to determine the costs, taxes and additional fees. Then user will be redirected to PayPal’s item summery view, where user can pay using their PayPal account.
Paypal Express Checkout
I’ve copied the Paypal Express Checkout folder into shopping cart and modified it to use shopping cart session variables, we just calculate the quantity and total amount and send it to PayPal. Have a look at the code below.
That’s it, this is the main modification here, rest is explained in my previous post PayPal express checkout. Without making things further complicated, I want you to download and test the script yourself, but nothing is perfect, so if you want to leave some feedback or improvement suggestions please do so by commenting below. Good luck!