Post Charge API
Method: POST
Path: <endpoint>/v1/payments/charge
ContentType: application/json
Description: This API initiates a transaction by triggering a 'Capture' intent. If the user has sufficient balance, the amount will be instantly deducted. If the balance is insufficient, a payment URL will be provided for the user to complete the payment.
Request Parameters
Parameter | Type | Description |
---|---|---|
intent | String | Identifies the type of charge request (Capture in this case) |
amount | String | Amount to be charged for the order |
currencyCode | String | Will always be INR |
callbackUrl | String | URL for user redirection post payment completion |
accessToken | String | Access token generated for the user |
chargeId | String | Unique id generated by the merchant for the transaction |
referenceId | String | Unique id tagging multiple transactions together |
merchantId | String | Your merchant ID with Amazon Pay |
attributableProgram | String | Passed as S2Spay |
noteToCustomer | String | Optional notes to the customers |
customData | String | Additional value for self-use |
timeoutInSecs | String | Transaction timeout value in seconds |
paymentMetaData | String | Client side SDK must have fetched Payments Meta data which needs to be passed here |
selectedPaymentInstrumentType | String | You have to pass it as AmazonPayLater |
Sample JSON for Request
{
"intent": "Capture",
"merchantId": "A28RUGPVUTQXU1",
"chargeId": "ve7v676dsdsde7f",
"accessToken": "A3RYF1HD1W5QCF",
"referenceId": "ve7vdsdsde7f",
"amount": "0.01",
"currencyCode": "INR",
"attributableProgram": "S2SPay",
"callbackUrl": "http://merchantx.com/pay",
"noteToCustomer": "note to customer",
"customData": "data",
"timeoutInSecs": "90000"
}
Response Parameters
Parameter | Type | Description |
---|---|---|
merchantId | String | Your merchant ID with Amazon Pay |
requestedAmount | String | Amount requested as part of the request |
approvedAmount | String | Approved amount from Amazon Pay |
amazonChargeId | String | Amazon generated unique transaction Id |
chargeId | String | Merchant transaction ID sent in the request |
status | String | Indicates the status of the request |
currencyCode | String | Will always be INR |
amazonPayUrl | String | URL for redirection if user balance is low |
customData | String | Additional data passed in the request |
createTime | String | Creation timestamp |
updateTime | String | Last update timestamp |
attributableProgram | String | You must pass it as S2Spay |
customData | String | (Optional) Will be part of the response only if the parameter was passed in the request createTime String |
createTime | String | When the request was created at our end |
Sample Response
{
"merchantId": "A28RUGPVUTQXU1",
"chargeId": "ve7vdsd99sde7f",
"amazonChargeId": "P04-0249917-0735882",
"requestedAmount": "0.01",
"approvedAmount": "0.01",
"currencyCode": "INR",
"status": "CaptureApproved",
"amazonPayUrl": "https://amazonpay.amazon.in/~",
"customData": "data passed in the request",
"createTime": "2020-01-13T05:28:30.377Z",
"updateTime": "2020-01-13T05:28:30.377Z"
}
Common Errors
Error | Resolution |
---|---|
InvalidAccessToken | This error indicates that the access token has turned stale and is no longer valid or doesn't have the right permissions. Access tokens turn stale 60 minutes after they are requested. To resolve, request a new access token. |
InvalidCallbackUrl | Ensure that your callback URL used in the API request is added to the list of approved URLs at Amazon. If they are not on the list of approved URLs, reach out to your integration POC to get them added to the list. |
Transaction has timed out | The default timeout value for transactions is set to 15 minutes. Ensure that the time out value is not set to less than 5 minutes to avoid transaction timeout. |