8ctopus/paypal-rest-api

0.4.0 2024-03-29 13:37 UTC

This package is auto-updated.

Last update: 2024-03-29 13:39:28 UTC


README

packagist downloads min php version license tests code coverage badge lines of code

php implementation of PayPal's REST api using PSR-7, PSR-17 and PSR-18.

It is a work in progress and contributions are welcome. For now, it covers subscriptions (Products and Plans) and web hooks.

install

composer require 8ctopus/paypal-rest-api

demo

Run demo.php to see what is possible. Here's a code snippet:

use HttpSoft\Message\RequestFactory;
use HttpSoft\Message\StreamFactory;
use Nimbly\Shuttle\Shuttle;
use Oct8pus\PayPal\Hooks;
use Oct8pus\PayPal\OAuth;
use Oct8pus\PayPal\HttpHandler;

require_once __DIR__ . '/vendor/autoload.php';

$sandbox = true;

$handler = new HttpHandler(
    // PSR-18 http client
    new Shuttle(),
    // PSR-17 request factory
    new RequestFactory(),
    // PSR-7 stream factory
    new StreamFactory()
);

// get oauth token
$auth = new OAuth($sandbox, $handler, 'rest.id', 'rest.pass');

// list webhooks
$webhooks = new Hooks($sandbox, $handler, $auth);
var_dump($webhooks->list());

run tests

composer test

references