Skip to main content

Responses & Callbacks

Response​

Upon receiving your request, Amanpay returns a synchronous response (within a single HTTP session) to your system.

The response contains details of the payment you initiated in the payment platform and the current status of this payment. Note that responses to purchase and payout requests don't contain the final status of the payment as the final status for these operations is submitted to you in a callback.

When receiving responses from Amanpay, you should verify the signature in the Authorization header of a response to ensure authenticity. For more details about request signature generation, see the About the signature section.

Payment statuses​

  • PENDING — The payment is being processed. No final result is available yet.
  • REDIRECT — The payment is being processed. No final result is available yet. Available for checkout transactions.
  • SUCCESS — The payment was completed successfully.
  • FAILED — The payment is declined.
  • SPECIFICATION — Additional information or action is required to continue processing the payment.

Callbacks​

Amanpay sends callbacks:

  • to the URL you provided the Amanpay support team with during integration
  • to the URL you submit in the notifyUrl parameter if you need to receive callbacks for a specific payment to an individual URL

When receiving callbacks from Amanpay, you should verify the signature in the Authorization header of a callback to ensure authenticity. For more details about request signature generation, see the About the signature section. A callback is an HTTP request that Amanpay sends to your system. Callbacks are sent to you using the POST method and are meant to notify you about the final status of purchases and payouts that you initiate in the payment platform.

note

For H2H integrations, Amanpay can also send callbacks containing additional information required to continue the payment process. For example, a callback may contain a QR code or payment data that should be presented to the customer to complete the payment.

For request and callback examples, including method-specific additional data, see the documentation page for the corresponding payment method.

Here is an example of the data from a callback containing information about a successfully completed purchase.

{
"transactionId": "62861",
"paymentID": "payment_812",
"status": "SUCCESS",
"amount": 250.00,
"currency": "BDT",
"paymentType": "purchase",
"customerName": "Mark Cooper",
"customerAccountNumber": "185927571757184"
}

The following is an example of a callback sent if a payment has been declined.

{
"transactionId": "62861",
"paymentID": "payment_812",
"status": "FAILED",
"errorCode": "GENERAL_ERROR",
"errorMessage": "An unexpected error occurred while processing your request",
"amount": 250.00,
"currency": "BDT",
"paymentType": "purchase"
}

Payment status​

When a transaction is being performed, it changes its statuses depending on different events occurring during its processing.

You can learn the status of your transaction:

  • by using the Amanpay Dashboard which is available at https://merchant.amanpay.io. Contact the Amanpay support team or your account manager to get access there
  • by checking callback the payment platform sends to your system
  • by sending Amanpay a request to retrieve the payout status.
ParameterValue
URLhttps://gateway.amanpay.io
API endpoint/payments/purchases/status
/payments/payouts/status
HTTP request methodPOST
Request body formatJSON
HeaderValueDescription
Content-Typeapplication/jsonHTTP header indicating the media type of the resource sent in the request body.
AuthorizationcalculatedSignature string. For the information on how to generate the signature, see Signature generation and verification.


Parameters of the request to retrieve a status:

The following table contains the parameters that have to be used in requests to retrieve a payout status.

ParameterTypeRequiredDescription
merchantIdintegerRequiredYour unique merchant ID that you got from Amanpay when integrating.
paymentIdstringRequiredPayment ID unique within your system.

Here is an example of a request to retrieve a payout status.

Request example
{
"merchantId": 138,
"paymentId": "ORDER_100001_185_329"
}
Successful retrieved response
{
"transactionId": "1122257",
"paymentID": "ORDER_100001_185_329",
"status": "FAILED",
"amount": 500,
"currency": "PKR",
"paymentType": "purchase",
"errorCode": "GENERAL_ERROR",
"errorMessage": "An unexpected error occurred while processing your request"
}
Error response
{
"result_code": "INVALID_REQUEST_ID",
"result_message": "The requested ID does not exist"
}

Parameters of responses and callbacks​

The following table contains the parameters used in responses and callbacks from the Amanpay payment platform.

Callback​

ParameterTypeAlways usedUsed inDescription
transactionIdstringYesCallback Check status ResponsePayment ID within the Amanpay payment platform.
operationIdstringYesCallback Check status ResponseOperation ID within the Amanpay payment platform.
paymentIDstringNoCallback Check status ResponsePayment ID within your system.
statusstringYesCallback Check status ResponseCurrent status of your payment.
errorCodestringNoCallback Check status ResponseError code.
errorMessagestringNoCallback Check status ResponseDescription of the error.
amountintegerYesCallback Check status ResponsePayment amount you passed in your request.
currencystringYesCallback Check status ResponsePayment currency you passed in your request.
paymentTypestringYesCallback Check status ResponsePayment method's type.
customerNamestringNoCallback Check status ResponseCustomer's full name.
customerAccountNumberstringNoCallback Check status ResponseCustomer's account number.
QrDatastringNoCallback Check status ResponseQr data
PaymentDatastringNoCallback Check status ResponsePayment data

Listed below are the values that can be passed in the errorCode and errorMessage parameters

Error codeError message
INVALID_CUSTOMER_ACCOUNTThe customer's phone number, email, or wallet ID is invalid or not found
CUSTOMER_NOT_VERIFIEDThe customer's account requires identity verification (KYC) to proceed
CUSTOMER_ACCOUNT_BLOCKEDThe customer's account is suspended or blocked
INSUFFICIENT_WALLET_BALANCEThe customer's wallet has insufficient balance to complete the transfer
MIN_TRANSFER_AMOUNT_VIOLATIONTransfer amount is below the minimum allowed threshold
MAX_TRANSFER_AMOUNT_VIOLATIONTransfer amount exceeds the maximum allowed per transaction
BLACKLISTED_CUSTOMERThe customer is on the internal blacklist
SELF_TRANSFER_NOT_ALLOWEDCannot transfer funds to the same wallet or linked account
CUSTOMER_COUNTRY_RESTRICTEDTransfers to customers in this country and from this country are not supported
TRANSACTION_NOT_FOUNDNo transfer found with the provided ID
TRANSFER_ALREADY_COMPLETEDThis transfer has already been successfully processed
TRANSFER_EXPIREDThe payment link or session has expired
INVALID_API_KEYAuthentication failed. API Key is invalid or expired
GENERAL_ERRORAn unexpected error occurred while processing your request
PAYMENT_CANCELLED_BY_CUSTOMERThe payment was cancelled by the customer before completion
PAYMENT_NOT_COMPLETED_BY_CUSTOMERThe payment was not completed by the customer
CUSTOMER_BANK_UNREACHABLEUnable to connect to the customer's bank. Please try again later
CUSTOMER_COUNTRY_RESTRICTEDTransfers to customers in this country and from this country are not supported
PAYMENT_CHANNEL_UNAVAILABLEPayment channel is disabled or temporarily unavailable due to downtime
INSUFFICIENT_MERCHANT_BALANCEMerchant has insufficient balance to complete the transaction
INVALID_API_CREDENTIALSAPI key or signature is invalid