Overview
The Dodo Payments Checkout SDK provides a seamless way to integrate our payment overlay into your web application. Built with TypeScript and modern web standards, it offers a robust solution for handling payments with real-time event handling and customizable themes.
Demo
Interactive Demo
See the overlay checkout in action with our live demo.
Quick Start
Get started with the Dodo Payments Checkout SDK in just a few lines of code:Step-by-Step Integration Guide
1
Install the SDK
Install the Dodo Payments Checkout SDK using your preferred package manager:
2
Initialize the SDK
Initialize the SDK in your application, typically in your main component or app entry point:
3
Create a Checkout Button Component
Create a component that opens the checkout overlay:
4
Add Checkout to Your Page
Use the checkout button component in your application:
5
Handle Success and Failure Pages
Create pages to handle checkout redirects:
6
Test Your Integration
- Start your development server:
- Test the checkout flow:
- Click the checkout button
- Verify the overlay appears
- Test the payment flow using test credentials
- Confirm redirects work correctly
You should see checkout events logged in your browser console.
7
Go Live
When you’re ready for production:
- Change the mode to
'live':
- Update your checkout URLs to use live checkout sessions from your backend
- Test the complete flow in production
- Monitor events and errors
API Reference
Configuration
Initialize Options
| Option | Type | Required | Description |
|---|---|---|---|
mode | "test" | "live" | Yes | Environment mode: 'test' for development, 'live' for production |
displayType | "overlay" | "inline" | No | Display type: 'overlay' for modal checkout (default), 'inline' for embedded checkout |
onEvent | function | Yes | Callback function for handling checkout events |
Checkout Options
| Option | Type | Required | Description |
|---|---|---|---|
checkoutUrl | string | Yes | Checkout session URL from the create checkout session API |
options.showTimer | boolean | No | Show or hide the checkout timer. Defaults to true. When disabled, you will receive the checkout.link_expired event when the session expires. |
options.showSecurityBadge | boolean | No | Show or hide the security badge. Defaults to true. |
options.manualRedirect | boolean | No | When enabled, the checkout will not automatically redirect after completion. Instead, you will receive checkout.status and checkout.redirect_requested events to handle the redirect yourself. |
Methods
Open Checkout
Opens the checkout overlay with the specified checkout session URL.manualRedirect, handle the checkout completion in your onEvent callback:
Close Checkout
Programmatically closes the checkout overlay.Check Status
Returns whether the checkout overlay is currently open.Events
The SDK provides real-time events that you can listen to through theonEvent callback:
Checkout Status Event Data
WhenmanualRedirect is enabled, you receive the checkout.status event with the following data:
Checkout Redirect Requested Event Data
WhenmanualRedirect is enabled, you receive the checkout.redirect_requested event with the following data:
| Event Type | Description |
|---|---|
checkout.opened | Checkout overlay has been opened |
checkout.payment_page_opened | Payment page has been displayed |
checkout.customer_details_submitted | Customer and billing details have been submitted |
checkout.closed | Checkout overlay has been closed |
checkout.redirect | Checkout will perform a redirect |
checkout.error | An error occurred during checkout |
checkout.link_expired | Fired when the checkout session expires. Only received when showTimer is set to false. |
checkout.status | Fired when manualRedirect is enabled. Contains the checkout status (succeeded, failed, or processing). |
checkout.redirect_requested | Fired when manualRedirect is enabled. Contains the URL to redirect the customer to. |
Implementation Options
Package Manager Installation
Install via npm, yarn, or pnpm as shown in the Step-by-Step Integration Guide.CDN Implementation
For quick integration without a build step, you can use our CDN:Theme Customization
You can customize the checkout appearance by passing athemeConfig object in the options parameter when opening checkout. The theme configuration supports both light and dark modes, allowing you to customize colors, borders, text, buttons, and border radius.
Basic Theme Configuration
Complete Theme Configuration
All available theme properties:Light Mode Only
If you only want to customize the light theme:Dark Mode Only
If you only want to customize the dark theme:Partial Theme Override
You can override only specific properties. The checkout will use default values for properties you don’t specify:Theme Configuration with Other Options
You can combine theme configuration with other checkout options:TypeScript Types
For TypeScript users, all theme configuration types are exported:Error Handling
The SDK provides detailed error information through the event system. Always implement proper error handling in youronEvent callback:
Best Practices
- Initialize once: Initialize the SDK once when your application loads, not on every checkout attempt
- Error handling: Always implement proper error handling in your event callback
- Test mode: Use
testmode during development and switch toliveonly when ready for production - Event handling: Handle all relevant events for a complete user experience
- Valid URLs: Always use valid checkout URLs from the create checkout session API
- TypeScript: Use TypeScript for better type safety and developer experience
- Loading states: Show loading states while the checkout is opening to improve UX
- Manual redirects: Use
manualRedirectwhen you need custom control over post-checkout navigation - Timer management: Disable the timer (
showTimer: false) if you want to handle session expiration manually
Troubleshooting
Checkout not opening
Checkout not opening
Possible causes:
- SDK not initialized before calling
open() - Invalid checkout URL
- JavaScript errors in console
- Network connectivity issues
- Verify SDK initialization happens before opening checkout
- Check for console errors
- Ensure checkout URL is valid and from the create checkout session API
- Verify network connectivity
Events not firing
Events not firing
Possible causes:
- Event handler not properly set up
- JavaScript errors preventing event propagation
- SDK not initialized correctly
- Confirm event handler is properly configured in
Initialize() - Check browser console for JavaScript errors
- Verify SDK initialization completed successfully
- Test with a simple event handler first
Styling issues
Styling issues
Possible causes:
- CSS conflicts with your application styles
- Theme settings not applied correctly
- Responsive design issues
- Check for CSS conflicts in browser DevTools
- Verify theme settings are correct
- Test on different screen sizes
- Ensure no z-index conflicts with overlay
Enabling Apple Pay
Apple Pay allows customers to complete payments quickly and securely using their saved payment methods. When enabled, customers can launch the Apple Pay modal directly from the checkout overlay on supported devices.Apple Pay is supported on iOS 17+, iPadOS 17+, and Safari 17+ on macOS.
1
Download and upload the Apple Pay domain association file
Download the Apple Pay domain association file.Upload the file to your web server at
/.well-known/apple-developer-merchantid-domain-association. For example, if your website is example.com, make the file available at https://example.com/well-known/apple-developer-merchantid-domain-association.2
Request Apple Pay activation
Email [email protected] with the following information:
- Your production domain URL (e.g.,
https://example.com) - Request to enable Apple Pay for your domain
You’ll receive confirmation within 1-2 working days once Apple Pay has been enabled for your domain.
3
Verify Apple Pay availability
After receiving confirmation, test Apple Pay in your checkout:
- Open your checkout on a supported device (iOS 17+, iPadOS 17+, or Safari 17+ on macOS)
- Verify that the Apple Pay button appears as a payment option
- Test the complete payment flow
Browser Support
The Dodo Payments Checkout SDK supports the following browsers:- Chrome (latest)
- Firefox (latest)
- Safari (latest)
- Edge (latest)
- IE11+
Overlay vs Inline Checkout
Choose the right checkout type for your use case:| Feature | Overlay Checkout | Inline Checkout |
|---|---|---|
| Integration depth | Modal on top of page | Fully embedded in page |
| Layout control | Limited | Full control |
| Branding | Separate from page | Seamless |
| Implementation effort | Lower | Higher |
| Best for | Quick integration, existing pages | Custom checkout pages, high-conversion flows |
Related Resources
Inline Checkout
Embed checkout directly into your page for fully integrated experiences.
Checkout Sessions API
Create checkout sessions to power your checkout experiences.
Webhooks
Handle payment events server-side with webhooks.
Integration Guide
Complete guide to integrating Dodo Payments.