# Save a card and charge it later

Use credential-on-file indicators to save a card for a declared usage type and charge it later.

Credential-on-file (CoF) is a card network requirement for businesses that store a customer’s card and charge it in future transactions with a specific usage type. Stripe provides two parameters to comply with this requirement:

- Use [setup_credential_usage](https://docs.stripe.com/api/setup_intents/create.md#create_setup_intent-payment_method_options-card-setup_credential_usage) when you’re saving the customer’s card details. This sets the intended future usage type on a SetupIntent or a PaymentIntent with `setup_future_usage`.
- Use [stored_credential_usage](https://docs.stripe.com/api/payment_intents/create.md#create_payment_intent-payment_method_options-card-stored_credential_usage) when you’re charging a saved card. This sets the usage type on a PaymentIntent of the subsequent charge.

## Before you begin

This guide covers how to use the card-specific credential usage type when creating the PaymentIntent or SetupIntent object on the server side. If you don’t have an existing integration, refer to one of the following:

- [Save a payment method without a payment](https://docs.stripe.com/payments/save-and-reuse.md) to save a card with a SetupIntent
- [Save a payment method during payment](https://docs.stripe.com/payments/save-during-payment.md) to save a card while charging the customer

## Choose the credential usage type 

The following usage types describe when saving for future *off-session* (A payment is described as off-session if it occurs without the direct involvement of the customer, using previously-collected payment information) or performing off-session charges. Both [setup_credential_usage](https://docs.stripe.com/api/setup_intents/create.md#create_setup_intent-payment_method_options-card-setup_credential_usage) and [stored_credential_usage](https://docs.stripe.com/api/payment_intents/create.md#create_payment_intent-payment_method_options-card-stored_credential_usage) accept these values:

| Value | Description | Typical use case |
| --- | --- | --- |
| `recurring` | A scheduled, repeated charge under an ongoing agreement. Use `recurring` only when you have a fixed schedule recurring arrangement with the customer. | Monthly subscriptions, utility bills, membership fees |
| `unscheduled` | A one-off charge initiated by a business outside of a regular schedule. | Hotel checkout charges, top-ups, ad hoc charges authorized in a previous session. |
| `installment` | A single purchase of goods split into several scheduled charges managed by the merchant. It’s distinct from [payment_method_options.card.installments](https://docs.stripe.com/api/payment_intents/create.md#create_payment_intent-payment_method_options-card-installments), which is used for issuer installments like [Mexico](https://docs.stripe.com/payments/meses-sin-intereses/accept-a-payment.md) and [Japan installments](https://docs.stripe.com/payments/jp-installments/accept-a-payment.md). | Buy now, pay later; financing a purchase over scheduled charges. |

When you save a card, set `setup_credential_usage` to the usage type of the main scenario you expect to charge it under. When you charge a saved card, set `stored_credential_usage` to the usage type of *that* charge, which can differ from the `setup_credential_usage` you declared when you saved the card. For example, you can save a card as `recurring` for a subscription, then charge an occasional top-up as `unscheduled`.

Because a saved credential can be charged across more than one scenario, make sure to disclose every scenario to the customer when they consent to save the card.

## Save the card (Server-side) 

After creating the customer, set `setup_credential_usage` to declare how you intend to use the saved card:

#### SetupIntent

```curl
curl https://api.stripe.com/v1/setup_intents \
  -u "<<YOUR_SECRET_KEY>>:" \
  -d "customer={{CUSTOMER_ID}}" \
  -d "automatic_payment_methods[enabled]=true" \
  -d "payment_method_options[card][setup_credential_usage]=unscheduled"
```

Collect payment details on the client with the Payment Element following [this guide](https://docs.stripe.com/payments/save-and-reuse.md?payment-ui=elements#collect-payment-details).

#### PaymentIntent

```curl
curl https://api.stripe.com/v1/payment_intents \
  -u "<<YOUR_SECRET_KEY>>:" \
  -d amount=2000 \
  -d currency=usd \
  -d "customer={{CUSTOMER_ID}}" \
  -d "automatic_payment_methods[enabled]=true" \
  -d "payment_method_options[card][setup_credential_usage]=unscheduled"
```

Collect payment details on the client with the Payment Element following [this guide](https://docs.stripe.com/payments/save-during-payment.md?payment-ui=elements#enable-saving-the-payment-method-in-the-payment-element).

`setup_credential_usage` only takes effect if the customer opts in to save their card or if you set `setup_future_usage` on the `PaymentIntent`.

## Charge the saved card 

### Make an on-session payment

To charge the saved card as an *on-session* (A payment is described as on-session if it occurs while the customer is actively in your checkout flow and able to authenticate the payment method) payment, set [payment_method](https://docs.stripe.com/api.md#create_payment_intent-payment_method) to the `PaymentMethod`’s ID attached to your customer. Stripe signals the card network that this is a subsequent *on-session* (A payment is described as on-session if it occurs while the customer is actively in your checkout flow and able to authenticate the payment method) payment if you correctly saved the `PaymentMethod` through the [Save Card](https://docs.stripe.com/payments/cards/save-and-reuse.md#save-the-card) integration.

```curl
curl https://api.stripe.com/v1/payment_intents \
  -u "<<YOUR_SECRET_KEY>>:" \
  -d amount=2000 \
  -d currency=usd \
  -d "customer={{CUSTOMER_ID}}" \
  -d "payment_method={{PAYMENTMETHOD_ID}}" \
  -d confirm=true \
  --data-urlencode "return_url=https://example.com/return"
```

### Make an off-session payment

To charge the saved card as an *off-session* (A payment is described as off-session if it occurs without the direct involvement of the customer, using previously-collected payment information) payment, on top of setting [off_session](https://docs.stripe.com/api.md#create_payment_intent-off_session) to `true`, make sure you set [stored_credential_usage](https://docs.stripe.com/api/payment_intents/create.md#create_payment_intent-payment_method_options-card-stored_credential_usage) to the appropriate [usage type](https://docs.stripe.com/payments/cards/save-and-reuse.md?#choose-credential-usage-type):

```curl
curl https://api.stripe.com/v1/payment_intents \
  -u "<<YOUR_SECRET_KEY>>:" \
  -d amount=2000 \
  -d currency=usd \
  -d "customer={{CUSTOMER_ID}}" \
  -d "payment_method={{PAYMENTMETHOD_ID}}" \
  -d off_session=true \
  -d "payment_method_options[card][stored_credential_usage]=unscheduled" \
  -d confirm=true \
  --data-urlencode "return_url=https://example.com/return"
```

A successful charge returns a PaymentIntent with `status: "succeeded"`:

```json
{
  "id": "pi_xxx",
  "object": "payment_intent",
  "status": "succeeded",
  "payment_method_options": {
    "card": {
      "stored_credential_usage": "unscheduled"
    }
  }
}
```

## See also

- [Customer-Initiated Transactions (CIT) and Merchant-Initiated Transactions (MIT)](https://docs.stripe.com/payments/cits-and-mits.md)
- [Save a payment method without a payment](https://docs.stripe.com/payments/save-and-reuse.md)
- [Save a payment method during payment](https://docs.stripe.com/payments/save-during-payment.md)
