### Example Response for Available Assets (OK) Source: https://developer.paychant.com/api-reference/rest-api-reference Example JSON response for the 'Available assets' endpoint, showing supported assets with their chain and asset identifiers. ```json [ { "chain": "CELO", "asset": "CELO" }, { "chain": "STELLAR", "asset": "USDC" }, { "chain": "BSC", "asset": "USDT" }, { "chain": "POLYGON", "asset": "USDC" }, ... ] ``` -------------------------------- ### Example Response for Get Price (OK) Source: https://developer.paychant.com/api-reference/rest-api-reference Example JSON response when successfully retrieving asset price information. It includes the price in different denominations, along with minimum and maximum transaction values. ```json { "usd": 1, "nga": 1186.04, "price": 1216.45, "minimum": 1000, "maximum": 5000 } ``` ```json { "usd": 0.099, "usdc": 0.00084, "price": 1213.11, "minimum": 1000, "maximum": 5000 } ``` -------------------------------- ### Example Response for Available Payment Methods (OK) Source: https://developer.paychant.com/api-reference/rest-api-reference Example JSON response for the 'Available Payment Methods' endpoint, listing supported payment methods by name and a unique identifier for a given fiat currency. ```json [ { "name": "M-Pesa", "nameId": "m_pesa" }, { "name": "Bank Transfer", "nameId": "bank_transfer" }, ... ] ``` -------------------------------- ### Example Response for Available Fiats (OK) Source: https://developer.paychant.com/api-reference/rest-api-reference Example JSON response for the 'Available fiats' endpoint, listing supported fiat currencies with their ISO 3-alpha codes. ```json [ { "fiat": "NGN", "iso_alpha_3": "NGA" }, { "fiat": "GHS", "iso_alpha_3": "GHA" }, ... ] ``` -------------------------------- ### Get Supported Assets (GET /assets/{action}/{env}) Source: https://developer.paychant.com/api-reference/rest-api-reference Retrieves a list of supported assets based on the specified action and environment. This endpoint helps identify which assets are available for trading or other operations within a particular context. ```http GET /assets/{action}/{env} ``` -------------------------------- ### Get Supported Payment Methods (GET /payment-method/{iso_alpha_3}) Source: https://developer.paychant.com/api-reference/rest-api-reference Retrieves a list of supported payment methods for a given fiat currency. This is useful for determining how users can fund or withdraw assets in a specific currency. ```http GET /payment-method/{iso_alpha_3} ``` -------------------------------- ### Get Supported Fiat Currency (GET /fiat) Source: https://developer.paychant.com/api-reference/rest-api-reference Retrieves a list of all supported fiat currencies by the Paychant API. Each currency is returned with its name and ISO 3-alpha code. ```http GET /fiat ``` -------------------------------- ### Get Asset Price (GET /price/{chain}/{asset}?iso={iso_alpha_3}&action={action}) Source: https://developer.paychant.com/api-reference/rest-api-reference Retrieves the current price of a specified asset on a given blockchain, denominated in a specified ISO currency. Optional parameters allow for calculation based on fiat or asset value, and inclusion of network or payment method fees. ```http GET /price/{chain}/{asset}?iso={iso_alpha_3}&action={action} ``` -------------------------------- ### Receive and Validate Paychant Webhook Events (Node.js) Source: https://developer.paychant.com/resources/webhooks This Node.js snippet demonstrates how to set up a webhook endpoint using Express to receive and validate incoming Paychant events. It uses the 'crypto' module to verify the 'paychant-signature' header against the request body, ensuring the event's authenticity. The secret key should be stored securely, for example, in environment variables. ```javascript const crypto = require('crypto'); const secret = process.env.SECRET_KEY; // Your paychant webhook secret // Using Express router.post("/webhook/url", function(req, res) { res.sendStatus(200); // Return status code 200 quickly // Validate event const hmac = crypto.createHmac('sha512', secret); const hash = hmac.update(JSON.stringify(req.body)).digest('hex'); const headerSig = req.headers['paychant-signature']; if (hash === headerSig) { var event = req.body; // Do someting with the event } }); ``` -------------------------------- ### Get Asset Price Source: https://developer.paychant.com/api-reference/rest-api-reference Retrieves the current price of a specified asset within a given blockchain and fiat currency context. Optional parameters allow for calculations based on fiat value, asset value, network fees, and payment methods. ```APIDOC ## GET /price/{chain}/{asset}?iso={iso_alpha_3}&action={action} ### Description Retrieves the current price of a specified asset within a given blockchain and fiat currency context. Optional parameters allow for calculations based on fiat value, asset value, network fees, and payment methods. ### Method GET ### Endpoint `/price/{chain}/{asset}` ### Parameters #### Path Parameters - **chain** (String) - Required - The blockchain network for the asset. - **asset** (String) - Required - The asset for which to get the price. #### Query Parameters - **iso** (String) - Required - The ISO alpha-3 code of the fiat currency. - **action** (String) - Required - The action type for the price query. - **fiatValue** (Integer) - Optional - The fiat value to use for calculating the asset price. - **assetValue** (Integer) - Optional - The asset value to use for calculating the fiat price. - **networkFee** (String) - Optional - Whether to include network fees in the calculation (ON/OFF). - **paymentMethod** (String) - Optional - The payment method ID to include transaction fees. ### Response #### Success Response (200) - **usd** (Number) - The price in USD. - **nga** (Number) - The price in NGN (example). - **price** (Number) - The calculated price. - **minimum** (Number) - The minimum transaction value. - **maximum** (Number) - The maximum transaction value. #### Response Example ```json { "usd": 1, "nga": 1186.04, "price": 1216.45, "minimum": 1000, "maximum": 5000 } ``` ``` -------------------------------- ### Initialize Paychant Widget with API Key (JavaScript) Source: https://developer.paychant.com/resources/api-keys Demonstrates how to initialize the Paychant Widget using the JavaScript SDK. It requires the partner API key to be passed as a string parameter during initialization. Ensure the API key is correctly formatted. ```javascript new PaychantWidget({ env: 'production', action: 'buy', partnerApiKey: '[YOUR_PARTNER_API_KEY]' }).openWindow(); ``` -------------------------------- ### Paychant Widget Configuration Parameters Source: https://developer.paychant.com/integrations/parameters Customize the Paychant widget's behavior and appearance using the following parameters. These parameters can be passed as query parameters to the widget's URL. ```APIDOC ## Paychant Widget Configuration Parameters ### Description This section details the available parameters for configuring the Paychant widget. These parameters allow you to customize the user experience, define available assets, set transaction details, and control integration behavior. ### Method GET (when used as query parameters in a URL) ### Endpoint `https://widget.paychant.com/[action]` (where [action] is 'buy' or 'sell') ### Parameters #### Query Parameters - **env** (string) - Required - Differentiates between 'production' and 'sandbox' environments. - **action** (string) - Required - Chooses between 'buy' or 'sell' mode. Not applicable for redirect integration (use base URL instead). - **partnerApiKey** (string) - Required - Your Paychant Partner API Key. - **listedAsset** (string) - Optional - A comma-separated list of crypto assets (e.g., 'ethereum_dai,polygon_matic'). If not set, all assets are available. - **fiatAmount** (integer) - Optional - Sets the initial fiat amount for buy or sell transactions. - **assetAmount** (integer) - Optional - Sets the initial crypto asset amount. If set, users cannot change this amount. - **walletAddress** (string) - Optional - The user's blockchain wallet address. If not set, the user will be prompted to enter it. - **selectedAsset** (string) - Optional - Pre-selects a crypto asset in the widget. - **partnerLogoUrl** (string) - Optional - A URL to your hosted brand logo. - **paymentMethod** (string) - Optional - Pre-selects the payment method type by its ID. - **userEmailAddress** (string) - Optional - Pre-sets the user's email address. - **webhookStatusUrl** (string) - Optional - A URL to receive webhook events for transaction status updates. - **partnerReferenceId** (string) - Optional - A unique identifier for your transactions. - **partnerThemeColor** (string) - Optional - Sets the widget's theme color using a hexadecimal code (without '#'). - **selectedFiatCurrency** (string) - Optional - Pre-sets the fiat currency code to be used in the transaction. - **successUrl** (string) - Optional - A URL to redirect the user to after a successful transaction (only for Redirect integration). ### Request Example ``` https://widget.paychant.com/buy?env=sandbox&action=buy&partnerApiKey=YOUR_API_KEY&listedAsset=ethereum_dai,polygon_matic&fiatAmount=100&walletAddress=0x123...&partnerLogoUrl=https://your.com/logo.png&successUrl=https://your.com/success ``` ### Response #### Success Response (200) (N/A - This describes configuration parameters, not a direct API response.) #### Response Example (N/A) ``` -------------------------------- ### Create Buy & Sell Crypto Link with API Key (HTML) Source: https://developer.paychant.com/resources/api-keys Shows how to create a direct link for users to buy and sell crypto using Paychant. The partner API key is appended as a query parameter to the widget URL. This method is suitable for redirect integrations. ```html Buy & Sell Crypto with Paychant ``` -------------------------------- ### HTML Link to Paychant Sandbox Widget Source: https://developer.paychant.com/integrations/redirect-integration This HTML code snippet creates a link that directs users to the Paychant sandbox widget. It includes parameters for the environment, asset amount, partner API key, logo URL, and theme color. This is useful for testing the integration before going live. ```html Stablecoin on/off ramp with Paychant ``` -------------------------------- ### Available Payment Methods API Source: https://developer.paychant.com/api-reference/rest-api-reference Retrieves a list of available payment methods supported for a given fiat currency. ```APIDOC ## GET /payment-method/{iso_alpha_3} ### Description Retrieves a list of available payment methods supported for a given fiat currency. ### Method GET ### Endpoint `/payment-method/{iso_alpha_3}` ### Parameters #### Path Parameters - **iso_alpha_3** (String) - Required - The ISO alpha-3 code of the fiat currency. ### Response #### Success Response (200) - **name** (String) - The name of the payment method. - **nameId** (String) - The unique identifier for the payment method. #### Response Example ```json [ { "name": "M-Pesa", "nameId": "m_pesa" }, { "name": "Bank Transfer", "nameId": "bank_transfer" }, ... ] ``` ``` -------------------------------- ### Supported Assets API Source: https://developer.paychant.com/api-reference/rest-api-reference Retrieves a list of supported assets based on a specified action and environment. This helps in identifying available assets for various integration purposes. ```APIDOC ## GET /assets/{action}/{env} ### Description Retrieves a list of supported assets based on a specified action and environment. This helps in identifying available assets for various integration purposes. ### Method GET ### Endpoint `/assets/{action}/{env}` ### Parameters #### Path Parameters - **action** (String) - Required - The action type (e.g., buy, sell). - **env** (String) - Required - The environment (e.g., production, test). ### Response #### Success Response (200) - **chain** (String) - The blockchain network of the asset. - **asset** (String) - The name of the asset. #### Response Example ```json [ { "chain": "CELO", "asset": "CELO" }, { "chain": "STELLAR", "asset": "USDC" }, { "chain": "BSC", "asset": "USDT" }, ... ] ``` ``` -------------------------------- ### Embed Paychant Widget using Javascript SDK Source: https://developer.paychant.com/integrations/overlay-embed This snippet demonstrates how to embed the Paychant widget as an overlay on your website. It includes the Paychant SDK script and a Javascript function to trigger the widget upon a button click. Configuration options like environment, action, API key, logo, theme color, and callback functions are provided. ```html Paychant ``` -------------------------------- ### HTML Link to Paychant Production Widget Source: https://developer.paychant.com/integrations/redirect-integration This HTML code snippet generates a link to the Paychant production widget for live transactions. It specifies the environment as 'production' and includes essential parameters like asset amount, partner API key, logo URL, and theme color. Use this for your live application. ```html Stablecoin on/off ramp with Paychant ``` -------------------------------- ### Supported Fiat Currency API Source: https://developer.paychant.com/api-reference/rest-api-reference Retrieves a list of all supported fiat currencies, including their names and ISO alpha-3 codes. ```APIDOC ## GET /fiat ### Description Retrieves a list of all supported fiat currencies, including their names and ISO alpha-3 codes. ### Method GET ### Endpoint `/fiat` ### Parameters #### Query Parameters None ### Response #### Success Response (200) - **fiat** (String) - The name of the fiat currency. - **iso_alpha_3** (String) - The ISO alpha-3 code of the fiat currency. #### Response Example ```json [ { "fiat": "NGN", "iso_alpha_3": "NGA" }, { "fiat": "GHS", "iso_alpha_3": "GHA" }, ... ] ``` ``` -------------------------------- ### WIDGET.CREATED Event Response (JavaScript) Source: https://developer.paychant.com/resources/webhooks This JSON object represents the webhook event triggered when a new widget transaction is created. It includes transaction details such as environment, fiat and asset information, amounts, user address, and partner parameters. This event signifies the initiation of a buy transaction. ```javascript { event: 'WIDGET.CREATED', data: { env: 'sandbox', pid: '8847431020', date: '30/03/2023 - 01:46:02', fiat: 'NGN', asset: 'CUSD', chain: 'CELO', action: 'BUY', fiatAmount: 149241, assetAmount: 300, userAddress: '0xCd96602dBbeE307a1d50cb074C294847aB4702FB', exchangeRate: 497.47, partnerParams: { reference_id: 'TRXNE5BKBEQ' }, paymentMethod: 'Bank Transfer', cryptoAddress: '---', transactionRef: '7CMJS1Q90GS79AA' } } ``` -------------------------------- ### API Key Integration Source: https://developer.paychant.com/resources/api-keys Details on how to add your Paychant API key to your integration for tracking and authentication. ```APIDOC ## API Key Usage ### Description API keys are unique identifiers used to track usage and activities like purchases and sales through your integration. The parameter name for the API key is `partnerApiKey` and its value type is a string. ### How to Get an API Key To obtain an API key, please fill out the form at [https://paychant.com/contact](https://paychant.com/contact). A team member will contact you with the next steps. For support, email [sales@paychant.com](mailto:sales@paychant.com). ### Adding API Key to Integration #### For Overlay Embed - (Javascript SDK) ```javascript new PaychantWidget({ env: 'production', action: 'buy', partnerApiKey: '[YOUR_PARTNER_API_KEY]' }).openWindow(); ``` #### For Redirect Integration ```html Buy & Sell Crypto with Paychant ``` ### Parameters #### Query Parameters (for Redirect Integration) - **partnerApiKey** (string) - Required - Your unique Paychant API key. ``` -------------------------------- ### Buy (OnRamp) Transaction Events Source: https://developer.paychant.com/resources/webhooks This section details the webhook events related to Buy (OnRamp) transactions. Each event signifies a different stage in the transaction lifecycle. ```APIDOC ## Buy (OnRamp) Transaction Events This section details the webhook events related to Buy (OnRamp) transactions. Each event signifies a different stage in the transaction lifecycle. ### Event: WIDGET.CREATED #### Description When the transaction is created. #### Method POST (Webhook) #### Endpoint `/websites/developer_paychant/events` #### Request Body Example ```json { "event": "WIDGET.CREATED", "data": { "env": "sandbox", "pid": "8847431020", "date": "30/03/2023 - 01:46:02", "fiat": "NGN", "asset": "CUSD", "chain": "CELO", "action": "BUY", "fiatAmount": 149241, "assetAmount": 300, "userAddress": "0xCd96602dBbeE307a1d50cb074C294847aB4702FB", "exchangeRate": 497.47, "partnerParams": { "reference_id": "TRXNE5BKBEQ" }, "paymentMethod": "Bank Transfer", "cryptoAddress": "---", "transactionRef": "7CMJS1Q90GS79AA" } } ``` ### Event: WIDGET.AWAITING_PAYMENT #### Description When the transaction state is expecting the user to make a payment. #### Method POST (Webhook) #### Endpoint `/websites/developer_paychant/events` #### Request Body Example ```json { "event": "WIDGET.AWAITING_PAYMENT", "data": { "env": "sandbox", "pid": "8847431020", "date": "30/03/2023 - 01:57:57", "fiat": "NGN", "asset": "CUSD", "chain": "CELO", "action": "BUY", "fiatAmount": 149241, "assetAmount": 300, "userAddress": "0xCd96602dBbeE307a1d50cb074C294847aB4702FB", "exchangeRate": 497.47, "partnerParams": { "reference_id": "TRXNE5BKBEQ" }, "paymentMethod": "Bank Transfer", "cryptoAddress": "---", "transactionRef": "7CMJS1Q90GS79AA" } } ``` ### Event: WIDGET.PAYMENT_CONFIRMED #### Description When we have received the fiat payment from the user. #### Method POST (Webhook) #### Endpoint `/websites/developer_paychant/events` #### Request Body Example ```json { "event": "WIDGET.PAYMENT_CONFIRMED", "data": { "env": "sandbox", "pid": "8847431020", "date": "30/03/2023 - 02:09:40", "fiat": "NGN", "asset": "CUSD", "chain": "CELO", "action": "BUY", "fiatAmount": 149241, "assetAmount": 300, "userAddress": "0xCd96602dBbeE307a1d50cb074C294847aB4702FB", "exchangeRate": 497.47, "partnerParams": { "reference_id": "TRXNE5BKBEQ" }, "paymentMethod": "Bank Transfer", "cryptoAddress": "---", "transactionRef": "7CMJS1Q90GS79AA" } } ``` ### Event: WIDGET.PAYMENT_COMPLETED #### Description When we have received the fiat payment and the asset is successfully sent to the user. #### Method POST (Webhook) #### Endpoint `/websites/developer_paychant/events` #### Request Body Example ```json { "event": "WIDGET.PAYMENT_COMPLETED", "data": { "env": "sandbox", "pid": "8847431020", "date": "30/03/2023 - 02:15:40", "fiat": "NGN", "asset": "CUSD", "chain": "CELO", "action": "BUY", "fiatAmount": 149241, "assetAmount": 300, "userAddress": "0xCd96602dBbeE307a1d50cb074C294847aB4702FB", "exchangeRate": 497.47, "partnerParams": { "reference_id": "TRXNE5BKBEQ" }, "paymentMethod": "Bank Transfer", "cryptoAddress": "---", "transactionRef": "7CMJS1Q90GS79AA" } } ``` ### Event: WIDGET.PAYMENT_INSUFFICIENT #### Description When we received the fiat payment but the amount of fiat sent by the user is not sufficient. #### Method POST (Webhook) #### Endpoint `/websites/developer_paychant/events` #### Request Body Example ```json { "event": "WIDGET.PAYMENT_INSUFFICIENT", "data": { "env": "sandbox", "pid": "8847431020", "date": "30/03/2023 - 02:15:40", "fiat": "NGN", "asset": "CUSD", "chain": "CELO", "action": "BUY", "fiatAmount": 149241, "assetAmount": 300, "userAddress": "0xCd96602dBbeE307a1d50cb074C294847aB4702FB", "exchangeRate": 497.47, "partnerParams": { "reference_id": "TRXNE5BKBEQ" }, "paymentMethod": "Bank Transfer", "cryptoAddress": "---", "transactionRef": "7CMJS1Q90GS79AA" } } ``` ### Event: WIDGET.PAYMENT_TIMEOUT #### Description When the user failed to make the fiat payment within the given timeframe. #### Method POST (Webhook) #### Endpoint `/websites/developer_paychant/events` #### Request Body Example ```json { "event": "WIDGET.PAYMENT_TIMEOUT", "data": { "env": "sandbox", "pid": "8847431020", "date": "30/03/2023 - 02:15:40", "fiat": "NGN", "asset": "CUSD", "chain": "CELO", "action": "BUY", "fiatAmount": 149241, "assetAmount": 300, "userAddress": "0xCd96602dBbeE307a1d50cb074C294847aB4702FB", "exchangeRate": 497.47, "partnerParams": { "reference_id": "TRXNE5BKBEQ" }, "paymentMethod": "Bank Transfer", "cryptoAddress": "---", "transactionRef": "7CMJS1Q90GS79AA" } } ``` ### Event: WIDGET.PAYMENT_FAILED #### Description There are a couple of things that can make a transaction fail, it can either be, a canceled transaction by the user, payment not made within the given timeframe, or a network connection problem. #### Method POST (Webhook) #### Endpoint `/websites/developer_paychant/events` #### Request Body Example ```json { "event": "WIDGET.PAYMENT_FAILED", "data": { "env": "sandbox", "pid": "8847431020", "date": "30/03/2023 - 02:15:40", "fiat": "NGN", "asset": "CUSD", "chain": "CELO", "action": "BUY", "fiatAmount": 149241, "assetAmount": 300, "userAddress": "0xCd96602dBbeE307a1d50cb074C294847aB4702FB", "exchangeRate": 497.47, "partnerParams": { "reference_id": "TRXNE5BKBEQ" }, "paymentMethod": "Bank Transfer", "cryptoAddress": "---", "transactionRef": "7CMJS1Q90GS79AA" } } ``` ``` -------------------------------- ### WIDGET.AWAITING_PAYMENT Event Response (JavaScript) Source: https://developer.paychant.com/resources/webhooks This JSON object represents the webhook event indicating that a transaction is awaiting payment. It contains the same transaction details as WIDGET.CREATED, signifying the state where the user needs to complete the fiat payment. This is crucial for tracking the payment status. ```javascript { event: 'WIDGET.AWAITING_PAYMENT', data: { env: 'sandbox', pid: '8847431020', date: '30/03/2023 - 01:57:57', fiat: 'NGN', asset: 'CUSD', chain: 'CELO', action: 'BUY', fiatAmount: 149241, assetAmount: 300, userAddress: '0xCd96602dBbeE307a1d50cb074C294847aB4702FB', exchangeRate: 497.47, partnerParams: { reference_id: 'TRXNE5BKBEQ' }, paymentMethod: 'Bank Transfer', cryptoAddress: '---', transactionRef: '7CMJS1Q90GS79AA' } } ``` -------------------------------- ### POST /webhook/url Source: https://developer.paychant.com/resources/webhooks This endpoint receives webhook notifications from Paychant for transaction status changes. It requires validation of the 'paychant-signature' header to ensure the request authenticity. ```APIDOC ## POST /webhook/url ### Description This endpoint is designed to receive unauthenticated POST requests from Paychant containing transaction status updates. It is crucial to validate the `paychant-signature` header to ensure the integrity and authenticity of the incoming event data. ### Method POST ### Endpoint /webhook/url ### Parameters #### Headers - **paychant-signature** (string) - Required - The signature hash used to validate the authenticity of the webhook request. #### Request Body - **event** (object) - Required - Contains the details of the transaction status event. ### Request Example (Node.js) ```javascript // Assuming express framework and body-parser middleware are used router.post("/webhook/url", function(req, res) { const crypto = require('crypto'); const secret = process.env.SECRET_KEY; // Your paychant webhook secret // Validate event const hmac = crypto.createHmac('sha512', secret); const hash = hmac.update(JSON.stringify(req.body)).digest('hex'); const headerSig = req.headers['paychant-signature']; if (hash === headerSig) { var event = req.body; // Process the event data here... console.log("Event received and validated:", event); res.sendStatus(200); // Respond quickly with 200 OK } else { res.sendStatus(400); // Bad request if signature is invalid } }); ``` ### Response #### Success Response (200 OK) - **Status**: 200 OK - Indicates that the webhook event was received and processed successfully. A 2xx status code is required to prevent repeated notifications. #### Error Response (e.g., 400 Bad Request) - **Status**: 400 Bad Request - Returned if the `paychant-signature` validation fails, indicating an invalid or tampered request. ### Notes - Your endpoint must return a `2xx` HTTP status code to confirm successful receipt of the event. Failure to do so will result in repeated notifications for up to 24 hours. - The webhook secret key (`SECRET_KEY`) should be stored securely as an environment variable. ``` -------------------------------- ### WIDGET.PAYMENT_COMPLETED Event Response (JavaScript) Source: https://developer.paychant.com/resources/webhooks This JSON object indicates that a transaction has been fully completed, meaning the fiat payment was received and the corresponding crypto asset has been successfully sent to the user. It contains all relevant transaction details, marking the successful conclusion of the buy process. ```javascript { event: 'WIDGET.PAYMENT_COMPLETED', data: { env: 'sandbox', pid: '8847431020', date: '30/03/2023 - 02:15:40', fiat: 'NGN', asset: 'CUSD', chain: 'CELO', action: 'BUY', fiatAmount: 149241, assetAmount: 300, userAddress: '0xCd96602dBbeE307a1d50cb074C294847aB4702FB', exchangeRate: 497.47, partnerParams: { reference_id: 'TRXNE5BKBEQ' }, paymentMethod: 'Bank Transfer', cryptoAddress: '---', transactionRef: '7CMJS1Q90GS79AA' } } ``` -------------------------------- ### Receive and Validate Paychant Webhook Events (Python/Flask) Source: https://developer.paychant.com/resources/webhooks This Python snippet utilizes the Flask framework to create a webhook endpoint for receiving Paychant events. It extracts the request body and headers to perform signature validation using HMAC-SHA512 and a secret key obtained from environment variables. A 200 OK response is returned upon successful validation, allowing further processing of the event data. ```python import os from flask import Flask, request, Response import hmac import hashlib import urllib.parse app = Flask(__name__) secret = os.environ.get('SECRET_KEY') # Your paychant webhook secret @app.route('/webhook', methods=['POST']) def respond(): # Validate event encode = urllib.parse.urlencode(request.json).encode('utf8') hashMac = hmac.new(secret, encode, hashlib.sha512).hexdigest() headerSig = request.headers.get('paychant-signature') if(hashMac === headerSig): event = request.json; # Do someting with the event return Response(status=200) ``` -------------------------------- ### WIDGET.PAYMENT_CONFIRMED Event Response (JavaScript) Source: https://developer.paychant.com/resources/webhooks This JSON object signifies that the fiat payment for a transaction has been successfully confirmed. It includes all standard transaction data, indicating that the funds have been received. This event is vital for downstream processing and confirmation. ```javascript { event: 'WIDGET.PAYMENT_CONFIRMED', data: { env: 'sandbox', pid: '8847431020', date: '30/03/2023 - 02:09:40', fiat: 'NGN', asset: 'CUSD', chain: 'CELO', action: 'BUY', fiatAmount: 149241, assetAmount: 300, userAddress: '0xCd96602dBbeE307a1d50cb074C294847aB4702FB', exchangeRate: 497.47, partnerParams: { reference_id: 'TRXNE5BKBEQ' }, paymentMethod: 'Bank Transfer', cryptoAddress: '---', transactionRef: '7CMJS1Q90GS79AA' } } ``` -------------------------------- ### Receive and Validate Paychant Webhook Events (PHP) Source: https://developer.paychant.com/resources/webhooks This PHP code provides a server-side implementation for receiving and validating Paychant webhook events. It checks for the POST method and the 'paychant-signature' header before processing the request body. The HMAC-SHA512 hash is used to verify the signature against a predefined secret key. A 200 HTTP status code is returned to acknowledge receipt. ```php php ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.