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:
-
A PayPal REST app in the PayPal Developer Dashboard
. To test, use a sandbox app. -
A Payment Manager. For more information, see Create a Payment Manager and Connector.
-
A web page that shows the PayPal button.
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
-
LIVEforapi-m.paypal.com, orSANDBOXforapi-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):LIVEorSANDBOX. -
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 omitclientSecretSource, or set it toMANAGED. -
clientSecretConfig: a reference to a secret that you own in AWS Secrets Manager, withsecretIdandjsonKey. SetclientSecretSourcetoEXTERNAL.
-
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
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
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
UpdatePaymentCredentialProviderwith the fullpayPalConfigurationand 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
SANDBOXprovider with a sandbox app and a sandbox buyer account. ALIVEprovider 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
USDandEUR. Your PayPal account must accept the currency of the payment intent. -
For a
FUTUREpayment, you can make more than one partial capture. -
AgentCore payments sends
checkoutDetails.referenceIdto PayPal as the invoice ID.