Skip to main content
Cashfree custom web checkout lets you embed payment UI elements in your application and keep customers on your site throughout checkout. Cashfree captures and transmits sensitive payment data, which helps you reduce your PCI DSS (Payment Card Industry Data Security Standard) compliance scope.

Key features

Custom web checkout provides the following capabilities:
  • Complete design control: Design payment forms that match your brand identity with full control over styling, layout, and user experience.
  • PCI DSS compliant: Payment data is securely captured and transmitted directly to Cashfree servers, reducing your PCI compliance scope.
  • Flexible integration: Build custom payment flows with individual components or use the hosted checkout option based on your requirements.
  • Multiple payment methods: Accept payments through cards (credit and debit), UPI (collect, intent, and QR), net banking, wallets, and Buy Now Pay Later options.
  • Enhanced user experience: Keep customers on your website throughout the payment journey without redirecting to external pages.
  • Framework support: Native libraries available for JavaScript, React, and Svelte for seamless integration.

Prerequisites

Ensure you complete the following tasks before starting the integration:

Integration steps

Follow these four steps to integrate custom web checkout:

Step 1: Create an order

Server-sideTo integrate the custom web checkout, you must first create an order. Complete this step before you process any payments. Configure an endpoint on your server to handle order creation. You can’t call this API from the client-side.
Create orders through your server as this API requires your secret key. Don’t call it directly from the client-side.
Here’s a sample request for creating an order using your desired backend language. Cashfree offers backend SDKs to simplify the integration process.
After successfully creating an order, you will receive a unique order_id and payment_session_id that you need for subsequent steps.You can view the complete API request and response for /orders in the Create Order API.
Client-side
You must whitelist your domain with Cashfree before you start this step.
Include the Cashfree SDK in your client-side code. You must load cashfree.js directly from the Cashfree CDN to maintain PCI compliance. Don’t bundle or self-host this library.
Use the CDN or NPM to include the SDK in your project.

Initialise the SDK

Initialise the SDK using the Cashfree() function with the appropriate mode:

Async and deferred loading

Asynchronous loading of JavaScript is recommended as it improves your site’s user experience by preventing the script from blocking DOM rendering during load time.You can load cashfree.js using the async or defer attribute on the script tag:
With asynchronous loading, you must make all SDK method calls only after the script execution completes. Ensure your code waits for the Cashfree SDK to load before initialising or calling any methods.
Client-sideBuild your payment interface using one of the following approaches:

Option 1: Use hosted checkout

Redirect customers to a Cashfree-hosted payment page that supports all payment methods. This is the quickest integration option.
The redirectTarget parameter controls how the checkout opens:
  • _self: Opens in same window (default)
  • _blank: Opens in new tab
  • _modal: Opens in popup window
  • DOM element: Embeds inline

Option 2: Build custom components

Create custom payment forms using individual components for complete design control. Components are available for cards, UPI, net banking, and wallets.

Card payments

Accept credit and debit card payments

UPI payments

Support UPI collect, intent, and QR

Other methods

Net banking, wallets, and BNPL
Component lifecycle:For detailed component examples, refer to the Examples page.
Server-sideAfter the customer completes the payment, verify the payment status on your server before delivering services.

Hosted checkout response

For hosted checkout, customers redirect to the returnUrl you provided when creating the order. For popup and inline checkouts, the cashfree.checkout() function returns a promise with payment details.

Custom component response

When using custom components, the cashfree.pay() method returns a promise with the payment result.

Order status verification

To verify an order you can call our /pg/orders endpoint from your backend. You can also use our SDK to achieve the same.
Always verify the order status before you deliver services to the customer. Use the Get Order API for this. An order is successful when the order_status is PAID.

Developer resources

SDK Libraries

JavaScript, React, and Svelte libraries for seamless integration

Integration Examples

Working code samples for cards, UPI, wallets, and multi-payment setups

Component Overview

Component lifecycle methods including mount, update, and unmount

Customise Styling

