A simple example of how to use PayPal Checkout in PHP.
This straightforward example shows you how to use PayPal Checkout to process a payment. You only need :
-
file class
PayPalController.php
that contains the code to process the payment. -
provide the client ID and secret of your PayPal app.
Here is a picture of the example (if you like sharks, you will love this sample) :
- Clone the repository.
git clone https://github.com/arthurlacoste/paypal-checkout-php.git
-
You have to use PayPal Sandbox to test the sample. You can create a sandbox account here.
-
Create a PayPal app here.
-
Provide the client ID and secret of your PayPal app in the file
app/config.php
(renameapp/config.php.example
). -
In your API view, handle the payment with the following code :
header('Content-Type: application/json');
require 'config.php';
require '../src/PaypalController.php';
$paypal = new PaypalController();
$response = $paypal->handlePayment($_POST);
echo $response;
- Everything is ready, now you can store the payment in your database by updating handlePayment() method in 'PaypalController.php' file. Another simple idea is to send an email to you & the customer with the payment details.
MIT License