Skip to content

localtools/coinbase-commerce-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Coinbase Commerce SDK

Latest Version on Packagist Total Downloads License

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.