PHP code example of coingate / coingate-php

1. Go to this page and download the library: Download coingate/coingate-php 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/ */

    

coingate / coingate-php example snippets



$client = new \CoinGate\Client('YOUR_API_TOKEN');

$client = new \CoinGate\Client('YOUR_API_TOKEN', true);

$client = new CoinGate\Client();

// if needed you can set configuration parameters later
$client->setApiKey('YOUR_API_TOKEN');
$client->setEnvironment('sandbox');

$params = [
    'order_id'          => 'YOUR-CUSTOM-ORDER-ID-115',
    'price_amount'      => 1050.99,
    'price_currency'    => 'USD',
    'receive_currency'  => 'EUR',
    'callback_url'      => 'https://example.com/payments?token=6tCENGUYI62ojkuzDPX7Jg',
    'cancel_url'        => 'https://example.com/cart',
    'success_url'       => 'https://example.com/account/orders',
    'title'             => 'Order #112',
    'description'       => 'Apple Iphone 13'
];

try {
    $order = $client->order->create($params);
} catch (\CoinGate\Exception\ApiErrorException $e) {
    // something went wrong...
    // var_dump($e->getErrorDetails());
}

echo $order->id;

$checkout = $client->order->checkout(7294, [
    'pay_currency' => 'BTC'
]);

$order = $client->order->get(7294);

$orders = $client->order->list([
    'created_at' => [
        'from' => '2022-01-25'
    ]
]);

$client->getExchangeRate('BTC', 'EUR');

$client->listExchangeRates();

$client->ping();

$client->getIPAddresses();

$client->getCurrencies();

// Crypto + Native + Merchant Pay 
$client->getCheckoutCurrencies();

// get Merchant Pay currencies only
$client->getMerchantPayCurrencies();

// get Merchant Receive currencies only
$client->getMerchantPayoutCurrencies();

$client->getPlatforms();

// set up your tweaked Curl client
$curl = new \CoinGate\HttpClient\CurlClient();
$curl->setTimeout(10);
$curl->setConnectTimeout(5);

// tell CoinGate Library to use the tweaked Curl client
\CoinGate\Client::setHttpClient($curl);

// use the CoinGate API client as you normally would

$result = \CoinGate\Client::testConnection('YOUR_API_TOKEN');

$result = \CoinGate\Client::testConnection('YOUR_API_TOKEN', true);

\CoinGate\Client::setAppInfo("MyAwesomePlugin", "1.0.0");
bash
composer