A demonstration application showcasing two payment integration methods with Dodo Payments in React Native:
- React Native SDK - Native payment sheet with full customization
- Payment Link (InAppBrowser) - Hosted checkout page in browser
- π¦ Install our SDK from NPM
- π Read our Integration Guide for detailed documentation.
- π₯ Watch our demo video to see the Dodo Payments SDK in action.
- π Two Payment Flows: Switch between SDK and Payment Link methods
- π Secure payment processing with PCI compliance
- π³ Support for multiple payment methods
- π± Native UI components for Android and iOS
- π¨ Customizable payment interface
- π Light and dark mode support
- π Deep linking for payment callbacks
- Node.js (v14 or higher)
- React Native development environment setup
- iOS: Xcode and CocoaPods
- Android: Android Studio and Android SDK
- Dodo Payments account and API keys
- Clone the repository:
git clone https://github.com/dodopayments/dodopayments-react-native-demo.git
cd dodopaymentdemoapp- Install dependencies:
npm install
# or
yarn install- Install iOS dependencies:
cd ios && pod install && cd ..- Navigate to the server directory and create
.envfile:
cd server
cp .env.example .env-
Get your credentials from Dodo Payments Dashboard:
- API Key: https://app.dodopayments.com/developer/api-keys
- Publishable Key: https://app.dodopayments.com/developer/others
- Product ID: https://app.dodopayments.com/products
-
Edit
server/.envwith your credentials:
DODOPAYMENTS_TEST_API_KEY=key_test_your_api_key_here
DODO_PUBLISHABLE_KEY=pk_test_your_publishable_key_here
DODO_PRODUCT_ID=pdt_your_product_id_here- Install server dependencies and start:
npm install
npm startServer will run on http://localhost:5252
- Update
App.tsxwith your publishable key (line 9):
const PUBLISHABLE_KEY = 'pk_test_your_publishable_key_here';- Configure network settings in
src/config.tsbased on your device:
For Android Emulator:
export const IS_ANDROID_EMULATOR = true;For Physical Device:
export const IS_ANDROID_EMULATOR = false;
export const YOUR_COMPUTER_IP = '192.168.1.100'; // Your computer's IPImportant: Start the backend server first!
- Start Backend Server (in
server/directory):
cd server
npm start- Start Metro Bundler (in root directory):
npm start- Launch App:
npm run iosnpm run androidThe app features a bottom tab bar with two payment methods:
- Native payment sheet
- Fully customizable UI
- Processes payment via React Native SDK
- Best for production apps
- Opens hosted checkout in InAppBrowser
- Quick integration, no SDK setup needed
- Good for testing or fallback option
- Returns to app via deep linking
dodopayments-react-native-demo/
βββ src/
β βββ Components/ # Reusable UI components
β β βββ PaymentContent.tsx # Shared payment UI
β β βββ BottomTabBar.tsx # Tab navigation
β β βββ ...
β βββ constants/ # Shared constants & data
β β βββ mockData.ts # Product data & calculations
β βββ utils/ # Utility functions
β βββ PaymentScreen.tsx # SDK payment flow
β βββ PaymentLinkScreen.tsx # InAppBrowser flow
β βββ config.ts # Network configuration
βββ server/ # Backend server
β βββ server.js # Express API server
β βββ .env.example # Environment template
β βββ package.json
βββ ios/ # iOS native code
βββ android/ # Android native code
βββ App.tsx # Main app entry
Wrap your app with the DodoPaymentProvider:
import {DodoPaymentProvider} from 'dodopayments-sdk-react-native';
function App() {
return (
<DodoPaymentProvider publishableKey={process.env.DODO_PUBLISHABLE_KEY}>
<PaymentScreen />
</DodoPaymentProvider>
);
}import { useCheckout } from 'dodopayments-sdk-react-native';
const PaymentScreen = () => {
const { initPaymentSession, presentPaymentSheet } = useCheckout();
const handlePayment = async () => {
try {
const { clientSecret } = await fetchPaymentParams();
const params = await initPaymentSession({ clientSecret });
const result = await presentPaymentSheet(params);
if (result?.status === 'succeeded') {
// Handle successful payment
}
} catch (error) {
// Handle error
}
};
return (
// Your payment UI
);
};const appearance = {
colors: {
light: {
primary: '#F8F8F2',
background: '#ffffff',
// ... other colors
},
dark: {
primary: '#00ff0099',
background: '#ff0000',
// ... other colors
},
},
shapes: {
borderRadius: 10,
borderWidth: 1,
},
};Use test card numbers in development:
- Test Card Number: 4242 4242 4242 4242
- Expiry: Any future date
- CVC: Any 3 digits
const handlePaymentResult = paymentSheetResponse => {
switch (paymentSheetResponse?.status) {
case 'cancelled':
// Handle cancellation
break;
case 'succeeded':
// Handle success
break;
case 'failed':
// Handle failure
break;
}
};- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
For support, email support@dodopayments.com or visit our documentation.