Skip to content

Save Customer Cards

Tokenize cards with the Payment Widget for future recurring payments.

In this guide, you will learn how to use the Payment Widget to save a customer’s card as a tokenized payment instrument and set up recurring payments. The Payment Widget handles the payment interface, consent collection, and 3D Secure authentication. This feature is also known as card on file or tokenization.

You will go through the following steps:

  1. Create a customer.
  2. Create a checkout for card tokenization. This is where 3D Secure authentication takes place. The transaction amount is instantly reimbursed.
  3. Process the payment with the Payment Widget.
  4. Retrieve the tokenized card.
  5. Make subsequent payments with the tokenized card.

A customer resource is a representation of a person or business paying for a product or service. It contains personal information such as name, contact details, postal address, as well as a unique identifier relevant to your business logic (customer_id).

  1. Create a new customer resource with a POST request to the https://api.sumup.com/v0.1/customers endpoint:
curl -X POST \
https://api.sumup.com/v0.1/customers \
-H "Authorization: Bearer $SUMUP_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"customer_id": "MYCUSTOMERID-123",
"personal_details": {
"address": {
"city": "Venice",
"state": "California",
"country": "US",
"line1": "606 Venezia Ave",
"line2": "Front",
"postal_code": "90291"
},
"birthdate": "1949-11-11",
"email": "thedude@example.com",
"first_name": "Jeffrey",
"last_name": "Lebowski",
"phone": "+1 310-555-1234"
}
}'

You should expect a standard 201 Created response, with the customer details you passed. For full details, see the endpoint documentation. Having created the customer, we can now proceed to making a payment

Now, we need to tokenize the customer’s card, and we will need a checkout for this. The checkout resource is a representation of a payment being made by the previously created customer. It contains information such as the amount, currency, and a unique checkout_reference identifier that is relevant to your business logic.

The flow is initiated with the create a checkout endpoint. It is important to pass the customer_id parameter in this step, for future linking to a payment instrument. Critically, a purpose parameter is passed to indicate the payment type as recurring payment and process an authorization charge of the checkout amount indicated, which is instantly reimbursed. Note that this doesn’t automatically imply further payments from this customer - at this point, we’re just tokenizing the card.

  1. To create a new checkout resource, make a POST request to the https://api.sumup.com/v0.1/checkouts endpoint.

Example of such request:

curl -X POST \
https://api.sumup.com/v0.1/checkouts \
-H "Authorization: Bearer $SUMUP_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"checkout_reference": "MYCHECKOUT",
"amount": 1,
"currency": "EUR",
"merchant_code": "MDEERENR",
"description": "My checkout",
"customer_id": "MYCUSTOMERID-123",
"purpose": "SETUP_RECURRING_PAYMENT"
}'

You should expect a standard 201 Created response, with the checkout reference and both merchant and customer information.

{
"amount": 1,
"checkout_reference": "MYCHECKOUT",
"checkout_type": "checkout",
"currency": "EUR",
"customer_id": "MYCUSTOMERID-123",
"date": "2025-10-29T15:09:11.550+00:00",
"description": "My checkout",
"id": "7164c99b-13cb-42a1-8ba1-3c2c46a29de7",
"merchant_code": "MDEERENR",
"merchant_country": "PL",
"merchant_name": "Sandbox Merchant Account",
"pay_to_email": "a8e019f9bb2f49159182e8bd61eb5ea6@developer.sumup.com",
"purpose": "SETUP_RECURRING_PAYMENT",
"status": "PENDING",
"transactions": []
}

For more information, see the create a checkout endpoint.

The SumUp Payment Widget securely collects card details and processes checkouts while handling consent collection and 3D Secure authentication.

Once you have the checkout ID from the previous step, mount the Payment Widget on your website and pass the ID as checkoutId.

<div id="sumup-card"></div>
<script
type="text/javascript"
src="https://gateway.sumup.com/gateway/ecom/card/v2/sdk.js"
></script>
<script type="text/javascript">
SumUpCard.mount({
id: "sumup-card",
checkoutId: `${checkout_id}`, // Ex: '7164c99b-13cb-42a1-8ba1-3c2c46a29de7'
onResponse: function (type, body) {
console.log("Type", type);
console.log("Body", body);
},
});
</script>

Upon mounting the Payment Widget with a recurring purpose checkout, you should see the following screen:

Card on file with Payment Widget
Card on file with Payment Widget

The customer enters their card details, consents to storing them, and completes the checkout in the Payment Widget. The card details are sent directly to SumUp and do not pass through your server.

If the previous operation is successful, and the card is stored with the Save for future payments option, a payment_instrument object containing a token representing the card is created (AKA tokenized card) for this customer.

"payment_instrument": {
"token": "6878cb7f-6515-47bf-bdd9-1408d270fdce"
}

At any time, you can fetch the list of tokenized cards of a customer by requesting them via the list payment instruments endpoint.

curl -X GET \
"https://api.sumup.com/v0.1/customers/${CUSTOMER_ID}/payment-instruments" \
-H "Authorization: Bearer $SUMUP_API_KEY" \
-H "Content-Type: application/json;charset=UTF-8"

Having successfully processed the checkout, a token representing the payment instrument (card) is created. You can now retrieve the checkout to find this token within a payment_instrument object for later recurrent payment.

Example response:

{
"id": "cd36780e-f43d-4f22-1i9e-e32a1a1bafc8",
"checkout_reference": "0BYNWLYC7KV",
"amount": 3.51,
"currency": "EUR",
...
"payment_instrument": {
"token": "2fa27578-e765-5dbh-aa97-d45d3d6cdfbb"
}
}

Having tokenized the customer’s card, you can now process recurring payments by referencing the saved token and the associated customer. Both token and customer_id fields are required.

  1. Create a checkout again. This time, it’s for the actual payment. The previous checkout was for tokenizing the card only.
  2. Process the checkout. Make sure to pass the following data (installments is only valid for the Brazilian market):
{
"payment_type": "card",
"installments": 1,
"token": "{{CARD_TOKEN}}"
"customer_id": "{{CUSTOMER_ID}}",
}

You may be interested in the following resources related to Online Payments: