Save payment details during payment
This guide covers how to save a Cash App Pay payment details using Checkout, our fully hosted checkout page.
To create recurring payments after saving a payment method in Checkout, see Set up a subscription with Cash App Pay for more details.
Set up StripeServer-side
First, you need a Stripe account. Register now.
Use our official libraries for access to the Stripe API from your application:
# For detailed setup, see our quickstarts at https://stripe.com/docs/development/quickstart bundle add stripe
Create or retrieve a CustomerServer-side
To reuse a Cash App Pay payment method for future payments, attach it to a Customer.
Create a Customer object when your customer creates an account with your business, and associate the ID of the Customer object with your own internal representation of a customer. Alternatively, you can create a new Customer later, right before saving a payment method for future payments.
Create a new Customer or retrieve an existing Customer to associate with this payment. Include the following code on your server to create a new Customer.
curl https://api.stripe.com/v1/customers \ -u
: \ -d description="My First Test Customer (created for API docs)"sk_test_4eC39HqLyjWDarjtT1zdp7dc
Create a Checkout SessionServer-side
Your customer must authorize you to use their Cash App account for future payments through Stripe Checkout. This allows you to accept Cash App payments. Add a checkout button to your website that calls a server-side endpoint to create a Checkout Session.
<html> <head> <title>Checkout</title> </head> <body> <form action="/create-checkout-session" method="POST"> <button type="submit">Checkout</button> </form> </body> </html>
Create a Checkout Session in setup
mode to collect the required information. After creating the Checkout Session, redirect your customer to the URL returned in the response.
Stripe::Checkout::Session.create({ mode: 'setup', payment_method_types: ['card'], payment_method_types: ['card', 'cashapp'], customer: customer.id, success_url: 'https://example.com/success', cancel_url: 'https://example.com/cancel', })
Test your integrationServer-side
To test your integration, choose Cash App Pay as the payment method and tap Pay. In test mode, this redirects you to a test payment page where you can approve or decline the payment.
In live mode, tapping Pay redirects you to the Cash App mobile application—you don’t have the option to approve or decline the payment within Cash App. The payment is automatically approved after the redirect.