### Get Payment Information with PHP Source: https://4clever.io/api/v1/pay This snippet shows how to retrieve payment information using the 4clever.io API v1. It sends a GET request to the payment information endpoint. The response includes the status and data of the payment. ```php $ch = curl_init('https://4clever.io/api/v1/pay/get/{hash}'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_HEADER, false); $result = json_decode(curl_exec($ch)); curl_close($ch); print_r($result); ``` -------------------------------- ### GET /api/v1/pay/get/{hash} Source: https://4clever.io/api/v1/pay Retrieves payment information using the payment hash. This is useful for checking the status of a payment without approving it. No body parameters are needed; the hash is in the path. ```APIDOC ## GET /api/v1/pay/get/{hash} ### Description Fetches details about a specific payment by its hash. ### Method GET ### Endpoint https://4clever.io/api/v1/pay/get/{hash} ### Parameters #### Path Parameters - **hash** (String) - Required - Payment hash ### Request Example GET https://4clever.io/api/v1/pay/get/payment_hash ### Response #### Success Response (200) - **status** (String) - Request status - **data** (Object) - Payment details #### Response Example { "status": "success", "data": { "order_id": "unique_order_id", "amount": "300", "status": "pending" } } ``` -------------------------------- ### Create Payment with PHP Source: https://4clever.io/api/v1/pay This snippet demonstrates how to create a payment using the 4clever.io API v1. It sends a POST request with required parameters such as token, order ID, amount, and URLs for redirection and callback. The response includes a payment URL. ```php $token = 'ВАШ ТОКЕН'; $order_id = time() . mt_rand(); $amount = 300; $params = []; $data = [ 'token' => $token, 'order_id' => $order_id, 'amount' => $amount, 'discount' => 1, 'data' => json_encode($params), 'redirect_url' => '', 'callback_url' => '' ]; $ch = curl_init('https://4clever.io/api/v1/pay/create'); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data, '', '&')); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_HEADER, false); $result = json_decode(curl_exec($ch)); curl_close($ch); print_r($result->url); ``` -------------------------------- ### POST /api/v1/pay/create Source: https://4clever.io/api/v1/pay This endpoint creates a new payment and returns a payment URL for the user to complete the transaction. It requires authentication via token and details like order ID, amount, and callback URLs. Upon success, it provides a hash and redirect URL for payment processing. ```APIDOC ## POST /api/v1/pay/create ### Description Creates a new payment link for the user to pay via 4Clever.io. ### Method POST ### Endpoint https://4clever.io/api/v1/pay/create ### Parameters #### Request Body - **token** (String) - Required - Your authentication token - **order_id** (String) - Required - Unique order ID in your system - **amount** (String) - Required - Payment amount - **discount** (Int) - Required - Discount percentage for payment tolerance - **data** (Json) - Required - Additional data object passed with notifications - **redirect_url** (String) - Required - URL to redirect user after payment - **callback_url** (String) - Required - URL for payment notifications ### Request Example { "token": "YOUR_TOKEN", "order_id": "unique_order_id", "amount": "300", "discount": 1, "data": "{}", "redirect_url": "https://your-site.com/success", "callback_url": "https://your-site.com/callback" } ### Response #### Success Response (200) - **status** (String) - Request status - **hash** (String) - Payment hash - **url** (String) - Payment page URL #### Response Example { "status": "success", "hash": "payment_hash", "url": "https://4clever.io/pay/payment_hash" } ``` -------------------------------- ### Handle Payment Callback with PHP Source: https://4clever.io/api/v1/pay This snippet shows how to handle a payment callback from 4clever.io. It verifies the signature and processes the payment data if the signature is valid. The server should respond with 'OK' upon successful processing. ```php $token = 'ТОКЕН ПОЛЬЗОВАТЕЛЯ'; $sign = $_SERVER['HTTP_SIGNATURE']; $sign2 = hash_hmac('sha256', $_POST['hash'] . '|' . $_POST['createdDateTime'] . '|' . $_POST['amount'], $token); if($sign == $sign2) { // Код в случае успешной оплаты // Для получения data используйте html_entity_decode($_POST['data']); echo 'OK'; // Вернуть ответ серверу } else { echo 'ERROR SIGN'; } ``` -------------------------------- ### Confirm Payment with PHP Source: https://4clever.io/api/v1/pay This snippet demonstrates how to confirm a payment using the 4clever.io API v1. It sends a POST request with the token and payment hash. The response includes the status of the request. ```php $token = 'ВАШ ТОКЕН'; $data = [ 'token' => $token, 'hash' => 'хэш платежа' ]; $ch = curl_init('https://4clever.io/api/v1/pay/approve'); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data, '', '&')); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_HEADER, false); $result = json_decode(curl_exec($ch)); curl_close($ch); print_r($result); ``` -------------------------------- ### POST [callback_url] - Success Notification Webhook Source: https://4clever.io/api/v1/pay This is a webhook endpoint on your server that receives POST notifications when a payment is successful. It includes payment details and requires signature verification for security. Respond with 'OK' on success or 'ERROR SIGN' on failure. ```APIDOC ## POST {callback_url} ### Description Webhook for receiving successful payment notifications from 4Clever.io. Verify the signature to ensure authenticity before processing. ### Method POST ### Endpoint {callback_url} (as specified during payment creation) ### Parameters #### Request Body - **hash** (String) - Operation number in 4Clever system - **order_id** (String) - Unique order ID from your system - **amount** (Float) - Payment amount - **data** (Json) - Additional data from payment creation - **createdDateTime** (String) - Payment creation timestamp - **status** (String) - Payment status (e.g., 'PAID') - **HTTP_SIGNATURE** (Header) - Signature for verification ### Request Example { "hash": "payment_hash", "order_id": "unique_order_id", "amount": 300.0, "data": "{}", "createdDateTime": "2023-10-01T12:00:00Z", "status": "PAID" } ### Response #### Success Response - Respond with 'OK' #### Error Response - Respond with 'ERROR SIGN' if signature invalid ``` -------------------------------- ### POST /api/v1/pay/approve Source: https://4clever.io/api/v1/pay Approves a payment using its hash and token. This endpoint confirms the transaction on the server side. It returns the status of the approval request. ```APIDOC ## POST /api/v1/pay/approve ### Description Confirms and approves a payment by hash. ### Method POST ### Endpoint https://4clever.io/api/v1/pay/approve ### Parameters #### Request Body - **token** (String) - Required - Your authentication token - **hash** (String) - Required - Payment hash to approve ### Request Example { "token": "YOUR_TOKEN", "hash": "payment_hash" } ### Response #### Success Response (200) - **status** (String) - Request status #### Response Example { "status": "success" } ``` -------------------------------- ### Transfer Funds - PHP Source: https://4clever.io/api/v1/transfer This snippet demonstrates how to transfer funds using the 4clever.io API. It uses the `curl` library in PHP to send a POST request to the `/transfer/send` endpoint, including authentication tokens, the recipient address, and the amount to transfer. The response is a JSON object containing the transfer ID and amount. ```PHP $token, 'address' => $address, 'amount' => $amount, ]; $ch = curl_init('https://4clever.io/api/v1/transfer/send'); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data, '', '&')); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_HEADER, false); $result = json_decode(curl_exec($ch)); curl_close($ch); print_r($result); ?> ``` -------------------------------- ### POST /api/v1/transfer/send Source: https://4clever.io/api/v1/transfer Allows users to transfer funds to another wallet address using their API token. ```APIDOC ## POST /api/v1/transfer/send ### Description Transfers funds from the authenticated user's wallet to a specified recipient wallet address. ### Method POST ### Endpoint https://4clever.io/api/v1/transfer/send ### Parameters #### Request Body - **token** (String) - Required - Your API authentication token. - **address** (String) - Required - The wallet address to which the funds will be transferred. - **amount** (String) - Required - The amount of funds to transfer. ### Request Example ```json { "token": "YOUR_API_TOKEN", "address": "RECIPIENT_WALLET_ADDRESS", "amount": "300" } ``` ### Response #### Success Response (200) - **id** (String) - The unique identifier for the transfer operation. - **amount** (String) - The amount of funds that were transferred. #### Response Example ```json { "id": "transfer_12345abcde", "amount": "300" } ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.