[Step 7 of 9] There is no time limit to initiate a refund. You can either issue refunds using Create Refund, or you can manually issue refunds through Seller Central, the account management site for Amazon Pay merchants. Amazon Pay will notify the buyer after a refund has been successfully processed. See buyer communication for more info.
In this step, you will add the ability to issue refunds via API. At the end of this step, you will be able to issue full or partial refunds and check on refund status.
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.
Create Refund to issue a full or partial refund for a successful Charge. You may (at your discretion) also choose to overcompensate the buyer, and refund more than the original Charge amount by either 15% or 75 USD/GBP/EUR or 8,400 YEN (whichever is less).
using Amazon.Pay.API.Types;
using Amazon.Pay.API.WebStore.Refund;
using Amazon.Pay.API.WebStore;
using Amazon.Pay.API.WebStore.Types;
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);
}
public void CreateRefund(string chargeId)
{
// prepare the request
var request = new CreateRefundRequest(chargeId, 14.00M, Currency.USD);
// send the request
RefundResponse result = client.CreateRefund(request);
// check if API call was successful
if (!result.Success)
{
// do something, e.g. throw an error
}
}
}
using Amazon.Pay.API.Types;
using Amazon.Pay.API.WebStore.Refund;
using Amazon.Pay.API.WebStore;
using Amazon.Pay.API.WebStore.Types;
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);
}
public void CreateRefund(string chargeId)
{
// prepare the request
var request = new CreateRefundRequest(chargeId, 14.00M, Currency.USD);
// send the request
RefundResponse result = client.CreateRefund(request);
// check if API call was successful
if (!result.Success)
{
// do something, e.g. throw an error
}
}
}
Get Refund to check Refund status. Amazon Pay processes refunds asynchronously. Either set up Instant Payment Notifications (IPNs), or implement a polling mechanism to query the Get Refund API for updates. See asynchronous processing for more info.
Refund state explanation
Refund status
Description
RefundInitiated
Refund is still pending processing
Refunded
Refund was successful
Declined
Refund was declined. Check the reason code for more information:
AmazonRejected - Amazon has rejected the refund, potentially due to a negative balance in your merchant account. To resolve this, you should repay the negative seller balance (NSB) to Amazon, then attempt the refund again or issue a refund to the buyer in an alternate manner (for example, a gift card or store credit).
ProcessingFailure - Amazon could not process the transaction because of an internal processing error, or because the buyer has already received a refund from an A-to-z claim, or a chargeback. You should only retry the refund if the Capture object is in the Completed state. Otherwise, you should refund the buyer in an alternative way (for example, a store credit or a check)
Request
curl "https://pay-api.amazon.com/:version/refunds/:refundId" \
-X GET
-H "authorization:Px2e5oHhQZ88vVhc0DO%2FsShHj8MDDg%3DEXAMPLESIGNATURE"
-H "x-amz-pay-date:20201012T235046Z"
curl "https://pay-api.amazon.com/:environment/:version/refunds/:refundId" \
-X GET
-H "authorization:Px2e5oHhQZ88vVhc0DO%2FsShHj8MDDg%3DEXAMPLESIGNATURE"
-H "x-amz-pay-date:20201012T235046Z"
using Amazon.Pay.API.Types;
using Amazon.Pay.API.WebStore;
using Amazon.Pay.API.WebStore.Refund;
using Amazon.Pay.API.WebStore.Types;
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);
}
public void GetRefund(string refundId)
{
// send the request
RefundResponse result = client.GetRefund(refundId);
// check if API call was successful
if (!result.Success)
{
// handle the API error (use Status field to get the numeric error code)
}
// do something with the result, for instance:
string refundState = result.StatusDetails.State;
}
}
using Amazon.Pay.API.Types;
using Amazon.Pay.API.WebStore;
using Amazon.Pay.API.WebStore.Refund;
using Amazon.Pay.API.WebStore.Types;
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);
}
public void GetRefund(string refundId)
{
// send the request
RefundResponse result = client.GetRefund(refundId);
// check if API call was successful
if (!result.Success)
{
// handle the API error (use Status field to get the numeric error code)
}
// do something with the result, for instance:
string refundState = result.StatusDetails.State;
}
}