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 |
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 |
Methods
Open Checkout
Opens the checkout overlay with the specified checkout session URL.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:
| 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 |
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:TypeScript Support
The SDK is written in TypeScript and includes comprehensive type definitions. All public APIs are fully typed for better developer experience and IntelliSense support.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
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
Browser Support
The Dodo Payments Checkout SDK supports the following browsers:- Chrome (latest)
- Firefox (latest)
- Safari (latest)
- Edge (latest)
- IE11+
Apple Pay is not currently supported in the overlay checkout experience. We plan to add support for Apple Pay in a future release.