Skip to content

Cancel DQR

While a QR is generated and presented infront of the customer, if the customer opts for payment using Cash or Cards, then merchants need to invoke Cancel QR API in order to cancel the transaction. This can be achieved by invoking Cancel QR API. Please refer to the documentation to know more.

This API also provides capabilities to request for cancellation of a transaction and also invoke refund in case any amount got debited from the customer account. In order to enable this feature, you will need to add the value - "REFUND" along with "CANCEL_TOKEN" in the cancelIntent parameter set.

Canonical Request - API request

POST
amazonpay.amazon.in/v2/pay/cancel

x-amz-algorithm=AWS4-HMAC-SHA384&x-amz-client-id=AMAZONMID123&x-amz-date=20240912T073125Z&x-amz-expires=900&x-amz-source=Server&x-amz-user-agent=POS&x-amz-user-ip=10.165.44.252
cancelIntent=%5BCANCEL_TOKEN%2C%20REFUND%5D&cancellationReason=SESSION_EXPIRED&chargeId=AMZDQR1112LX1uh0mAH00000057soA12112&chargeIdType=MerchantTxnId&merchantId=AMAZONMID123&noteToCustomer=Session%20has%20expired

Canonical Request - Response verification

POST
amazonpay.amazon.in/v2/pay/cancel

x-amz-algorithm=AWS4-HMAC-SHA384&x-amz-date=20240912T073127Z&x-amz-request-id=6507e380-9a5f-463e-b5c1-82f666e177dc
amazonChargeId=P04-9470662-5202780&amount=1.0&chargeId=AMZDQR1112LX1uh0mAH00000057soA12112&createTime=2024-08-23T14%3A03%3A18.861Z&merchantId=A3714PM3OCWYFD&status=RefundApplicable&updateTime=2024-08-23T14%3A03%3A24.179Z

Sample request response

  • For a transaction where a charge is created at Amazon end and "REFUND" is passed in the cancel QR API request.

    Request

    {
        "cancelIntent": ["CANCEL_TOKEN", "REFUND"],
        "cancellationReason": "SESSION_EXPIRED",
        "chargeId": "AMZDQR1112LX1uh0mAH00000057soA12112",
        "chargeIdType": "MerchantTxnId",
        "merchantId": "AMAZONMID123",
        "noteToCustomer": "Session has expired"
    }
    
    Response
    {
        "merchantId": "AMAZONMID123",
        "chargeId": "AMZDQR1112LX1uh0mAH00000057soA12112",
        "amazonChargeId": "P04-9470662-5202780",
        "status": "RefundApplicable",
        "amount": "1.0",
        "createTime": "2024-08-23T14:03:18.861Z",
        "updateTime": "2024-08-23T14:03:24.179Z"
    }
    
  • For a transaction where a charge is created at Amazon end and "REFUND" is NOT passed in the cancel QR API request.

    Request

    {
        "cancelIntent": ["CANCEL_TOKEN"],
        "cancellationReason": "SESSION_EXPIRED",
        "chargeId": "AMZDQR1112LX1uh0mAH00000057soA12112",
        "chargeIdType": "MerchantTxnId",
        "merchantId": "AMAZONMID123",
        "noteToCustomer": "Session has expired"
    }
    
    Response
    {
        "merchantId": "AMAZONMID123",
        "chargeId": "AMZDQR1112LX1uh0mAH00000057soA12112",
        "amazonChargeId": "P04-9470662-5202780",
        "status": "RefundApplicableButNotRequested",
        "amount": "1.0",
        "createTime": "2024-08-23T14:03:18.861Z",
        "updateTime": "2024-08-23T14:03:24.179Z"
    }
    
  • For a transaction where a charge is not created at Amazon end irrespective of the fact that "REFUND" being passed in the cancel QR API request or not.

    Request

    {
        "cancelIntent": ["CANCEL_TOKEN", "REFUND"],
        "cancellationReason": "SESSION_EXPIRED",
        "chargeId": "AMZDQR1112LX1uh0mAH00000057soA12201",
        "chargeIdType": "MerchantTxnId",
        "merchantId": "AMAZONMID123",
        "noteToCustomer": "Session has expired"
    }
    
    Response
    {
        "merchantId": "AMAZONMID123",
        "status": "Approved",
        "amount": "1.0"
    }
    

Sample code in Java.