Apply custom styles, fonts, and themes to match your brand

Card Payments

Build custom card payment forms with secure components

UPI Components

Integrate UPI collect, QR code, and intent-based payments

Other Payment Methods

Add net banking, wallets, and Buy Now Pay Later options

Payment Options

Configure payment methods, filters, and checkout behaviour

Testing

After integration, verify that your payment flow works correctly:
  1. Open the Network tab in your browser developer tools.
  2. Initiate a payment and check the console logs.
  3. Ensure you pass the correct environment (sandbox or production) and payment_session_id.
  4. Use console.log() to confirm data is passed correctly to the SDK methods.
  5. Test with sandbox credentials before going live.

FAQs

Use hosted checkout if you want the quickest implementation with minimal code. It provides a ready-made payment page with all payment methods.Use custom components when you need:
  • Complete control over the payment form design
  • Seamless integration with your existing UI
  • Custom validation and error handling
  • Specific payment flow customizations
Yes. When you use Cashfree’s custom web checkout, payment card data is captured directly by secure components and transmitted to Cashfree servers. Your server never touches sensitive card information, which reduces your PCI DSS compliance scope significantly.However, you must:
  • Load the SDK from Cashfree’s CDN (don’t bundle or self-host)
  • Never log or store card data on your servers
  • Use HTTPS for all website pages
Always implement proper error handling:
  1. Client-side: Check for result.error in the promise returned by cashfree.checkout() or cashfree.pay()
  2. Server-side: Always verify the order status using the Get Order API before delivering services
  3. Use webhooks: Implement webhook handlers for real-time payment status notifications
  4. Display clear messages: Show user-friendly error messages to customers when payments fail
No. Payment sessions are single-use and expire after 30 minutes. For each new payment attempt, generate a fresh payment session through the Create Order API on your server.
The Cashfree SDK supports all modern browsers:
  • Chrome 90+
  • Firefox 88+
  • Safari 14+
  • Edge 90+
  • Mobile browsers (iOS Safari 14+, Chrome Mobile 90+)
The SDK automatically handles browser compatibility and provides fallbacks where needed.
Yes. Domain whitelisting is mandatory for security. You must whitelist:
  • Your website domain for web integrations
  • Your app package name for mobile apps
Whitelist your domains in the Merchant Dashboard under Settings > Developers > Domain Whitelisting.
Yes. Custom components are fully styleable. You can customize:
  • Colors and fonts
  • Border styles and radius
  • Padding and spacing
  • Focus and error states
  • Placeholder text
See the Customise Styling guide for detailed examples.
  1. Use sandbox mode in the SDK initialization
  2. Generate test API keys from the sandbox environment
  3. Use test card numbers from the documentation
  4. Test all payment scenarios: success, failure, pending
  5. Verify webhook handling with test notifications
  6. Switch to production mode and use live API keys only when ready to go live
If the SDK fails to load:
  • Check browser console for errors
  • Verify the CDN address is correct
  • Ensure you’re loading from https://sdk.cashfree.com
  • Check for network connectivity issues
  • Verify no browser extensions are blocking the script
For async loading, ensure you wait for the SDK to load before making any method calls.
Yes. Use the savePaymentInstrument component in your card payment form. Customers can opt-in to save their card details securely. On subsequent payments, you can retrieve and use saved payment instruments through the Token Vault feature.Learn more in the Token Vault documentation.

Affiliate partner program

As a developer building payment experiences for your clients, you can earn additional income while providing them with industry-leading payment solutions.

Join the Cashfree affiliate partner program and get rewarded every time your clients use Cashfree.

What you get:

  • Earn up to 0.25% commission on every transaction.
  • Become a trusted fintech partner for your clients.
  • Access to a dedicated partner manager for expert support.

What your clients get:

  • Instant activation and go live in minutes.
  • Industry-best success rate across all payment modes.
  • Effortless acceptance of international payments in 140+ currencies.

Get started today. Become a partner now.