8ctopus / paypal-rest-api
PayPal REST api
0.4.0
2024-03-29 13:37 UTC
Requires
- php: >=8.1
Requires (Dev)
- clue/commander: ^1.4
- friendsofphp/php-cs-fixer: ^3.8
- hassankhan/config: ^3.1
- nimbly/shuttle: ^1.0
- nunomaduro/collision: ^6.2
- phpmd/phpmd: ^2.13
- phpstan/phpstan: ^1.9
- phpunit/phpunit: ^9.0|^10.0
README
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
- PayPal REST api official documentation: https://developer.paypal.com/api/rest/
- PayPal REST archived SDK https://github.com/paypal/PayPal-PHP-SDK/