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.
Resources
Installation
Quick Start
Configuration
Initialize Options
Option | Type | Required | Description |
---|---|---|---|
mode | string | Yes | Environment mode: ‘test’ or ‘live’ |
onEvent | function | Yes | Callback function for handling checkout events |
Checkout Options
Option | Type | Required | Description |
---|---|---|---|
checkoutUrl | string | Yes | Checkout session URL from create checkout session API |
Event Handling
The SDK provides real-time events that you can listen to:Methods
Open Checkout
Close Checkout
Check Status
Browser Support
- Chrome (latest)
- Firefox (latest)
- Safari (latest)
- Edge (latest)
- IE11+
Note: Apple Pay is not currently supported in the overlay checkout experience. We plan to add support for Apple Pay in a future release.
CDN Implementation
For quick integration, 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.Error Handling
The SDK provides detailed error information through the event system. Always implement proper error handling in youronEvent
callback:
Best Practices
- Always initialize the SDK before attempting to open the checkout
- Implement proper error handling in your event callback
- Use the test mode during development
- Handle all relevant events for a complete user experience
- Use valid checkout URLs from the create checkout session API
- Use TypeScript for better type safety and developer experience
Step-by-Step Guide
1. Project Setup
First, ensure you have a modern JavaScript/TypeScript project. We recommend using Next.js, React, or Vue.js.2. Install the SDK
Install the Dodo Payments Checkout SDK using your preferred package manager:3. Basic Implementation
Create a new component for your checkout button:4. Add to Your Page
Use the checkout button in your page:5. Handle Success and Failure
Create success and failure pages:6. Testing 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
7. Going Live
When you’re ready to go live:- Change the mode to ‘live’:
- Update your checkout URLs to use live checkout sessions
- Test the complete flow in production
- Monitor events and errors
Common Issues and Solutions
-
Checkout not opening
- Verify SDK initialization
- Check for console errors
- Ensure checkout URL is valid and from create checkout session API
-
Events not firing
- Confirm event handler is properly set up
- Check for JavaScript errors
- Verify network connectivity
-
Styling issues
- Ensure no CSS conflicts
- Check theme settings
- Verify responsive design