

# Save a payment method for later charges

With `captureStrategy` set to `SETUP` and `checkoutDetails.amountMode` set to `UPTO`, the buyer saves a payment method once, and you charge it later without the buyer present. `totalAmount` is the maximum total of all later charges. `SETUP` is supported for Stripe only.

Use `SETUP` for pre-approved purchases, where the buyer is present to approve but not when you charge. Use it when the final amount or the charge time isn’t known at checkout. For example, charge when an order ships, charge for each item of a split shipment, or charge for a booking after the service. If you know the amount at checkout and only want to delay the charge, use the `FUTURE` capture strategy instead. For more information, see [Capture strategies](payments-agentic-commerce.md#payments-agentic-commerce-capture-strategies).

1. Call `CreatePaymentIntent` with `captureStrategy` set to `SETUP`, `amountMode` set to `UPTO`, and `totalAmount` set to the maximum amount. `SETUP` requires `checkoutDetails.returnUrl`.

1. Get buyer approval with `CreateBuyerApprovalUrl`. The buyer approves charges up to that amount. For more information, see [Get buyer approval for a payment intent](payments-buyer-approval.md).

1. Call `InitiatePaymentIntent` with the buyer’s `userId`. AgentCore payments creates a Stripe-hosted Checkout Session in setup mode. `partnerIntentData` contains `setupCheckoutUrl`, and the status becomes `SAVE_PENDING`. No money moves.

1. Redirect the buyer to `setupCheckoutUrl`. Stripe sends the buyer back to `returnUrl` after the save.

1. Later, without the buyer present, call `CapturePaymentIntent` on the same payment intent. Each call can charge part of the maximum amount. Omit `captureAmount` to charge whatever remains.

 `GetPaymentIntent` and `CapturePaymentIntent` check the Checkout Session and move the payment intent to `SAVED`, or to `SAVE_FAILED` if the buyer abandons the page. After a charge that leaves part of the maximum amount, the status is `PARTIALLY_CAPTURED`.

The remaining amount is `totalAmount` minus the captured amount and any pending charges. A charge over the remaining amount returns a `ValidationException`. AgentCore payments sets no time limit: a saved payment method stays usable until Stripe or the card issuer declines it. AgentCore payments stores only Stripe IDs, never card data.

If the card needs 3-D Secure for the first charge, the status becomes `REAUTH_REQUIRED`. If the card declines the first charge, the status becomes `PAYMENT_DECLINED`. Both statuses are final. To try again, bring the buyer back and create a new `SETUP` payment intent.

## Your responsibilities for later charges
<a name="payments-agentic-commerce-save-payment-method-terms"></a>

The buyer saves the payment method in a customer-initiated transaction (CIT). Each later charge, made without the buyer present, is a merchant-initiated transaction (MIT). Card networks and Stripe set rules for saving a payment method and charging it later. You’re responsible for following them. For Stripe’s requirements, see [Customer-initiated and merchant-initiated transactions](https://docs.stripe.com/payments/cits-and-mits) and [Save and reuse payment methods](https://docs.stripe.com/payments/save-and-reuse) in the Stripe documentation.

Stripe’s requirements include the following:
+ Show your terms for saving the payment method, and get the buyer’s agreement before you save it. The buyer approval widget shows only the maximum amount and your merchant name, so show your own terms on your checkout page.
+ State in your terms when and how often you charge, and how you determine the amount.
+ Use the saved payment method only for the purposes in your terms.
+ Keep a record of each buyer’s agreement to your terms.

AgentCore payments records part of this for you. The signed payment mandate records the merchant, a hash of the cart, the maximum amount, and the approval time. `GetPaymentIntent` returns the cart and each charge with its Stripe reference. Store the terms that the buyer accepted alongside these records.

## Cancel a saved payment method
<a name="payments-agentic-commerce-save-payment-method-cancel"></a>

To stop future charges before any charge is made, call `CancelPaymentIntent` while the status is `SAVE_PENDING` or `SAVED`. AgentCore payments expires the Stripe Checkout Session. If the buyer already saved a payment method, AgentCore payments detaches it from the Stripe Customer, and keeps the Customer.

After the first charge (`PARTIALLY_CAPTURED` or `CAPTURED`), or while a charge is `CAPTURE_PENDING`, `CancelPaymentIntent` returns a `ConflictException`.