### Complete PayChangu Inline Checkout JavaScript Example Source: https://developer.paychangu.com/docs/inline-popup This comprehensive code block provides a full, runnable example of integrating PayChangu Inline Checkout. It combines the library inclusion, the payment button, and the `makePayment` function into a single, self-contained implementation. ```JavaScript
``` -------------------------------- ### Initiate PayChangu Transaction using cURL Source: https://developer.paychangu.com/docs/standard-checkout Example cURL command to send a POST request to the PayChangu payment endpoint. This demonstrates how to include authentication, amount, currency, customer details, and callback/return URLs in the request body. ```cURL curl -X POST "https://api.paychangu.com/payment" -H "Accept: application/json" -H "Authorization: Bearer {secret_key}" -d "{ \"amount\": \"100\", \"currency\": \"MWK\", \"email\": \"[email\u00a0protected]\", \"first_name\":\"Kelvin\", \"last_name\":\"Banda\", \"callback_url\": \"https://webhook.site/9d0b00ba-9a69-44fa-a43d-a82c33c36fdc\", \"return_url\": \"https://webhook.site\", \"tx_ref\": '' + Math.floor((Math.random() * 1000000000) + 1), \"customization\": { \"title\": \"Test Payment\", \"description\": \"Payment Description\" }, \"meta\": { \"uuid\": \"uuid\", \"response\": \"Response\" } }" ``` -------------------------------- ### Sample Mobile Money Verification Response Source: https://developer.paychangu.com/docs/get-single-charge-details This JSON object provides an example of a successful verification response for a Mobile Money transaction. It includes details such as amount, charge ID, status, customer information, and mobile money specifics. ```json { "status": "successful", "message": "Payment authorized and completed successfully.", "data": { "amount": 65, "charge_id": "TRAU28987693", "ref_id": "40725788795", "trans_id": "83822270-958d-4fb7-a370-ec132e8c5b06", "first_name": "Kim", "last_name": "Darry", "email": "[email\u00a0protected]", "status": "successful", "mobile": "+265992xxxx20", "attempts": 1, "currency": "MWK", "mode": "live", "created_at": "2024-06-14T15:43:25.000000Z", "completed_at": "2024-06-14T15:43:58.000000Z", "mobile_money": { "name": "Airtel Money", "ref_id": "20be6c20-adeb-4b5b-a7ba-0769820df4fb", "country": "Malawi" } } } ``` -------------------------------- ### PayChangu Initiate Transaction API Success Response Source: https://developer.paychangu.com/docs/standard-checkout Example JSON response received upon successful initiation of a payment session. This structure includes the message, status, event type, checkout URL, and detailed transaction data such as tx_ref, currency, amount, mode, and status. ```JSON { "message": "Hosted payment session generated successfully.", "status": "success", "data": { "event": "checkout.session:created", "checkout_url": "https://checkout.paychangu.com/923677185321", "data": { "tx_ref": "ae041eae-6abd-4602-a949-56fbd65c29fe", "currency": "MWK", "amount": 100, "mode": "live", "status": "pending" } } } ``` -------------------------------- ### Successful Payment Webhook Payload Source: https://developer.paychangu.com/docs/webhooks Example JSON payload for a successful payment event, detailing currency, amount, status, charge ID, reference, and authorization details including bank transfer information. ```APIDOC { "event_type": "api.charge.payment", "currency": "MWK", "amount": 1000, "charge": "20", "mode": "test", "type": "Direct API Payment", "status": "success", "charge_id": "5d676fg", "reference": "71308131545", "authorization": { "channel": "Mobile Bank Transfer", "card_details": null, "bank_payment_details": { "payer_bank_uuid":"82310dd1-ec9b-4fe7-a32c-2f262ef08681", "payer_bank": "National Bank of Malawi", "payer_account_number": "10010000", "payer_account_name": "Jonathan Manda" }, "mobile_money": null, "completed_at": "2025-01-15T19:53:18.000000Z" }, "created_at": "2025-01-15T19:53:18.000000Z", "updated_at": "2025-01-15T19:53:18.000000Z" } ``` -------------------------------- ### Sample Direct Charge Verification Response Source: https://developer.paychangu.com/docs/get-single-charge-details This JSON object illustrates a successful verification response for a Direct Charge transaction. It contains comprehensive details including transaction status, amount, currency, authorization channel, and a log of events. ```json { "status": "success", "message": "Transaction retrieved successfully.", "data": { "transaction": { "charge_id": "PTC12383", "ref_id": "75513659949", "trans_id": null, "currency": "MK", "amount": 1000, "first_name": null, "last_name": null, "email": null, "type": "Direct API Payment", "trace_id": "v0atWHs0NLEN3vbTAL4DKFLm59dVHuRM", "status": "success", "mobile": "0", "attempts": 1, "mode": "live", "created_at": "2025-02-17T21:14:35.000000Z", "completed_at": "2025-02-17T21:18:40.000000Z", "event_type": "api.charge.payment", "transaction_charges": { "currency": "MK", "amount": "20" }, "authorization": { "channel": "Mobile Bank Transfer", "card_number": null, "expiry": null, "brand": null, "provider": null, "mobile_number": null, "payer_bank_uuid": "82310dd1-ec9b-4fe7-a32c-2f262ef08681", "payer_bank": "National Bank of Malawi", "payer_account_number": "1007134421", "payer_account_name": "Jonathan Manda", "completed_at": "2025-02-17T21:18:40.000000Z" }, "logs": [ { "type": "log", "message": "Attempted to pay with bank transfer", "created_at": "2025-02-17T21:14:35.000000Z" }, { "type": "log", "message": "Bank transfer payment processed successfully.", "created_at": "2025-02-17T21:18:40.000000Z" } ] } } } ``` -------------------------------- ### API Payout Webhook Payload Source: https://developer.paychangu.com/docs/webhooks Example JSON payload for an API payout event, including charge ID, reference, amount, status, and recipient account details for bank transfers. ```APIDOC { "event_type":"api.payout", "charge_id":"4567tfuty", "reference":"54438943842", "first_name":null, "last_name":null, "email":null, "currency":"MWK", "amount":1000, "charge":"0", "mode":"live", "type":"API Payout", "status":"success", "recipient_account_details":{ "bank_name":"National Bank of Malawi", "bank_uuid":"82310dd1-ec9b-4fe7-a32c-2f262ef08681", "account_name":"Nohaata Seven", "account_number":"1007534422" } } ``` -------------------------------- ### Retrieve Mobile Money Charge Details with cURL Source: https://developer.paychangu.com/docs/get-single-charge-details This cURL command demonstrates how to fetch details for a Mobile Money transaction. It requires the specific charge ID and an Authorization bearer token (secret_key) to authenticate the request. ```curl curl -X GET "https://api.paychangu.com/mobile-money/payments/{{chargeId}}/details" -H "Accept: application/json" -H "Authorization: Bearer {secret_key}" ``` -------------------------------- ### Retrieve Direct Charge Details with cURL Source: https://developer.paychangu.com/docs/get-single-charge-details This cURL command illustrates how to retrieve detailed information for a Direct Charge transaction. It uses the charge ID and a bearer token for authentication, targeting the direct-charge API endpoint. ```curl curl --request GET \ --url https://api.paychangu.com/direct-charge/transactions/{{charge_id}}/details \ --header 'Authorization: Bearer {secret_key}' \ --header 'accept: application/json' ``` -------------------------------- ### Verify PayChangu Transaction Status with cURL Source: https://developer.paychangu.com/docs/charge-verification Demonstrates server-side validation for PayChangu transactions using cURL. This includes examples for both Mobile Money and Bank Transfer charge verification. The charge ID can be obtained from the transaction creation response or webhook payload. ```curl curl -X GET "https://api.paychangu.com/mobile-money/payments/{{chargeId}}/verify" -H "Accept: application/json" -H "Authorization: Bearer {secret_key}" ``` ```curl curl --request GET \ --url https://api.paychangu.com/direct-charge/transactions/{{charge_id}}/details \ --header 'Authorization: Bearer {secret_key}' \ --header 'accept: application/json' ``` -------------------------------- ### Initiate Mobile Money Transfer (cURL) Source: https://developer.paychangu.com/docs/mobile-money This cURL command sends a POST request to initialize a mobile money payment. It requires the mobile money operator's reference ID, recipient's mobile number, transfer amount, and a unique charge ID. The operator ID must be obtained from the 'get operators' endpoint before initiating the transfer. ```cURL curl --request POST \ --url https://api.paychangu.com/mobile-money/payments/initialize \ --header 'accept: application/json' \ --header 'content-type: application/json' \ --data ' { "mobile_money_operator_ref_id": "20be6c20-adeb-4b5b-a7ba-0769820df4fb", "mobile": "0990000000", "amount": "1000", "charge_id": "PC-64FU65435" } ' ``` -------------------------------- ### Verify PayChangu Transaction using cURL Source: https://developer.paychangu.com/docs/transaction-verification This cURL command sends a GET request to the PayChangu API's verify-payment endpoint. It requires a transaction reference (`tx_ref`) in the URL path and an `Authorization` header with a bearer token (`secret_key`) to authenticate the request and retrieve transaction details. ```cURL curl -X GET "https://api.paychangu.com/verify-payment/{tx_ref}" -H "Accept: application/json" -H "Authorization: Bearer {secret_key}" ``` -------------------------------- ### PayChangu Transfer API Request Parameters Source: https://developer.paychangu.com/docs/introduction-2 This section details the required and optional parameters for initiating a transfer via the PayChangu API. Transfers can be made to bank accounts and mobile money wallets, specifying the amount, currency, recipient details, and optional user information. The endpoint for creating a transfer is a POST request. ```APIDOC Endpoint: POST /create-transfer (hypothetical based on description) Required Parameters: amount: The amount to transfer. currency: The currency of the transfer. bank_uuid: Identifier for the bank or mobile money operator. (Can be retrieved using the Get banks endpoint: /reference/get-banks) bank_account_number: The recipient's bank account number or mobile money number. bank_account_name: The name associated with the bank account or mobile money wallet. charge_id: The ID of the charge associated with the transfer. Optional Parameters (primarily for mobile money transfers): email: Recipient's email address. first_name: Recipient's first name. last_name: Recipient's last name. mobile_money_operator_ref_id: Reference ID for the mobile money operator. (Required for mobile money transfers. Can be retrieved using the get operator id endpoint: /reference/supported-momo-operators) ``` -------------------------------- ### PayChangu Initiate Transaction API Parameters Source: https://developer.paychangu.com/docs/standard-checkout Defines the parameters required to initiate a payment transaction via the PayChangu API, including data types, required status, and descriptions for each field. This is crucial for constructing the request payload. ```APIDOC API Endpoint: POST https://api.paychangu.com/payment Parameters: - secret_key: string (Required) - This is important for creating payment links - callback_url: url (Required) - This is your IPN URL, which is essential for receiving payment notifications. Successful transactions will redirect to this URL after payment. The {tx_ref} is returned, so you don’t need to include it in your URL. - return_url: url (Required) - Once the customer cancels or after multiple failed attempts, we will redirect to the return_url with the query parameters tx_ref and status of failed. - tx_ref: string (Optional) - Your transaction reference. This MUST be unique for every transaction. - first_name: string (Optional) - This is the first name of your customer. - last_name: string (Optional) - This is the last name of your customer. - email: string (Optional) - This is the email address of your customer. Transaction notification will be sent to this email address - currency: string (Required) - Currency to charge in. [ 'MWK', 'USD' ] - amount: int32 (Required) - Amount to charge the customer. - customization: array (Optional) - { "title":"Title of payment", "description":"Description of payment", } - meta: array (Optional) - You can pass on extra information here. ``` -------------------------------- ### Initiate Bank Account Payout API Interaction Source: https://developer.paychangu.com/docs/bank-account This snippet demonstrates the full flow of initiating a bank transfer payout via the PayChangu API, including the cURL request to the /direct-charge/payouts/initialize endpoint and the expected JSON response for a successful transaction. It outlines the required input parameters and the structure of the returned data. ```curl curl --request POST \ --url https://api.paychangu.com/direct-charge/payouts/initialize \ --header 'accept: application/json' \ --header 'content-type: application/json' \ --data ' { "payout_method": "bank_transfer", "bank_uuid": "82310dd1-ec9b-4fe7-a32c-2f262ef08681", "amount": "10000", "charge_id": "PC-TR2344567534", "bank_account_name": "Madalitso Kamwendo", "bank_account_number": "1001000010" } ' ``` ```json { "status": "success", "message": "Payout request submitted successfully.", "data": { "transaction": { "charge_id": "PC-TR2344567534", "ref_id": "97073812876", "trans_id": null, "currency": "MK", "amount":10000, "first_name": null, "last_name": null, "email": null, "type": "API Payout", "trace_id": null, "status": "pending", "mobile": "0", "attempts": 1, "mode": "live", "created_at": "2025-01-23T17:03:28.000000Z", "completed_at": null, "event_type": "api.payout", "transaction_charges": { "currency": "MK", "amount": "0" }, "recipient_account_details": { "bank_uuid": "82310dd1-ec9b-4fe7-a32c-2f262ef08681", "bank_name": "National Bank of Malawi", "account_name": "Madalitso Kamwendo", "account_number": "1001000010" } } } } ``` -------------------------------- ### Initiate Bank Transfer Charge with cURL Source: https://developer.paychangu.com/docs/bank-transfer This cURL command initiates a direct charge via bank transfer, generating unique account details for the customer. It requires specifying the payment method, amount, currency (MWK), and a unique charge ID. Optionally, a permanent account can be created by setting 'create_permanent_account' to 'true'. ```cURL curl --request POST \ --url https://api.paychangu.com/direct-charge/payments/initialize \ --header 'Authorization: Bearer sec-test-2Xhuyv2Plb24DQMG26CN2sDKYzyoFMEM' \ --header 'accept: application/json' \ --header 'content-type: application/json' \ --data ' { "payment_method": "mobile_bank_transfer", "amount": "1000", "currency": "MWK", "charge_id": "PC-YR6D43446" "create_permanent_account": "false" } ' ``` -------------------------------- ### Include PayChangu Inline JavaScript Library Source: https://developer.paychangu.com/docs/inline-popup This script tag integrates the PayChangu Inline library into your web page, making the `PaychanguCheckout` function available for initiating payment flows. It's the first step in setting up the inline checkout. ```JavaScript ``` -------------------------------- ### Sample JSON Response for Transaction Verification Source: https://developer.paychangu.com/docs/transaction-verification This JSON object represents a successful response from the PayChangu transaction verification API. It includes details such as payment status, transaction reference, mode, type, amount, currency, customization, authorization details (channel, card info), customer information, and logs of the transaction process. ```JSON { "status": "success", "message": "Payment details retrieved successfully.", "data": { "event_type": "checkout.payment", "tx_ref": "PA54231315", "mode": "live", "type": "API Payment (Checkout)", "status": "success", "number_of_attempts": 1, "reference": "26262633201", "currency": "MWK", "amount": 1000, "charges": 40, "customization": { "title": "iPhone 10", "description": "Online order", "logo": null }, "meta": null, "authorization": { "channel": "Card", "card_number": "230377******0408", "expiry": "2035-12", "brand": "MASTERCARD", "provider": null, "mobile_number": null, "completed_at": "2024-08-08T23:21:22.000000Z" }, "customer": { "email": "[email protected]", "first_name": "Mac", "last_name": "Phiri" }, "logs": [ { "type": "log", "message": "Attempted to pay with card", "created_at": "2024-08-08T23:20:59.000000Z" }, { "type": "log", "message": "Processing and verification of card payment completed successfully.", "created_at": "2024-08-08T23:21:22.000000Z" } ], "created_at": "2024-08-08T23:20:21.000000Z", "updated_at": "2024-08-08T23:20:21.000000Z" } } ``` -------------------------------- ### Sample Bank Transfer Verification Response JSON Source: https://developer.paychangu.com/docs/charge-verification This JSON object represents a successful verification response for a bank transfer payment. It contains transaction details, currency, amount, and specific authorization information for bank transfers, including payer bank and account details. ```JSON { "status": "success", "message": "Transaction retrieved successfully.", "data": { "transaction": { "charge_id": "PTC12383", "ref_id": "75513659949", "trans_id": null, "currency": "MK", "amount": 1000, "first_name": null, "last_name": null, "email": null, "type": "Direct API Payment", "trace_id": "v0atWHs0NLEN3vbTAL4DKFLm59dVHuRM", "status": "success", "mobile": "0", "attempts": 1, "mode": "live", "created_at": "2025-02-17T21:14:35.000000Z", "completed_at": "2025-02-17T21:18:40.000000Z", "event_type": "api.charge.payment", "transaction_charges": { "currency": "MK", "amount": "20" }, "authorization": { "channel": "Mobile Bank Transfer", "card_number": null, "expiry": null, "brand": null, "provider": null, "mobile_number": null, "payer_bank_uuid":"82310dd1-ec9b-4fe7-a32c-2f262ef08681", "payer_bank": "National Bank of Malawi", "payer_account_number": "1007134421", "payer_account_name": "Jonathan Manda", "completed_at": "2025-02-17T21:18:40.000000Z" }, "logs": [ { "type": "log", "message": "Attempted to pay with bank transfer", "created_at": "2025-02-17T21:14:35.000000Z" }, { "type": "log", "message": "Bank transfer payment processed successfully.", "created_at": "2025-02-17T21:18:40.000000Z" } ] } } } ``` -------------------------------- ### JavaScript `makePayment` Function for PayChangu Checkout Source: https://developer.paychangu.com/docs/inline-popup This JavaScript function defines how to call `PaychanguCheckout()` with necessary parameters. It configures the payment amount, currency, customer details, callback URLs, and custom metadata, initiating the payment popup. ```JavaScript function makePayment(){ PaychanguCheckout({ "public_key": "pub-test-HYSBQpa5K91mmXMHrjhkmC6mAjObPJ2u", "tx_ref": '' + Math.floor((Math.random() * 1000000000) + 1), "amount": 1000, "currency": "MWK", "callback_url": "https://example.com/callbackurl", "return_url": "https://example.com/returnurl", "customer":{ "email": "[email protected]", "first_name":"Mac", "last_name":"Phiri" }, "customization": { "title": "Test Payment", "description": "Payment Description" }, "meta": { "uuid": "uuid", "response": "Response" } }); } ``` -------------------------------- ### Sample Mobile Money Verification Response JSON Source: https://developer.paychangu.com/docs/charge-verification This JSON object represents a successful verification response for a mobile money payment. It includes details such as amount, transaction IDs, customer information, mobile money provider details, and authorization channel. ```JSON { "status": "successful", "message": "Payment authorized and completed successfully.", "data": { "amount": 100, "charge_id": "ksni", "ref_id": "29263119322", "trans_id": null, "first_name": "Kim", "last_name": "Banda", "email": "[email protected]", "type": "Direct API Payment", "status": "success", "mobile": "+265993xxxx40", "attempts": 1, "currency": "MK", "mode": "Live", "created_at": "2024-08-18T14:45:11.000000Z", "completed_at": "2024-08-18T14:52:44.000000Z", "event_type": "api.charge.payment", "mobile_money": { "name": "Airtel Money", "ref_id": "20be6c20-adeb-4b5b-a7ba-0769820df4fb", "country": "Malawi" }, "transaction_charges": { "currency": "MK", "amount": "4" }, "authorization": { "channel": "Mobile Money", "card_number": null, "expiry": null, "brand": null, "provider": "Airtel Money", "mobile_number": null, "completed_at": "2024-08-18T14:52:44.000000Z" }, "logs": [] } } ``` -------------------------------- ### Mobile Money Transfer Success Response (JSON) Source: https://developer.paychangu.com/docs/mobile-money This JSON object illustrates a successful response from the mobile money payment initialization endpoint. It contains details such as the transaction status, amount, charge ID, reference ID, and specific mobile money operator information. The `status.data.status` and `status.data.charge_id` fields are important for tracking the transfer. ```JSON { "status": "success", "message": "Payment initiated successfully.", "data": { "amount": 1000, "charge_id": "PC-64FU65435", "ref_id": "95652259752", "trans_id": "f28e10a6-5d71-4499-9ac3-fdce917fae98", "first_name": null, "last_name": null, "email": null, "status": "pending", "mobile": "+265990xxxx00", "attempts": 2, "currency": "MWK", "mode": "live", "created_at": "2024-06-15T00:21:33.000000Z", "completed_at": null, "mobile_money": { "name": "Airtel Money", "ref_id": "20be6c20-adeb-4b5b-a7ba-0769820df4fb", "country": "Malawi" } } } ``` -------------------------------- ### HTML for PayChangu Inline Payment Button Source: https://developer.paychangu.com/docs/inline-popup This HTML snippet creates a button that triggers the `makePayment()` JavaScript function when clicked. It also includes a `div` element, which might be used by the PayChangu library for rendering purposes. ```JavaScript
``` -------------------------------- ### PayChangu API Provider Error Codes Source: https://developer.paychangu.com/docs/paychangu-errors A list of common error codes returned by payment providers through the PayChangu API, detailing reasons for transaction failures such as declines, timeouts, insufficient funds, and authentication issues. ```APIDOC DECLINED: Transaction declined. TIMED_OUT: Response timed out EXPIRED_CARD: Transaction declined due to expired card INSUFFICIENT_FUNDS: Transaction declined due to insufficient funds AUTHENTICATION_FAILED: 3DS authentication failed NOT_ENROLLED_3D_SECURE: Cardholder is not enrolled in 3D Secure EXCEEDED_RETRY_LIMIT: Transaction retry limit exceeded CARD_NOT_ENROLLED: The card is not enrolled for 3DS authentication AUTHENTICATION_NOT_AVAILABLE: Authentication is not currently available AUTHENTICATION_ATTEMPTED: Authentication was attempted but the card issuer did not perform the authentication CARD_DOES_NOT_SUPPORT_3DS: The card does not support 3DS authentication ``` -------------------------------- ### PayChangu Bank-Related API Endpoints Reference Source: https://developer.paychangu.com/docs/bank-account A reference to additional PayChangu API endpoints relevant to bank transfers. This includes endpoints for retrieving bank UUIDs necessary for transfers and for verifying the status of previously initiated bank payout transactions. These are essential for comprehensive integration. ```APIDOC GET /reference/get-banks: Retrieves a list of available banks and their UUIDs. POST /direct-charge/payouts/initialize (Bank Payout): Purpose: Initiate a bank transfer payout. Parameters: - payout_method: string (e.g., "bank_transfer") - bank_uuid: string (UUID of the recipient bank) - amount: string (Amount to transfer) - charge_id: string (Unique identifier for the charge) - bank_account_name: string (Name of the recipient bank account) - bank_account_number: string (Number of the recipient bank account) Example Request: See 'Initiate Bank Account Payout API Interaction' snippet. Example Response: See 'Initiate Bank Account Payout API Interaction' snippet. GET /reference/single-bank-payout-details: Retrieves the status and details of a specific bank payout transaction. ``` -------------------------------- ### Successful Bank Transfer Charge API Response Source: https://developer.paychangu.com/docs/bank-transfer This JSON object represents a successful response after initiating a bank transfer charge. It provides payment account details including bank name, account number, account name, and expiration timestamp. Additionally, it contains transaction details such as amount, charge ID, reference ID, status, currency, creation timestamp, and transaction charges. ```APIDOC { "status": "success", "message": "Payment initialized successfully.", "data": { "payment_account_details": { "bank_name": "Centenary Bank", "account_number": "2652455380", "account_name": "PayChangu", "account_expiration_timestamp": 1736805724 }, "transaction": { "amount": 1000, "charge_id": "PC-YR6D43446", "ref_id": "25274666909", "type": "Direct API Payment", "trace_id": "OiG8diXHAbw3Y7yz4sZwuY610GdIc1dy", "status": "pending", "mobile": "0", "attempts": 1, "currency": "MK", "mode": "sandbox", "created_at": "2025-01-13T21:02:04.000000Z", "event_type": "api.charge.payment", "transaction_charges": { "currency": "MK", "amount": "20" }, "authorization": { "channel": "Mobile Bank Transfer" } } } } ``` -------------------------------- ### PayChangu API Error Response Format Source: https://developer.paychangu.com/docs/paychangu-errors This JSON structure illustrates the common format for errors returned by the PayChangu API, typically with a 400 HTTP status code. It includes a 'message' field detailing specific errors, a 'status' indicating failure, and a 'data' field which is often null. ```JSON { "message": { "callback_url": [ "The callback url field is required." ] }, "status": "failed", "data": null } ``` -------------------------------- ### Verify PayChangu Webhook Signature (PHP) Source: https://developer.paychangu.com/docs/webhooks This PHP function demonstrates how to authenticate an incoming PayChangu webhook request. It computes an HMAC SHA-256 hash of the request payload using a secret key and compares it against the 'Signature' header provided by PayChangu. This ensures the request's integrity and origin. ```PHP function handleWebhookEvent(){ // retrieve request body $payload = file_get_contents('php://input'); // retrieve all headers $headers = getallheaders(); $computedSignature = hash_hmac('sha256', $payload, $webhookSecret); /* change the value of webhookSecret to the webhook secret generated on your merchant dashboard */ $webhookSecret = 'your_webhook_secret_key'; // generate hash of the webhook payload using the secret key $computedSignature = hash_hmac('sha256', $payload, $webhookSecret); // compare the computed signature of the incoming request with the value on the "Signature" header if($computedSignature != $headers['Signature']) { /* request may have been tampered with or is likely from another source */ /* enter code to discard webhook */ } else{ /* request is from PayChangu */ /* enter code to implement on the basis of the data on the webhook payload */ } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.