PHP code example of localtools / coinbase-commerce-sdk

1. Go to this page and download the library: Download localtools/coinbase-commerce-sdk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

localtools / coinbase-commerce-sdk example snippets


use LocalTools\CoinbaseCommerceSdk\CoinbaseCommerce;

$token = 'your-access-token';
$sdk = new CoinbaseCommerce($token);

$checkouts = $sdk->checkouts->listCheckouts();
echo json_encode($checkouts, JSON_PRETTY_PRINT);

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;

$charge = $sdk->charges->retrieveCharge('charge_id');
echo json_encode($charge, JSON_PRETTY_PRINT);

$events = $sdk->events->retrieveAllEvents();
echo json_encode($events, JSON_PRETTY_PRINT);

$event = $sdk->events->retrieveEvent('event_id');
echo json_encode($event, JSON_PRETTY_PRINT);