Request

curl --location 'https://amazonpay.amazon.in/v1/payments/charge' \
--header 'Content-Type: application/json' \
--header 'x-amz-algorithm: AWS4-HMAC-SHA384' \
--header 'x-amz-client-id: AZ4WQCLDT2DF0' \
--header 'x-amz-date: 20210217T132711Z' \
--header 'x-amz-expires: 900' \
--header 'x-amz-source: Browser' \
--header 'x-amz-user-agent: Postman' \
--header 'x-amz-user-ip: 52.95.75.13' \
--header 'Authorization: AMZ+f57bbc68-fa6a-4c5e-a281-d39db51a26c6:KEt1Fcd7p5QVbF6FjnExoe-4PbXLazLsFY0Fc2GzKJpi1ksflVBZC6ocvp57iSrb' \
--data '{"accessToken":"Atza|IwEBIO","amount":"1.00","attributableProgram":"S2SPay","callbackUrl":"http://ar-deepthi.com/amazonpay/thankyou.php","chargeId":"test123111","currencyCode":"INR","intent":"Capture","merchantId":"AZ4WQCLDT2DF0","noteToCustomer":"TestSellerNote","referenceId":"900","selectedPaymentInstrumentType":"AmazonPayLater"} '

Response


            
/* Create HTTP request Object */
OkHttpClient client = new OkHttpClient().newBuilder().build();

/* API request type */
MediaType mediaType = MediaType.parse("application/json");

/* Request parameters */
RequestBody body = RequestBody.create(mediaType, "{\"accessToken\":\"Atza|IwEBIOYKxXD5LM-IEQgzIxKAJXQ\",\"amount\":\"1.00\",\"attributableProgram\":\"S2SPay\",\"callbackUrl\":\"http://ar-deepthi.com/amazonpay/thankyou.php\",\"chargeId\":\"test123111\",\"currencyCode\":\"INR\",\"intent\":\"Capture\",\"merchantId\":\"AZ4WQCLDT2DF0\",\"noteToCustomer\":\"TestSellerNote\",\"referenceId\":\"900\",\"selectedPaymentInstrumentType\":\"AmazonCredit\"}\n");

Request request = new Request.Builder() .url("https://amazonpay.amazon.in/v1/payments/charge") .method("POST", body)
.addHeader("Content-Type", "application/json")
.addHeader("x-amz-algorithm", "AWS4-HMAC-SHA384")
.addHeader("x-amz-client-id", "AZ4WQCLDT2DF0")
.addHeader("x-amz-date", "20210217T132711Z")
.addHeader("x-amz-expires", "900")
.addHeader("x-amz-source", "Browser")
.addHeader("x-amz-user-agent", "Postman")
.addHeader("x-amz-user-ip", "52.95.75.13")
.addHeader("Authorization", "AMZ+f57bbc68-fa6a-4c5e-a281-XXXXXXX:KEt1Fcd7p5QVbF6FjnExoe-4PbXLazLsFY0Fc2GzKJpi1ksflVBZC6ocvp57iSrb") .build();


/* Capture Response */
Response response = client.newCall(request).execute();
var request = require('request');

/* Prepearing API request */
var options = { 'method': 'POST', 'url': 'https://amazonpay.amazon.in/v1/payments/charge',
'headers': {
'Content-Type': 'application/json',
'x-amz-algorithm': 'AWS4-HMAC-SHA384',
'x-amz-client-id': 'AZ4WQCLDT2DF0',
'x-amz-date': '20210217T132711Z',
'x-amz-expires': '900',
'x-amz-source': 'Browser',
'x-amz-user-agent': 'Postman',
'x-amz-user-ip': '52.95.75.13',
'Authorization': 'AMZ+f57bbc68-fa6a-4c5e-a281-XXXXXXXX:KEt1Fcd7p5QVbF6FjnExoe-4PbXLazLsFY0Fc2GzKJpi1ksflVBZC6ocvp57iSrb' },

/* API Body */
body: JSON.stringify({
"accessToken": "Atza|IwEBIOYKxXD5LM",
"amount": "1.00",
"attributableProgram": "S2SPay",
"callbackUrl": "http://ar-deepthi.com/amazonpay/thankyou.php",
"chargeId": "test123111",
"currencyCode": "INR",
"intent": "Capture",
"merchantId": "AZ4WQCLDT2DF0",
"noteToCustomer": "TestSellerNote",
"referenceId": "900",
"selectedPaymentInstrumentType": "AmazonCredit"
})
};


/* Capture Response */
request(options, function (error, response) { if (error) throw new Error(error); console.log(response.body); });
$client = new Client();

/* API headers */
$headers = [ 'Content-Type' => 'application/json', 'x-amz-algorithm' => 'AWS4-HMAC-SHA384', 'x-amz-client-id' => 'AZ4WQCLDT2DF0', 'x-amz-date' => '20210217T132711Z', 'x-amz-expires' => '900', 'x-amz-source' => 'Browser', 'x-amz-user-agent' => 'Postman', 'x-amz-user-ip' => '52.95.75.13', 'Authorization' => 'AMZ+f57bbc68-fa6a-4c5e-a281-XXXXXXXXX:KEt1Fcd7p5QVbF6FjnExoe-4PbXLazLsFY0Fc2GzKJpi1ksflVBZC6ocvp57iSrb' ];

/* API Body */
$body = '{
"accessToken": "Atza|IwEBIOYKxXD5LM-IEQgzIxKAJg",
"amount": "1.00",
"attributableProgram": "S2SPay",
"callbackUrl": "http://ar-deepthi.com/amazonpay/thankyou.php",
"chargeId": "test123111",
"currencyCode": "INR",
"intent": "Capture",
"merchantId": "AZ4WQCLDT2DF0",
"noteToCustomer": "TestSellerNote",
"referenceId": "900",
"selectedPaymentInstrumentType": "AmazonCredit"
}';


/* Capture Response */
$request = new Request('POST', 'https://amazonpay.amazon.in/v1/payments/charge', $headers, $body);
$res = $client->sendAsync($request)->wait();
echo $res->getBody();