Step 9: Mark the order reference as closed

Mark an Order Reference object that is in an Open or Suspended state as Closed to indicate that the order has been fulfilled, and you will not request any more authorizations against it. If you can only partially fulfill the order, you should still mark the Order Reference object as Closed after charging the appropriate amount.

Amazon uses a Closed Order Reference object to indicate to buyers that they have completed payment for their order. Otherwise, when buyers review their transactions on the Amazon Pay website, these order references are shown as Open for 180 days. After 180 days, Amazon changes the status of the Order Reference object to Closed with a reason code of Expired.

When the Order Reference object is marked as Closed:

  • You can still capture funds against open authorizations on the order reference.
  • You cannot create any new authorizations on the Order Reference object.
  • You can still execute refunds against the Order Reference object.

Procedure

Make a call to the CloseOrderReference API.


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.close_order_reference(
  amazon_order_reference_id=order_id,
  closure_reason='My closure reason.')


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_order_reference_id = 'AMAZON_ORDER_REFERENCE_ID'

client.close_order_reference(
  amazon_order_reference_id,
  mws_auth_token: 'amzn.mws.4ea38b7b-f563-7709-4bae-87aeaEXAMPLE'
)

See also