View a markdown version of this page

Set up Amazon Pay - Amazon Bedrock AgentCore

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 button, you do only step 1 (add the Amazon Pay script) and step 4 (render the button). AgentCore payments does steps 2 and 3 for you. InitiatePaymentIntent 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 amazonCheckoutSessionId query parameter. You pass its URL to CreatePaymentIntent as checkoutDetails.returnUrl, and AgentCore payments sends it to Amazon Pay as webCheckoutDetails.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

merchantId

Merchant ID or Seller ID, for example A1EXAMPLE2EXAMPLE

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.

storeId

Store ID, Client ID, or Client ID / Store ID, for example amzn1.application-oa2-client.EXAMPLE

Next to Merchant ID under API access, or under Manage client ID/store ID(s) in Integration Central.

authorizationToken

MWS Auth Token, for example amzn.mws.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

LIVE for real payments, or SANDBOX for 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 NA for North America or EU for 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 in the Amazon Pay documentation.

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 or Europe. Then complete the registration in Seller Central. Use an email address that isn’t used for any other Amazon account. You can’t use an existing Selling on Amazon account. For more information, see Start the registration process in the Amazon Pay help. In the United States, the registration has these sections: Basic details, Advanced details, Business representative, and Connect your store. Check the business place of establishment, business type, and legal business name before you confirm them, because you can’t change them later. Under Connect your store, keep Enter details now selected, and enter your store details. This step creates the store ID that AgentCore payments needs. If a page asks you to choose an Amazon store to sell in, you left the Amazon Pay registration. Restart from the Amazon Pay sign-up page. For more information, see Get set up for integration in the Amazon Pay documentation.

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 Amazon Pay documentation. You do this once, in the Production view, even if you only plan to test in the Sandbox view. The authorization applies to the whole merchant account, and the MWS Authorizations section appears only in the Production view. Authorizing doesn’t start live payments. You choose the environment later, in the credential provider.

  1. In the Production view of Seller Central, open Integration Central.

  2. Under MWS Authorizations, choose Authorize new developer.

  3. For Developer ID, enter the AgentCore payments developer ID for the Amazon Pay region of your merchant account.

    Amazon Pay region Developer ID

    NA

    1000000003070

    EU

    1000000003071

  4. For Developer Name, enter AgentCore payments.

  5. Choose Next.

  6. On the review page, choose Next.

  7. 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.

Note

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): LIVE or SANDBOX.

  • amazonPayRegion (required): NA or EU.

  • 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 omit authorizationTokenSource, or set it to MANAGED.

    • authorizationTokenConfig: a reference to a secret that you own in AWS Secrets Manager, with secretId and jsonKey. Set authorizationTokenSource to EXTERNAL.

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
AWS CLI

The following example passes the token inline:

aws bedrock-agentcore-control create-payment-credential-provider \ --name "amazon-pay-provider" \ --credential-provider-vendor AmazonPay \ --provider-configuration-input '{ "amazonPayConfiguration": { "merchantId": "A1EXAMPLE2EXAMPLE", "storeId": "amzn1.application-oa2-client.EXAMPLE", "environment": "SANDBOX", "amazonPayRegion": "NA", "authorizationToken": "amzn.mws.EXAMPLE-TOKEN" } }' \ --region us-east-1

The following example references a token that you stored in AWS Secrets Manager:

aws bedrock-agentcore-control create-payment-credential-provider \ --name "amazon-pay-provider" \ --credential-provider-vendor AmazonPay \ --provider-configuration-input '{ "amazonPayConfiguration": { "merchantId": "A1EXAMPLE2EXAMPLE", "storeId": "amzn1.application-oa2-client.EXAMPLE", "environment": "SANDBOX", "amazonPayRegion": "NA", "authorizationTokenSource": "EXTERNAL", "authorizationTokenConfig": { "secretId": "arn:aws:secretsmanager:us-east-1:123456789012:secret:amazon-pay-token", "jsonKey": "authorizationToken" } } }' \ --region us-east-1
AWS SDK
import boto3 client = boto3.client("bedrock-agentcore-control", region_name="us-east-1") provider = client.create_payment_credential_provider( name="amazon-pay-provider", credentialProviderVendor="AmazonPay", providerConfigurationInput={ "amazonPayConfiguration": { "merchantId": "A1EXAMPLE2EXAMPLE", "storeId": "amzn1.application-oa2-client.EXAMPLE", "environment": "SANDBOX", "amazonPayRegion": "NA", "authorizationTokenSource": "EXTERNAL", "authorizationTokenConfig": { "secretId": "arn:aws:secretsmanager:us-east-1:123456789012:secret:amazon-pay-token", "jsonKey": "authorizationToken", }, } }, ) provider_arn = provider["credentialProviderArn"]

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
AWS CLI
aws bedrock-agentcore-control create-payment-connector \ --payment-manager-id <paymentManagerId> \ --name "AmazonPayConnector" \ --type AmazonPay \ --credential-provider-configurations '[{ "amazonPay": { "credentialProviderArn": "arn:aws:bedrock-agentcore:us-east-1:123456789012:token-vault/default/paymentcredentialprovider/amazon-pay-provider" } }]' \ --region us-east-1
AWS SDK
connector = client.create_payment_connector( paymentManagerId="<paymentManagerId>", name="AmazonPayConnector", type="AmazonPay", credentialProviderConfigurations=[ {"amazonPay": {"credentialProviderArn": provider_arn}} ], ) connector_id = connector["paymentConnectorId"]

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 UpdatePaymentCredentialProvider with the full amazonPayConfiguration and 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 NA and EU Amazon Pay regions are supported. Set amazonPayRegion to your account’s region.

  • Amazon Pay charges in the ledger currency of your merchant account. AgentCore payments supports USD and EUR.

  • For USD, use a merchant account in the NA region. For EUR, use a merchant account in the EU region with its ledger currency in EUR. An EU merchant account with a GBP ledger currency isn’t supported.

  • To test, use a SANDBOX provider, the Sandbox view of your merchant account, and a sandbox buyer account. A LIVE provider 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 NA merchant account, the buyer can also pay with Amazon Store Card.

  • For a FUTURE payment, you make one final capture of the full amount.