Skip to content

arthurlacoste/paypal-checkout-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PayPal Checkout for Craft Commerce icon

Paypal Checkout PHP

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 :

  1. file class PayPalController.php that contains the code to process the payment.

  2. provide the client ID and secret of your PayPal app.

How to run the sample

Here is a picture of the example (if you like sharks, you will love this sample) :

  1. Clone the repository.
git clone https://github.com/arthurlacoste/paypal-checkout-php.git
  1. You have to use PayPal Sandbox to test the sample. You can create a sandbox account here.

  2. Create a PayPal app here.

  3. Provide the client ID and secret of your PayPal app in the file app/config.php (rename app/config.php.example).

  4. 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;
  1. 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.

Licence

MIT License

About

A simple example of how to use PayPal Checkout in PHP.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published