See the code behind this demo!

Setup a card

Learn how to save card details and charge your customers later.

The Setup Intents API lets you save a customer’s card without an initial payment. This is helpful if you want to onboard customers now, set them up for payments, and charge them in the future—when they’re offline. Read more here.


Console

> Ready ...

            
              const {clientSecret} = await fetch('/create-setup-intent', {
                method: 'POST',
                headers: {
                  'Content-Type': 'application/json',
                },
                body: JSON.stringify({}),
              }).then((r) => r.json());

              addMessage('Setting up the card for future payments ...');

              stripe.confirmCardSetup(clientSecret, {
                payment_method: {
                  card: cardElement,
                  billing_details: {
                    name: 'Jenny Rosen',
                  },
                },
              }).then((result) => {
                if (result.error) {
                  addMessage(result.error.message);
                } else {
                  addMessage('Card setup for future payments! 🎉');
                };
              });
            
          

Experiment and learn

Make copies, remix, change and learn how to play with this tinydemo.


Any questions?

Reach out to us on any of our contact channels: