View a markdown version of this page

Set up PayPal - Amazon Bedrock AgentCore

Set up PayPal

With a PayPal payment connector, your agent can take payments through your own PayPal REST app. AgentCore payments uses your app’s client ID and client secret to get a short-lived PayPal access token for each call. The buyer approves the order with the PayPal JavaScript SDK on your web page.

Get your PayPal app credentials

Before you begin, make sure that you have the following:

Collect the following values from your PayPal REST app:

Client ID

The client ID of your PayPal REST app. Your web page also uses it to load the PayPal JavaScript SDK.

Client secret

The client secret of your PayPal REST app.

Environment

LIVE for api-m.paypal.com, or SANDBOX for api-m.sandbox.paypal.com. Use the environment that your REST app belongs to.

Create a PayPal payment credential provider

A payment credential provider stores your PayPal credentials in AgentCore Identity. Set credentialProviderVendor to PayPal and supply a payPalConfiguration block with the following fields:

  • clientId (required): your PayPal app client ID.

  • environment (required): LIVE or SANDBOX.

  • The client secret, in one of the following ways. The two ways are mutually exclusive.

    • clientSecret: the secret value. AgentCore Identity stores it in a service-managed secret. You can omit clientSecretSource, or set it to MANAGED.

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

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

Example
AWS CLI

The following example passes the secret inline:

aws bedrock-agentcore-control create-payment-credential-provider \ --name "paypal-provider" \ --credential-provider-vendor PayPal \ --provider-configuration-input '{ "payPalConfiguration": { "clientId": "EXAMPLE-CLIENT-ID", "environment": "SANDBOX", "clientSecret": "<your-client-secret>" } }' \ --region us-east-1

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

aws bedrock-agentcore-control create-payment-credential-provider \ --name "paypal-provider" \ --credential-provider-vendor PayPal \ --provider-configuration-input '{ "payPalConfiguration": { "clientId": "EXAMPLE-CLIENT-ID", "environment": "SANDBOX", "clientSecretSource": "EXTERNAL", "clientSecretConfig": { "secretId": "arn:aws:secretsmanager:us-east-1:123456789012:secret:paypal-client-secret", "jsonKey": "clientSecret" } } }' \ --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="paypal-provider", credentialProviderVendor="PayPal", providerConfigurationInput={ "payPalConfiguration": { "clientId": "EXAMPLE-CLIENT-ID", "environment": "SANDBOX", "clientSecretSource": "EXTERNAL", "clientSecretConfig": { "secretId": "arn:aws:secretsmanager:us-east-1:123456789012:secret:paypal-client-secret", "jsonKey": "clientSecret", }, } }, ) provider_arn = provider["credentialProviderArn"]

The response returns credentialProviderArn and a payPalConfiguration output. The output includes clientId, environment, and clientSecretArn, the ARN of the secret that holds the client secret. It never includes the client secret value.

Create a PayPal payment connector

Create a connector of type PayPal 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 "PayPalConnector" \ --type PayPal \ --credential-provider-configurations '[{ "payPal": { "credentialProviderArn": "arn:aws:bedrock-agentcore:us-east-1:123456789012:token-vault/default/paymentcredentialprovider/paypal-provider" } }]' \ --region us-east-1
AWS SDK
connector = client.create_payment_connector( paymentManagerId="<paymentManagerId>", name="PayPalConnector", type="PayPal", credentialProviderConfigurations=[ {"payPal": {"credentialProviderArn": provider_arn}} ], ) connector_id = connector["paymentConnectorId"]

Wait until the connector status is READY before you create payment intents with it.

Next, create a payment intent.

Rotate or replace your PayPal credentials

To rotate the client secret, do one of the following:

  • If you use clientSecretConfig, store a new version of the secret in AWS Secrets Manager.

  • If you passed the secret inline, call UpdatePaymentCredentialProvider with the full payPalConfiguration and the new secret.

To connect a different PayPal REST app, create a new payment credential provider and a new connector. Don’t change clientId on an existing provider.

PayPal considerations

  • Use a SANDBOX provider with a sandbox app and a sandbox buyer account. A LIVE provider charges real buyers.

  • The buyer pays in the PayPal checkout. The buyer can sign in and pay from their PayPal wallet: PayPal balance, a linked bank account, or a linked card. The buyer can also pay by card as a guest, or with Pay Later or PayPal Credit. Whether guest checkout is offered depends on your PayPal account settings and PayPal’s own checks.

  • PayPal offers the funding sources that settle immediately. Funding sources that settle later, such as eChecks, aren’t offered.

  • AgentCore payments supports USD and EUR. Your PayPal account must accept the currency of the payment intent.

  • For a FUTURE payment, you can make more than one partial capture.

  • AgentCore payments sends checkoutDetails.referenceId to PayPal as the invoice ID.