...

Paypal

Integrate the Paypal Express Checkout on your website.


Thanks to Paypal API, you are able to sell some products and services easily via the Express Checkout Service.

Framework free, can be easily integrated with your existent platforms thanks to interface to implement to represent a basket, products and users

Features


Framework Free

Not dependent to a framework or a tool.

cURL compatible

Need only cUrl to perform request.

Easily integrable

Implement only interfaces on your classes.

GitHub


Fork the project on GitHub

It is open source! It's hosted, developed, and maintained on GitHub by folks like you.


View GitHub Project

Patreon


Support this project on Patreon

This project is free and will remain free, but it is developed on my free time. If you like it and help me maintain it and evolve it, don't hesitate to support me on Patreon. Thanks :) Richard.


Support it

Example



<?php

declare(strict_types=1);

require_once 
'vendor/autoload.php';

use 
Http\Discovery\HttpClientDiscovery;
use 
Http\Discovery\Psr17FactoryDiscovery;
use 
Teknoo\Paypal\Express\Service\ExpressCheckout;
use 
Teknoo\Paypal\Express\Transport\PsrTransport;

//Initialize Paypal library

//Transport object to communicate with curl
$transport = new PsrTransport(
    
HttpClientDiscovery::find(),
    
Psr17FactoryDiscovery::findUrlFactory(),
    
Psr17FactoryDiscovery::findRequestFactory(),
    
Psr17FactoryDiscovery::findStreamFactory(),
    
'https://api-3t.sandbox.paypal.com/nvp',
    
'93',
    
'user id',
    
'password',
    
'paypal signature',
    
'PP-ECWizard'
);

//Paypal service
$service = new ExpressCheckout(
    
$transport,
    
'https://www.sandbox.paypal.com/webscr?cmd=_express-checkout&token={token}'
);

//Prepare demo purchase
$purchase = new class implementing Teknoo\Paypal\Express\Entity\PurchaseInterface {
// ...
};

//In your html, purchase is an custom object implementing the interface PurchaseInterface
<a href="<?php echo $service->prepareTransaction($purchase); ?>">Process to checkout to paypal</a>

//On the result page
$result $service->getTransactionResult($_GET['token']);
if (
$result->isSuccessful()) {
    
/* ... */
} else {
    
$errors $result->getErrors();
}