### Create CryptoCloud Invoice: Python and JavaScript Examples Source: https://docs.cryptocloud.plus/ru/api-reference-v1-old/create-invoice These examples demonstrate how to send a POST request to the CryptoCloud V1 API to create an invoice. They show how to set up the authorization header with your API key and include the necessary request body parameters like amount and currency. The Python example uses the `requests` library, and the JavaScript example uses the `fetch` API. ```Python import requests import json url = "https://api.cryptocloud.plus/v1/invoice/create" headers = { "Authorization": "Token ", "Content-Type": "application/json" } data = { "amount": 100.0, "currency": "USD", "description": "Pay" } response = requests.post(url, headers=headers, json=data) ``` ```JavaScript fetch('https://api.cryptocloud.plus/v1/invoice/create', { method: 'POST', headers: { 'Authorization': 'Token ', 'Content-Type': 'application/json' }, body: JSON.stringify({ amount: 100.0, currency: 'USD', description: 'Pay' }) }) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error)); ``` -------------------------------- ### Implement CryptoCloud Plus Postback Handler Source: https://docs.cryptocloud.plus/ru/api-reference-v2/postback These code examples demonstrate how to set up a server-side endpoint to receive and process postback notifications from the CryptoCloud Plus API using Python (Flask), JavaScript (Express.js), and PHP. They show how to parse `x-www-form-urlencoded` data containing payment status, invoice ID, and other relevant information. ```Python from flask import Flask, request, jsonify app = Flask(__name__) @app.route('/postback', methods=['POST']) def handle_postback(): # Changed to request.form for handling x-www-form-urlencoded data status = request.form.get('status') invoice_id = request.form.get('invoice_id') amount_crypto = request.form.get('amount_crypto') currency = request.form.get('currency') order_id = request.form.get('order_id') token = request.form.get('token') # ... your code for processing postback ... return jsonify({'message': 'Postback received'}), 200 if __name__ == '__main__': app.run(port=5000) ``` ```JavaScript const express = require('express'); const app = express(); // Adds middleware for JSON processing app.use(express.json()); // Adds middleware for handling x-www-form-urlencoded data app.use(express.urlencoded({ extended: true })); app.post('/postback', (req, res) => { const { status, invoice_id, amount_crypto, currency, order_id, token } = req.body; // ... your code for processing postback ... res.json({ message: 'Postback received' }); }); app.listen(3000, () => { console.log('Server is running on port 3000'); }); ``` ```PHP 'Postback received']); ?> ``` -------------------------------- ### PHP Cryptocloud Plus: Example Usage for Creating Payout Source: https://docs.cryptocloud.plus/ru/api-reference-v2/withdrawals This example demonstrates how to use the `PayoutAPIClient` to create a cryptocurrency payout. It initializes the client with an API key, calls the `createPayout` method with specific currency, address, and amount, and then prints the success response or catches and displays any `PayoutAPIError`. ```php try { $client = new PayoutAPIClient(''); $response = $client->createPayout('BTC', '', 0.00023); echo "Success:\n"; print_r($response); } catch (PayoutAPIError $e) { echo "Error occurred:\n" . $e->getMessage(); } ``` -------------------------------- ### Cryptocloud Plus API Success Response Example Source: https://docs.cryptocloud.plus/ru/api-reference-v2/invoice-list An example JSON structure for a successful API response, typically containing a list of transaction or invoice records with detailed information for each entry. ```JSON { "status": "success", "result": [ { "uuid": "INV-XXXXXXXX", "created": "2023-01-01 12:00:00.000000", "address": "", "currency": { "id": 4, "code": "USDT", "fullcode": "USDT_TRC20", "network": { "code": "TRC20", "id": 4, "icon": "https://cdn.cryptocloud.plus/currency/crypto/TRX.svg", "fullname": "Tron" }, "name": "Tether", "is_email_required": false, "stablecoin": true, "icon_base": "https://cdn.cryptocloud.plus/currency/icons/main/usdt.svg", "icon_network": "https://cdn.cryptocloud.plus/icons-currency/USDT-TRC20.svg", "icon_qr": "https://cdn.cryptocloud.plus/currency/icons/stroke/usdt.svg", "order": 1 }, "date_finished": null, "expiry_date": "2023-01-02 12:00:00", "side_commission": "client", "side_commission_cc": "merchant", "type_payments": "crypto", "status": "created", "is_email_required": false, "project": { "id": 1, "name": "My store", "fail": "https://test.com/fail?order_id=1111&invoice_uuid=INV-XXXXXXXX", "success": "https://test.com/success?order_id=1111&invoice_uuid=INV-XXXXXXXX", "logo": "None" }, "tx_list": [], "test_mode": false, "type": "up", "user_email": "", "pay_url": "None", "phone": "", "order_id": "1111", "amount_in_crypto": null, "amount_in_fiat": 100, "amount": 100.0, "amount_usd": 100.0, "amount_to_pay": 101.4, "amount_to_pay_usd": 101.4, "amount_paid": 0.0, "amount_paid_usd": 0.0, "fee": 1.4, "fee_usd": 1.4, "service_fee": 0, "service_fee_usd": 1.9, "received": 0.0, "received_usd": 0.0, "to_surcharge": 0.0, "to_surcharge_usd": 0.0 }, {...}, {...}, {...}, {...}, {...} ], "all_count": 100 } ``` -------------------------------- ### JavaScript CryptoCloud Payout API Client with Axios Source: https://docs.cryptocloud.plus/ru/api-reference-v2/withdrawals Defines a custom `PayoutAPIError` class and a `PayoutAPIClient` class for interacting with the CryptoCloud Payout API using Axios. It includes the constructor for client setup, the `createPayout` method for sending requests, and an example of its asynchronous usage. ```javascript /** * Custom error for handling payout API response failures. */ class PayoutAPIError extends Error { /** * @param {number} statusCode - HTTP status code returned by the API. * @param {object} [errorData={}] - Error details returned by the API. */ constructor(statusCode, errorData = {}) { super(`API Request failed with status ${statusCode}: ${JSON.stringify(errorData)}`); this.name = 'PayoutAPIError'; this.statusCode = statusCode; this.errorData = errorData; } } /** * Client for interacting with CryptoCloud Payout API. */ class PayoutAPIClient { /** * @param {string} apiKey - API token used for authentication. */ constructor(apiKey) { this.apiKey = apiKey; this.baseUrl = 'https://api.cryptocloud.plus'; this.headers = { 'Authorization': `Token ${this.apiKey}`, 'Content-Type': 'application/json' }; } /** * Creates a payout request. * * @param {string} currencyCode - Currency code (e.g., "BTC", "ETH", "USDT", "LTC"). * @param {string} toAddress - Recipient address. * @param {number} amount - Amount to send. * @returns {Promise} - API response data. * @throws {PayoutAPIError} - On failed request. */ async createPayout(currencyCode, toAddress, amount) { const url = `${this.baseUrl}/v2/invoice/api/out/create`; const payload = { currency_code: currencyCode, to_address: toAddress, amount: amount }; try { const response = await axios.post(url, payload, { headers: this.headers }); return response.data; } catch (error) { const status = error.response?.status || 500; const data = error.response?.data || {}; throw new PayoutAPIError(status, data); } } } // Example usage with Axios (async () => { const client = new PayoutAPIClient(''); try { const result = await client.createPayout("BTC", "", 0.00023); console.log("Success:", result); } catch (error) { console.error("Error occurred:", error); } })(); ``` -------------------------------- ### Handle POSTBACK Notifications with Flask and Express.js Source: https://docs.cryptocloud.plus/ru/api-reference-v1-old/postback This snippet demonstrates how to set up server-side applications in both Python (Flask) and JavaScript (Express.js) to receive and process POSTBACK notifications. Both examples define a POST endpoint (`/postback`) that parses JSON data from the request body, extracts relevant fields like status, invoice ID, and amount, and returns a JSON response. This serves as a basic template for integrating with a payment service's callback mechanism. ```Python from flask import Flask, request, jsonify app = Flask(__name__) @app.route('/postback', methods=['POST']) def handle_postback(): data = request.json status = data.get('status') invoice_id = data.get('invoice_id') amount_crypto = data.get('amount_crypto') currency = data.get('currency') order_id = data.get('order_id') token = data.get('token') # ... your code for processing postback ... return jsonify({'message': 'Postback received'}), 200 if __name__ == '__main__': app.run(port=5000) ``` ```JavaScript const express = require('express'); const app = express(); app.use(express.json()); app.post('/postback', (req, res) => { const { status, invoice_id, amount_crypto, currency, order_id, token } = req.body; // ... your code for processing postback ... res.json({ message: 'Postback received' }); }); app.listen(3000, () => { console.log('Server is running on port 3000'); }); ``` -------------------------------- ### Make API Request with Authorization Token Source: https://docs.cryptocloud.plus/ru/api-reference-v2 Demonstrates how to include an 'Authorization' header with a 'Token' for API requests to `https://api.cryptocloud.plus/v2/invoice/create`. This example performs a POST request and handles the response. ```cURL curl -X POST https://api.cryptocloud.plus/v2/invoice/create \ -header "Authorization: Token eyJ0eXAi1iJKV1QiLCJhbGci1iJIAcI1NiJ9.eyJpZCI6MTMsImV4cCI6MTYzMTc4NjQyNn0.HQavV3z8dFnk56bX3MSY5X9lR6qVa9YhAoeTEH" ``` ```Python import requests url = "https://api.cryptocloud.plus/v2/invoice/create" headers = { "Authorization": "Token eyJ0eXAi1iJKV1QiLCJhbGciOiJIAcI1NiJ9.eyJpZCI6MTMsImV4cCI6MTYzMTc4NjQyNn0.HQavV3z8dFnk56bX3MSY5X9lR6qVa9YhAoeTEH" } response = requests.post(url, headers=headers) if response.status_code == 200: print("Success:", response.json()) else: print("Fail:", response.status_code, response.text) ``` ```JavaScript const url = 'https://api.cryptocloud.plus/v2/invoice/create'; const headers = new Headers({ 'Authorization': 'Token eyJ0eXAi1iJKV1QiLCJhbGciOiJIAcI1NiJ9.eyJpZCI6MTMsImV4cCI6MTYzMTc4NjQyNn0.HQavV3z8dFnk56bX3MSY5X9lR6qVa9YhAoeTEH' }); fetch(url, { method: 'POST', headers }) .then(response => { if (response.ok) { return response.json(); } else { return Promise.reject('Auth error'); } }) .then(data => { console.log('Success:', data); }) .catch(error => { console.error('Fail:', error); }); ``` ```PHP ``` -------------------------------- ### Sample CryptoCloud Plus Invoice Response Structure Source: https://docs.cryptocloud.plus/ru/api-reference-v2/postback This JSON object illustrates the typical structure of a successful invoice response from the CryptoCloud Plus API. It includes details such as payment status, invoice ID, crypto and fiat amounts, currency information, and transaction specifics, providing a comprehensive overview of the payment event. ```JSON { "status": "success", "invoice_id": "XXXXXXXX", "amount_crypto": 100, "currency": "USDT_TRC20", "order_id": "order_id", "token": "b\"token\"", "invoice_info": { "uuid": "INV-XXXXXXXX", "created": "2024-08-22 11:49:59.756692", "address": "address", "currency": { "id": 4, "code": "USDT", "fullcode": "USDT_TRC20", "network": { "code": "TRC20", "id": 4, "icon": "https://cdn.cryptocloud.plus/currency/crypto/TRX.svg", "fullname": "Tron" }, "name": "Tether", "is_email_required": false, "stablecoin": true, "icon_base": "https://cdn.cryptocloud.plus/currency/icons/main/usdt.svg", "icon_network": "https://cdn.cryptocloud.plus/icons-currency/USDT-TRC20.svg", "icon_qr": "https://cdn.cryptocloud.plus/currency/icons/stroke/usdt.svg", "order": 1 }, "date_finished": "2024-08-22 11:51:53.753528", "expiry_date": "2024-08-23 11:49:59.746385", "side_commission": "client", "type_payments": "crypto", "amount": 100, "amount_": 100, "status": "overpaid", "invoice_status": "success", "is_email_required": false, "project": { "id": 0, "name": "My Project", "fail": "", "success": "", "logo": "" }, "tx_list": [ "" ], "amount_in_crypto": null, "amount_in_fiat": 0.0, "amount_usd": 100.0, "amount_to_pay": 102.0, "amount_to_pay_usd": 102.0, "amount_paid": 102.0, "amount_paid_usd": 102.0, "fee": 1.4, "fee_usd": 1.4, "service_fee": 0.8048, "service_fee_usd": 0.8, "received": 99.7952, "received_usd": 99.8, "to_surcharge": 0.0, "to_surcharge_usd": 0.0, "total_rub": 0, "step": 3, "test_mode": false, "type": "up", "aml_enabled": false, "aml_side": "merchant", "aml_checks": [], "links_invoice": null } } ``` -------------------------------- ### Cryptocloud Plus API Error Responses Source: https://docs.cryptocloud.plus/ru/api-reference-v2/invoice-list Examples of JSON responses returned by the Cryptocloud Plus API when various errors occur, including missing required parameters, authentication failures, and invalid request signatures. ```JSON { "status": "error", "result": { "start": "start not passed.", "end": "end not passed." } } ``` ```JSON { "detail": "Credentials were not provided" } ``` ```JSON { "detail": "Invalid header padding" } ``` ```JSON { "detail": "Signature verification failed" } ``` -------------------------------- ### Cryptocloud Plus API Request Parameters and Error Codes Source: https://docs.cryptocloud.plus/ru/api-reference-v2/invoice-list Defines the required and optional parameters for API requests, including their data types, descriptions, and examples. It also lists common HTTP status codes and their corresponding error messages. ```APIDOC Request Body Parameters: start*: String Description: Дата в формате "dd.mm.yyyy" (Date in "dd.mm.yyyy" format) Example: 01.01.2023 end*: String Description: Дата в формате "dd.mm.yyyy". Должна быть больше или равна start (Date in "dd.mm.yyyy" format. Must be greater than or equal to start) Example: 31.01.2023 offset: Int Description: Это номер начальной записи, с которой начнется вывод данных. Например, если установить `offset=10`, то данные начнут показываться с 11-й записи. Значение по умолчанию 0 (This is the starting record number from which data output will begin. For example, if you set `offset=10`, data will start showing from the 11th record. Default value is 0) Example: 0 limit: Int Description: Это номер последней записи, которую вы хотите получить. Например, если `limit=20`, то вы получите записи до 20-й включительно, начиная с той, что указана в `offset`. Значение по умолчанию 10 (This is the last record number you want to receive. For example, if `limit=20`, you will receive records up to the 20th inclusive, starting from the one specified in `offset`. Default value is 10) Example: 10 HTTP Status Codes: 200: OK Description: Успешный ответ (Successful response) 400: Bad Request Description: Ошибка: Не переданы обязательные параметры (Error: Required parameters not passed) 403: Forbidden Description: Ошибка: Не передан API KEY (Error: API KEY not passed) 403: Forbidden Description: Ошибка: Не корректный API KEY (Error: Invalid API KEY) ``` -------------------------------- ### Cryptocloud Plus: Invoice Creation Error Responses Source: https://docs.cryptocloud.plus/ru/api-reference-v2/create-invoice These JSON snippets demonstrate various error responses returned by the Cryptocloud Plus API when invoice creation fails due to missing required parameters, invalid amounts, or unsupported currencies. Each example provides a specific error message. ```JSON { "status": "error", "result": { "amount": "amount not passed.", "shop_id": "shop_id not passed." } } ``` ```JSON { "status": "error", "result": { "amount": "Invalid value amount." } } ``` ```JSON { "status": "error", "result": { "currency": "Invalid account currency specified. Available currencies 'USD', 'UZS', 'KGS', 'KZT', 'AMD', 'AZN', 'BYN', 'AUD', 'TRY', 'AED', 'CAD', 'CNY', 'HKD', 'IDR', 'INR', 'JPY', 'PHP', 'SGD', 'THB', 'VND', 'MYR', 'RUB', 'UAH', 'EUR', 'GBP'." } } ``` -------------------------------- ### Send POST Request for Merchant Statistics Source: https://docs.cryptocloud.plus/ru/api-reference-v2/statistics This snippet demonstrates how to send an authenticated POST request to the CryptoCloud Plus API's merchant statistics endpoint. It includes examples in cURL, Python, JavaScript, and PHP, showing how to set the Authorization header with an API key and provide a JSON payload with 'start' and 'end' dates to retrieve statistics. ```cURL curl -X POST https://api.cryptocloud.plus/v2/invoice/merchant/statistics \ -H "Authorization: Token " \ -H "Content-Type: application/json" \ -d '{"start":"01.01.2023","end":"31.01.2023"}' ``` ```Python import requests url = "https://api.cryptocloud.plus/v2/invoice/merchant/statistics" headers = { "Authorization": "Token " } data = { "start": "01.01.2023", "end": "31.01.2023" } response = requests.post(url, headers=headers, json=data) if response.status_code == 200: print("Success:", response.json()) else: print("Fail:", response.status_code, response.text) ``` ```JavaScript fetch('https://api.cryptocloud.plus/v2/invoice/merchant/statistics', { method: 'POST', headers: { 'Authorization': 'Token ', 'Content-Type': 'application/json' }, body: JSON.stringify({ start: '01.01.2023', end: '31.01.2023' }) }) .then(response => { if (response.ok) { return response.json(); } else { throw new Error('Fail: ' + response.status + ' ' + response.statusText); } }) .then(data => console.log('Success:', data)) .catch(error => console.error('Error:', error)); ``` ```PHP "01.01.2023", "end" => "31.01.2023" ))); $headers = array( "Authorization: Token ", "Content-Type: application/json" ); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $response = curl_exec($ch); if (curl_errno($ch)) { echo 'Error:' . curl_error($ch); } else { $statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); if ($statusCode == 200) { echo "Success: " . $response; } else { echo "Fail: " . $statusCode . " " . $response; } } curl_close($ch); ?> ``` -------------------------------- ### JavaScript CryptoCloud Payout API Request with XMLHttpRequest Source: https://docs.cryptocloud.plus/ru/api-reference-v2/withdrawals Shows how to send a POST request to the CryptoCloud Payout API using the XMLHttpRequest object. This example demonstrates setting request headers, defining an `onload` handler for success/error, and sending the JSON payload. ```javascript const apiKey = ''; const xhr = new XMLHttpRequest(); xhr.open("POST", "https://api.cryptocloud.plus/v2/invoice/api/out/create"); xhr.setRequestHeader("Authorization", `Token ${apiKey}`); xhr.setRequestHeader("Content-Type", "application/json"); xhr.onload = function () { if (xhr.status === 200) { console.log("Success:", JSON.parse(xhr.responseText)); } else { console.error("Error:", xhr.status, xhr.responseText); } }; const payload = { currency_code: 'BTC', to_address: '', amount: 0.00023 }; xhr.send(JSON.stringify(payload)); ``` -------------------------------- ### Cryptocloud Plus: Create Invoice Request Body & Parameters Source: https://docs.cryptocloud.plus/ru/api-reference-v2/create-invoice Defines the parameters required for creating a new invoice via the Cryptocloud Plus API, including main and additional fields. This section details data types, descriptions, and examples for each parameter. ```APIDOC Request Body Parameters: shop_id*: string Description: Unique shop identifier from your personal account. Example: xBAivfPIbskwuEWj amount*: decimal Description: Payment amount in USD. Example: 100.5 currency: string Description: Available currencies for conversion. Defaults to USD if not specified. Available values: 'USD', 'UZS', 'KGS', 'KZT', 'AMD', 'AZN', 'BYN', 'AUD', 'TRY', 'AED', 'CAD', 'CNY', 'HKD', 'IDR', 'INR', 'JPY', 'PHP', 'SGD', 'THB', 'VND', 'MYR', 'RUB', 'UAH', 'EUR', 'GBP' Example: USD add_fields: dict Description: Additional parameters for invoice creation. Nested Parameters: time_to_pay: Dict Description: Invoice lifetime. Example: { "hours": 24, "minutes": 0 } email_to_send: String Description: If provided, the invoice will be automatically sent to this email address. Example: user@example.com available_currencies: List[String] Description: Specific cryptocurrencies allowed for payment. Available values: BTC, LTC, TRX, USDT_TRC20, USDD_TRC20, ETH, USDT_ERC20, USDC_ERC20, TUSD_ERC20, SHIB_ERC20, ETH_ARB, USDT_ARB, USDC_ARB, ETH_OPT, USDT_OPT, USDC_OPT, ETH_BASE, USDC_BASE, BNB, USDT_BSC, USDC_BSC, TUSD_BSC, TON, USDT_TON, SOL, USDT_SOL, USDC_SOL Example: [ "USDT_TRC20", "ETH", "BTC" ] cryptocurrency: String Description: Pre-selects the payment currency for the user. If specified, payment details will be provided in the response. Available values: BTC, LTC, TRX, USDT_TRC20, USDD_TRC20, ETH, USDT_ERC20, USDC_ERC20, TUSD_ERC20, SHIB_ERC20, ETH_ARB, USDT_ARB, USDC_ARB, ETH_OPT, USDT_OPT, USDC_OPT, ETH_BASE, USDC_BASE, BNB, USDT_BSC, USDC_BSC, TUSD_BSC, TON, USDT_TON, SOL, USDT_SOL, USDC_SOL Example: ETH period: String Description: Recurrence period for invoice (only if email_to_send is provided for automatic sending). Available values: month, week, day Example: week order_id: string Description: Arbitrary invoice number in an external system. email: string Description: Payer's email address. ``` -------------------------------- ### CryptoCloud V1 API: Create Invoice Endpoint Source: https://docs.cryptocloud.plus/ru/api-reference-v1-old/create-invoice Documents the API endpoint for creating a new invoice in CryptoCloud V1. It specifies the HTTP method, endpoint URL, required headers for authorization, and parameters for the request body, including amount, currency, and optional order details. It also lists possible HTTP response codes and their meanings, along with an example successful response payload. ```APIDOC POST https://api.cryptocloud.plus/v1/invoice/create Headers: Authorization*: string - Token (Your API key for authentication) Request Body: shop_id*: string - Unique store identifier from your personal account amount*: decimal - Payment amount in USD currency: string - Available currencies for conversion: USD, RUB, EUR, GBP, UAH order_id: string - Your internal order identifier email: string - User's email Responses: 200: OK - Invoice created 401: Unauthorized - Invalid API KEY 400: Bad Request - Invoice creation error 406: Not Acceptable - Service unavailable ``` ```JSON { "status": "success", "pay_url": "https://pay.cryptocloud.plus/DZLF4212", "currency": "BTC", "invoice_id": "DZLF4212" } ``` -------------------------------- ### Make Authenticated POST Request to CryptoCloud API Source: https://docs.cryptocloud.plus/ru/api-reference-v2/authorization Demonstrates how to send a POST request to the CryptoCloud API, including an authentication token in the 'Authorization' header. The example targets the '/v2/invoice/create' endpoint. The token is a JWT-like string prefixed with 'Token'. ```cURL curl -X POST https://api.cryptocloud.plus/v2/invoice/create \ -header "Authorization: Token eyJ0eXAi1iJKV1QiLCJhbGci1iJIAcI1NiJ9.eyJpZCI6MTMsImV4cCI6MTYzMTc4NjQyNn0.HQavV3z8dFnk56bX3MSY5X9lR6qVa9YhAoeTEH" ``` ```Python import requests url = "https://api.cryptocloud.plus/v2/invoice/create" headers = { "Authorization": "Token eyJ0eXAi1iJKV1QiLCJhbGciOiJIAcI1NiJ9.eyJpZCI6MTMsImV4cCI6MTYzMTc4NjQyNn0.HQavV3z8dFnk56bX3MSY5X9lR6qVa9YhAoeTEH" } response = requests.post(url, headers=headers) if response.status_code == 200: print("Success:", response.json()) else: print("Fail:", response.status_code, response.text) ``` ```JavaScript const url = 'https://api.cryptocloud.plus/v2/invoice/create'; const headers = new Headers({ 'Authorization': 'Token eyJ0eXAi1iJKV1QiLCJhbGciOiJIAcI1NiJ9.eyJpZCI6MTMsImV4cCI6MTYzMTc4NjQyNn0.HQavV3z8dFnk56bX3MSY5X9lR6qVa9YhAoeTEH' }); fetch(url, { method: 'POST', headers }) .then(response => { if (response.ok) { return response.json(); } else { return Promise.reject('Auth error'); } }) .then(data => { console.log('Success:', data); }) .catch(error => { console.error('Fail:', error); }); ``` ```PHP ``` -------------------------------- ### CryptoCloud API Error Responses Source: https://docs.cryptocloud.plus/ru/api-reference-v2/authorization Details common error responses from the CryptoCloud API, including HTTP status codes, corresponding error keys, and a sample JSON error payload returned by the API. ```APIDOC Possible Errors: - HTTP Status Code: 400 - Error Key: Bad request - Description: Неверный запрос (Invalid request) Example Error Response: { "status": "error", "result": { "authorization": "Unauthorized request." } } ``` -------------------------------- ### CryptoCloud Plus Payout API Endpoint Reference Source: https://docs.cryptocloud.plus/ru/api-reference-v2/withdrawals Detailed API documentation for the CryptoCloud Plus Payout API, including the endpoint for creating payouts, required parameters, expected response, and error handling. This covers the core functionality for initiating cryptocurrency transfers. ```APIDOC Endpoint: POST https://api.cryptocloud.plus/v2/invoice/api/out/create Description: Creates a new cryptocurrency payout request. Headers: Authorization: Token (Required) - API token for authentication. Content-Type: application/json (Required) - Specifies the request body format. Request Body (JSON): currency_code: string (Required) - The cryptocurrency code for the payout (e.g., "BTC", "ETH", "USDT", "LTC"). to_address: string (Required) - The recipient's cryptocurrency address. amount: number (Required) - The amount of cryptocurrency to send. Successful Response (HTTP 200 OK): Content-Type: application/json Body: object - Contains details of the created payout, e.g., transaction ID, status. Error Responses: PayoutAPIError (Custom Error/Exception): statusCode: number - HTTP status code (e.g., 400, 401, 403, 500). errorData: object - JSON object containing specific error details from the API. Common HTTP Status Codes: 400 Bad Request: Invalid input parameters (e.g., incorrect currency_code, invalid address, insufficient amount). 401 Unauthorized: Missing or invalid API key. 403 Forbidden: API key does not have permissions for this operation. 500 Internal Server Error: An unexpected error occurred on the server side. ``` -------------------------------- ### Python CryptoCloud Payout API Client Usage Source: https://docs.cryptocloud.plus/ru/api-reference-v2/withdrawals Demonstrates how to initialize and use the `PayoutAPIClient` in Python to create a payout request, including basic error handling for `PayoutAPIError` exceptions. ```python if __name__ == "__main__": # Client Configuration api_key = "" client = PayoutAPIClient(api_key) try: result = client.create_payout( currency_code="BTC", to_address="", amount=0.00023 ) print("Success:", result) except PayoutAPIError as e: print("Error occurred:", e) ``` -------------------------------- ### Cryptocloud Plus: Successful Invoice Creation Response Source: https://docs.cryptocloud.plus/ru/api-reference-v2/create-invoice This JSON snippet illustrates a successful response from the Cryptocloud Plus API after an invoice has been successfully created. It includes details such as UUID, creation and expiry dates, amounts, fees, currency information, and a payment link. ```JSON { "status": "success", "result": { "uuid": "INV-XXXXXXXX", "created": "2023-01-01 12:00:00.000000", "address": "", "expiry_date": "2023-01-02 12:00:00.000000", "side_commission": "client", "side_commission_cc": "client", "amount": 100.0, "amount_usd": 100.0, "amount_in_fiat": 100.0, "fee": 1.4, "fee_usd": 1.4, "service_fee": 1.9, "service_fee_usd": 1.9, "type_payments": "crypto", "fiat_currency": "USD", "status": "created", "is_email_required": false, "link": "https://pay.cryptocloud.plus/XXXXXXXX", "invoice_id": null, "currency": { "id": 4, "code": "USDT", "fullcode": "USDT_TRC20", "network": { "code": "TRC20", "id": 4, "icon": "https://cdn.cryptocloud.plus/currency/crypto/TRX.svg", "fullname": "Tron" }, "name": "Tether", "is_email_required": false, "stablecoin": true, "icon_base": "https://cdn.cryptocloud.plus/currency/icons/main/usdt.svg", "icon_network": "https://cdn.cryptocloud.plus/icons-currency/USDT-TRC20.svg", "icon_qr": "https://cdn.cryptocloud.plus/currency/icons/stroke/usdt.svg", "order": 1 }, "project": { "id": 1, "name": "TestShop", "fail": "https://TestShop.com/fail", "success": "https://TestShop.com/success", "logo": "None" }, "test_mode": false } } ``` -------------------------------- ### JavaScript CryptoCloud Payout API Request with Fetch Source: https://docs.cryptocloud.plus/ru/api-reference-v2/withdrawals Illustrates how to make a direct POST request to the CryptoCloud Payout API using the Fetch API. It covers setting authorization and content type headers, stringifying the request body, and handling both successful responses and network errors. ```javascript const apiKey = ''; const payload = { currency_code: 'BTC', to_address: '', amount: 0.00023 }; fetch('https://api.cryptocloud.plus/v2/invoice/api/out/create', { method: 'POST', headers: { 'Authorization': `Token ${apiKey}`, 'Content-Type': 'application/json' }, body: JSON.stringify(payload) }) .then(response => { if (!response.ok) throw new Error(`HTTP error ${response.status}`); return response.json(); }) .then(data => console.log('Success:', data)) .catch(err => console.error('Error:', err)); ``` -------------------------------- ### Create Withdrawal Request API Source: https://docs.cryptocloud.plus/ru/api-reference-v2/withdrawals This API endpoint allows you to create a new withdrawal request. It requires a specific API key for authentication, which must be generated in the 'Security' section of your account settings. The key is displayed only once, so ensure it is saved securely. A minimum interval of 12 seconds must be observed between consecutive requests. ```APIDOC POST https://api.cryptocloud.plus/v2/invoice/api/out/create Headers: Authorization*: String - Token Description: Authentication token. A separate API KEY is required, generated in the 'Security' section of your account. Request Body Parameters: currency_code*: String - Code of the cryptocurrency for withdrawal. Supported values: BTC, LTC, TRX, USDT_TRC20, USDD_TRC20, ETH, USDT_ERC20, USDC_ERC20, TUSD_ERC20, SHIB_ERC20, ETH_ARB, USDT_ARB, USDC_ARB, ETH_OPT, USDT_OPT, USDC_OPT, ETH_BASE, USDC_BASE, BNB, USDT_BSC, USDC_BSC, TUSD_BSC, TON, USDT_TON, SOL, USDT_SOL, USDC_SOL. to_address*: String - Recipient's wallet address. amount*: Int - Amount of the withdrawal request in the specified currency. Responses: 200: OK - Request successfully created. Example: { "status": "success", "data": { "invoice_id": "INV-XXXXXXXX", "status": "created", "currency": "BTC", "amount": 0.05 } } 400: Bad Request - Indicates an error in the request. Error Codes and Descriptions: required_parameter: Missing required request parameters. currency_code: Unsupported or invalid currency code. network: Incorrect recipient address format. uncorrected_amount: Amount is too small, too large, or in an incorrect format. rate_limit: Request limit per minute exceeded. validate_error: Internal validation error. ``` -------------------------------- ### PHP Cryptocloud Plus: Implement Create Payout Function Source: https://docs.cryptocloud.plus/ru/api-reference-v2/withdrawals This PHP function `createPayout` sends a request to the Cryptocloud Plus API to initiate a cryptocurrency payout. It constructs a JSON payload with currency code, recipient address, and amount, then uses cURL to send a POST request. The function handles API responses, returning the decoded data on success or throwing a `PayoutAPIError` on failure. ```php public function createPayout(string $currencyCode, string $toAddress, float $amount): array { $url = $this->baseUrl . '/v2/invoice/api/out/create'; $payload = json_encode([ 'currency_code' => $currencyCode, 'to_address' => $toAddress, 'amount' => $amount, ]); $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $payload); curl_setopt($ch, CURLOPT_HTTPHEADER, $this->headers); $response = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); $decoded = json_decode($response, true); curl_close($ch); if ($httpCode === 200) { return $decoded; } else { throw new PayoutAPIError($httpCode, $decoded ?? []); } } ``` -------------------------------- ### Cryptocloud Plus Payout API: Create Payout Endpoint Source: https://docs.cryptocloud.plus/ru/api-reference-v2/withdrawals Documentation for the Cryptocloud Plus API endpoint used to create cryptocurrency payouts. This endpoint facilitates sending a specified amount of a given cryptocurrency to a recipient address, detailing the required parameters and expected return values. ```APIDOC POST /v2/invoice/api/out/create Parameters: currency_code (string): Currency code (e.g., BTC, ETH). to_address (string): Recipient address. amount (float): Amount to send. Returns: array: Response from API containing payout details. Errors: PayoutAPIError: On API failure (e.g., HTTP status code not 200). ``` -------------------------------- ### PHP CryptoCloud Payout API Client Source: https://docs.cryptocloud.plus/ru/api-reference-v2/withdrawals Defines a `PayoutAPIError` custom exception and the `PayoutAPIClient` class for PHP 8.0+. The client handles API key authentication and sets up the base URL and headers for making requests to the CryptoCloud Payout API. ```php statusCode = $statusCode; $this->errorData = $errorData; $message = "API Request failed with status $statusCode: " . json_encode($errorData); parent::__construct($message, $statusCode); } } /** * Class PayoutAPIClient * * Client for creating crypto payouts via CryptoCloud API. */ class PayoutAPIClient { private string $apiKey; private string $baseUrl; private array $headers; /** * PayoutAPIClient constructor. * * @param string $apiKey */ public function __construct(string $apiKey) { $this->apiKey = $apiKey; $this->baseUrl = 'https://api.cryptocloud.plus'; $this->headers = [ 'Authorization: Token ' . $this->apiKey, 'Content-Type: application/json' ]; } /** * Create payout request. * ``` -------------------------------- ### API V2 Request Authorization Header Source: https://docs.cryptocloud.plus/ru/api-reference-v2 To authorize each request to the CryptoCloud API V2, you must pass your API key in the 'Authorization' header. This snippet demonstrates the required format for the header. ```APIDOC Authorization: Token ``` -------------------------------- ### Retrieve Account Balance (CryptoCloud API v2) Source: https://docs.cryptocloud.plus/ru/api-reference-v2/balance This API endpoint allows users to retrieve the current balance of their CryptoCloud account across various currencies. It requires a POST request and returns a detailed array of balances, along with potential error responses for authentication issues. ```APIDOC POST https://api.cryptocloud.plus/v2/merchant/wallet/balance/all Description: Retrieves the current balance of your CryptoCloud account across all supported currencies. Authentication: Requires a valid API Key in the request headers. Responses: 200 OK: Successful response. Returns an array of balance objects. Example Body: { "status": "success", "result": [ { "currency": { "id": 4, "code": "USDT_TRC20", "short_code": "USDT", "name": "Tether", "is_email_required": false, "stablecoin": true, "icon_base": "https://cdn.cryptocloud.plus/currency/icons/main/usdt.svg", "icon_network": "https://cdn.cryptocloud.plus/icons-currency/USDT-TRC20.svg", "icon_qr": "https://cdn.cryptocloud.plus/currency/icons/stroke/usdt.svg", "order": 1, "obj_network": { "code": "TRC20", "id": 4, "icon": "https://cdn.cryptocloud.plus/currency/crypto/TRX.svg", "fullname": "Tron" }, "enable": true }, "balance_crypto": 0.0, "balance_usd":0.0, "available_balance": 0.0, "available_balance_usd": 0.0 }, {...}, {...}, ... ] } 403 Forbidden: Authentication or authorization error. Possible Error Bodies: { "detail": "Invalid header padding" } or { "detail": "Signature verification failed" } or { "detail": "Credentials were not provided" } ``` -------------------------------- ### API Error Response Structure Source: https://docs.cryptocloud.plus/ru/api-reference-v2 Documents the common error codes and the JSON structure for error responses from the CryptoCloud Plus API, specifically for unauthorized requests. ```APIDOC Possible Errors: - HTTP Status Code: 400 - Error Key: Bad request - Description: Invalid request Error Response Example: { "status": "error", "result": { "authorization": "Unauthorized request." } } ``` -------------------------------- ### Retrieve CryptoCloud V2 Account Statistics Source: https://docs.cryptocloud.plus/ru/api-reference-v2/statistics This API endpoint allows you to retrieve detailed payment statistics for your CryptoCloud account over a specified date range. It provides counts and total amounts for invoices based on their status (created, paid, overpaid, partial, canceled). ```APIDOC POST https://api.cryptocloud.plus/v2/invoice/merchant/statistics Request Body: start: String (required) - Start date in 'dd.mm.yyyy' format. end: String (required) - End date in 'dd.mm.yyyy' format. Response (200 OK): { "status": "success", "result": { "count": { "all": Integer, // Total number of invoices "created": Integer, // Number of invoices with 'Created' status "paid": Integer, // Number of invoices with 'Paid' status "overpaid": Integer, // Number of invoices with 'Overpaid' status "partial": Integer, // Number of invoices with 'Partially Paid' status "canceled": Integer // Number of invoices with 'Canceled' status }, "amount": { "all": Float, // Total amount across all invoices in USD "created": Float, // Total amount for 'Created' invoices in USD "paid": Float, // Total amount for 'Paid' invoices in USD "overpaid": Float, // Total amount for 'Overpaid' invoices in USD "partial": Float, // Total amount for 'Partially Paid' invoices in USD "canceled": Float // Total amount for 'Canceled' invoices in USD } } } Example Response: { "status": "success", "result": { "count": { "all": 59, "created": 41, "paid": 16, "overpaid": 1, "partial": 1, "canceled": 0 }, "amount": { "all": 4683.83, "created": 3032.63, "paid": 1531.0, "overpaid": 100.2, "partial": 20.0, "canceled": 0 } } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.