Everyone’s been really excited about PayPal REST API since its launch, so I decided to try and explore PayPal’s new RESTful web service. And after playing a bit with it, I was able to create my own simple online cell phone store successfully. Here’s how!
Before we continue, make sure you have signed up for PayPal Developer account for testing mode, and for production mode you will need real PayPal account. Obtain your Client Id and Client Secret from developer portal (for testing) OR from your real PayPal account (for production mode). PayPal REST SDK requires PHP version 5.3.0 +, so make sure your PHP is latest.
PayPal PHP SDK is included in downloadable file below, but you can get your own copy from github. If you are using composer, just point to downloaded file and give “composer update” command to have your SDK updated to latest version. Well, you can forget whole composer thing right now if it doesn’t ring a bell!
Back to tutorial, I have created four files for my Online Cell Phone store, but we only need to focus on first two files to get things done. Other two files are helper script and cancellation page.
In this page I have created list of items I want to sell, each item has HTML form, which contains its name, quantity, code and price ready to be posted to Order_process.php. I have tried using some CSS to make it look good, but hopefully you will do it better.
Next we look into order processes page. Here you might get bit confused, but the steps are fairly simple, let me make bit easier for you by pointing out the steps below.
That’s it! you should now have a functional online store of your own using PayPal REST API. There is now just one more step to follow. Before you make it live find sdk_config.ini config file, open it and change Service mode to live and don’t forget to enter real PayPal client ID and Secret in order_process.php.
PayPal REST API has lots of new features and supports a number of countries and currencies, please check whether your country is in the list. For countries not yet supported by the REST API, you can take a look at my other tutorial about PayPal.