Step 10: Request a refund

You can issue full or partial refunds against previously successful Captured funds.

Note: When you have issued a refund, that amount is no longer available for authorization or capture.

After a refund is successfully processed, the Refund object is in a Completed state and a Refund notification email is sent to the buyer.

If the Refund is declined by Amazon, the Refund object is in a Declined state. For more information, see step 4, "Check the response for errors or declines" below.

There is no time limit for initiating a refund, but the longer you take to request a refund the more likely that a payment method associated with the purchase will become invalid and the refund will fail.

Note: If you infrequently run into refund scenarios, you can manually issue refunds through Seller Central in lieu of integrating the Refund API call into your workflow.

Procedure

Request a refund by doing this:

  1. Make a call to the Refund API. Set the following values in the Refund request so that they appear in the buyer's Refund notification email and account status and in your Settlement and Transaction reports.
    • Refund Reference ID
    • Refund amount
    • Seller Refund Note
    Make sure that the reference ID is unique. For more information, see Handling errors from Pay with Amazon API calls .
  2. Listen for the Refund IPN message returned by Amazon. Refund requests are not processed in real time and the initial RefundStatus is always Pending. Processing time varies and can be several hours. Amazon will notify you of the processing status via an IPN message.
  3. Get Refund Details. You can query the details of a Refund object by calling the GetRefundDetails API using the AmazonRefundId that was returned with the Refund IPN message.
  4. Check the response for errors or declines. You need to handle any errors that might occur from the API call, and you need to manage any refunds that are in a Declined state. If a Refund is declined, you will see one of the following reason codes in the response:

    AmazonRejected
    Amazon has rejected the refund. You should 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 one of the following:
    • Amazon could not process the transaction because of an internal error.
    • A refund has already been issued from an A-to-z Guarantee claim or from a chargeback.
    If you receive a ProcessingFailure reason code, check the A-to-z Guarantee claim and chargeback status for your order in Seller Central by clicking Performance. If no A-to-z claim or chargeback refund has been issued to the buyer and the Capture object is still in the Completed state, retry your request in one to two minutes. If the retry attempt does not succeed, contact the buyer and issue the refund in another way.

    For more information, see Handling errors from Amazon Pay API calls.

from pay_with_amazon.client import PayWithAmazonClient

client = PayWithAmazonClient(
  mws_access_key='YOUR_ACCESS_KEY',
  mws_secret_key='YOUR_SECRET_KEY',
  merchant_id='YOUR_MERCHANT_ID',
  region='na',
  currency_code='USD')

response = client.refund(
  amazon_capture_id='AMAZON_CAPTURE_ID',
  refund_reference_id='REFUND_REFERENCE_ID',
  refund_amount='1.00',
  seller_refund_note='Test order.')


require 'pay_with_amazon'

merchant_id = 'YOUR_MERCHANT_ID'
access_key = 'YOUR_ACCESS_KEY'
secret_key = 'YOUR_SECRET_KEY'

client = PayWithAmazon::Client.new(
  merchant_id,
  access_key,
  secret_key,
  sandbox: true,
  currency_code: :usd,
  region: :na
)

amazon_capture_id = 'S23-1234567-1234567-0000002'
refund_reference_id = 'test_refund_1'
amount = 106

client.refund(
  amazon_capture_id,
  refund_reference_id,
  amount,
  seller_refund_note: 'Lorem ipsum dolor',
  mws_auth_token: 'amzn.mws.4ea38b7b-f563-7709-4bae-87aeaEXAMPLE'
)


https://mws.amazonservices.com/OffAmazonPayments_Sandbox/2013-01-01
?AWSAccessKeyId=AKIAFBM3LG5JEEXAMPLE
&Action=Refund
&AmazonCaptureId=S23-1234567-1234567-0000002
&RefundAmount.Amount=199.00
&RefundAmount.CurrencyCode=USD
&RefundReferenceId=test_refund_1
&SellerRefundNote=For%20your%20returned%20item%2C%20Casad%20%272Jours
%20Bonheur%27%20Satchel%20in%20Sandstorm
&SellerId=YOUR_SELLER_ID_HERE   
&SignatureMethod=HmacSHA256
&SignatureVersion=2
&Timestamp=2013-11-27T19%3A01%3A11Z
&Version=2013-01-01
&Signature=WlQ708aqyHXMkoUBk69Hjxj8qdh3aDcqpY71hVgEXAMPLE