PHP • PayPal REST-API :: How to

If you want to use ExpressCheckout via the REST API from Paypal, you can follow these steps to get a working API within your webapp.

1. Install Composer, Curl and PHP on a Webserver

2. a) Create a composer.json file with following data from the top of this page:

2.b) Install the libraries with composer install

2.c) Include the autoload.php from the Composer installation with a require_once.

3.a) Setup the REST-API-SDK-PHP library files with your credentials from the Paypal developer site: sdk_config.ini and in the bootstrap.php that could be found in the folder vendor/paypal/rest-api-sdk-php

3.b) Set up a define command with a pointer to the sdk_config.ini file. define(‘PP_CONFIG_PATH’, …path to the sdk_config.ini file…);

4. Build a form with a PayPal-button and send the form parameters via $_POST to this file:

5. After successful payment from the Paypal website you have to redirect the user to this file:

You are done!