### Install CoinGate PHP Library via Composer Source: https://github.com/coingate/coingate-php/blob/master/README.md Installs the CoinGate PHP library using Composer, the standard dependency manager for PHP. This is the recommended installation method as it handles dependencies automatically. ```bash composer require coingate/coingate-php ``` -------------------------------- ### Get CoinGate Platforms Source: https://github.com/coingate/coingate-php/blob/master/README.md Retrieves a list of platforms supported by CoinGate. This public API endpoint provides information about available platform integrations. ```php $client->getPlatforms(); ``` -------------------------------- ### Get CoinGate Supported Currencies using PHP Source: https://context7.com/coingate/coingate-php/llms.txt Retrieves lists of currencies supported by CoinGate, with options to filter for checkout, merchant pay (crypto or fiat), or merchant payout (crypto or fiat). This is a public endpoint. ```php getCurrencies(); // Get checkout currencies (Crypto + Native + Merchant Pay) $checkoutCurrencies = $client->getCheckoutCurrencies(); // Get Merchant Pay currencies only $payableCurrencies = $client->getMerchantPayCurrencies(); // Get crypto Merchant Pay currencies $cryptoPayable = $client->getMerchantPayCurrencies('crypto'); // Get Merchant Receive/Payout currencies only $payoutCurrencies = $client->getMerchantPayoutCurrencies(); // Get fiat payout currencies $fiatPayout = $client->getMerchantPayoutCurrencies('fiat'); foreach ($checkoutCurrencies as $currency) { echo "{$currency->title} ({$currency->symbol})\n"; } ``` -------------------------------- ### Get CoinGate Server IP Addresses Source: https://github.com/coingate/coingate-php/blob/master/README.md Retrieves the IP addresses of CoinGate servers. This public endpoint is useful for network configurations or firewall rules. ```php $client->getIPAddresses(); ``` -------------------------------- ### Get CoinGate Exchange Rate Source: https://github.com/coingate/coingate-php/blob/master/README.md Fetches the current exchange rate between two specified currencies (fiat or crypto). This is a public API endpoint and does not require authentication. ```php $client->getExchangeRate('BTC', 'EUR'); ``` -------------------------------- ### Get CoinGate Currencies Source: https://github.com/coingate/coingate-php/blob/master/README.md Fetches various lists of currencies supported by CoinGate, including crypto, native, merchant pay, and payout currencies. These are public API endpoints. ```php $client->getCurrencies(); // Crypto + Native + Merchant Pay $client->getCheckoutCurrencies(); // get Merchant Pay currencies only $client->getMerchantPayCurrencies(); // get Merchant Receive currencies only $client->getMerchantPayoutCurrencies(); ``` -------------------------------- ### Get a Specific CoinGate Order Source: https://github.com/coingate/coingate-php/blob/master/README.md Retrieves details of a specific CoinGate order using its unique ORDER ID. This is useful for checking the status or details of an order after it has been created. ```php $order = $client->order->get(7294); ``` -------------------------------- ### Client Initialization Source: https://context7.com/coingate/coingate-php/llms.txt Initialize the CoinGate client with your API token and optionally enable sandbox mode for testing. ```APIDOC ## Client Initialization Create a CoinGate client instance with your API token. The second parameter enables sandbox mode for testing. ```php setApiKey('YOUR_API_TOKEN'); $client->setEnvironment('sandbox'); // 'live' or 'sandbox' // Get current configuration echo $client->getApiKey(); // Returns: YOUR_API_TOKEN echo $client->getEnvironment(); // Returns: live or sandbox echo $client->getApiBase(); // Returns: https://api.coingate.com ``` ``` -------------------------------- ### Initialize CoinGate PHP Client Source: https://github.com/coingate/coingate-php/blob/master/README.md Initializes the CoinGate PHP client with an API token. It demonstrates how to set up the client for both production and sandbox environments, and how to use it without authentication for public endpoints. ```php $client = new CoinGateClient('YOUR_API_TOKEN'); ``` ```php $client = new CoinGateClient('YOUR_API_TOKEN', true); ``` ```php $client = new CoinGateClient(); // if needed you can set configuration parameters later $client->setApiKey('YOUR_API_TOKEN'); $client->setEnvironment('sandbox'); ``` -------------------------------- ### Identify Plugins with setAppInfo (PHP) Source: https://context7.com/coingate/coingate-php/llms.txt Enables plugin developers to identify their integration with CoinGate by setting application name and version using `Client::setAppInfo()`. This information is included in the User-Agent header for all subsequent API requests. ```php order->create([ 'price_amount' => 100, 'price_currency' => 'USD', 'receive_currency' => 'EUR' ]); ``` -------------------------------- ### Identify Plugins with CoinGate PHP Client Source: https://github.com/coingate/coingate-php/blob/master/README.md Plugin developers integrating the CoinGate library should use the setAppInfo function to identify their plugin and its version. This method should be called once before any API requests are made. The version parameter is optional. ```php \CoinGate\Client::setAppInfo("MyAwesomePlugin", "1.0.0"); ``` -------------------------------- ### List CoinGate Orders with Filtering using PHP Source: https://context7.com/coingate/coingate-php/llms.txt Retrieves a list of CoinGate orders, with options to filter by creation date range. Requires an API token. Handles 'ApiErrorException'. ```php order->list(); // List orders with date filter $filteredOrders = $client->order->list([ 'created_at' => [ 'from' => '2024-01-01', 'to' => '2024-12-31' ] ]); foreach ($filteredOrders as $order) { echo "Order #{$order->id}: {$order->status} - "; echo "{$order->price_amount} {$order->price_currency}\n"; } } catch (ApiErrorException $e) { echo "Failed to list orders: " . $e->getMessage(); } ``` -------------------------------- ### Test API Connection Source: https://context7.com/coingate/coingate-php/llms.txt Verify that your API token is valid and the connection to CoinGate works properly. ```APIDOC ## Test API Connection Verify that your API token is valid and the connection to CoinGate works properly. ```php order->create([ 'price_amount' => 100, 'price_currency' => 'INVALID' ]); } catch (BadAuthToken $e) { // HTTP 401 - Invalid API token echo "Invalid API token. Please check your credentials."; } catch (Unauthorized $e) { // HTTP 401 - Other authorization errors echo "Unauthorized: " . $e->getMessage(); } catch (BadRequest $e) { // HTTP 400 - Malformed request echo "Bad request: " . $e->getMessage(); } catch (OrderNotFound $e) { // HTTP 404/422 - Order doesn't exist echo "Order not found: " . $e->getMessage(); } catch (OrderIsNotValid $e) { // HTTP 422 - Order validation failed echo "Order validation failed: " . $e->getMessage(); print_r($e->getErrorDetails()); } catch (UnprocessableEntity $e) { // HTTP 422 - Other validation errors echo "Validation error: " . $e->getMessage(); echo "Reason: " . $e->getReason(); } catch (RateLimitException $e) { // HTTP 429 - Too many requests echo "Rate limited. Please slow down requests."; } catch (InternalServerError $e) { // HTTP 500/504 - Server error echo "CoinGate server error. Please try again later."; } catch (ApiConnectionException $e) { // Network/connection error echo "Connection failed: " . $e->getMessage(); } catch (ApiErrorException $e) { // Catch-all for any API error echo "API Error: " . $e->getMessage() . "\n"; echo "HTTP Status: " . $e->getHttpStatus() . "\n"; echo "Reason: " . $e->getReason() . "\n"; print_r($e->getErrorDetails()); } ``` -------------------------------- ### Create a CoinGate Order Source: https://github.com/coingate/coingate-php/blob/master/README.md Creates a new order with CoinGate, specifying payment details and redirect URLs. It includes error handling for API exceptions and demonstrates how to retrieve the order ID upon successful creation. ```php $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 (CoinGateExceptionApiErrorException $e) { // something went wrong... // var_dump($e->getErrorDetails()); } echo $order->id; ``` -------------------------------- ### Manually Include CoinGate PHP Library Source: https://github.com/coingate/coingate-php/blob/master/README.md Includes the CoinGate PHP library manually by requiring the init.php file. This method is an alternative to Composer and requires ensuring dependencies like curl and json are met. ```php require_once('/path/to/coingate-php/init.php'); ``` -------------------------------- ### List All CoinGate Orders Source: https://github.com/coingate/coingate-php/blob/master/README.md Retrieves a list of all placed orders. This function allows filtering orders by creation date, enabling efficient retrieval of historical order data. ```php $orders = $client->order->list([ 'created_at' => [ 'from' => '2022-01-25' ] ]); ``` -------------------------------- ### POST /order/{order_id}/checkout Source: https://context7.com/coingate/coingate-php/llms.txt Checkout a created order with a pre-selected payment currency. Use this for white-label invoices where you display payment details directly. ```APIDOC ## POST /order/{order_id}/checkout ### Description Checkout a created order with a pre-selected payment currency. Use this for white-label invoices where you display payment details directly. ### Method POST ### Endpoint /order/{order_id}/checkout ### Parameters #### Path Parameters - **order_id** (integer) - Required - The ID of the order to checkout. #### Query Parameters - **pay_currency** (string) - Required - The cryptocurrency to pay with (e.g., BTC, ETH). ### Request Example ```php order->checkout($orderId, [ 'pay_currency' => 'BTC' ]); // ... process checkout details ... } catch (ApiErrorException $e) { echo "Checkout failed: " . $e->getMessage(); } ``` ### Response #### Success Response (200) - **id** (integer) - The unique identifier of the order. - **pay_currency** (string) - The cryptocurrency used for payment. - **pay_amount** (float) - The amount to be paid in the selected cryptocurrency. - **payment_address** (string) - The cryptocurrency address to send the payment to. - **expire_at** (string) - The expiration date and time of the payment address. - **payment_url** (string) - A URL to view the payment details. #### Response Example ```json { "id": 7294, "pay_currency": "BTC", "pay_amount": "0.0005 BTC", "payment_address": "1A1oP9oV447y11`, "expire_at": "2024-07-26T10:00:00+00:00", "payment_url": "https://coingate.com/pay/abcdef123" } ``` #### Error Handling - **ApiErrorException**: Thrown for API-related errors. ``` -------------------------------- ### Configure Request Timeouts with CurlClient in PHP Source: https://github.com/coingate/coingate-php/blob/master/README.md Modify the default request timeouts (connect and total) for the CoinGate API client by instantiating and configuring a CurlClient. This allows for granular control over connection and total request durations in seconds. The custom client is then set for the CoinGate library. ```php $curl = new \CoinGate\HttpClient\CurlClient(); $curl->setTimeout(10); $curl->setConnectTimeout(5); \CoinGate\Client::setHttpClient($curl); ``` -------------------------------- ### List All CoinGate Exchange Rates Source: https://github.com/coingate/coingate-php/blob/master/README.md Retrieves all current CoinGate exchange rates for merchants and traders. This public endpoint is accessible without authentication. ```php $client->listExchangeRates(); ``` -------------------------------- ### Test API Connection with CoinGate PHP Client Source: https://github.com/coingate/coingate-php/blob/master/README.md Verify the API connection using the testConnection method of the CoinGate PHP client. This function requires an API token for authentication. An optional boolean parameter can be set to true to test the connection in sandbox mode. ```php $result = \CoinGate\Client::testConnection('YOUR_API_TOKEN'); ``` ```php $result = \CoinGate\Client::testConnection('YOUR_API_TOKEN', true); ``` -------------------------------- ### Test CoinGate API Connection Source: https://context7.com/coingate/coingate-php/llms.txt Verifies the connection to the CoinGate API using a provided API token. This function checks if the token is valid and the client can communicate with the CoinGate servers in both production and sandbox environments. ```php order->checkout(7294, [ 'pay_currency' => 'BTC' ]); ``` -------------------------------- ### Checkout a CoinGate Order with Specific Currency Source: https://context7.com/coingate/coingate-php/llms.txt Checks out a previously created CoinGate order, specifying a payment currency. This is useful for white-label invoices where payment details are displayed directly. It returns payment details like the address and expiration time. ```php order->checkout($orderId, [ 'pay_currency' => 'BTC' ]); echo "Order ID: " . $checkout->id . "\n"; echo "Pay Currency: " . $checkout->pay_currency . "\n"; echo "Pay Amount: " . $checkout->pay_amount . "\n"; echo "Payment Address: " . $checkout->payment_address . "\n"; echo "Expires At: " . $checkout->expire_at . "\n"; echo "Payment URL: " . $checkout->payment_url . "\n"; } catch (ApiErrorException $e) { echo "Checkout failed: " . $e->getMessage(); } ``` -------------------------------- ### Ping CoinGate API Source: https://github.com/coingate/coingate-php/blob/master/README.md Performs a health check on the CoinGate API. This public endpoint is used to verify the API's availability and responsiveness. ```php $client->ping(); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.