A PayPal REST API sandbox to experiment with payments and subscriptions
I did my best to make easy to get started experimenting with the PayPal REST API. If something is not clear or can be improved, your contribution is welcome!
- create orders (one-time payments)
- create subscriptions
- list and create products
- list and create plans
- list, create and delete webhooks
- process webhook notifications received from PayPal
- php 8.x
- composer
- ngrok
-
git clone the project
-
install composer dependencies
composer install
-
copy
.env.example
to.env
and fill in your PayPal REST api credentials. If you don't have credentials yet, follow the guide: -
You will also need both a sandbox user account and sandbox business account. You get those from:
-
start the website
php -S localhost:80 public/router.php
- start ngrok to receive PayPal notifications to your development environment
ngrok http 80
- head to
http://localhost
in your browser
The demo when started automatically lists all existing products, plans and webhooks.
Once started, you can place an order (use the ngrok url as return url) For subscriptions, if you never used the PayPal REST api before, you will need to create a product, a plan and a webhook first.
To debug the javacript code, the browser needs to be started with the remote debugging option. For example, on Windows:
"C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222
Then in Visual Studio Code, use js attach to browser
.