1. Go to this page and download the library: Download cicerbro/coinbase-commerce 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/ */
cicerbro / coinbase-commerce example snippets
php
use CoinbaseCommerce\ApiClient;
//Make sure you don't store your API Key in your source code!
$apiClientObj = ApiClient::init(<API_KEY>);
$apiClientObj->setTimeout(3);
php
$checkoutObj = new Checkout();
$checkoutObj->id = <checkout_id>;
$checkoutObj->delete();
// or
Checkout::deleteById(<checkout_id>);
php
$params = [
'limit' => 2,
'order' => 'desc'
];
$list = Checkout::getList($params);
foreach($list as $checkout) {
var_dump($checkout);
}
// Get number of items in list
$count = $list->count();
// or
$count = count($list);
// Get number of all checkouts
$countAll = $list->countAll();
// Get pagination
$pagination = $list->getPagination();
// To load next page with previous setted params(in this case limit, order)
if ($list->hasNext()) {
$list->loadNext();
foreach($list as $checkout) {
var_dump($checkout);
}
}
php
$chargeData = [
'name' => 'The Sovereign Individual',
'description' => 'Mastering the Transition to the Information Age',
'local_price' => [
'amount' => '100.00',
'currency' => 'USD'
],
'pricing_type' => 'fixed_price'
];
Charge::create($chargeData);
// or
$chargeObj = new Charge();
$chargeObj->name = 'The Sovereign Individual';
$chargeObj->description = 'Mastering the Transition to the Information Age';
$chargeObj->local_price = [
'amount' => '100.00',
'currency' => 'USD'
];
$chargeObj->pricing_type = 'fixed_price';
$chargeObj->save();
php
use CoinbaseCommerce\ApiClient;
//Make sure you don't store your API Key in your source code!
$apiClientObj = ApiClient::init(<API_KEY>);
$apiClientObj->setLogger($logger);