PHP code example of behzadbabaei / omnipay-coinbase-commerce
1. Go to this page and download the library: Download behzadbabaei/omnipay-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/ */
behzadbabaei / omnipay-coinbase-commerce example snippets
use Omnipay\Omnipay;
$gateway = Omnipay::create('CoinbaseCommerce');
$gateway->setAccessToken('your-api-key');
$gateway->setApiVersion('your-api-version');
$gateway->setLanguage(App::getLocale());
$redirectUrl = 'success-url'
$cancelUrl = 'cancel-url'
$metaData = [
'orderId' => $data['orderId']
];
return $this->gateway->purchase([
'name' => $data['name'],
'description' => $data['description'],
'amount' => $data['amount'],
'currency' => $data['currency'],
'customData' => $metaData,
'redirectUrl' => $redirectUrl,
'cancelUrl' => $cancelUrl,
])->send()->getData();
return $this->gateway->cancel([
'orderId' => $orderId
])->send()->getData();
} catch (Throwable $exception) {
return null;
}
return $this->gateway->fetchTransaction([
'orderId' => $orderId
])->send()->getData();