Set up Amazon Pay
With an Amazon Pay payment connector, your agent can take payments from buyers who check out with their Amazon account. AgentCore payments acts as an Amazon Pay Solution Provider for your Amazon Pay merchant account. You grant AgentCore payments access to your account once in Amazon Pay, and then AgentCore payments calls the Amazon Pay API for you. Your web page shows the Amazon Pay button with the Amazon Pay JavaScript library. You don’t need an Amazon Pay server SDK.
In the Amazon Pay guide Add the Amazon Pay buttonInitiatePaymentIntent returns the checkout session payload already built and signed, in buttonPayload, signature, and publicKeyId. Don’t create Amazon Pay API keys or sign a payload yourself. Your checkout then wouldn’t match the payment intent. For the button code, see Complete checkout with your payment service provider.
Get your Amazon Pay merchant details
Before you begin, make sure that you have the following:
-
An Amazon Pay merchant account. If you don’t have one yet, start with Get an Amazon Pay merchant account.
-
A Payment Manager. For more information, see Create a Payment Manager and Connector.
-
A web page that shows the Amazon Pay button.
-
A return page on your site that can receive the
amazonCheckoutSessionIdquery parameter. You pass its URL toCreatePaymentIntentascheckoutDetails.returnUrl, and AgentCore payments sends it to Amazon Pay aswebCheckoutDetails.checkoutResultReturnUrl.
AgentCore payments needs three values from your merchant account. Seller Central uses different names for them on different pages. The following table maps each field to the labels in Seller Central.
| AgentCore payments field | Seller Central label | Where to find it |
|---|---|---|
|
|
Merchant ID or Seller ID, for example |
In Integration Central, choose your integration type, for example Self-developed and One-time Payments. Then choose Get instructions, and look under API access. The MWS authorization page also shows it as Seller ID. |
|
|
Store ID, Client ID, or Client ID / Store ID, for example |
Next to Merchant ID under API access, or under Manage client ID/store ID(s) in Integration Central. |
|
|
MWS Auth Token, for example |
The last page of the MWS authorization. This page calls it the MWS authorization token. For the steps, see Grant AgentCore payments access to your merchant account. |
Seller Central also shows values that AgentCore payments doesn’t use. Don’t enter them:
-
Marketplace ID, which appears next to the MWS Auth Token.
-
Client secret, which appears with the store ID under Manage client ID/store ID(s).
-
Amazon Pay API keys (a public key ID and a private key) from Create keys. AgentCore payments signs Amazon Pay requests with its own keys.
-
Client IDs from the Solution Provider Portal or the Selling Partner API. These also start with
amzn1.application-oa2-client., but they aren’t your Amazon Pay store ID. Copy the store ID only from Amazon Pay Seller Central.
To catch a swapped value, check the prefixes. The store ID starts with amzn1.application-oa2-client., and the token starts with amzn.mws..
You also choose two settings:
- Environment
-
LIVEfor real payments, orSANDBOXfor testing. The token doesn’t record which environment it belongs to, so you declare it. - Amazon Pay region
-
The Amazon Pay region of your merchant account. AgentCore payments uses it to choose the Amazon Pay API endpoint. Use
NAfor North America orEUfor Europe (including the UK).
Before you take LIVE payments, edit your store in Manage client ID/store ID(s), and add the origin of your checkout page to its JavaScript origins. For example, add https://shop.example.com. You don’t need to add origins to test in the Sandbox view. Amazon Pay reviews each domain, and the button can be inactive during the review. For more information, see Add domains to Seller Central
Get an Amazon Pay merchant account
Each Amazon Pay merchant account has a Production view and a Sandbox view in Seller Central, with the same merchant ID and store ID. To test, register a merchant account, and then use its Sandbox view.
To create an account, start at the Amazon Pay sign-up page for your region: North America
When Seller Central shows that you completed the basic setup, you can use the Sandbox view and authorize AgentCore payments. Amazon Pay can still be verifying your business at that point. Before you take LIVE payments, Amazon Pay must complete its know your customer (KYC) verification of your business. You don’t need to wait for it to test in the Sandbox view.
Grant AgentCore payments access to your merchant account
To get the MWS authorization token, authorize AgentCore payments as a developer on your merchant account. For the same steps with screenshots, see Create mwsAuthToken in Seller Central
-
In the Production view of Seller Central, open Integration Central.
-
Under MWS Authorizations, choose Authorize new developer.
-
For Developer ID, enter the AgentCore payments developer ID for the Amazon Pay region of your merchant account.
Amazon Pay region Developer ID NA1000000003070EU1000000003071 -
For Developer Name, enter
AgentCore payments. -
Choose Next.
-
On the review page, choose Next.
-
Copy the MWS Auth Token. The token starts with
amzn.mws.. The same page shows your Seller ID and a Marketplace ID. You need the Seller ID, but not the Marketplace ID.
After you authorize it, AgentCore payments appears in the MWS Authorizations list with its developer name and developer ID. Use the same token for LIVE and SANDBOX credential providers.
The MWS authorization token is bound to the AgentCore payments developer ID. Only AgentCore payments can use it to call Amazon Pay for your merchant account. Keep it confidential anyway.
Create an Amazon Pay payment credential provider
A payment credential provider stores your Amazon Pay credentials in AgentCore Identity. Set credentialProviderVendor to AmazonPay and supply an amazonPayConfiguration block with the following fields:
-
merchantId(required): your Amazon Pay merchant ID. -
storeId(required): your Amazon Pay store ID. -
environment(required):LIVEorSANDBOX. -
amazonPayRegion(required):NAorEU. -
The MWS authorization token, in one of the following ways. The two ways are mutually exclusive.
-
authorizationToken: the token value. AgentCore Identity stores it in a service-managed secret. You can omitauthorizationTokenSource, or set it toMANAGED. -
authorizationTokenConfig: a reference to a secret that you own in AWS Secrets Manager, withsecretIdandjsonKey. SetauthorizationTokenSourcetoEXTERNAL.
-
We recommend the Secrets Manager reference. The token then stays in one secret that you own, instead of a second copy in a service-managed secret. Passing the token inline suits quick setup, such as in the console.
Example
The response returns credentialProviderArn and an amazonPayConfiguration output. The output includes merchantId, storeId, environment, amazonPayRegion, and authorizationTokenArn, the ARN of the secret that holds the token. It never includes the token value.
Create an Amazon Pay payment connector
Create a connector of type AmazonPay in your Payment Manager, and reference the credential provider ARN.
Example
Wait until the connector status is READY before you create payment intents with it.
When you create the connector, AgentCore payments checks your MWS authorization token with Amazon Pay. So setup problems appear as errors from CreatePaymentConnector:
-
ValidationException, "Amazon Pay did not accept the credential provider’s authorization token." The token isn’t from authorizing the AgentCore payments developer ID for your Amazon Pay region, or the merchant ID doesn’t match it. Authorize the developer ID for your region, and create a credential provider with the new token. -
AccessDeniedException, "The payment manager’s role is not authorized to use the Amazon Pay credential provider." Add the missing permission to the Payment Manager execution role. For more information, see IAM roles for AgentCore payments. -
InternalServerException, "Failed to verify the Amazon Pay authorization token. Please retry." Retry the request. If you just created the credential provider or changed the role, wait a few minutes first, because IAM changes can take time to apply.
Next, create a payment intent.
Rotate or replace your Amazon Pay credentials
To rotate the MWS authorization token, do one of the following:
-
If you use
authorizationTokenConfig, store a new version of the secret in AWS Secrets Manager. -
If you passed the token inline, call
UpdatePaymentCredentialProviderwith the fullamazonPayConfigurationand the new token.
To connect a different Amazon Pay merchant account, create a new payment credential provider and a new connector. Don’t change merchantId or amazonPayRegion on an existing provider.
If you remove AgentCore payments from MWS Authorizations in Seller Central, Amazon Pay rejects the token. InitiatePaymentIntent can still return a button, but AuthorizePaymentIntent fails. To restore access, authorize AgentCore payments again. If Amazon Pay issues a new MWS authorization token, update the credential provider with it.
Amazon Pay considerations
-
Merchant accounts in the
NAandEUAmazon Pay regions are supported. SetamazonPayRegionto your account’s region. -
Amazon Pay charges in the ledger currency of your merchant account. AgentCore payments supports
USDandEUR. -
For
USD, use a merchant account in theNAregion. ForEUR, use a merchant account in theEUregion with its ledger currency inEUR. AnEUmerchant account with aGBPledger currency isn’t supported. -
To test, use a
SANDBOXprovider, the Sandbox view of your merchant account, and a sandbox buyer account. ALIVEprovider charges real buyers. -
AgentCore payments supports the pay-only variant of Amazon Pay checkout. Amazon Pay doesn’t collect or show a shipping address. If your order ships, collect the address in your own checkout.
-
The buyer pays with a card in their Amazon wallet. With an
NAmerchant account, the buyer can also pay with Amazon Store Card. -
For a
FUTUREpayment, you make one final capture of the full amount.