localtools / coinbase-commerce-sdk
Coinbase commerce PHP API Wrapper
v0.0.1
2024-11-15 21:04 UTC
Requires
- php: >=7.4
- ext-json: *
- localtools/php-http-client: ^0.0.1
Requires (Dev)
- laravel/pint: ^1.18
- pestphp/pest: ^3.2 || ^v3.5.1
- phpunit/phpunit: ^8.5.40 || ^11.4.3
README
Coinbase Commerce SDK is a PHP library for interacting with the Coinbase Commerce API.
Installation
You can install the package via composer:
composer require localtools/coinbase-commerce-sdk
Usage
Initialization
use LocalTools\CoinbaseCommerceSdk\CoinbaseCommerce; $token = 'your-access-token'; $sdk = new CoinbaseCommerce($token);
Checkouts
List Checkouts
$checkouts = $sdk->checkouts->listCheckouts(); echo json_encode($checkouts, JSON_PRETTY_PRINT);
Charges
Create Charge
use LocalTools\CoinbaseCommerceSdk\Dtos\CreateChargeDto; use LocalTools\CoinbaseCommerceSdk\Responses\Checkout\Extra\LocalPrice; $createChargeDto = new CreateChargeDto( 'The Human Fund', 'Money For People', 'fixed_price', new LocalPrice('1.00', 'USD'), 'USD' ); $charge = $sdk->charges->createCharge($createChargeDto); echo $charge->id;
Retrieve Charge
$charge = $sdk->charges->retrieveCharge('charge_id'); echo json_encode($charge, JSON_PRETTY_PRINT);
Events
Retrieve All Events
$events = $sdk->events->retrieveAllEvents(); echo json_encode($events, JSON_PRETTY_PRINT);
Retrieve Event
$event = $sdk->events->retrieveEvent('event_id'); echo json_encode($event, JSON_PRETTY_PRINT);
Testing
composer test
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.