### Withdrawal Request Example Source: https://docs.alphapo.net/integration-guide/withdrawals This example demonstrates a POST request to the /api/v2/withdrawal/crypto endpoint. It includes essential headers like Host and X-Processing-Key. ```text POST /api/v2/withdrawal/crypto HTTP/1.1 Host: app.alphapo.net X-Processing-Key: ``` -------------------------------- ### Deposit Request Example Source: https://docs.alphapo.net/integration-guide/deposits This snippet shows an example of a deposit request payload. Ensure all required fields are correctly populated. ```json { "end_user_reference": "user_12345", "convert_to": "EUR" } ``` -------------------------------- ### Deposit Callback Example Source: https://docs.alphapo.net/api-reference/callbacks/deposit-callbacks This example demonstrates the structure of a deposit callback payload. It includes details such as transaction ID, address, currency, and amount. ```json { "transaction_id": "1234567890", "address": "0x071B2E45e2CD08011555755b93d5C76D2E62C4Cd", "tag": null, "foreign_id": "11", "currency_sent": { "currency": "ETH", "amount": "0.01000000" }, "currency_received": { "currency": "ETH", "amount": "0.01000000" }, "status": "completed", "created_at": "2023-10-27T10:00:00Z", "updated_at": "2023-10-27T10:05:00Z" } ``` -------------------------------- ### Withdrawal Callback Example Source: https://docs.alphapo.net/api-reference/callbacks/withdrawal-callbacks This example demonstrates the structure of a withdrawal callback, including details about the operation, cryptocurrency address, and associated transactions. ```APIDOC ## Withdrawal Callback ### Description Callback sent when a withdrawal status changes. Includes details like operation ID, end-user reference, cryptocurrency address, and transaction information. ### Type withdrawal ### Fields - **id** (integer) - Unique identifier for the callback. - **foreign_id** (string) - External identifier for the operation. - **end_user_reference** (string) - Identifier for the customer receiving the funds. - **type** (string) - Type of the operation, should be "withdrawal". - **crypto_address** (object) - Details of the cryptocurrency address used for withdrawal. - **id** (integer) - Unique identifier for the crypto address. - **currency** (string) - Currency of the address (e.g., "BTC"). - **address** (string) - The cryptocurrency address. - **tag** (string or null) - Optional tag for the address. - **transactions** (array) - List of transactions associated with the withdrawal. - **id** (integer) - Unique identifier for the transaction. - **currency** (string) - Currency of the transaction. - **transaction_type** (string) - Type of the transaction (e.g., "blockchain"). - **type** (string) - Type of the operation within the transaction. - **address** (string) - The destination address for the transaction. - **tag** (string or null) - Optional tag for the address. ### Response Example ```json { "id": 123, "foreign_id": "operation_987", "end_user_reference": "user_12345", "type": "withdrawal", "crypto_address": { "id": 123, "currency": "BTC", "address": "tb1qurv0m4ufsj8xqejvmn0y43kqew33kvqrrxswgm", "tag": null }, "transactions": [ { "id": 999, "currency": "BTC", "transaction_type": "blockchain", "type": "withdrawal", "address": "tb1qurv0m4ufsj8xqejvmn0y43kqew33kvqrrxswgm", "tag": null } ] } ``` ``` -------------------------------- ### Deposit Callback Example Source: https://docs.alphapo.net/api-reference/callbacks/deposit-callbacks This is an example of a deposit callback notification. It includes details about the transaction, currency, amount, and status. ```APIDOC ## Deposit Callback Example ### Description This callback is triggered when a deposit is successfully processed. It provides comprehensive details about the deposit transaction. ### Method POST (Assumed, as callbacks are typically sent via POST) ### Endpoint `/callback/deposit` (Assumed, based on common callback patterns) ### Request Body - **type** (string) - The type of the event, e.g., "deposit". - **currency** (string) - The currency of the deposit (e.g., "EUR"). - **amount** (string) - The amount of the deposit as a string. - **error** (string) - Any error message associated with the deposit, empty if none. - **status** (string) - The status of the deposit (e.g., "confirmed"). ### Request Example ```json { "type": "deposit", "currency": "EUR", "amount": "4.20853511", "error": "", "status": "confirmed" } ``` ### Response (Callbacks typically do not expect a response body from the client, but a 2xx status code indicates successful receipt.) #### Success Response (200 OK) Indicates the callback was received successfully. ``` -------------------------------- ### Confirmed Deposit Callback Example Source: https://docs.alphapo.net/api-reference/callbacks/deposit-callbacks Provides a JSON example of a deposit callback when the deposit has been successfully confirmed. This is the safest stage to credit customer balances. ```json { "id": 1, "end_user_reference": "12345", "type": "deposit", "crypto_address": { "id": 1, "address": "bc1qxy2kgdygjrsqtzv5w0j0j0j0j0j0j0j0j0j0", "currency": "BTC" }, "currency_sent": { "amount": "0.001", "currency": "BTC" }, "currency_received": { "amount": "0.000998", "currency": "BTC", "amount_minus_fee": "0.000998" }, "status": "confirmed", "created_at": "2023-01-01T12:00:00Z", "updated_at": "2023-01-01T12:05:00Z" } ``` -------------------------------- ### Exchange Now Response Example Source: https://docs.alphapo.net/api-reference/endpoints/exchange-now This is an example of a successful response after executing an exchange. It includes details about the transaction, such as currencies, amounts, fees, and the transaction status. ```JSON { "data": { "sender_currency": "BTC", "sender_amount": "0.00300000", "receiver_currency": "EUR", "receiver_amount": "231.94279333", "fee_currency": "BTC", "fee_amount": "0.00015000", "price": "77314.26444333", "id": 134704200, "foreign_id": "test_foreign_id_0319", "type": "exchange", "status": "processing" } } ``` -------------------------------- ### Deposit Callback Example Source: https://docs.alphapo.net/api-reference/callbacks/deposit-callbacks This example demonstrates the structure of a deposit callback payload. It includes details such as transaction tags, currency, amount, and foreign identifiers. ```json { "tag": null, "cross_currency": true, "foreign_id": "12345", "currency_sent": { "currency": "ETH", "amount": "0.01000000" }, "currency_received": { "currency": "ETH", "amount": "0.01000000" } } ``` -------------------------------- ### Deposit Callback Payload Examples Source: https://docs.alphapo.net/api-reference/callbacks/deposit-callbacks Provides examples of deposit callback payloads, specifically for confirmed deposits. ```APIDOC ## Deposit Callback Payload Examples ### Confirmed Deposit Sent when a deposit has been successfully confirmed and can be treated as final on your side. At this stage, it is safe to perform business actions such as crediting the customer’s balance. ```json { "id": 1, "end_user_reference": "12345", "type": "deposit", "crypto_address": { "id": 1, "address": "bc1qxy2kgdygjrsqtzp2n0xpr46237x544f044070f", "currency": "BTC" }, "currency_sent": { "amount": "0.001", "currency": "BTC" }, "currency_received": { "amount": "0.001", "currency": "BTC", "amount_minus_fee": "0.000999" }, "status": "confirmed", "created_at": "2022-01-01T12:00:00Z", "updated_at": "2022-01-01T12:05:00Z" } ``` ``` -------------------------------- ### Instant Withdrawal Callback Example Source: https://docs.alphapo.net/api-reference/callbacks/withdrawal-callbacks This JSON example shows the payload for an instant withdrawal callback. It contains essential details about the withdrawal transaction. ```json { "id": "123", "foreign_id": "operation_987", "end_user_reference": "user_12345", "type": "withdrawal_instant", "crypto_address": { "id": "123", "foreign_id": "operation_987", "end_user_reference": "user_12345", "type": "withdrawal_instant", "crypto_address": { "address": "0x1234567890abcdef1234567890abcdef12345678", "network": "ETH" }, "amount": { "amount": "1.0", "currency": "ETH" }, "status": "pending", "created_at": "2023-10-27T10:05:00Z" }, "amount": { "amount": "1.0", "currency": "ETH" }, "status": "pending", "created_at": "2023-10-27T10:05:00Z" } ``` -------------------------------- ### Crypto Withdrawal Request Example Source: https://docs.alphapo.net/integration-guide/withdrawals This example demonstrates the structure of a POST request to initiate a crypto withdrawal. Ensure 'foreign_id' and 'end_user_reference' are included as unique identifiers. ```text POST /api/v2/withdrawal/crypto HTTP/1.1 Host: app.alphapo.net X-Processing-Key: X-Processing-Signature: Content-Type: application/json Accept: */* Content-Length: 161 { "amount": "25", "currency": "EUR", "convert_to": "BTC", "address": "tb1qjv8alc7c708tddm9nrdtpwm5xna30fgkql5vgs", "foreign_id": "user_12345", "end_user_reference": "user_12345" } ``` -------------------------------- ### BTC Payment Callback Example Source: https://docs.alphapo.net/api-reference/callbacks/invoice-payment-callbacks This example demonstrates the structure of a callback for a Bitcoin (BTC) payment. It highlights the specific fields for cryptocurrency transactions. ```json { "event": "invoice.payment.succeeded", "data": { "id": "inv_67890", "object": "invoice", "paid": true, "amount_due": "0.00990000", "attempt_count": 1, "currency_sent": { "currency": "BTC", "amount": "0.01000000" }, "currency_received": { "currency": "BTC", "amount": "0.00990000" }, "customer": "cus_fghij", "description": "Invoice payment via BTC", "due_date": 1678972800, "lines": { "object": "list", "data": [ { "id": "line_2", "object": "line_item", "amount": "0.00990000", "currency": "BTC", "description": "BTC Payment", "quantity": 1 } ], "has_more": false, "url": "/v1/invoices/inv_67890/lines" }, "payment_intent": { "id": "pi_uvw123", "object": "payment_intent", "amount": "0.00990000", "currency": "btc", "status": "succeeded" }, "status_transitions": { "paid_at": 1678972800 }, "created_at": 1678972700, "updated_at": 1678972800 } } ``` -------------------------------- ### Deposit Callback Payload Example Source: https://docs.alphapo.net/api-reference/callbacks/deposit-callbacks This example demonstrates the structure of a deposit callback payload. It includes details such as the crypto address, transaction ID, currency, and foreign ID. ```json { "crypto_address": { "id": 1, "currency": "BTC", "address": "39mFf3X46YzUtfdwVQpYXPCMydc74ccbAZ", "foreign_id": "12345", "tag": null }, "currency_sent": { "currency": "BTC" } } ``` -------------------------------- ### Invoice Payment Callback Example Source: https://docs.alphapo.net/api-reference/callbacks/invoice-payment-callbacks This example demonstrates the structure of a typical invoice payment callback. It includes details about the payment ID, currency, address, and amounts. ```json { "id": 1846, "currency": "BTC", "address": "2MyL2ftBdNsmpsx1EKggPzNVuoiZCWdVaLX", "tag": null, "currency_sent": { "currency": "BTC", "amount": "0.02000000", "remaining_amount": ``` -------------------------------- ### Invoice Payment Callback Example Source: https://docs.alphapo.net/api-reference/callbacks/invoice-payment-callbacks This example demonstrates the structure of a typical invoice payment callback. It includes details about the transaction, amount, currency, and address. ```json { "amount": "0.02000000", "transactions": [ { "id": "750294", "currency": "BTC", "transaction_type": "blockchain", "type": "deposit", "address": "2Mvo6FMduhHz1BTDHsQ5GyRoifcG3y4ycpk", "tag": null } ] } ``` -------------------------------- ### Deposit Callback Payload Example Source: https://docs.alphapo.net/api-reference/callbacks/deposit-callbacks This example demonstrates the structure of a typical deposit callback payload. It includes essential details like transaction ID, currency, and address information. ```json { "id": 2686510, "end_user_reference": "12345", "type": "deposit", "expected_currency": "USDC", "crypto_address": { "id": 382270, "currency": "ETH", "address": "0xd61180ff0cf74dc3ee8e264751f18c47060729b9" } } ``` -------------------------------- ### Deposit Callback Payload Example Source: https://docs.alphapo.net/api-reference/callbacks/deposit-callbacks This example demonstrates the structure of a typical deposit callback payload. It includes details such as currency, address, tag, foreign ID, and transaction information. ```json { "currency": "BTC", "address": "tb1qhaj2ruldumppj49ystync0um6239qsjj44s67e", "tag": null, "foreign_id": "12345", "transactions": [ { "id": 999, "currency": "BTC" } ] } ``` -------------------------------- ### Deposit Callback Payload Example Source: https://docs.alphapo.net/api-reference/callbacks/deposit-callbacks This example shows the structure of a typical deposit callback payload. It includes details such as amounts, currency, transaction type, and unique identifiers. ```json { "amount": "84.17070222", "amount_minus_fee": "79.96216711" }, { "transactions": [ { "id": 714576, "currency": "BTC", "transaction_type": "blockchain", "type": "deposit" } ] } ``` -------------------------------- ### Withdrawal Callback Example Source: https://docs.alphapo.net/api-reference/callbacks/withdrawal-callbacks This example shows the structure of a withdrawal callback when a withdrawal is confirmed. It includes details like the type of event, currency, amount, and status. ```APIDOC ## Withdrawal Callback Example ### Description This example shows the structure of a withdrawal callback when a withdrawal is confirmed. It includes details like the type of event, currency, amount, and status. ### Event Structure - **type** (string) - The type of callback event. For crypto withdrawals from fiat, this would be `"fee_crypto_withdrawal_from_fiat"`. - **currency** (string) - The currency of the withdrawal (e.g., `"BTC"`). - **amount** (string) - The amount of the withdrawal (e.g., `"0.00028735"`). - **error** (string) - Any error message associated with the withdrawal. This will be an empty string if the withdrawal was successful. - **status** (string) - The current status of the withdrawal (e.g., `"confirmed"`). ### Request Example ```json { "type": "fee_crypto_withdrawal_from_fiat", "currency": "BTC", "amount": "0.00028735", "error": "", "status": "confirmed" } ``` ### Response This callback does not expect a response from your system, but it should be received and processed to update your records. ``` -------------------------------- ### Payment Request Callback Example Source: https://docs.alphapo.net/api-reference/callbacks/payment-request This snippet shows an example of the data structure received in a payment request callback. It includes details about the payment amount, currency, and destination address. ```json { "iso": "ETH", "network_name": "ethereum", "convert_to": { "iso": "ETH", "network_name": "ethereum" }, "address": "0x114da762447ccb464ac29134B2930e0570139F83", "payment_request_amount": { "currency": { "iso": "ETH", "network_name": "ethereum" } } } ``` -------------------------------- ### Deposit Callback Payload Example Source: https://docs.alphapo.net/api-reference/callbacks/deposit-callbacks This example shows the structure of a deposit callback payload. It includes details such as transaction ID, currency, type, address, and tag. ```json { "amount_minus_fee": "0.01000000", "transactions": [ { "id": 3745588, "currency": "ETH", "transaction_type": "blockchain", "type": "deposit", "address": "0x071B2E45e2CD08011555755b93d5C76D2E62C4Cd", "tag": null } ] } ``` -------------------------------- ### Invoice Payment Callback Example Source: https://docs.alphapo.net/api-reference/callbacks/invoice-payment-callbacks This example demonstrates the structure of a typical invoice payment callback. It includes details about the payment amount, currency, transaction type, and address. ```json { "amount": "0.02000000", "transactions": [ { "id": 750294, "currency": "BTC", "transaction_type": "blockchain", "type": "deposit", "address": "2Mvo6FMduhHz1BTDHsQ5GyRoifcG3y4ycpk", "tag": null } ] } ``` -------------------------------- ### Invoice Payment Callback Example Source: https://docs.alphapo.net/api-reference/callbacks/invoice-payment-callbacks This example demonstrates the structure of a typical invoice payment callback. It includes details such as currency sent, amount sent, currency received, and remaining amount. ```json { "tag": null, "currency_sent": { "currency": "BTC", "amount": "0.00309556", "remaining_amount": "0.00000000" }, "currency_received": { "currency": "EUR", "amount": "100.00", "remaining_amount": "0.00" } } ``` -------------------------------- ### Verify your implementation Source: https://docs.alphapo.net/api-reference/authentication Use this example to verify your signature generation implementation. ```APIDOC ## Verify your implementation ### Description Generate a signature for the provided JSON body using the specified secret key to verify your implementation. ### Example Generate a signature for the following JSON body using `AbCdEfG123456` as the secret key: ```json {"currency":"BTC","foreign_id":"123456"} ``` ``` -------------------------------- ### Invoice Payment by Installments Callback Source: https://docs.alphapo.net/llms-full.txt Sent when an invoice is paid using multiple transactions. The invoice is marked as confirmed once the full amount is received. This example shows two separate BTC deposit transactions. ```json { "id": 588, "foreign_id": "8FW1KI7LesB9yxWcK1K", "end_user_reference": "12345", "type": "invoice", "crypto_address": { "id": 386897, "currency": "BTC", "address": "2Mvo6FMduhHz1BTDHsQ5GyRoifcG3y4ycpk", "tag": null }, "currency_sent": { "currency": "BTC", "amount": "0.02000000", "remaining_amount": "0.00000000" }, "currency_received": { "currency": "BTC", "amount": "0.02000000" }, "transactions": [ { "id": 750294, "currency": "BTC", "transaction_type": "blockchain", "type": "deposit", "address": "2Mvo6FMduhHz1BTDHsQ5GyRoifcG3y4ycpk", "tag": null, "amount": "0.01000000", "txid": "6647cf5cae701507b7076b32ca12f19d8e9fe037407c02e09b04abdaede99fd0", "confirmations": "1" }, { "id": 750384, "currency": "BTC", "transaction_type": "blockchain", "type": "deposit", "address": "2Mvo6FMduhHz1BTDHsQ5GyRoifcG3y4ycpk", "tag": null, "amount": "0.01000000", "txid": "528dcda13270f8590853405600bf5634d53aa66d2ce5d3a873006a670f9da788", "confirmations": "1" } ], "fees": [ { "type": "fee_crypto_deposit", "currency": "BTC", "amount": "0.0008" } ], "error": "", "status": "confirmed", "fixed_at": 1592307241, "expires_at": 1592394104 } ``` -------------------------------- ### Setting up a Webhook Endpoint Source: https://docs.alphapo.net/api-reference/callbacks/exchange-callbacks This example shows a basic Express.js route for receiving and processing webhook callbacks from the exchange. Ensure your endpoint is publicly accessible and secured. ```javascript const express = require('express'); const bodyParser = require('body-parser'); const app = express(); app.post('/webhook/exchange', bodyParser.json(), (req, res) => { const callbackData = req.body; console.log('Received exchange callback:', callbackData); // TODO: Implement robust callback handling logic here // e.g., validate signature, process event type, update database res.sendStatus(200); // Acknowledge receipt of the callback }); const PORT = process.env.PORT || 3000; app.listen(PORT, () => { console.log(`Webhook server listening on port ${PORT}`); }); ``` -------------------------------- ### System Health Callback Example Source: https://docs.alphapo.net/api-reference/callbacks/withdrawal-callbacks Illustrates the structure of a system health callback, showing fees and error messages. ```json { "fees": [], "error": "Declined by user ID:777", "status": "declined" } ``` -------------------------------- ### System Health Callback Example Source: https://docs.alphapo.net/api-reference/callbacks/payment-request This callback is sent for system health monitoring. It includes details about the currency and amount. ```json { "type":"fee_payment_request_crypto", "currency":{ "iso":"ETH", "network_name":"ethereum" }, "amount":"0.00854354" } ], "fixed_at":1769780669, "expires_at":1769780868, "valid_until":1769780868 } ``` -------------------------------- ### Withdrawal Callback Example Source: https://docs.alphapo.net/api-reference/callbacks/withdrawal-callbacks This example demonstrates the structure of a withdrawal callback payload. It includes details such as currency, address, tag, and transaction information. ```json { "id": 123, "currency": "BTC", "address": "tb1qurv0m4ufsj8xqejvmn0y43kqew33kvqrrxswgm", "tag": null, "transactions": [ { "id": 999, "currency": "BTC", "transaction_type": "blockchain" } ] } ``` -------------------------------- ### Withdrawal Callback Example Source: https://docs.alphapo.net/api-reference/callbacks/withdrawal-callbacks This example demonstrates the structure of a withdrawal callback notification. It includes details such as transaction ID, currency, address, and type. ```json { "transactions": [ { "id": "999", "currency": "BTC", "transaction_type": "blockchain", "type": "withdrawal", "address": "tb1qurv0m4ufsj8xqejvmn0y43kqew33kvqrrxswgm", "tag": null } ] } ``` -------------------------------- ### Initialize and Configure Exchange Now Source: https://docs.alphapo.net/api-reference/endpoints/exchange-now This snippet shows how to initialize and configure the Exchange Now functionality. It includes logic for handling banner states and user preferences based on local storage. ```javascript try{ let f,g,h=[]; try{ h=window.location.pathname.split("/").filter(a=>""!==a&&"global"!==a).slice(0,2) }catch{ h=[] } let i=h.find(a=>c.includes(a)),j=[]; for(let c of(i?j.push(i):j.push(b),j.push("global"),j)){ if(!c)continue; let b=a[c]; if(b?.content){ f=b.content,g=c; break } } if(!f)return void document.documentElement.setAttribute(d,"hidden"); let k=!0,l=0; for(;l