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:- Create a Cashfree Merchant Account.
- Log in to the Merchant Dashboard and generate an App ID and Secret Key. Learn how to generate API keys.
- Whitelist your website domain for integration. Learn more about domain whitelisting.
Integration steps
Follow these four steps to integrate custom web checkout:Step 1: Create an order
Step 1: Create an order
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.Step 2: Include SDK
Step 2: Include SDK
cashfree.js directly from the Cashfree CDN to maintain PCI compliance. Don’t bundle or self-host this library.- JavaScript
- React
- Svelte
Initialise the SDK
Initialise the SDK using theCashfree() 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 loadcashfree.js using the async or defer attribute on the script tag:Step 3: Build payment interface
Step 3: Build payment interface
Option 1: Use hosted checkout
Redirect customers to a Cashfree-hosted payment page that supports all payment methods. This is the quickest integration option.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
UPI payments
Other methods
Step 4: Confirm the payment
Step 4: Confirm the payment
Hosted checkout response
For hosted checkout, customers redirect to thereturnUrl 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, thecashfree.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.order_status is PAID.Developer resources
SDK Libraries
Integration Examples
Component Overview
Customise Styling
Card Payments
UPI Components
Other Payment Methods
Payment Options
Testing
After integration, verify that your payment flow works correctly:- Open the Network tab in your browser developer tools.
- Initiate a payment and check the console logs.
- Ensure you pass the correct environment (
sandboxorproduction) andpayment_session_id. - Use
console.log()to confirm data is passed correctly to the SDK methods. - Test with sandbox credentials before going live.
FAQs
Which integration approach should I choose: hosted checkout or custom components?
Which integration approach should I choose: hosted checkout or custom components?
- Complete control over the payment form design
- Seamless integration with your existing UI
- Custom validation and error handling
- Specific payment flow customizations
Is my website PCI DSS compliant when using custom web checkout?
Is my website PCI DSS compliant when using custom web checkout?
- 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
How do I handle payment failures and errors?
How do I handle payment failures and errors?
- Client-side: Check for
result.errorin the promise returned bycashfree.checkout()orcashfree.pay() - Server-side: Always verify the order status using the Get Order API before delivering services
- Use webhooks: Implement webhook handlers for real-time payment status notifications
- Display clear messages: Show user-friendly error messages to customers when payments fail
Can I use the same payment session for multiple payment attempts?
Can I use the same payment session for multiple payment attempts?
What browsers are supported by the custom web checkout?
What browsers are supported by the custom web checkout?
- Chrome 90+
- Firefox 88+
- Safari 14+
- Edge 90+
- Mobile browsers (iOS Safari 14+, Chrome Mobile 90+)
Do I need to whitelist my domain?
Do I need to whitelist my domain?
- Your website domain for web integrations
- Your app package name for mobile apps
Can I customize the styling of payment components?
Can I customize the styling of payment components?
- Colors and fonts
- Border styles and radius
- Padding and spacing
- Focus and error states
- Placeholder text
How do I test the integration before going live?
How do I test the integration before going live?
- Use
sandboxmode in the SDK initialization - Generate test API keys from the sandbox environment
- Use test card numbers from the documentation
- Test all payment scenarios: success, failure, pending
- Verify webhook handling with test notifications
- Switch to
productionmode and use live API keys only when ready to go live
What happens if the SDK fails to load?
What happens 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
Can I save customer card details for future payments?
Can I save customer card details for future payments?
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.