Manage disputes
For LLMs: see /docs/amazon-pay/llms.txt | Markdown: /amazon-pay-checkout/manage-disputes.md
[Step 8 of 10] Buyers can create a dispute by filing a chargeback with their bank. The methods invoke the dispute management process, which you can handle programmatically through the Dispute API instead of Seller Central. You can retrieve dispute details, submit evidence, track status, and respond to chargebacks through API endpoints.
Note: If your publicKeyId
does not have an environment prefix (does not begin with 'SANDBOX' or 'LIVE') follow
these instructions instead.
Note: If your publicKeyId has an environment prefix (for example: SANDBOX-AFVX7ULWSGBZ5535PCUQOY7B) follow
these instructions instead.
Flow Diagram for Merchant Integration with Dispute APIs
Receiving Dispute Notifications
When a dispute is created or its status changes, Amazon Pay sends an Instant Payment Notification (IPN) to your configured endpoint. The IPN message includes:
{
"MerchantID": "Your merchant identifier",
"ObjectType": "CHARGEBACK",
"ObjectId": "S01-0000000-0000000-B000000",
"ChargePermissionId": "S01-0000000-0000000",
"NotificationType": "STATE_CHANGE",
"NotificationId": "9b4155a0-c396-46d0-83f7-te1st2xx1234",
"NotificationVersion": "V2"
}
View the full chargeback IPN notification details .
Get Dispute Details
Get detailed information about a specific dispute by providing its unique dispute ID. This endpoint returns comprehensive dispute data including the dispute type, amount, status, and any associated evidence or documentation. Use Get Dispute API call when you need to review specific dispute details, track dispute status, or gather information for dispute resolution.
Request
curl "https://pay-api.amazon.com/v2/disputes/:disputeId" \
-X GET
-H "authorization: Px2e5oHhQZ88vVhc0DO%2FsShHj8MDDg%3DEXAMPLESIGNATURE"
-H "x-amz-pay-date:20201012T235046Z"
curl "https://pay-api.amazon.com/:environment/v2/disputes/:disputeId" \
-X GET
-H "authorization: Px2e5oHhQZ88vVhc0DO%2FsShHj8MDDg%3DEXAMPLESIGNATURE"
-H "x-amz-pay-date:20201012T235046Z"
Sample Code
<?php
include 'vendor/autoload.php';
$amazonpay_config = array(
'public_key_id' => 'YOUR_PUBLIC_KEY_ID',
'private_key' => 'keys/private.pem', // Path to RSA Private Key (or a string representation)
'region' => 'YOUR_REGION_CODE',
'algorithm' => 'AMZN-PAY-RSASSA-PSS-V2'
);
try {
$disputeId = 'S01-0000000-0000000-B000000';
$client = new Amazon\Pay\API\Client($amazonpay_config);
$result = $client->getDispute($disputeId);
if ($result['status'] === 200) {
$response = json_decode($result['response'], true);
$disputeState = $response['statusDetails']['state'];
} else {
// check the error
echo 'status=' . $result['status'] . '; response=' . $result['response'];
}
} catch (Exception $e) {
// handle the exception
echo $e;
}
?>
using Amazon.Pay.API.Types;
using Amazon.Pay.API.WebStore;
using Amazon.Pay.API.WebStore.Dispute;
using Amazon.Pay.API.WebStore.Types;
using System;
public class Sample
{
public WebStoreClient InitiateClient()
{
// set up config
var payConfiguration = new ApiConfiguration
(
region: Region.YOUR_REGION_CODE,
publicKeyId: "YOUR_PUBLIC_KEY_ID",
privateKey: "PATH_OR_CONTENT_OF_YOUR_PRIVATE_KEY",
algorithm: AmazonSignatureAlgorithm.V2
);
// init API client
var client = new WebStoreClient(payConfiguration);
return client;
}
public void GetDispute(string disputeId)
{
// send the request
DisputeResponse result = client.GetDispute(disputeId);
// check if API call was successful
if (!result.Success)
{
// handle the API error (use Status field to get the numeric error code)
} else {
// do something with the result, for instance:
Console.WriteLine(result.RawResponse);
}
}
}
import com.amazon.pay.api.AmazonPayResponse;
import com.amazon.pay.api.PayConfiguration;
import com.amazon.pay.api.WebstoreClient;
import com.amazon.pay.api.exceptions.AmazonPayClientException;
import com.amazon.pay.api.types.Region;
public void sample() {
PayConfiguration payConfiguration = null;
try {
payConfiguration = new PayConfiguration()
.setPublicKeyId("YOUR_PUBLIC_KEY_ID")
.setRegion(Region.YOUR_REGION_CODE)
.setPrivateKey("YOUR_PRIVATE_KEY".toCharArray())
.setAlgorithm("AMZN-PAY-RSASSA-PSS-V2");
WebstoreClient webstoreClient = new WebstoreClient(payConfiguration);
AmazonPayResponse response = webstoreClient.getDispute("S01-0000000-0000000-B000000");
} catch (AmazonPayClientException e) {
e.printStackTrace();
}
}
const fs = require('fs');
const Client = require('@amazonpay/amazon-pay-api-sdk-nodejs');
const config = {
publicKeyId: 'YOUR_PUBLIC_KEY_ID',
privateKey: fs.readFileSync('tst/private.pem'),
region: 'YOUR_REGION_CODE',
algorithm: 'AMZN-PAY-RSASSA-PSS-V2'
};
const disputeId = 'S01-0000000-0000000-B000000';
const testPayClient = new Client.WebStoreClient(config);
const response = testPayClient.getDispute(disputeId);
response.then(function (result) {
console.log(result.data);
}).catch(err => {
console.log(err);
});
require 'amazon-pay-api-sdk-ruby'
config = {
region: 'YOUR_REGION_CODE', # Supported values: na, eu, jp
public_key_id: 'YOUR_PUBLIC_KEY_ID',
private_key: File.read('privateKey.pem')
}
client = AmazonPayClient.new(config)
dispute_id = 'S01-0000000-0000000-B000000'
response = client.get_dispute(dispute_id)
if response.code.to_i == 200
puts response.body
else
# check the error
puts "status=#{response.code}"
puts response.body
end
<?php
include 'vendor/autoload.php';
$amazonpay_config = array(
'public_key_id' => 'YOUR_PUBLIC_KEY_ID',
'private_key' => 'keys/private.pem', // Path to RSA Private Key (or a string representation)
'region' => 'YOUR_REGION_CODE',
'sandbox' => true,
'algorithm' => 'AMZN-PAY-RSASSA-PSS-V2'
);
try {
$disputeId = 'S01-0000000-0000000-B000000';
$client = new Amazon\Pay\API\Client($amazonpay_config);
$result = $client->getDispute($disputeId);
if ($result['status'] === 200) {
$response = json_decode($result['response'], true);
$disputeState = $response['statusDetails']['state'];
} else {
// check the error
echo 'status=' . $result['status'] . '; response=' . $result['response'];
}
} catch (Exception $e) {
// handle the exception
echo $e;
}
?>
using Amazon.Pay.API.Types;
using Amazon.Pay.API.WebStore;
using Amazon.Pay.API.WebStore.Dispute;
using Amazon.Pay.API.WebStore.Types;
using System;
public class Sample
{
public WebStoreClient InitiateClient()
{
// set up config
var payConfiguration = new ApiConfiguration
(
region: Region.YOUR_REGION_CODE,
environment: Environment.Sandbox,
publicKeyId: "YOUR_PUBLIC_KEY_ID",
privateKey: "PATH_OR_CONTENT_OF_YOUR_PRIVATE_KEY",
algorithm: AmazonSignatureAlgorithm.V2
);
// init API client
var client = new WebStoreClient(payConfiguration);
return client;
}
public void GetDispute(string disputeId)
{
// send the request
DisputeResponse result = client.GetDispute(disputeId);
// check if API call was successful
if (!result.Success)
{
// handle the API error (use Status field to get the numeric error code)
} else {
// do something with the result, for instance:
Console.WriteLine(result.RawResponse);
}
}
}
import com.amazon.pay.api.AmazonPayResponse;
import com.amazon.pay.api.PayConfiguration;
import com.amazon.pay.api.WebstoreClient;
import com.amazon.pay.api.exceptions.AmazonPayClientException;
import com.amazon.pay.api.types.Environment;
import com.amazon.pay.api.types.Region;
public void sample() {
PayConfiguration payConfiguration = null;
try {
payConfiguration = new PayConfiguration()
.setPublicKeyId("YOUR_PUBLIC_KEY_ID")
.setRegion(Region.YOUR_REGION_CODE)
.setPrivateKey("YOUR_PRIVATE_KEY".toCharArray())
.setEnvironment(Environment.SANDBOX)
.setAlgorithm("AMZN-PAY-RSASSA-PSS-V2");
WebstoreClient webstoreClient = new WebstoreClient(payConfiguration);
AmazonPayResponse response = webstoreClient.getDispute("S01-0000000-0000000-B000000");
} catch (AmazonPayClientException e) {
e.printStackTrace();
}
}
const fs = require('fs');
const Client = require('@amazonpay/amazon-pay-api-sdk-nodejs');
const config = {
publicKeyId: 'YOUR_PUBLIC_KEY_ID',
privateKey: fs.readFileSync('tst/private.pem'),
region: 'YOUR_REGION_CODE',
sandbox: true,
algorithm: 'AMZN-PAY-RSASSA-PSS-V2'
};
const disputeId = 'S01-0000000-0000000-B000000';
const testPayClient = new Client.WebStoreClient(config);
const response = testPayClient.getDispute(disputeId);
response.then(function (result) {
console.log(result.data);
}).catch(err => {
console.log(err);
});
require 'amazon-pay-api-sdk-ruby'
config = {
region: 'YOUR_REGION_CODE', # Supported values: na, eu, jp
public_key_id: 'YOUR_PUBLIC_KEY_ID',
private_key: File.read('privateKey.pem'),
sandbox: true
}
client = AmazonPayClient.new(config)
dispute_id = 'S01-0000000-0000000-B000000'
response = client.get_dispute(dispute_id)
if response.code.to_i == 200
puts response.body
else
# check the error
puts "status=#{response.code}"
puts response.body
end
The API returns a Dispute object containing:
Basic dispute information (ID, type, amount, filing reason)
Transaction details (charge ID, timestamps)
Status information (state, resolution, reason codes)
Evidence submissions (merchant documentation and files)
{
"disputeId": "P01-1111111-1111111-B123456",
"chargeId": "P01-1111111-1111111-C123456",
"disputeType": "Chargeback",
"disputeAmount": {
"amount": "400",
"currencyCode": "USD"
},
"filingReason": "Fraudulent",
"filingTimestamp": "20190714T155300Z",
"resolutionAuthority": "AmazonPay",
"statusDetails": {
"state": "Resolved",
"reasonCode": "MerchantAcceptedDispute",
"reasonDescription": "Merchant accepted the dispute request",
"resolution": "BuyerWon",
"lastUpdatedTimestamp": "20190716T156500Z"
},
"resolutionAuthority": "AmazonPay",
"merchantEvidences": [
{
"evidenceType" : "TrackingNumber",
"fileId" : null,
"evidenceText": "raw text supporting merchant evidence"
},
{
"evidenceType": "CustomerSignature",
"fileId": "customer_signature_file_id",
"evidenceText": null
}
],
"closureTimestamp": "20190716T155300Z",
"releaseEnvironment": "Live"
}
Update Dispute Details
Submit your response through the Update Dispute API to accept a dispute when you agree the customer's chargeback is valid.
Request
curl "https://pay-api.amazon.com/v2/disputes/:disputeId" \
-X PATCH
-H "authorization: Px2e5oHhQZ88vVhc0DO%2FsShHj8MDDg%3DEXAMPLESIGNATURE"
-H "x-amz-pay-date:20201012T235046Z"
-d @request_body
curl "https://pay-api.amazon.com/:environment/v2/disputes/:disputeId" \
-X PATCH
-H "authorization: Px2e5oHhQZ88vVhc0DO%2FsShHj8MDDg%3DEXAMPLESIGNATURE"
-H "x-amz-pay-date:20201012T235046Z"
-d @request_body
Request body
{
"statusDetails": {
"resolution": "BuyerWon",
"state": "Resolved",
"reasonCode": "MerchantAcceptedDispute",
"reasonDescription": "Merchant accepted the dispute request"
},
"closureTimestamp": "20190716T162300Z"
}
Request parameters
Name
Location
Description
StatusDetails(required) Type: DisputeStatusDetails
Body
Specifies the dispute state (Resolved/Closed), resolution (BuyerWon/MerchantWon/NoFault), and reason code. All fields required.
ClosureTimeStamp(required) Type: dateTime
Body
Required for "Closed" state only. UTC timestamp in ISO 8601 format.
Sample Code
<?php
include 'vendor/autoload.php';
use Amazon\Pay\API\Constants\DisputeResolution;
use Amazon\Pay\API\Constants\DisputeState;
use Amazon\Pay\API\Constants\DisputeReasonCode;
$amazonpay_config = array(
'public_key_id' => 'YOUR_PUBLIC_KEY_ID',
'private_key' => 'keys/private.pem', // Path to RSA Private Key (or a string representation)
'region' => 'YOUR_REGION_CODE',
'algorithm' => 'AMZN-PAY-RSASSA-PSS-V2'
);
$disputeId = 'S01-0000000-0000000-B000000';
$closureTimestamp = time();
$payload = array(
'statusDetails' => array(
'resolution' => DisputeResolution::MERCHANT_WON,
'state' => DisputeState::RESOLVED,
'reasonCode' => DisputeReasonCode::MERCHANT_ACCEPTED_DISPUTE,
'reasonDescription' => 'Merchant accepted the dispute request'
),
'closureTimestamp' => $closureTimestamp
);
try {
$client = new Amazon\Pay\API\Client($amazonpay_config);
$result = $client->updateDispute($disputeId, $payload);
if ($result['status'] === 200) {
$response = json_decode($result['response'], true);
$disputeState = $response['statusDetails']['state'];
} else {
// check the error
echo 'status=' . $result['status'] . '; response=' . $result['response'];
}
} catch (Exception $e) {
// handle the exception
echo $e;
}
?>
using Amazon.Pay.API.Types;
using Amazon.Pay.API.WebStore;
using Amazon.Pay.API.WebStore.Dispute;
using Amazon.Pay.API.WebStore.Types;
using System;
public class Sample
{
public WebStoreClient InitiateClient()
{
// set up config
var payConfiguration = new ApiConfiguration
(
region: Region.YOUR_REGION_CODE,
publicKeyId: "YOUR_PUBLIC_KEY_ID",
privateKey: "PATH_OR_CONTENT_OF_YOUR_PRIVATE_KEY",
algorithm: AmazonSignatureAlgorithm.V2
);
// init API client
var client = new WebStoreClient(payConfiguration);
return client;
}
public void UpdateDispute(string disputeId)
{
// prepare the request
var request = new UpdateDisputeRequest(
state: "Resolved",
reasonCode: "MerchantAcceptedDispute",
closureTimestamp: DateTime.UtcNow,
reasonDescription: "Merchant accepted the dispute request",
resolution: "MerchantWon"
);
// send the request
DisputeResponse result = client.UpdateDispute(disputeId, request);
// check if API call was successful
if (!result.Success)
{
// handle the API error (use Status field to get the numeric error code)
} else {
// do something with the result, for instance:
Console.WriteLine(result.RawResponse);
}
}
}
import com.amazon.pay.api.AmazonPayResponse;
import com.amazon.pay.api.PayConfiguration;
import com.amazon.pay.api.WebstoreClient;
import com.amazon.pay.api.exceptions.AmazonPayClientException;
import com.amazon.pay.api.types.DisputeReasonCode;
import com.amazon.pay.api.types.DisputeResolution;
import com.amazon.pay.api.types.DisputeState;
import com.amazon.pay.api.types.Region;
import org.json.JSONObject;
public void sample() {
PayConfiguration payConfiguration = null;
try {
payConfiguration = new PayConfiguration()
.setPublicKeyId("YOUR_PUBLIC_KEY_ID")
.setRegion(Region.YOUR_REGION_CODE)
.setPrivateKey("YOUR_PRIVATE_KEY".toCharArray())
.setAlgorithm("AMZN-PAY-RSASSA-PSS-V2");
WebstoreClient webstoreClient = new WebstoreClient(payConfiguration);
String disputeId = "S01-0000000-0000000-B000000";
JSONObject statusDetails = new JSONObject();
statusDetails.put("resolution", DisputeResolution.MERCHANT_WON.getDisputeResolution());
statusDetails.put("state", DisputeState.RESOLVED.getDisputeState());
statusDetails.put("reasonCode", DisputeReasonCode.MERCHANT_ACCEPTED_DISPUTE.getDisputeReasonCode());
statusDetails.put("reasonDescription", "Merchant accepted the dispute request");
JSONObject payload = new JSONObject();
payload.put("statusDetails", statusDetails);
// Current Unix timestamp (seconds since epoch)
payload.put("closureTimestamp", System.currentTimeMillis() / 1000L);
AmazonPayResponse response = webstoreClient.updateDispute(disputeId, payload);
} catch (AmazonPayClientException e) {
e.printStackTrace();
}
}
const fs = require('fs');
const Client = require('@amazonpay/amazon-pay-api-sdk-nodejs');
const config = {
publicKeyId: 'YOUR_PUBLIC_KEY_ID',
privateKey: fs.readFileSync('tst/private.pem'),
region: 'YOUR_REGION_CODE',
algorithm: 'AMZN-PAY-RSASSA-PSS-V2'
};
const disputeId = 'S01-0000000-0000000-B000000';
const payload = {
statusDetails: {
resolution: "MerchantWon",
state: "Resolved",
reasonCode: "MerchantAcceptedDispute",
reasonDescription: "Merchant accepted the dispute request"
},
closureTimestamp: Date.now()
};
const testPayClient = new Client.WebStoreClient(config);
const response = testPayClient.updateDispute(disputeId, payload);
response.then(function (result) {
console.log(result.data);
}).catch(err => {
console.log(err);
});
require 'amazon-pay-api-sdk-ruby'
config = {
region: 'YOUR_REGION_CODE', # Supported values: na, eu, jp
public_key_id: 'YOUR_PUBLIC_KEY_ID',
private_key: File.read('privateKey.pem')
}
client = AmazonPayClient.new(config)
dispute_id = 'S01-0000000-0000000-B000000'
payload = {
"statusDetails": {
"resolution": "MerchantWon",
"state": "Resolved",
"reasonCode": "MerchantAcceptedDispute",
"reasonDescription": "Merchant accepted the dispute request"
},
"closureTimestamp": Time.now.to_i
}
response = client.update_dispute(dispute_id, payload)
if response.code.to_i == 200
puts response.body
else
# check the error
puts "status=#{response.code}"
puts response.body
end
<?php
include 'vendor/autoload.php';
use Amazon\Pay\API\Constants\DisputeResolution;
use Amazon\Pay\API\Constants\DisputeState;
use Amazon\Pay\API\Constants\DisputeReasonCode;
$amazonpay_config = array(
'public_key_id' => 'YOUR_PUBLIC_KEY_ID',
'private_key' => 'keys/private.pem', // Path to RSA Private Key (or a string representation)
'region' => 'YOUR_REGION_CODE',
'sandbox' => true,
'algorithm' => 'AMZN-PAY-RSASSA-PSS-V2'
);
$disputeId = 'S01-0000000-0000000-B000000';
$closureTimestamp = time();
$payload = array(
'statusDetails' => array(
'resolution' => DisputeResolution::MERCHANT_WON,
'state' => DisputeState::RESOLVED,
'reasonCode' => DisputeReasonCode::MERCHANT_ACCEPTED_DISPUTE,
'reasonDescription' => 'Merchant accepted the dispute request'
),
'closureTimestamp' => $closureTimestamp
);
try {
$client = new Amazon\Pay\API\Client($amazonpay_config);
$result = $client->updateDispute($disputeId, $payload);
if ($result['status'] === 200) {
$response = json_decode($result['response'], true);
$disputeState = $response['statusDetails']['state'];
} else {
// check the error
echo 'status=' . $result['status'] . '; response=' . $result['response'];
}
} catch (Exception $e) {
// handle the exception
echo $e;
}
?>
using Amazon.Pay.API.Types;
using Amazon.Pay.API.WebStore;
using Amazon.Pay.API.WebStore.Dispute;
using Amazon.Pay.API.WebStore.Types;
using System;
public class Sample
{
public WebStoreClient InitiateClient()
{
// set up config
var payConfiguration = new ApiConfiguration
(
region: Region.YOUR_REGION_CODE,
environment: Environment.Sandbox,
publicKeyId: "YOUR_PUBLIC_KEY_ID",
privateKey: "PATH_OR_CONTENT_OF_YOUR_PRIVATE_KEY",
algorithm: AmazonSignatureAlgorithm.V2
);
// init API client
var client = new WebStoreClient(payConfiguration);
return client;
}
public void UpdateDispute(string disputeId)
{
// prepare the request
var request = new UpdateDisputeRequest(
state: "Resolved",
reasonCode: "MerchantAcceptedDispute",
closureTimestamp: DateTime.UtcNow,
reasonDescription: "Merchant accepted the dispute request",
resolution: "MerchantWon"
);
// send the request
DisputeResponse result = client.UpdateDispute(disputeId, request);
// check if API call was successful
if (!result.Success)
{
// handle the API error (use Status field to get the numeric error code)
} else {
// do something with the result, for instance:
Console.WriteLine(result.RawResponse);
}
}
}
import com.amazon.pay.api.AmazonPayResponse;
import com.amazon.pay.api.PayConfiguration;
import com.amazon.pay.api.WebstoreClient;
import com.amazon.pay.api.exceptions.AmazonPayClientException;
import com.amazon.pay.api.types.DisputeReasonCode;
import com.amazon.pay.api.types.DisputeResolution;
import com.amazon.pay.api.types.DisputeState;
import com.amazon.pay.api.types.Environment;
import com.amazon.pay.api.types.Region;
import org.json.JSONObject;
public void sample() {
PayConfiguration payConfiguration = null;
try {
payConfiguration = new PayConfiguration()
.setPublicKeyId("YOUR_PUBLIC_KEY_ID")
.setRegion(Region.YOUR_REGION_CODE)
.setPrivateKey("YOUR_PRIVATE_KEY".toCharArray())
.setEnvironment(Environment.SANDBOX)
.setAlgorithm("AMZN-PAY-RSASSA-PSS-V2");
WebstoreClient webstoreClient = new WebstoreClient(payConfiguration);
String disputeId = "S01-0000000-0000000-B000000";
JSONObject statusDetails = new JSONObject();
statusDetails.put("resolution", DisputeResolution.MERCHANT_WON.getDisputeResolution());
statusDetails.put("state", DisputeState.RESOLVED.getDisputeState());
statusDetails.put("reasonCode", DisputeReasonCode.MERCHANT_ACCEPTED_DISPUTE.getDisputeReasonCode());
statusDetails.put("reasonDescription", "Merchant accepted the dispute request");
JSONObject payload = new JSONObject();
payload.put("statusDetails", statusDetails);
// Current Unix timestamp (seconds since epoch)
payload.put("closureTimestamp", System.currentTimeMillis() / 1000L);
AmazonPayResponse response = webstoreClient.updateDispute(disputeId, payload);
} catch (AmazonPayClientException e) {
e.printStackTrace();
}
}
const fs = require('fs');
const Client = require('@amazonpay/amazon-pay-api-sdk-nodejs');
const config = {
publicKeyId: 'YOUR_PUBLIC_KEY_ID',
privateKey: fs.readFileSync('tst/private.pem'),
region: 'YOUR_REGION_CODE',
sandbox: true,
algorithm: 'AMZN-PAY-RSASSA-PSS-V2'
};
const disputeId = 'S01-0000000-0000000-B000000';
const payload = {
statusDetails: {
resolution: "MerchantWon",
state: "Resolved",
reasonCode: "MerchantAcceptedDispute",
reasonDescription: "Merchant accepted the dispute request"
},
closureTimestamp: Date.now()
};
const testPayClient = new Client.WebStoreClient(config);
const response = testPayClient.updateDispute(disputeId, payload);
response.then(function (result) {
console.log(result.data);
}).catch(err => {
console.log(err);
});
require 'amazon-pay-api-sdk-ruby'
config = {
region: 'YOUR_REGION_CODE', # Supported values: na, eu, jp
public_key_id: 'YOUR_PUBLIC_KEY_ID',
private_key: File.read('privateKey.pem'),
sandbox: true
}
client = AmazonPayClient.new(config)
dispute_id = 'S01-0000000-0000000-B000000'
payload = {
"statusDetails": {
"resolution": "MerchantWon",
"state": "Resolved",
"reasonCode": "MerchantAcceptedDispute",
"reasonDescription": "Merchant accepted the dispute request"
},
"closureTimestamp": Time.now.to_i
}
response = client.update_dispute(dispute_id, payload)
if response.code.to_i == 200
puts response.body
else
# check the error
puts "status=#{response.code}"
puts response.body
end
Response
The API returns an updated Dispute object containing:
Basic dispute information (ID, type, amount, filing reason)
Transaction details (charge ID, timestamps)
Updated status information (state, resolution, reason codes)
Evidence submissions (merchant documentation and files)
{
"disputeId": "P01-1111111-1111111-B123456",
"chargeId": "P01-1111111-1111111-C123456",
"disputeType": "Chargeback",
"disputeAmount": {
"amount": "400",
"currencyCode": "USD"
},
"filingReason": "Fraudulent",
"filingTimestamp": "20190714T155300Z",
"resolutionAuthority": "AmazonPay",
"statusDetails": {
"state": "Resolved",
"reasonCode": "MerchantAcceptedDispute",
"reasonDescription": "Merchant accepted the dispute request",
"resolution": "BuyerWon",
"lastUpdatedTimestamp": "20190716T156500Z"
},
"resolutionAuthority": "AmazonPay",
"closureTimestamp": "20190716T155300Z",
"releaseEnvironment": "Live"
}
Contest Dispute Details
Challenge a dispute by submitting evidence and documentation to support your case against the chargeback. This endpoint enables merchants to formally contest a dispute by providing relevant proof such as shipping confirmations, customer communications, or product documentation. Use the Contest Dispute API call when you have valid grounds to dispute a customer's chargeback and want to submit supporting evidence for review.
Request
curl "https://pay-api.amazon.com/v2/disputes/:disputeId/contest" \
-X POST
-H "authorization: Px2e5oHhQZ88vVhc0DO%2FsShHj8MDDg%3DEXAMPLESIGNATURE"
-H "x-amz-pay-date:20201012T235046Z"
-d @request_body
curl "https://pay-api.amazon.com/:environment/v2/disputes/:disputeId/contest" \
-X POST
-H "authorization: Px2e5oHhQZ88vVhc0DO%2FsShHj8MDDg%3DEXAMPLESIGNATURE"
-H "x-amz-pay-date:20201012T235046Z"
-d @request_body
Request body
{
"merchantEvidences": [
{
"evidenceType" : "TrackingNumber",
"fileId": null,
"evidenceText": "raw text supporting merchant evidence"
},
{
"evidenceType": "CustomerSignature",
"fileId": "customer_signature_file_id",
"evidenceText": null
}
]
}
Request parameters
Name
Location
Description
merchantEvidences(required) Type: list <Evidence >
Body
List of evidence items supporting your case Each evidence item needs either fileId or evidenceText See Evidence Types table for supported values
Sample Code
<?php
include 'vendor/autoload.php';
use Amazon\Pay\API\Constants\EvidenceType;
$amazonpay_config = array(
'public_key_id' => 'YOUR_PUBLIC_KEY_ID',
'private_key' => 'keys/private.pem', // Path to RSA Private Key (or a string representation)
'region' => 'YOUR_REGION_CODE',
'algorithm' => 'AMZN-PAY-RSASSA-PSS-V2'
);
$disputeId = 'S01-0000000-0000000-B000000';
$payload = array(
'merchantEvidences' => array(
array(
'evidenceType' => EvidenceType::TRACKING_NUMBER,
'fileId' => 'YOUR_FILE_ID',
'evidenceText' => 'raw text supporting merchant evidence'
)
)
);
try {
$client = new Amazon\Pay\API\Client($amazonpay_config);
$result = $client->contestDispute($disputeId, $payload);
if ($result['status'] === 200) {
$response = json_decode($result['response'], true);
$disputeState = $response['statusDetails']['state'];
} else {
// check the error
echo 'status=' . $result['status'] . '; response=' . $result['response'];
}
} catch (Exception $e) {
// handle the exception
echo $e;
}
?>
using Amazon.Pay.API.Types;
using Amazon.Pay.API.WebStore;
using Amazon.Pay.API.WebStore.Dispute;
using Amazon.Pay.API.WebStore.Types;
using System;
using System.Collections.Generic;
public class Sample
{
public WebStoreClient InitiateClient()
{
// set up config
var payConfiguration = new ApiConfiguration
(
region: Region.YOUR_REGION_CODE,
publicKeyId: "YOUR_PUBLIC_KEY_ID",
privateKey: "PATH_OR_CONTENT_OF_YOUR_PRIVATE_KEY",
algorithm: AmazonSignatureAlgorithm.V2
);
// init API client
var client = new WebStoreClient(payConfiguration);
return client;
}
public void ContestDispute(string disputeId)
{
// prepare the request
var merchantEvidences = new List<MerchantEvidence>
{
new MerchantEvidence
{
EvidenceType = "TrackingNumber",
FileId = "YOUR_FILE_ID",
EvidenceText = "raw text supporting merchant evidence"
}
};
var request = new ContestDisputeRequest(merchantEvidences);
// send the request
DisputeResponse result = client.ContestDispute(disputeId, request);
// check if API call was successful
if (!result.Success)
{
// handle the API error (use Status field to get the numeric error code)
} else {
// do something with the result, for instance:
Console.WriteLine(result.RawResponse);
}
}
}
import com.amazon.pay.api.AmazonPayResponse;
import com.amazon.pay.api.PayConfiguration;
import com.amazon.pay.api.WebstoreClient;
import com.amazon.pay.api.exceptions.AmazonPayClientException;
import com.amazon.pay.api.types.EvidenceType;
import com.amazon.pay.api.types.Region;
import org.json.JSONObject;
// for generating an idempotency key
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
public void sample() {
PayConfiguration payConfiguration = null;
try {
payConfiguration = new PayConfiguration()
.setPublicKeyId("YOUR_PUBLIC_KEY_ID")
.setRegion(Region.YOUR_REGION_CODE)
.setPrivateKey("YOUR_PRIVATE_KEY".toCharArray())
.setAlgorithm("AMZN-PAY-RSASSA-PSS-V2");
WebstoreClient webstoreClient = new WebstoreClient(payConfiguration);
String disputeId = "S01-0000000-0000000-B000000";
JSONObject evidence = new JSONObject();
evidence.put("evidenceType", EvidenceType.TRACKING_NUMBER.getEvidenceType());
evidence.put("fileId", "YOUR_FILE_ID");
evidence.put("evidenceText", "raw text supporting merchant evidence");
JSONObject payload = new JSONObject();
payload.append("merchantEvidences", evidence);
Map<String, String> header = new HashMap<String, String>();
header.put("x-amz-pay-idempotency-key", UUID.randomUUID().toString().replace("-", ""));
AmazonPayResponse response = webstoreClient.contestDispute(disputeId, payload, header);
} catch (AmazonPayClientException e) {
e.printStackTrace();
}
}
const fs = require('fs');
const Client = require('@amazonpay/amazon-pay-api-sdk-nodejs');
const config = {
publicKeyId: 'YOUR_PUBLIC_KEY_ID',
privateKey: fs.readFileSync('tst/private.pem'),
region: 'YOUR_REGION_CODE',
algorithm: 'AMZN-PAY-RSASSA-PSS-V2'
};
const disputeId = 'S01-0000000-0000000-B000000';
const payload = {
merchantEvidences: [
{
evidenceType: "TrackingNumber",
fileId: "YOUR_FILE_ID",
evidenceText: "raw text supporting merchant evidence"
}
]
};
const testPayClient = new Client.WebStoreClient(config);
const response = testPayClient.contestDispute(disputeId, payload);
response.then(function (result) {
console.log(result.data);
}).catch(err => {
console.log(err);
});
require 'amazon-pay-api-sdk-ruby'
config = {
region: 'YOUR_REGION_CODE', # Supported values: na, eu, jp
public_key_id: 'YOUR_PUBLIC_KEY_ID',
private_key: File.read('privateKey.pem')
}
client = AmazonPayClient.new(config)
dispute_id = 'S01-0000000-0000000-B000000'
payload = {
"merchantEvidences": [
{
"evidenceType": "TrackingNumber",
"fileId": "YOUR_FILE_ID",
"evidenceText": "raw text supporting merchant evidence"
}
]
}
response = client.contest_dispute(dispute_id, payload)
if response.code.to_i == 200
puts response.body
else
# check the error
puts "status=#{response.code}"
puts response.body
end
<?php
include 'vendor/autoload.php';
use Amazon\Pay\API\Constants\EvidenceType;
$amazonpay_config = array(
'public_key_id' => 'YOUR_PUBLIC_KEY_ID',
'private_key' => 'keys/private.pem', // Path to RSA Private Key (or a string representation)
'region' => 'YOUR_REGION_CODE',
'sandbox' => true,
'algorithm' => 'AMZN-PAY-RSASSA-PSS-V2'
);
$disputeId = 'S01-0000000-0000000-B000000';
$payload = array(
'merchantEvidences' => array(
array(
'evidenceType' => EvidenceType::TRACKING_NUMBER,
'fileId' => 'YOUR_FILE_ID',
'evidenceText' => 'raw text supporting merchant evidence'
)
)
);
try {
$client = new Amazon\Pay\API\Client($amazonpay_config);
$result = $client->contestDispute($disputeId, $payload);
if ($result['status'] === 200) {
$response = json_decode($result['response'], true);
$disputeState = $response['statusDetails']['state'];
} else {
// check the error
echo 'status=' . $result['status'] . '; response=' . $result['response'];
}
} catch (Exception $e) {
// handle the exception
echo $e;
}
?>
using Amazon.Pay.API.Types;
using Amazon.Pay.API.WebStore;
using Amazon.Pay.API.WebStore.Dispute;
using Amazon.Pay.API.WebStore.Types;
using System;
using System.Collections.Generic;
public class Sample
{
public WebStoreClient InitiateClient()
{
// set up config
var payConfiguration = new ApiConfiguration
(
region: Region.YOUR_REGION_CODE,
environment: Environment.Sandbox,
publicKeyId: "YOUR_PUBLIC_KEY_ID",
privateKey: "PATH_OR_CONTENT_OF_YOUR_PRIVATE_KEY",
algorithm: AmazonSignatureAlgorithm.V2
);
// init API client
var client = new WebStoreClient(payConfiguration);
return client;
}
public void ContestDispute(string disputeId)
{
// prepare the request
var merchantEvidences = new List<MerchantEvidence>
{
new MerchantEvidence
{
EvidenceType = "TrackingNumber",
FileId = "YOUR_FILE_ID",
EvidenceText = "raw text supporting merchant evidence"
}
};
var request = new ContestDisputeRequest(merchantEvidences);
// send the request
DisputeResponse result = client.ContestDispute(disputeId, request);
// check if API call was successful
if (!result.Success)
{
// handle the API error (use Status field to get the numeric error code)
} else {
// do something with the result, for instance:
Console.WriteLine(result.RawResponse);
}
}
}
import com.amazon.pay.api.AmazonPayResponse;
import com.amazon.pay.api.PayConfiguration;
import com.amazon.pay.api.WebstoreClient;
import com.amazon.pay.api.exceptions.AmazonPayClientException;
import com.amazon.pay.api.types.Environment;
import com.amazon.pay.api.types.EvidenceType;
import com.amazon.pay.api.types.Region;
import org.json.JSONObject;
// for generating an idempotency key
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
public void sample() {
PayConfiguration payConfiguration = null;
try {
payConfiguration = new PayConfiguration()
.setPublicKeyId("YOUR_PUBLIC_KEY_ID")
.setRegion(Region.YOUR_REGION_CODE)
.setPrivateKey("YOUR_PRIVATE_KEY".toCharArray())
.setEnvironment(Environment.SANDBOX)
.setAlgorithm("AMZN-PAY-RSASSA-PSS-V2");
WebstoreClient webstoreClient = new WebstoreClient(payConfiguration);
String disputeId = "S01-0000000-0000000-B000000";
JSONObject evidence = new JSONObject();
evidence.put("evidenceType", EvidenceType.TRACKING_NUMBER.getEvidenceType());
evidence.put("fileId", "YOUR_FILE_ID");
evidence.put("evidenceText", "raw text supporting merchant evidence");
JSONObject payload = new JSONObject();
payload.append("merchantEvidences", evidence);
Map<String, String> header = new HashMap<String, String>();
header.put("x-amz-pay-idempotency-key", UUID.randomUUID().toString().replace("-", ""));
AmazonPayResponse response = webstoreClient.contestDispute(disputeId, payload, header);
} catch (AmazonPayClientException e) {
e.printStackTrace();
}
}
const fs = require('fs');
const Client = require('@amazonpay/amazon-pay-api-sdk-nodejs');
const config = {
publicKeyId: 'YOUR_PUBLIC_KEY_ID',
privateKey: fs.readFileSync('tst/private.pem'),
region: 'YOUR_REGION_CODE',
sandbox: true,
algorithm: 'AMZN-PAY-RSASSA-PSS-V2'
};
const disputeId = 'S01-0000000-0000000-B000000';
const payload = {
merchantEvidences: [
{
evidenceType: "TrackingNumber",
fileId: "YOUR_FILE_ID",
evidenceText: "raw text supporting merchant evidence"
}
]
};
const testPayClient = new Client.WebStoreClient(config);
const response = testPayClient.contestDispute(disputeId, payload);
response.then(function (result) {
console.log(result.data);
}).catch(err => {
console.log(err);
});
require 'amazon-pay-api-sdk-ruby'
config = {
region: 'YOUR_REGION_CODE', # Supported values: na, eu, jp
public_key_id: 'YOUR_PUBLIC_KEY_ID',
private_key: File.read('privateKey.pem'),
sandbox: true
}
client = AmazonPayClient.new(config)
dispute_id = 'S01-0000000-0000000-B000000'
payload = {
"merchantEvidences": [
{
"evidenceType": "TrackingNumber",
"fileId": "YOUR_FILE_ID",
"evidenceText": "raw text supporting merchant evidence"
}
]
}
response = client.contest_dispute(dispute_id, payload)
if response.code.to_i == 200
puts response.body
else
# check the error
puts "status=#{response.code}"
puts response.body
end
Response
The API returns an updated Dispute object:
{
"disputeId": "P01-1111111-1111111-B123456",
"chargeId": "P01-1111111-1111111-C123456",
"disputeType": "Claim",
"disputeAmount": {
"amount": "400",
"currencyCode": "USD"
},
"filingReason": "ProductNotReceived",
"filingTimestamp": "20190714T155300Z",
"statusDetails": {
"state": "UnderReview",
"reasonCode": null,
"reasonDescription": null,
"resolution": null,
"lastUpdatedTimestamp": "20190714T156500Z"
},
"resolutionAuthority": "AmazonPay",
"releaseEnvironment": "Live",
"merchantEvidences": [
{
"evidenceType" : "TrackingNumber",
"fileId" : null,
"evidenceText": "raw text supporting merchant evidence"
},
{
"evidenceType": "CustomerSignature",
"fileId": "customer_signature_file_id",
"evidenceText": null
}
]
}
Upload files
Upload and manage files for dispute evidence and other documentation needs. The Upload File API supports common file formats and provides secure upload URLs. The API provides a two-step process to upload files securely.
Step 1: Get Upload URL
First, request a secure upload URL:
Request
curl "https://pay-api.amazon.com/v2/files" \
-X POST \
-H "authorization: Bearer YOUR_TOKEN" \
-H "x-amz-pay-date: 20201012T235046Z" \
-H "x-amz-pay-idempotency-key: YOUR_IDEMPOTENCY_KEY" \
-d @request_body
curl "https://pay-api.amazon.com/:environment/v2/files" \
-X POST \
-H "authorization: Bearer YOUR_TOKEN" \
-H "x-amz-pay-date: 20201012T235046Z" \
-H "x-amz-pay-idempotency-key: YOUR_IDEMPOTENCY_KEY" \
-d @request_body
Request body
{
"type" : "jpg",
"purpose" : "disputeEvidence"
}
Request parameters
Name
Location
Description
x-amz-pay-idempotency-key(required) Type: String
Header
Unique key to prevent duplicate uploads. For detailed guidance on creating and using idempotency keys, see Idempotency.
type Type: String
Body
File format (jpg, png, pdf)
purpose Type: String
Body
Upload reason (disputeEvidence)
Supported file types
fileType
Description
Content-Type
csv
CSV files
text/csv
pdf
PDF documents
application/pdf
xls/xlsx
Excel spreadsheets
application/vnd.ms-excel (xls) application/vnd.openxmlformats-officedocument.spreadsheetml.sheet (xlsx)
doc/docx
Word documents
application/msword (doc) application/vnd.openxmlformats-officedocument.wordprocessingml.document (docx)
ods
OpenDocument spreadsheets
application/vnd.oasis.opendocument.spreadsheet
jpg/png
Image files
image/jpeg (jpg) image/png (png)
Sample Code
<?php
include 'vendor/autoload.php';
$amazonpay_config = array(
'public_key_id' => 'YOUR_PUBLIC_KEY_ID',
'private_key' => 'keys/private.pem', // Path to RSA Private Key (or a string representation)
'region' => 'YOUR_REGION_CODE',
'algorithm' => 'AMZN-PAY-RSASSA-PSS-V2'
);
$payload = array(
'type' => 'jpg',
'purpose' => 'disputeEvidence'
);
$headers = array('x-amz-pay-Idempotency-Key' => uniqid());
try {
$client = new Amazon\Pay\API\Client($amazonpay_config);
$result = $client->uploadFile($payload, $headers);
if ($result['status'] === 200) {
$response = json_decode($result['response'], true);
$fileId = $response['id'];
$uploadUrl = $response['url'];
} else {
// check the error
echo 'status=' . $result['status'] . '; response=' . $result['response'];
}
} catch (Exception $e) {
// handle the exception
echo $e;
}
?>
using Amazon.Pay.API.Types;
using Amazon.Pay.API.WebStore;
using Amazon.Pay.API.WebStore.File;
using Amazon.Pay.API.WebStore.Types;
using System;
using System.Collections.Generic;
public class Sample
{
public WebStoreClient InitiateClient()
{
// set up config
var payConfiguration = new ApiConfiguration
(
region: Region.YOUR_REGION_CODE,
publicKeyId: "YOUR_PUBLIC_KEY_ID",
privateKey: "PATH_OR_CONTENT_OF_YOUR_PRIVATE_KEY",
algorithm: AmazonSignatureAlgorithm.V2
);
// init API client
var client = new WebStoreClient(payConfiguration);
return client;
}
public void UploadFile()
{
// prepare the request
var request = new UploadFileRequest(type: "jpg", purpose: "disputeEvidence");
// init Headers
var myHeaderKey = "x-amz-pay-idempotency-key";
var myHeaderValue = Guid.NewGuid().ToString();
var headers = new Dictionary<string, string> { { myHeaderKey, myHeaderValue } };
// send the request
FileResponse result = client.UploadFile(request, headers);
// check if API call was successful
if (!result.Success)
{
// handle the API error (use Status field to get the numeric error code)
} else {
// do something with the result, for instance:
string fileId = result.Id;
string uploadUrl = result.URL;
DateTime urlExpiryTimestamp = result.UrlExpirationTimestamp;
}
}
}
import com.amazon.pay.api.AmazonPayResponse;
import com.amazon.pay.api.PayConfiguration;
import com.amazon.pay.api.WebstoreClient;
import com.amazon.pay.api.exceptions.AmazonPayClientException;
import com.amazon.pay.api.types.DisputeFilePurpose;
import com.amazon.pay.api.types.EvidenceDocumentFileType;
import com.amazon.pay.api.types.Region;
import org.json.JSONObject;
// for generating an idempotency key
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
public void sample() {
PayConfiguration payConfiguration = null;
try {
payConfiguration = new PayConfiguration()
.setPublicKeyId("YOUR_PUBLIC_KEY_ID")
.setRegion(Region.YOUR_REGION_CODE)
.setPrivateKey("YOUR_PRIVATE_KEY".toCharArray())
.setAlgorithm("AMZN-PAY-RSASSA-PSS-V2");
WebstoreClient webstoreClient = new WebstoreClient(payConfiguration);
JSONObject payload = new JSONObject();
payload.put("type", EvidenceDocumentFileType.JPG.getEvidenceDocumentFileType());
payload.put("purpose", DisputeFilePurpose.DISPUTE_EVIDENCE.getDisputeFilePurpose());
Map<String, String> header = new HashMap<String, String>();
header.put("x-amz-pay-idempotency-key", UUID.randomUUID().toString().replace("-", ""));
AmazonPayResponse response = webstoreClient.uploadFile(payload, header);
} catch (AmazonPayClientException e) {
e.printStackTrace();
}
}
const fs = require('fs');
const Client = require('@amazonpay/amazon-pay-api-sdk-nodejs');
const uuidv4 = require('uuid/v4');
const config = {
publicKeyId: 'YOUR_PUBLIC_KEY_ID',
privateKey: fs.readFileSync('tst/private.pem'),
region: 'YOUR_REGION_CODE',
algorithm: 'AMZN-PAY-RSASSA-PSS-V2'
};
const payload = {
type: "jpg",
purpose: "disputeEvidence"
};
const headers = {
'x-amz-pay-idempotency-key': uuidv4().toString().replace(/-/g, '')
};
const testPayClient = new Client.WebStoreClient(config);
const response = testPayClient.uploadFile(payload, headers);
response.then(function (result) {
console.log(result.data);
}).catch(err => {
console.log(err);
});
require 'amazon-pay-api-sdk-ruby'
require 'securerandom'
config = {
region: 'YOUR_REGION_CODE', # Supported values: na, eu, jp
public_key_id: 'YOUR_PUBLIC_KEY_ID',
private_key: File.read('privateKey.pem')
}
client = AmazonPayClient.new(config)
payload = {
"type": "jpg",
"purpose": "disputeEvidence"
}
headers = {
"x-amz-pay-Idempotency-Key": SecureRandom.uuid
}
response = client.upload_file(payload, headers: headers)
if response.code.to_i == 200
puts response.body
else
# check the error
puts "status=#{response.code}"
puts response.body
end
<?php
include 'vendor/autoload.php';
$amazonpay_config = array(
'public_key_id' => 'YOUR_PUBLIC_KEY_ID',
'private_key' => 'keys/private.pem', // Path to RSA Private Key (or a string representation)
'region' => 'YOUR_REGION_CODE',
'sandbox' => true,
'algorithm' => 'AMZN-PAY-RSASSA-PSS-V2'
);
$payload = array(
'type' => 'jpg',
'purpose' => 'disputeEvidence'
);
$headers = array('x-amz-pay-Idempotency-Key' => uniqid());
try {
$client = new Amazon\Pay\API\Client($amazonpay_config);
$result = $client->uploadFile($payload, $headers);
if ($result['status'] === 200) {
$response = json_decode($result['response'], true);
$fileId = $response['id'];
$uploadUrl = $response['url'];
} else {
// check the error
echo 'status=' . $result['status'] . '; response=' . $result['response'];
}
} catch (Exception $e) {
// handle the exception
echo $e;
}
?>
using Amazon.Pay.API.Types;
using Amazon.Pay.API.WebStore;
using Amazon.Pay.API.WebStore.File;
using Amazon.Pay.API.WebStore.Types;
using System;
using System.Collections.Generic;
public class Sample
{
public WebStoreClient InitiateClient()
{
// set up config
var payConfiguration = new ApiConfiguration
(
region: Region.YOUR_REGION_CODE,
environment: Environment.Sandbox,
publicKeyId: "YOUR_PUBLIC_KEY_ID",
privateKey: "PATH_OR_CONTENT_OF_YOUR_PRIVATE_KEY",
algorithm: AmazonSignatureAlgorithm.V2
);
// init API client
var client = new WebStoreClient(payConfiguration);
return client;
}
public void UploadFile()
{
// prepare the request
var request = new UploadFileRequest(type: "jpg", purpose: "disputeEvidence");
// init Headers
var myHeaderKey = "x-amz-pay-idempotency-key";
var myHeaderValue = Guid.NewGuid().ToString();
var headers = new Dictionary<string, string> { { myHeaderKey, myHeaderValue } };
// send the request
FileResponse result = client.UploadFile(request, headers);
// check if API call was successful
if (!result.Success)
{
// handle the API error (use Status field to get the numeric error code)
} else {
// do something with the result, for instance:
string fileId = result.Id;
string uploadUrl = result.URL;
DateTime urlExpiryTimestamp = result.UrlExpirationTimestamp;
}
}
}
import com.amazon.pay.api.AmazonPayResponse;
import com.amazon.pay.api.PayConfiguration;
import com.amazon.pay.api.WebstoreClient;
import com.amazon.pay.api.exceptions.AmazonPayClientException;
import com.amazon.pay.api.types.DisputeFilePurpose;
import com.amazon.pay.api.types.Environment;
import com.amazon.pay.api.types.EvidenceDocumentFileType;
import com.amazon.pay.api.types.Region;
import org.json.JSONObject;
// for generating an idempotency key
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
public void sample() {
PayConfiguration payConfiguration = null;
try {
payConfiguration = new PayConfiguration()
.setPublicKeyId("YOUR_PUBLIC_KEY_ID")
.setRegion(Region.YOUR_REGION_CODE)
.setPrivateKey("YOUR_PRIVATE_KEY".toCharArray())
.setEnvironment(Environment.SANDBOX)
.setAlgorithm("AMZN-PAY-RSASSA-PSS-V2");
WebstoreClient webstoreClient = new WebstoreClient(payConfiguration);
JSONObject payload = new JSONObject();
payload.put("type", EvidenceDocumentFileType.JPG.getEvidenceDocumentFileType());
payload.put("purpose", DisputeFilePurpose.DISPUTE_EVIDENCE.getDisputeFilePurpose());
Map<String, String> header = new HashMap<String, String>();
header.put("x-amz-pay-idempotency-key", UUID.randomUUID().toString().replace("-", ""));
AmazonPayResponse response = webstoreClient.uploadFile(payload, header);
} catch (AmazonPayClientException e) {
e.printStackTrace();
}
}
const fs = require('fs');
const Client = require('@amazonpay/amazon-pay-api-sdk-nodejs');
const uuidv4 = require('uuid/v4');
const config = {
publicKeyId: 'YOUR_PUBLIC_KEY_ID',
privateKey: fs.readFileSync('tst/private.pem'),
region: 'YOUR_REGION_CODE',
sandbox: true,
algorithm: 'AMZN-PAY-RSASSA-PSS-V2'
};
const payload = {
type: "jpg",
purpose: "disputeEvidence"
};
const headers = {
'x-amz-pay-idempotency-key': uuidv4().toString().replace(/-/g, '')
};
const testPayClient = new Client.WebStoreClient(config);
const response = testPayClient.uploadFile(payload, headers);
response.then(function (result) {
console.log(result.data);
}).catch(err => {
console.log(err);
});
require 'amazon-pay-api-sdk-ruby'
require 'securerandom'
config = {
region: 'YOUR_REGION_CODE', # Supported values: na, eu, jp
public_key_id: 'YOUR_PUBLIC_KEY_ID',
private_key: File.read('privateKey.pem'),
sandbox: true
}
client = AmazonPayClient.new(config)
payload = {
"type": "jpg",
"purpose": "disputeEvidence"
}
headers = {
"x-amz-pay-Idempotency-Key": SecureRandom.uuid
}
response = client.upload_file(payload, headers: headers)
if response.code.to_i == 200
puts response.body
else
# check the error
puts "status=#{response.code}"
puts response.body
end
Response
The API returns:
{
"id": "file_sdcjscbjckndjhckj",
"type" : "jpg",
"purpose": "disputeEvidence",
"uploadTimestamp": "20190714T155300Z",
"url": "https://pay-api.amazon.com/v1/files/file_sdcjscbjckndjhckj/contents",
"urlExpirationTimeStamp": "20190714T155300Z"
}
Step 2: Upload your file
Send your file to the returned URL:
curl "YOUR_PRESIGNED_URL" \
-X PUT \
-H "Content-Type: application/pdf" \
-T "/path/to/file"
File Requirements:
Maximum size: 2MB
Files must be relevant dispute evidence
After uploading, use the returned fileId when submitting dispute evidence.