

# Set up Stripe

With a Stripe payment connector, your agent can accept the payment methods that you turn on in your Stripe Dashboard, including card payments, through your own Stripe account. AgentCore payments calls Stripe with a restricted API key that you create in the Stripe Dashboard. For `INSTANT` and `FUTURE` payments, the buyer confirms the payment in the [Stripe Payment Element](https://docs.stripe.com/payments/payment-element) on your own checkout page. For `SETUP`, the buyer saves a payment method on a Stripe-hosted Checkout page.

## Get your Stripe keys
<a name="payments-stripe-prerequisites"></a>

Before you begin, make sure that you have the following:
+ A Stripe account. To test, use test mode.
+ A Payment Manager. For more information, see [Create a Payment Manager and Connector](payments-create-manager.md).
+ A web page that shows the Stripe Payment Element.

Collect the following values from your Stripe account:

 **Restricted key**   
A restricted API key that starts with `rk_live_` or `rk_test_`. The key prefix sets live or test mode. When you create the key in the Stripe Dashboard, set the following permissions on these Stripe resources:  
+  **Write**: Customers, PaymentIntents, SetupIntents, and Checkout Sessions.
+  **Read**: Charges and PaymentMethods.
+  **Write** on PaymentMethods, only if you cancel `SETUP` payment intents after the buyer saves a payment method.

  These are Stripe resources, not AgentCore payments resources. AgentCore payments rejects a secret key (`sk_`) or a publishable key (`pk_`). For more information, see [Restricted API keys](https://docs.stripe.com/keys/restricted-api-keys) in the Stripe documentation.

 **Publishable key** (optional)  
The key that your web page uses for the Payment Element, starting with `pk_live_` or `pk_test_`. Its mode must match the restricted key: `pk_test_` with `rk_test_`, and `pk_live_` with `rk_live_`. If you add it, `InitiatePaymentIntent` returns it in `partnerIntentData`, and your backend can pass it to your page.

## Create a Stripe payment credential provider
<a name="payments-stripe-credential-provider"></a>

A payment credential provider stores your Stripe credentials in AgentCore Identity. Set `credentialProviderVendor` to `Stripe` and supply a `stripeConfiguration` block with the following fields:
+ The restricted key, in one of the following ways. The two ways are mutually exclusive.
  +  `restrictedKey`: the key value. AgentCore Identity stores it in a service-managed secret. You can omit `restrictedKeySource`, or set it to `MANAGED`.
  +  `restrictedKeyConfig`: a reference to a secret that you own in AWS Secrets Manager, with `secretId` and `jsonKey`. Set `restrictedKeySource` to `EXTERNAL`.
+  `publishableKey` (optional): your publishable key. Stripe publishable keys are public, so AgentCore Identity stores it as a plain attribute, not as a secret.

We recommend the Secrets Manager reference. The key then stays in one secret that you own, instead of a second copy in a service-managed secret. Passing the key inline suits quick setup, such as in the console.

**Example**  
The following example passes the key inline:  

```bash
aws bedrock-agentcore-control create-payment-credential-provider \
  --name "stripe-provider" \
  --credential-provider-vendor Stripe \
  --provider-configuration-input '{
    "stripeConfiguration": {
      "restrictedKey": "<your-restricted-key>",
      "publishableKey": "pk_test_EXAMPLE"
    }
  }' \
  --region us-east-1
```
The following example references a key that you stored in AWS Secrets Manager:  

```bash
aws bedrock-agentcore-control create-payment-credential-provider \
  --name "stripe-provider" \
  --credential-provider-vendor Stripe \
  --provider-configuration-input '{
    "stripeConfiguration": {
      "restrictedKeySource": "EXTERNAL",
      "restrictedKeyConfig": {
        "secretId": "arn:aws:secretsmanager:us-east-1:123456789012:secret:stripe-restricted-key",
        "jsonKey": "restrictedKey"
      },
      "publishableKey": "pk_test_EXAMPLE"
    }
  }' \
  --region us-east-1
```

```python
import boto3

client = boto3.client("bedrock-agentcore-control", region_name="us-east-1")

provider = client.create_payment_credential_provider(
    name="stripe-provider",
    credentialProviderVendor="Stripe",
    providerConfigurationInput={
        "stripeConfiguration": {
            "restrictedKeySource": "EXTERNAL",
            "restrictedKeyConfig": {
                "secretId": "arn:aws:secretsmanager:us-east-1:123456789012:secret:stripe-restricted-key",
                "jsonKey": "restrictedKey",
            },
            "publishableKey": "pk_test_EXAMPLE",
        }
    },
)

provider_arn = provider["credentialProviderArn"]
```

The response returns `credentialProviderArn` and a `stripeConfiguration` output. The output includes `restrictedKeyArn`, the ARN of the secret that holds the key, and `publishableKey` if you supplied one. It never includes the restricted key value.

## Create a Stripe payment connector
<a name="payments-stripe-connector"></a>

Create a connector of type `Stripe` in your Payment Manager, and reference the credential provider ARN.

**Example**  

```bash
aws bedrock-agentcore-control create-payment-connector \
  --payment-manager-id <paymentManagerId> \
  --name "StripeConnector" \
  --type Stripe \
  --credential-provider-configurations '[{
    "stripe": {
      "credentialProviderArn": "arn:aws:bedrock-agentcore:us-east-1:123456789012:token-vault/default/paymentcredentialprovider/stripe-provider"
    }
  }]' \
  --region us-east-1
```

```python
connector = client.create_payment_connector(
    paymentManagerId="<paymentManagerId>",
    name="StripeConnector",
    type="Stripe",
    credentialProviderConfigurations=[
        {"stripe": {"credentialProviderArn": provider_arn}}
    ],
)

connector_id = connector["paymentConnectorId"]
```

When the connector status is `READY`, your agent can accept payments using Stripe. Don’t create payment intents with the connector before then.

Next, [create a payment intent](payments-agentic-commerce-create-intent.md).

## Rotate or replace your Stripe credentials
<a name="payments-stripe-manage"></a>

AgentCore payments doesn’t require a rotation schedule. Rotate the restricted key on your organization’s schedule, and right away if the key might be exposed. To rotate the restricted key, do one of the following:
+ If you use `restrictedKeyConfig`, store a new version of the secret in AWS Secrets Manager.
+ If you passed the key inline, call `UpdatePaymentCredentialProvider` with the full `stripeConfiguration` and the new key.

Rotate only to a key from the same Stripe account. AgentCore payments doesn’t check that a new key belongs to the same account. To connect a different Stripe account, create a new payment credential provider and a new connector.

To move from testing to live payments, we recommend a separate payment credential provider and connector with your live key (`rk_live_`). You can also replace a test key with a live key on the same connector, because both keys belong to the same Stripe account. Stripe keeps test mode and live mode objects apart, so payment intents and saved payment methods from test mode don’t work after the change. Finish or cancel your test payment intents before you replace the key.

## Stripe considerations
<a name="payments-stripe-limits"></a>
+ AgentCore payments accepts only restricted keys. It rejects secret keys (`sk_`) and publishable keys (`pk_`).
+ More than one capture for a `FUTURE` payment requires Stripe [multicapture](https://docs.stripe.com/payments/multicapture). AgentCore payments requests multicapture for each `FUTURE` payment. Multicapture is available to you based on Stripe’s eligibility criteria. If the payment doesn’t support it, a capture that isn’t the final capture returns a `ValidationException`. In that case, capture the full remaining amount at once.
+ AgentCore payments supports `USD` and `EUR`. Your Stripe account must accept the currency of the payment intent.
+ Use test mode keys (`rk_test_`) with Stripe test cards. Live mode keys (`rk_live_`) charge real buyers.
+ AgentCore payments offers the payment methods that you turn on in your Stripe Dashboard. Methods that redirect the buyer, such as Klarna, use your `return_url`. Methods that settle later, such as ACH Direct Debit or SEPA Direct Debit, leave the capture `CAPTURE_PENDING` after `AuthorizePaymentIntent`.
+ Stripe is the only payment service provider that supports `SETUP`. For more information, see [Save a payment method for later charges](payments-agentic-commerce-save-payment-method.md).
+  `FUTURE` doesn’t support ACH Direct Debit. `SETUP` supports cards (including Apple Pay and Google Pay), Link, and ACH Direct Debit.