Set up future UPI payments
Learn how to save UPI details and charge your customers later.
Checkout
Direct API
This guide covers how to save UPI payment details using Checkout, our fully hosted checkout page.
You need permission to save your customer’s payment method for future use. Creating an agreement (sometimes called a mandate) up front allows you to save your customer’s payment details, and potentially charge your customer when they’re not actively using your website or app. Learn more about how e-mandates work in India.
Set up Stripe Server-side
First, you need a Stripe account. Register now.
Use our official libraries for access to the Stripe API from your application:
Command Line
Select a language
Ruby
Python
PHP
Java
Node.js
Go
.NET
No results
# Available as a gem
sudo gem install stripe
Gemfile
Select a language
Ruby
Python
PHP
Java
Node.js
Go
.NET
No results
# If you use bundler, you can add this line to your Gemfile
gem 'stripe'
Create or retrieve a customer Server-side
To reuse a UPI payment method for future payments, attach it to an object that represents your customer.
Use the Accounts v2 API to represent customers
The Accounts v2 API is generally available for Connect users, and in public preview for other Stripe users. If you’re part of the Accounts v2 preview, you need to specify a preview version in your code.
To join the Accounts v2 preview, go to Account previews and features in your Dashboard and enable Reusable payment methods for Global Payouts.
For most use cases, we recommend modelling your customers as customer-configured Account objects instead of using Customer objects.
Create a customer-configured Account or Customer when your customer creates an account with your business or when saving a payment method. Associate the object’s ID with your own internal representation of a customer.
Create a new customer or retrieve an existing one to associate with this payment.
Command Line
Select a language
cURL
Stripe CLI
Ruby
Python
PHP
Java
Node.js
Go
.NET
No results
Create a Checkout Session Server-side
Your customer must authorise you to use UPI for future payments through Stripe Checkout. This lets you accept UPI payments. Add a checkout button to your website that calls a server-side endpoint to create a Checkout Session.
index.html
<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 that the response returns.
Select a language
Ruby
Python
PHP
Java
Node.js
Go
.NET
No results
client.v1.checkout.sessions.create({
mode: 'setup',
customer: customer.id,
success_url: 'https://example.com/success',
})
Test your integration
Select UPI as the payment method, then click Pay with UPI. If you’re using a mobile device, you’ll be automatically redirected to a test page where you can approve the purchase. Otherwise, you’ll see a QR code, and when you scan it you’ll be redirected to the same test page.