Ti ringraziamo per la visita. Questa pagina è per il momento disponibile solo in inglese.
 Testing your integration in the Sandbox environment | Amazon Pay

Testing your integration in the Sandbox environment

The Amazon Pay and Login with Amazon Sandbox environment enables you to thoroughly test your Amazon Pay and Login with Amazon integration before going live with the Amazon Pay payment option. You can enable Sandbox mode by changing the widgets.js URL in the header of each web page where you have added an Amazon Pay button to this:

https://static-na.payments-amazon.com/OffAmazonPayments/us/sandbox/js/Widgets.js

For the full set of endpoints, see Taking your integration live.

When you test your implementation in Sandbox mode, you can simulate the buyer experience as buyers navigate through the Amazon Pay widgets on your website.

You can also test your API operation calls to Amazon to ensure that the calls are configured correctly and that the responses include all the payment parameters that you need to for tracking the entire order. The Sandbox environment even lets you simulate various error conditions to help you better manage your buyers' experiences in the event that something goes wrong during the checkout experience.

You can also test your API operation calls to Amazon to ensure that the calls are configured correctly and that the responses include all the payment parameters that you need for tracking the entire order. The Sandbox environment even lets you simulate various error conditions to help you better manage your buyers' experiences in the event that something goes wrong during the checkout experience.

For example, you can test the decline flow and validate the different declines using several test credit card numbers that are provided in Sample addresses and payment instruments.

Differences between the Sandbox and Production environments


Button in Sandbox mode

Button in Production mode

The various objects used in Amazon Pay and Login with Amazon are all managed through a set of business rules, like the amount of time until an object expires after being created. To help facilitate testing in the Amazon Pay and Login with Amazon Sandbox, the following business rule has been adjusted:

Object Production business rule Sandbox business rule
An Authorization object in the Open state Moves to the Closed state in 30 days Moves to the Closed state in two days

Adding test buyer accounts

When you first access the Sandbox environment through Seller Central, Amazon recommends configuring some test buyer accounts to help with your integration testing. These test accounts can be modified to suit most use cases, including the addition of shipping addresses that might violate a business rule your company has about where items can be shipped. You can configure these accounts in Seller Central by clicking Integration and choosing Test Accounts.

With the customization available through Seller Central, Amazon encourages you to test as many scenarios as you see fit through multiple test buyer accounts.

Shipping addresses and payment instruments

Sample shipping addresses and payment instruments have been added in the Sandbox environment to enable the development and debugging of the AddressBook and Wallet widgets.

When you create a test buyer account, the account is preloaded with test payment instruments and a set of shipping addresses. You can edit the test buyer account properties, except for the payment instruments, to simulate various purchase scenarios. The shipping address and payment instrument are rendered in the AddressBook and Wallet widgets accordingly.

You can simulate declined authorizations by using one of these preconfigured cards in the Sandbox environment. You can't simulate the ProcessingFailure error.

Billing address

A single default billing address has been added to the Sandbox environment to enable testing of addresses for your locale. The sample billing address cannot be changed.

Sandbox simulations of constraints

You can simulate the PaymentMethodNotAllowed constraint in the Sandbox environment to test your code and ensure that you handle this constraint properly.

Here is how to simulate the PaymentMethodNotAllowed constraint response to the SetOrderReferenceDetails operation in Sandbox:

  1. Set the SellerNote field of OrderReferenceAttributes with this simulation string: {"SandboxSimulation": {"Constraint":"PaymentMethodNotAllowed"}}
  2. Choose the direct debit method from the sandbox Wallet widget.

In Sandbox, switching to and from direct debit enables or disables this constraint as long as the applicable simulation string is set. This is helpful for simulating real world scenarios in the Production environment where the constraint might appear or disappear depending upon the payment method chosen by the buyer. To reduce the likelihood of this constraint triggering in Production, we recommend you set the OrderTotal before you render the Wallet widget.

Here is a fully encoded example:


https://mws-eu.amazonservices.com/OffAmazonPayments_Sandbox/2013-01-01
?AWSAccessKeyId=0GS7553JW74RRM612K02EXAMPLE
&Action=SetOrderReferenceDetails
&AmazonOrderReferenceId=S23-1234567-1234567
&OrderReferenceAttributes.OrderTotal.Amount=106
&OrderReferenceAttributes.OrderTotal.CurrencyCode=GBP
&OrderReferenceAttributes.SellerNote=%7B%22SandboxSimulation%22%3A%7B
%22Constraint%22%3A%22PaymentMethodNotAllowed%22%7D%7D
&OrderReferenceAttributes.SellerOrderAttributes.SellerOrderId=5678-23
&SellerId=YOUR_SELLER_ID_HERE
&SignatureMethod=HmacSHA256
&SignatureVersion=2
&Timestamp=2013-11-16T19%3A01%3A11Z
&Version=2013-01-01
&Signature=2RPzkOgQmDybUjk0dA54maCEXAMPLE}

For more information about the SetOrderReferenceDetails operation, including the request parameters and response elements, see SetOrderReferenceDetails in the Amazon Pay API reference guide.

Direct debit

Currently, direct debit is available only as a buyer payment method for those sellers registered with Amazon Pay in Germany.

Testing responses and state transitions

The following tables outline how certain responses and state transitions can be simulated. For more information about the states and reason codes, see the Introduction section of the Amazon Pay API reference guide.

Note: For states and reason codes that can be used with a simulation string, you must specify the desired State and ReasonCode in a call to an Amazon Pay API section operation. Invalid combinations result in an InvalidSandboxSimulationSpecified error.

To simulate various object states and reason codes:

Billing Agreement object

State: Draft
Reason code Simulation string To simulate in Sandbox
  N/A Click the Amazon Pay Sandbox button and sign in using your test buyer account credentials. This creates a Billing Agreement object in the Draft state.
State: Open
Reason code Simulation string To simulate in Sandbox
  N/A Confirm a Draft Billing Agreement object by calling the ConfirmBillingAgreement operation.
State: Suspended
Reason code Simulation string To simulate in Sandbox
InvalidPaymentMethod N/A The Billing Agreement object moves to the Suspended state after you simulate the Authorization object moving to the Declined state with reason code InvalidPaymentMethod.
State: Cancelled
Reason code Simulation string To simulate in Sandbox
Stale N/A Do not confirm a Draft Billing Agreement object within three hours of its creation. The Billing Agreement object then moves to the Stale state.
AmazonCanceled N/A Cannot be simulated.
State: Closed
Reason code Simulation string To simulate in Sandbox
AmazonClosed {"SandboxSimulation":{"State":"Closed","ReasonCode":"AmazonClosed"}} Specify this value in the ClosureReason request parameter of the CloseBillingAgreement operation for an Open BillingAgreement object.
SellerClosed N/A Close an Open Billing Agreement object by calling the CloseBillingAgreement operation without specifying the simulation string for the AmazonClosed reason code.

Authorization object

State: Pending
Reason code Simulation string To simulate in Sandbox
  N/A Request an authorization by calling the AuthorizeOnBillingAgreement operation in asynchronous mode. All Authorization objects are in the Pending state for 30 seconds after you submit the AuthorizeOnBillingAgreement request. This cannot be simulated in synchronous mode.
State: Open
Reason code Simulation string To simulate in Sandbox
  N/A Request an authorization by calling the AuthorizeOnBillingAgreement operation. In asynchronous mode, the Authorization object moves to the Open state after remaining in the Pending state for 30 seconds. In synchronous mode, the Authorize object immediately moves to the Open state.
State: Declined
Reason code Simulation string To simulate in Sandbox
InvalidPaymentMethod {"SandboxSimulation":{"State":"Declined", "ReasonCode":"InvalidPaymentMethod", "PaymentMethodUpdateTimeInMins":5}} {"SandboxSimulation": {"State":"Declined", "ReasonCode":"InvalidPaymentMethod", "PaymentMethodUpdateTimeInMins":5, "SoftDecline":"true"}} Specify this value in the SellerAuthorizationNote request parameter of the AuthorizeOnBillingAgreement operation. The order reference then moves from the Open state to the Suspended state. You can use the PaymentMethodUpdateTimeInMins parameter to specify the time (between 1 and 240 minutes), after which the Billing Agreement object should move from the Suspended state back to the Open state. This simulates the buyer updating an invalid payment method and the Billing Agreement object moving back to the Open state.

To simulate the soft decline retry behavior, use "SoftDecline":"True" in the simulation string. You can call the ConfirmBillingAgreement operation on the Suspended Billing Agreement object to move it to the Open state. This simulates the merchant confirming on the Suspended Billing Agreement object and moving it back to the Open state to retry the AuthorizeOnBillingAgreement operation.
AmazonRejected {"SandboxSimulation": {"State": "Declined", "ReasonCode": "AmazonRejected"}} Specify this value in the SellerAuthorizationNote request parameter of the AuthorizeOnBillingAgreement operation.
ProcessingFailure N/A Cannot be simulated.
TransactionTimedOut {"SandboxSimulation": {"State":"Declined", "ReasonCode":"TransactionTimedOut"}} Specify this value in the SellerAuthorizationNote request parameter of the AuthorizeOnBillingAgreement operation.
State: Closed
Reason code Simulation string To simulate in Sandbox
ExpiredUnused {"SandboxSimulation": {"State":"Closed", "ReasonCode":"ExpiredUnused", "ExpirationTimeInMins":1}} Specify this value in the SellerAuthorizationNote request parameter of the AuthorizeOnBillingAgreement operation. You can use the ExpirationTimeInMins parameter to specify the time after which the Authorization object should be closed (between 1 and 60 minutes).
MaxCapturesProcessed N/A Capture an Open Authorization object by calling the Capture operation.
AmazonClosed {"SandboxSimulation": {"State":"Closed", "ReasonCode":"AmazonClosed"}} Specify this value in the SellerAuthorizationNote request parameter of the AuthorizeOnBillingAgreement operation. Note: This simulation string is invalid with CaptureNow = true in AuthorizeOnBillingAgreement operation.
SellerClosed N/A Close an Open Authorization object by calling the CloseAuthorization operation.

Capture object

State: Pending
Reason code Simulation string To simulate in Sandbox
  {"SandboxSimulation": {"State":"Pending"}} Specify this value in the SellerCaptureNote request parameter of the Capture operation. The Capture object then remains in the Pending state for 30 seconds.
State: Declined
Reason code Simulation string To simulate in Sandbox
AmazonRejected {"SandboxSimulation": {"State":"Declined", "ReasonCode":"AmazonRejected"}} Specify this value in the SellerCaptureNote request parameter of the Capture operation.
ProcessingFailure N/A Cannot be simulated.
State: Completed
Reason code Simulation string To simulate in Sandbox
  N/A Capture funds against an Open Authorization object by calling the Capture operation.
State: Closed
Reason code Simulation string To simulate in Sandbox
MaxAmountRefunded N/A Refund 15% or £75 whichever is less) above the captured amount by calling the Refund operation.
MaxRefundsProcessed N/A Issue 10 refunds by calling the Refund operation against the corresponding Completed Capture object.
AmazonClosed {"SandboxSimulation": {"State":"Closed", "ReasonCode":"AmazonClosed"}} Specify this value in the SellerCaptureNote request parameter of the Capture operation.

Refund object

State: Pending
Reason code Simulation string To simulate in Sandbox
  N/A Request a Refund by calling the Refund operation. All Refund objects will be in the Pending state for 30 seconds after you submit the Refund
State: Declined
Reason code Simulation string To simulate in Sandbox
AmazonRejected {"SandboxSimulation": {"State":"Declined", "ReasonCode":"AmazonRejected"}} Specify this value in the SellerRefundNote request parameter of the Refund operation.
ProcessingFailure N/A Cannot be simulated.
State: Completed
Reason code Simulation string To simulate in Sandbox
  N/A Refund funds against a Completed Capture object by calling the Refund operation.

To simulate various ValidationResult and reason codes for the ValidateBillingAgreement operation:

ValidateBillingAgreement operation

Validation result: Success
Reason code Simulation string To simulate in Sandbox
  N/A Submit a ValidateBillingAgreement request in Sandbox for an Open Billing Agreement.
Validation result: Failure
Reason code Simulation string To simulate in Sandbox
InvalidPaymentMethod {"SandboxSimulation": {"Operation":"ValidateBillingAgreement", "ReasonCode":"InvalidPaymentMethod", "State":"Declined"}} Specify this value in the SellerNote request parameter of the SetBillingAgreeementDetails operation. After you submit the ValidateBillingAgreeement request, the Billing Agreement moves from the Open state to the Suspended state. You can use the PaymentMethodUpdateTimeInMins parameter to specify the time (between 1 and 240 minutes), after which the Billing Agreement object moves from the Suspended state back to the Open state. This simulates the buyer updating an invalid payment method and the Billing Agreement object moving back to the Open state.
ValidationTimedOut {"SandboxSimulation": {"Operation":"ValidateBillingAgreement", "ReasonCode":"ValidationTimedOut", "State":"Declined"}} Specify this value in the SellerNote request parameter of the SetBillingAgreementDetails operation.

The following example demonstrates how you can simulate the Authorization Declined state with reason code InvalidPaymentMethod by using the SellerAuthorizationNote request parameter:

 
https://mws-eu.amazonservices.com/OffAmazonPayments_Sandbox/2013-01-01
?AWSAccessKeyId=AKIAFBM3LG5JEEXAMPLE
&Action=AuthorizeOnBillingAgreement
&AmazonBillingAgreementId=C12-1234567-1234567
&AuthorizationAmount.Amount=10
&AuthorizationAmount.CurrencyCode=GBP
&AuthorizationReferenceId=test_authorize_1
&MWSAuthToken=amzn.mws.4ea38b7b-f563-7709-4bae-87aeaEXAMPLE
&SellerId=YOUR_SELLER_ID_HERE
&SellerAuthorizationNote=
    %7B%22SandboxSimulation%22%3A%7B%22State%22%3A%22Declined%22%2C
    %22ReasonCode%22%3A%22InvalidPaymentMethod%22%7D%7D
&SellerOrderAttributes.SellerOrderId=testSellerOrderId
&SellerOrderAttributes.StoreName=testStore
&SellerOrderAttributes.CustomInformation=ExampleInformation
&InheritShippingAddress=true
&SignatureMethod=HmacSHA256
&SignatureVersion=2
&Timestamp=2012-10-03T19%3A01%3A11Z
&TransactionTimeout=60
&Version=2013-01-01
&Signature=WlQ708aqyHXMkoUBk69Hjxj8qdh3aDcqpY71hVgEXAMPLE
    

See also

Taking your integration live