### Dynamic Documentation Query Example Source: https://docs.fonbnk.com/server-to-server/api-endpoints/confirm-order Demonstrates how to perform an HTTP GET request to query the documentation dynamically for additional information. ```http GET https://docs.fonbnk.com/server-to-server/api-endpoints/confirm-order.md?ask= ``` -------------------------------- ### Request URL Example Source: https://docs.fonbnk.com/server-to-server/api-endpoints/get-user-kyc-state Example of how to construct the request URL with required query parameters. ```http GET /api/v2/user/kyc?userEmail=testuser_ng@fonbnk.com&countryIsoCode=NG ``` -------------------------------- ### Elixir Fonbnk Client Example Source: https://docs.fonbnk.com/server-to-server/signing-requests This example demonstrates how to make a GET request to the Fonbnk API, including setting headers, handling successful responses, and reporting errors. It requires the `HTTPoison` and `Jason` libraries. ```Elixir defmodule FonbnkClient do @base_url "https://api.fonbnk.com" @client_id System.get_env("FONBNK_CLIENT_ID") def main() do endpoint = "/v1/accounts" timestamp = DateTime.utc_now() |> DateTime.to_unix!() |> Integer.to_string() signature = sign_request(endpoint, timestamp) make_request(endpoint, timestamp, signature) end defp sign_request(endpoint, timestamp) do "" <> endpoint <> timestamp <> @client_id |> :crypto.hash(:sha256) |> Base.encode16() |> String._downcase() end defp make_request(endpoint, timestamp, signature) do headers = [ {"Content-Type", "application/json"}, {"x-client-id", @client_id}, {"x-timestamp", timestamp}, {"x-signature", signature} ] url = @base_url <> endpoint case HTTPoison.get(url, headers) do {:ok, %HTTPoison.Response{body: body, status_code: code}} when code in 200..299 -> data = Jason.decode!(body) IO.inspect(data) {:ok, %HTTPoison.Response{body: body, status_code: code}} -> IO.puts("HTTP Error #{code}: #{body}") {:error, %HTTPoison.Error{reason: reason}} -> IO.puts("Request Error: #{inspect(reason)})") end end end FonbnkClient.main() ``` -------------------------------- ### GET /api/v2/order Response Example Source: https://docs.fonbnk.com/server-to-server/api-endpoints/get-order An example of a successful response from the GET /api/v2/order endpoint, showing a completed payout. ```json { "_id": "69283d079061f4031ad1ba03", "countryIsoCode": "KE", "userId": "69283c0518613bc9de730cb4", "userEmail": "testuser+ke@fonbnk.com", "status": "payout_successful", "deposit": { "paymentChannel": "mobile_money", "currencyType": "fiat", "currencyCode": "KES", "currencyDetails": { "countryIsoCode": "KE", "carrier": { "code": "ke_safaricom", "name": "Safaricom Kenya", "_id": "618e43914f57e07d255ff353" } }, "cashout": { "amountBeforeFees": 135, "amountAfterFees": 130, "amountBeforeFeesUsd": 1.037823, "amountAfterFeesUsd": 0.999385, "chargedFees": [ { "id": "service_fee", "type": "percentage", "recipient": "platform", "amount": 3.38 }, { "id": "merchant_fee", "type": "percentage", "recipient": "merchant", "amount": 1.35 } ], "chargedFeesUsd": [ { "id": "service_fee", "type": "percentage", "recipient": "platform", "amount": 0.025984 }, { "id": "merchant_fee", "type": "percentage", "recipient": "merchant", "amount": 0.010378 } ], "totalChargedFees": 4.73, "totalChargedFeesUsd": 0.036362, "exchangeRate": 130.08, "exchangeRateAfterFees": 135.0831, "chargedFeesPerRecipient": { "platform": 3.38, "merchant": 1.35 }, "chargedFeesPerRecipientUsd": { "platform": 0.025984, "merchant": 0.010378 }, "feeSettings": [ { "id": "service_fee", "recipient": "platform", "type": "percentage", "value": 2.5, "min": 0, "max": "Infinity" }, { "id": "merchant_fee", "recipient": "merchant", "type": "percentage", "value": 1, "min": 0, "max": "Infinity" } ] }, "providedFieldsToCreateOrder": { "phoneNumber": "2348012345678", "carrierCode": "ke_safaricom" }, "providedFieldsToConfirmOrder": {}, "transferInstructions": { "type": "otp_stk_push", "intermediateActionAttempts": 2, "intermediateActionMaxAttempts": 3, "intermediateActionButtonText": "Verify OTP code", "intermediateActionNextAttemptAvailableAt": "2025-11-27T12:00:14.390Z", "intermediateActionTimeoutMs": 30000, "isIntermediateActionAvailable": true, "forcePhoneNumberVerification": true, "fieldsForIntermediateAction": [ { "key": "otpCode", "label": "OTP code", "type": "number", "required": true } ] } } ``` -------------------------------- ### Order Response Example Source: https://docs.fonbnk.com/server-to-server/api-endpoints/get-orders An example of a successful response from the GET /api/v2/orders endpoint, showing order details including status, currency information, and fee breakdowns. ```json { "nextCursor": "69283d079061f4031ad1ba03", "list": [ { "_id": "69283e024a1db009177f2146", "countryIsoCode": "KE", "userId": "69283c0518613bc9de730cb4", "userEmail": "testuser+ke@fonbnk.com", "status": "deposit_canceled", "deposit": { "paymentChannel": "mobile_money", "currencyType": "fiat", "currencyCode": "KES", "currencyDetails": { "countryIsoCode": "KE", "carrier": { "code": "ke_safaricom", "name": "Safaricom Kenya", "_id": "618e43914f57e07d255ff353" } }, "cashout": { "amountBeforeFees": 135, "amountAfterFees": 130, "amountBeforeFeesUsd": 1.037584, "amountAfterFeesUsd": 0.999155, "chargedFees": [ { "id": "service_fee", "type": "percentage", "recipient": "platform", "amount": 3.38 }, { "id": "merchant_fee", "type": "percentage", "recipient": "merchant", "amount": 1.35 } ], "chargedFeesUsd": [ { "id": "service_fee", "type": "percentage", "recipient": "platform", "amount": 0.025978 }, { "id": "merchant_fee", "type": "percentage", "recipient": "merchant", "amount": 0.010376 } ], "totalChargedFees": 4.73, "totalChargedFeesUsd": 0.036354, "exchangeRate": 130.11, "exchangeRateAfterFees": 135.1142, "chargedFeesPerRecipient": { "platform": 3.38, "merchant": 1.35 }, "chargedFeesPerRecipientUsd": { "platform": 0.025978, "merchant": 0.010376 }, "feeSettings": [ { "id": "service_fee", "recipient": "platform", "type": "percentage", "value": 2.5, "min": 0, "max": "Infinity" }, { "id": "merchant_fee", "recipient": "merchant", "type": "percentage", "value": 1, "min": 0, "max": "Infinity" } ] }, "providedFieldsToCreateOrder": { "phoneNumber": "2348012345678", "carrierCode": "ke_safaricom" }, "transferInstructions": { "type": "stk_push", "intermediateActionAttempts": 1, "intermediateActionMaxAttempts": 3, "intermediateActionButtonText": "Retry USSD prompt initialization", ``` -------------------------------- ### Query Documentation via HTTP GET Source: https://docs.fonbnk.com/how-it-works Demonstrates how to dynamically query this documentation using an HTTP GET request with an 'ask' query parameter. ```http GET https://docs.fonbnk.com/how-it-works.md?ask= ``` -------------------------------- ### Response Example Source: https://docs.fonbnk.com/server-to-server/api-endpoints/get-merchant-balances An example of the JSON response when querying merchant balances. ```json { "USD": 545 } ``` -------------------------------- ### Response Example Source: https://docs.fonbnk.com/server-to-server/api-endpoints/create-quote An example response for a generated quote, showing quote details, fee breakdown, and required fields for order creation. ```json { "quoteId": "6928130ca263ba8d44fad2cf", "quoteExpiresAt": "2025-11-27T09:29:56.167Z", "deposit": { "paymentChannel": "bank", "currencyType": "fiat", "currencyCode": "NGN", "currencyDetails": { "countryIsoCode": "NG" }, "cashout": { "amountBeforeFees": 10000, "amountAfterFees": 9650, "chargedFees": [ { "id": "service_fee", "type": "percentage", "recipient": "platform", "amount": 250 }, { "id": "merchant_fee", "type": "percentage", "recipient": "merchant", "amount": 100 } ], "totalChargedFees": 350, "chargedFeesPerRecipient": { "platform": 250, "merchant": 100 }, "amountBeforeFeesUsd": 6.821794, "amountAfterFeesUsd": 6.583031, "chargedFeesUsd": [ { "id": "service_fee", "type": "percentage", "recipient": "platform", "amount": 0.170545 }, { "id": "merchant_fee", "type": "percentage", "recipient": "merchant", "amount": 0.068218 } ], "totalChargedFeesUsd": 0.238763, "exchangeRate": 1465.89, "exchangeRateAfterFees": 1519.0571, "chargedFeesPerRecipientUsd": { "platform": 0.170545, "merchant": 0.068218 }, "feeSettings": [ { "id": "service_fee", "recipient": "platform", "type": "percentage", "value": 2.5, "min": 0, "max": "Infinity" }, { "id": "merchant_fee", "recipient": "merchant", "type": "percentage", "value": 1, "min": 0, "max": "Infinity" } ] }, "fieldsToCreateOrder": [ { "key": "phoneNumber", "label": "Phone Number", "required": true, "type": "phone" }, { "key": "bankCode", "label": "Bank name", "required": true, "type": "enum", "options": [ { "label": "Sandbox Bank", "value": "1" }, { "label": "Sandbox Bank 2", "value": "2" }, { "label": "Sandbox Bank 3", "value": "3" } ] }, { "key": "bankAccountNumber", "label": "Bank Account Number", "required": true, "type": "string" }, { ``` -------------------------------- ### Create Order Response Example Source: https://docs.fonbnk.com/server-to-server/integration-guide/flow-examples/fiat-to-crypto This is an example of the response received after creating an order. It includes order details and transfer instructions for the user to complete the deposit. ```javascript const response = { "order": { "_id": "68728fa56ff494df5f39faf5", "countryIsoCode": "NG", "userId": "57a28fa56ff494df5f39faf5", "userEmail": "someuser@example.com", "status": "deposit_awaiting", "deposit": { //... transferInstructions: { type: "manual", instructionsText: "Please use the following bank details to make a transfer...", warningText: "Make sure to include the reference code in your transfer.", transferDetails: [ {id: "recipientBankName", label: "Bank Name", value: "9Payment Service Bank"}, {id: "recipientBankAccountNumber", label: "Account Number", value: "1234567890"}, {id: "recipientBankAccountName", label: "Account Name", value: "Example Company Ltd"}, {id: "amountToSend", label: "Amount to Send", value: "153128"}, { id: "bankTransferNarration", label: "Transfer Narration / Reference", value: "ORDER-5F8D0D55B54764421B7156C5", description: "Use this as the transfer reference." } ], fieldsToConfirmOrder: [], } }, "payout": { //... } } } ``` -------------------------------- ### Example GET Request URL for Order Limits Source: https://docs.fonbnk.com/server-to-server/api-endpoints/get-order-limits Illustrates a sample GET request URL to the /api/v2/order-limits endpoint, specifying deposit and payout channel, currency types, codes, and country codes. ```http GET /api/v2/order-limits?depositPaymentChannel=bank&depositCurrencyType=fiat&depositCurrencyCode=NGN&depositCountryIsoCode=NG&payoutPaymentChannel=crypto&payoutCurrencyType=crypto&payoutCurrencyCode=CELO_USDT ``` -------------------------------- ### Create Order Response Example Source: https://docs.fonbnk.com/server-to-server/integration-guide/flow-examples/crypto-to-fiat This is an example of a response when creating an order for a crypto to fiat transaction. It includes details about fees, exchange rates, and provided fields. ```json { "data": { "orderId": "ord_test_1765710476300000000", "createdAt": "2025-12-01T13:31:28.372Z", "updatedAt": "2025-12-01T13:31:28.372Z", "expiresAt": "2025-12-01T14:01:28.156Z", "status": "awaiting_funds", "type": "buy", "sourceCurrency": "USDT", "sourceCurrencyAmount": 21.272315, "destinationCurrency": "NGN", "destinationCurrencyAmount": 15000, "quoteId": "quote_test_1765710476290000000", "feeDetails": { "totalChargedFees": 1088.08, "totalChargedFeesUsd": 0.744531, "chargedFeesPerRecipient": { "platform": 777.2, "merchant": 310.88 }, "chargedFeesPerRecipientUsd": { "platform": 0.531808, "merchant": 0.212723 }, "feeSettings": [ { "id": "service_fee", "recipient": "platform", "type": "percentage", "value": 2.5, "min": 0, "max": "Infinity" }, { "id": "merchant_fee", "recipient": "merchant", "type": "percentage", "value": 1, "min": 0, "max": "Infinity" } ] }, "providedFieldsToCreateOrder": { "phoneNumber": "2348012345678", "bankCode": "1", "bankAccountNumber": "1234567890" } }, "statusChangeLogs": [], "createdAt": "2025-12-01T13:31:28.372Z", "updatedAt": "2025-12-01T13:31:28.372Z", "expiresAt": "2025-12-01T14:01:28.156Z" } ``` -------------------------------- ### Response Example Source: https://docs.fonbnk.com/server-to-server/api-endpoints/generate-user-auth-tokens An example of a successful response from the user token generation API. It contains the generated access and refresh tokens. ```json { "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyRGF0YSI6eyJ1c2VybmFtZSI6InVzZXIjLWhsRjNmek8iLCJfaWQiOiI2OTI4MWQ0ZjE4NjEzYmM5ZGU3MmVkOGUiLCJpc0RldlVzZXIiOmZhbHNlLCJjb3VudHJ5SXNvQ29kZSI6Ik5HIiwiaXNBbWJhc3NhZG9yIjpmYWxzZSwiZW1haWwiOiJ0ZXN0dXNlcituZ0Bmb25ibmsuY29tIn0sInR5cGUiOiJhY2Nlc3MiLCJ1aWQiOiIwMUtDNk02TTJEVkZSSzkxNUtZUTdQQkJBUCIsImlhdCI6MTc2NTQ1NDA3MywiZXhwIjoxNzY1NDU0OTczfQ.zRI7_Dins7VskO9epKJWIlZLwxPMiyKG8Fq_hjXOTAc", "refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyRGF0YSI6eyJ1c2VybmFtZSI6InVzZXIjLWhsRjNmek8iLCJfaWQiOiI2OTI4MWQ0ZjE4NjEzYmM5ZGU3MmVkOGUiLCJpc0RldlVzZXIiOmZhbHNlLCJjb3VudHJ5SXNvQ29kZSI6Ik5HIiwiaXNBbWJhc3NhZG9yIjpmYWxzZSwiZW1haWwiOiJ0ZXN0dXNlcituZ0Bmb25ibmsuY29tIn0sInR5cGUiOiJyZWZyZXNoIiwidWlkIjoiMDFLQzZNNk0ySjc2SEY0WlgzUFRQRTUwQjAiLCJpYXQiOjE3NjU0NTQwNzMsImV4cCI6MTc2NjY2MzY3M30.P1peJxGy7HivuubXbUEnqAW_3vbhem41zMU6v75uI6U" } ``` -------------------------------- ### Create Order Response Example Source: https://docs.fonbnk.com/server-to-server/integration-guide/flow-examples/merchant-balance-to-fiat Example of a successful response when creating an order to move merchant balance to fiat. This includes timestamps for creation, update, and expiration. ```json { "createdAt": "2025-12-02T14:10:43.333Z", "updatedAt": "2025-12-02T14:10:43.333Z", "expiresAt": "2025-12-02T17:10:43.294Z" } ``` -------------------------------- ### Create Order Request Body Example Source: https://docs.fonbnk.com/server-to-server/api-endpoints/create-order An example of a request body for creating an order, specifying user details, deposit and payout information, and required fields for order creation. ```json { "userCountryIsoCode": "NG", "userEmail": "testuser+ng@fonbnk.com", "userIp": "223.134.123.12", "deposit": { "paymentChannel": "bank", "currencyType": "fiat", "currencyCode": "NGN", "countryIsoCode": "NG" }, "payout": { "paymentChannel": "crypto", "currencyType": "crypto", "currencyCode": "POLYGON_USDT", "amount": 1 }, "fieldsToCreateOrder": { "blockchainWalletAddress": "0x5b7ae3c6c87f4a3f94b35c77233b13191ebfad20", "phoneNumber": "2348012345678", "bankCode": "1", "bankAccountNumber": "1234567890" } } ``` -------------------------------- ### Create Order Response Example Source: https://docs.fonbnk.com/server-to-server/integration-guide/flow-examples/fiat-to-merchant-balance This is an example of the response received after successfully creating an order to transfer fiat to a merchant's balance. It includes details about the order, payout information, and status. ```json { "id": "ord_7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c", "orderType": "PAYOUT", "status": "PENDING_PAYMENT", "createdAt": "2025-12-02T13:08:11.013Z", "updatedAt": "2025-12-02T13:08:11.013Z", "expiresAt": "2025-12-02T13:13:10.972Z", "orderRequest": { "orderType": "PAYOUT", "payout": { "currencyCode": "USD", "amount": 100, "recipient": { "type": "MERCHANT", "merchantId": "merch_a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6" } }, "fieldsToConfirmOrder": [ { "id": "amountToSend", "label": "Amount to send", "value": "152206" } ] }, "payout": { "paymentChannel": "merchant_balance", "currencyType": "merchant_balance", "currencyCode": "USD", "currencyDetails": { "merchantName": "bohdan test" }, "cashout": { "amountBeforeFees": 100, "amountAfterFees": 100, "amountBeforeFeesUsd": 100, "amountAfterFeesUsd": 100, "chargedFees": [], "chargedFeesUsd": [], "totalChargedFees": 0, "totalChargedFeesUsd": 0, "exchangeRate": 1, "exchangeRateAfterFees": 1, "chargedFeesPerRecipient": {}, "chargedFeesPerRecipientUsd": { "platform": 2.59067, "merchant": 1.036268 }, "feeSettings": [] }, "providedFieldsToCreateOrder": {} }, "statusChangeLogs": [], "createdAt": "2025-12-02T13:08:11.013Z", "updatedAt": "2025-12-02T13:08:11.013Z", "expiresAt": "2025-12-02T13:13:10.972Z" } ``` -------------------------------- ### Basic KYC Request Body Example Source: https://docs.fonbnk.com/server-to-server/api-endpoints/submit-user-kyc An example of a request body for basic KYC submission, including user email, document ID, and essential user fields. ```json { "userEmail": "testuser_ng@fonbnk.com", "documentId": "67da909b739fc481aa525c43", "userFields": { "first_name": "John", "last_name": "Doe", "dob": "1990-01-01", "id_number": "A123456789" } } ``` -------------------------------- ### Query Documentation Dynamically Source: https://docs.fonbnk.com/fiat-transfer-types To get more information not present on the page, make an HTTP GET request to the page URL with an 'ask' query parameter. The question should be in natural language. ```HTTP GET https://docs.fonbnk.com/fiat-transfer-types.md?ask= ``` -------------------------------- ### GET /api/v2/order Request URL Example Source: https://docs.fonbnk.com/server-to-server/api-endpoints/get-order Example of a GET request to retrieve an order using its unique order ID. ```http GET /api/v2/order?orderId=69281d944a1db009177f0198 ``` -------------------------------- ### Get Currencies API Response Example Source: https://docs.fonbnk.com/server-to-server/integration-guide/flow-examples/merchant-balance-to-fiat Example response from the Get Currencies endpoint, showing supported currency types, codes, and payment channels. Use this to verify if NGN supports payouts and merchant balance supports deposits. ```json [ { "currencyType": "fiat", "currencyCode": "NGN", "paymentChannels": [ { "type": "bank", "transferTypes": [ "manual", "redirect" ], "isDepositAllowed": true, "isPayoutAllowed": true }, { "type": "airtime", "transferTypes": [ "ussd" ], "carriers": [ { "code": "MTN", "name": "MTN" }, { "code": "AIRTEL", "name": "Airtel" }, { "code": "GLO", "name": "Glo" }, { "code": "9MOBILE", "name": "9Mobile" } ], "isDepositAllowed": true, "isPayoutAllowed": false }, { "type": "mobile_money", "transferTypes": [ "stk_push", "otp_stk_push" ], "carriers": [ { "code": "MTN", "name": "MTN Mobile Money" }, { "code": "AIRTEL", "name": "Airtel Money" }, { "code": "GLO", "name": "Glo Mobile Money" }, { "code": "9MOBILE", "name": "9Mobile Money" } ], "isDepositAllowed": true, "isPayoutAllowed": true } ], "currencyDetails": { "countryIsoCode": "NG" }, "pairs": [ "crypto", "merchant_balance" ] }, { "currencyType": "merchant_balance", "currencyCode": "USD", "paymentChannels": [ { "type": "merchant_balance", "transferTypes": [ "manual" ], "isDepositAllowed": true, "isPayoutAllowed": true } ], "currencyDetails": { "merchantName": "Fonbnk" }, "pairs": [ "fiat", "crypto" ] } ] ``` -------------------------------- ### Querying Documentation Source: https://docs.fonbnk.com/server-to-server/api-endpoints/get-merchant-balances Demonstrates how to dynamically query the documentation using an HTTP GET request with the 'ask' query parameter. ```http GET https://docs.fonbnk.com/server-to-server/api-endpoints/get-merchant-balances.md?ask= ``` -------------------------------- ### Get Merchant Balance Example Source: https://docs.fonbnk.com/server-to-server/integration-guide/flow-examples/merchant-balance-to-fiat Call the Get merchant balance endpoint to determine available funds. This is the first step in understanding your disposable balance. ```json { "USD": 761 } ``` -------------------------------- ### Query Documentation Dynamically Source: https://docs.fonbnk.com/widget-integration/getting-started Use this GET request to ask questions about the documentation. Replace with your specific query. ```http GET https://docs.fonbnk.com/widget-integration/getting-started.md?ask= ``` -------------------------------- ### Go Request Signing Example Source: https://docs.fonbnk.com/server-to-server/signing-requests This Go snippet shows how to set request headers including client ID, timestamp, and signature. It then makes an HTTP request and processes the JSON response. ```go req.Header.Set("x-client-id", CLIENT_ID) req.Header.Set("x-timestamp", timestamp) req.Header.Set("x-signature", signature) resp, err := client.Do(req) if err != nil { fmt.Println("Error making request:", err) return } deffer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println("Error reading response body:", err) return } var data map[string]interface{} if err := json.Unmarshal(body, &data); err != nil { fmt.Println("Error unmarshalling response:", err) return } fmt.Println(data) } ``` -------------------------------- ### Response Example Source: https://docs.fonbnk.com/server-to-server/api-endpoints/get-user-kyc-state Illustrates the structure of a successful response, detailing user KYC status, limits, and document requirements. ```json { "passedKycType": "basic", "reachedKycLimit": false, "currentKycType": "basic", "currentKycStatus": "approved", "currentKycStatusDescription": "Exact Match", "kycDocuments": [ { "_id": "67da93c0dfd3a00f3380b857", "title": "Driving License", "value": "DRIVERS_LICENSE", "type": "advanced", "requiredFields": [ { "key": "first_name", "type": "string", "label": "First Name", "required": true }, { "key": "last_name", "type": "string", "label": "Last Name", "required": true }, { "key": "dob", "type": "date", "label": "Date of birth", "required": true }, { "key": "images", "type": "smile-identity-images", "label": "Verification images", "required": true } ] }, { "_id": "67da93c0dfd3a00f3380b859", "title": "National IDs, Consular IDs & Diplomat IDs", "value": "IDENTITY_CARD", "type": "advanced", "requiredFields": [ { "key": "first_name", "type": "string", "label": "First Name", "required": true }, { "key": "last_name", "type": "string", "label": "Last Name", "required": true }, { "key": "dob", "type": "date", "label": "Date of birth", "required": true }, { "key": "images", "type": "smile-identity-images", "label": "Verification images", "required": true } ] }, { "_id": "67da93c0dfd3a00f3380b85b", "title": "Passports", "value": "PASSPORT", "type": "advanced", "requiredFields": [ { "key": "first_name", "type": "string", "label": "First Name", "required": true }, { "key": "last_name", "type": "string", "label": "Last Name", "required": true }, { "key": "dob", "type": "date", "label": "Date of birth", "required": true }, { "key": "images", "type": "smile-identity-images", "label": "Verification images", "required": true } ] }, { "_id": "67da93c0dfd3a00f3380b85d", "title": "Registration certificate", "value": "REGISTRATION_CERTIFICATE", "type": "advanced", "requiredFields": [ { "key": "first_name", "type": "string", "label": "First Name", "required": true }, { "key": "last_name", "type": "string", "label": "Last Name", "required": true }, { "key": "dob", "type": "date", "label": "Date of birth", ``` -------------------------------- ### Example JSON Response for Order Limits Source: https://docs.fonbnk.com/server-to-server/api-endpoints/get-order-limits Provides a sample JSON response from the Get Order Limits API, showing the deposit and payout limits in both local currency and USD. ```json { "deposit": { "min": 1494, "max": 747367, "minUsd": 1, "maxUsd": 500 }, "payout": { "min": 1, "max": 500, "minUsd": 1, "maxUsd": 500 } } ``` -------------------------------- ### Java Request Signing and Execution Source: https://docs.fonbnk.com/server-to-server/signing-requests This Java example shows how to generate an HMAC-SHA256 signature and construct an HTTP GET request with the necessary headers. It uses standard Java libraries for crypto and networking. ```java import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; import java.net.HttpURLConnection; import java.net.URL; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.util.Base64; import java.util.HashMap; import java.util.Map; import java.util.Scanner; public class Main { private static final String BASE_URL = "https://api.fonbnk.com"; private static final String ENDPOINT = "/api/v2/order-limits"; private static final String CLIENT_ID = ""; private static final String CLIENT_SECRET = ""; public static void main(String[] args) throws Exception { long timestamp = System.currentTimeMillis(); Map queryParams = new HashMap<>(); queryParams.put("depositPaymentChannel", "bank"); queryParams.put("depositCurrencyType", "fiat"); queryParams.put("depositCurrencyCode", "NGN"); queryParams.put("depositCountryIsoCode", "NG"); queryParams.put("payoutPaymentChannel", "crypto"); queryParams.put("payoutCurrencyType", "crypto"); queryParams.put("payoutCurrencyCode", "CELO_USDT"); String endpoint = ENDPOINT + "?" + getQuery(queryParams); String signature = generateSignature(CLIENT_SECRET, String.valueOf(timestamp), endpoint); URL url = new URL(BASE_URL + endpoint); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("GET"); connection.setRequestProperty("Content-Type", "application/json"); connection.setRequestProperty("x-client-id", CLIENT_ID); connection.setRequestProperty("x-timestamp", String.valueOf(timestamp)); connection.setRequestProperty("x-signature", signature); Scanner scanner = new Scanner(connection.getInputStream()); String response = scanner.useDelimiter("\\A").next(); System.out.println(response); scanner.close(); } private static String padBase64(String base64String) { return base64String + "=".repeat((4 - base64String.length() % 4) % 4); } private static String generateSignature(String clientSecret, String timestamp, String endpoint) throws Exception { String clientSecretPadded = padBase64(clientSecret); SecretKeySpec secretKeySpec = new SecretKeySpec(Base64.getDecoder().decode(clientSecretPadded), "HmacSHA256"); Mac mac = Mac.getInstance("HmacSHA256"); mac.init(secretKeySpec); String data = timestamp + ":" + endpoint; byte[] hmacBytes = mac.doFinal(data.getBytes(StandardCharsets.UTF_8)); ``` -------------------------------- ### Get Available Currencies Response Example Source: https://docs.fonbnk.com/server-to-server/integration-guide/flow-examples/fiat-to-crypto This JSON response shows the available fiat and crypto currencies, their supported payment channels, and other details. It's used to determine if a fiat-to-crypto conversion is possible. ```json [ { "currencyType": "fiat", "currencyCode": "NGN", "paymentChannels": [ { "type": "bank", "transferTypes": [ "manual", "redirect" ], "isDepositAllowed": true, "isPayoutAllowed": true }, { "type": "airtime", "transferTypes": [ "ussd" ], "carriers": [ { "code": "MTN", "name": "MTN" }, { "code": "AIRTEL", "name": "Airtel" }, { "code": "GLO", "name": "Glo" }, { "code": "9MOBILE", "name": "9Mobile" } ], "isDepositAllowed": true, "isPayoutAllowed": false }, { "type": "mobile_money", "transferTypes": [ "stk_push", "otp_stk_push" ], "carriers": [ { "code": "MTN", "name": "MTN Mobile Money" }, { "code": "AIRTEL", "name": "Airtel Money" }, { "code": "GLO", "name": "Glo Mobile Money" }, { "code": "9MOBILE", "name": "9Mobile Money" } ], "isDepositAllowed": true, "isPayoutAllowed": true } ], "currencyDetails": { "countryIsoCode": "NG" }, "pairs": [ "crypto", "merchant_balance" ] }, { "currencyType": "crypto", "currencyCode": "POLYGON_USDT", "paymentChannels": [ { "type": "crypto", "transferTypes": [ "manual" ], "isDepositAllowed": true, "isPayoutAllowed": true } ], "currencyDetails": { "network": "POLYGON", "asset": "USDT", "contractAddress": "0xc2132D05D31c914a87C6611C10748AEb04B58e8F" }, "pairs": [ "fiat", "merchant_balance" ] } ] ``` -------------------------------- ### Querying Documentation Dynamically Source: https://docs.fonbnk.com/server-to-server/api-endpoints/get-order-limits Demonstrates how to query this documentation dynamically using an HTTP GET request with the 'ask' query parameter. This is useful for retrieving specific information not explicitly stated on the page. ```http GET https://docs.fonbnk.com/server-to-server/api-endpoints/get-order-limits.md?ask= ``` -------------------------------- ### Example Response: Get Order Limits Source: https://docs.fonbnk.com/server-to-server/integration-guide/flow-examples/crypto-to-fiat This JSON response provides the minimum and maximum limits for a crypto-to-fiat transaction, including USD equivalents. Use this to validate user transaction amounts against their KYC tier. ```json {"deposit": {"min": 1, "max": 500, "minUsd": 1, "maxUsd": 500}, "payout": {"min": 1409, "max": 704460, "minUsd": 1, "maxUsd": 500}} ``` -------------------------------- ### Dart HMAC-SHA256 Signature Generation and Request Source: https://docs.fonbnk.com/server-to-server/signing-requests This Dart example demonstrates how to generate an HMAC-SHA256 signature and make a signed GET request to the Fonbnk API. It includes helper functions for query string generation and Base64 decoding. ```dart import 'dart:convert'; import 'package:crypto/crypto.dart'; import 'package:http/http.dart' as http; void main() async { const String BASE_URL = "https://api.fonbnk.com"; const String ENDPOINT = "/api/v2/order-limits"; const String CLIENT_ID = ""; const String CLIENT_SECRET = ""; // Get the current timestamp in milliseconds int timestamp = DateTime.now().millisecondsSinceEpoch; // Create query parameters Map queryParams = { 'depositPaymentChannel': 'bank', 'depositCurrencyType': 'fiat', 'depositCurrencyCode': 'NGN', 'depositCountryIsoCode': 'NG', 'payoutPaymentChannel': 'crypto', 'payoutCurrencyType': 'crypto', 'payoutCurrencyCode': 'CELO_USDT', }; // Generate the query string String queryString = getQuery(queryParams); // Create the endpoint with query parameters String endpoint = ENDPOINT + "?" + queryString; // Generate the signature String signature = generateSignature(CLIENT_SECRET, timestamp.toString(), endpoint); // Build the URL String url = BASE_URL + endpoint; // Set up the HTTP GET request var headers = { "Content-Type": "application/json", "x-client-id": CLIENT_ID, "x-timestamp": timestamp.toString(), "x-signature": signature, }; // Send the GET request var response = await http.get(Uri.parse(url), headers: headers); // Print the response body print(response.body); } String getQuery(Map params) { return params.entries .map((entry) => Uri.encodeQueryComponent(entry.key) + "=" + Uri.encodeQueryComponent(entry.value)) .join("&"); } String generateSignature(String clientSecret, String timestamp, String endpoint) { // Use the custom lenient Base64 decoder List secretKey = lenientBase64Decode(clientSecret); Hmac hmac = Hmac(sha256, secretKey); String data = '$timestamp:$endpoint'; Digest digest = hmac.convert(utf8.encode(data)); // Encode the signature using Base64 String signature = base64Encode(digest.bytes); return signature; } List lenientBase64Decode(String input) { // Base64 index table const String base64Chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; // Remove all characters that are not in the Base64 alphabet String sanitizedInput = input.replaceAll(RegExp(r'[^A-Za-z0-9+/]'), ''); // Map each character to its Base64 index List buffer = []; int bits = 0; int bitsCount = 0; for (int i = 0; i < sanitizedInput.length; i++) { int val = base64Chars.indexOf(sanitizedInput[i]); if (val < 0) { // Skip invalid characters continue; } bits = (bits << 6) | val; bitsCount += 6; if (bitsCount >= 8) { bitsCount -= 8; int byte = (bits >> bitsCount) & 0xFF; buffer.add(byte); } } return buffer; } ``` -------------------------------- ### Dynamic Documentation Query Source: https://docs.fonbnk.com/server-to-server/api-endpoints/get-order Perform an HTTP GET request to query documentation dynamically. Include your question as the value for the 'ask' query parameter. ```bash GET https://docs.fonbnk.com/server-to-server/api-endpoints/get-order.md?ask= ``` -------------------------------- ### Get Order Limits Response Example Source: https://docs.fonbnk.com/server-to-server/integration-guide/flow-examples/fiat-to-crypto This JSON response provides the minimum and maximum limits for both deposit and payout operations for a given currency pair and payment channel. Use this to validate transaction amounts against user tiers. ```json { "deposit": { "min": 1556, "max": 311184, "minUsd": 1, "maxUsd": 200 }, "payout": { "min": 1, "max": 200, "minUsd": 1, "maxUsd": 200 } } ``` -------------------------------- ### Query Documentation Dynamically Source: https://docs.fonbnk.com/server-to-server/servers Use this method to ask questions about the documentation. The response includes direct answers and relevant excerpts. ```http GET https://docs.fonbnk.com/server-to-server/servers.md?ask= ``` -------------------------------- ### Create Quote Request Source: https://docs.fonbnk.com/server-to-server/integration-guide/flow-examples/merchant-balance-to-fiat Send a request to the Create Quote API to get an exchange rate and fee breakdown for converting merchant balance to fiat. This example shows a deposit from merchant balance (USD) to a fiat payout (NGN). ```json { "deposit": { "paymentChannel": "merchant_balance", "currencyType": "merchant_balance", "currencyCode": "USD", "amount": 100 }, "payout": { "paymentChannel": "bank", "currencyType": "fiat", "currencyCode": "NGN", "countryIsoCode": "NG" } } ```