A React Native plugin for integrating Zoho Payments with support for both Android and iOS platforms. This plugin provides a seamless way to accept payments in your React Native applications using Zoho Payments SDK.
π Quick Setup Guide | π§ Troubleshooting | π¬ Report Issue
- β Support for both Android and iOS
- β Multiple payment methods (Cards, Net Banking, UPI)
- β Easy-to-use JavaScript API
- β Promise-based async operations
- β Comprehensive error handling
- β TypeScript type definitions (coming soon)
π₯ Quick Fix for Android Build Errors: If you encounter
package com.zoho.payment.checkout does not exist, you need to addmaven { url 'https://maven.zohodl.com' }to your project'sandroid/build.gradle. See Android Setup section below or the TROUBLESHOOTING.md guide.
- Minimum SDK: Android 8 (API level 26)
- Zoho Payments SDK 1.0.0
- Minimum iOS version: 13.0
- Zoho Payments iOS SDK 1.0.0
- React Native 0.60+
Install the package using npm or yarn:
npm install react-native-zoho-paymentsor
yarn add react-native-zoho-payments- Navigate to your iOS directory and install CocoaPods dependencies:
cd ios
pod install
cd ..- Ensure your
Podfilehas the minimum iOS version set to 13.0:
platform :ios, '13.0'- IMPORTANT: Add the Zoho Maven repository to your project-level
android/build.gradlefile:
allprojects {
repositories {
google()
mavenCentral()
maven { url 'https://maven.zohodl.com' } // Add this line
}
}For React Native 0.73+ using settings.gradle:
dependencyResolutionManagement {
repositories {
google()
mavenCentral()
maven { url 'https://maven.zohodl.com' } // Add this line
}
}- Ensure your
android/build.gradlehas the minimum SDK version:
buildscript {
ext {
minSdkVersion = 26 // Must be 26 or higher
}
}- Make sure you have internet permission in your
AndroidManifest.xml(usually already present):
<uses-permission android:name="android.permission.INTERNET" />- After adding the repository, clean and rebuild:
cd android
./gradlew clean
cd ..
npx react-native run-android
β οΈ Common Issue: If you get "package com.zoho.payment.checkout does not exist" error, see the TROUBLESHOOTING.md guide.
import { ZohoPayments, PaymentMethod } from 'react-native-zoho-payments';Initialize the Zoho Payments SDK with your API credentials. This should be done once when your app starts:
import { useEffect } from 'react';
useEffect(() => {
initializeZohoPayments();
}, []);
const initializeZohoPayments = async () => {
try {
await ZohoPayments.initialize('YOUR_API_KEY', 'YOUR_ACCOUNT_ID');
console.log('Zoho Payments initialized successfully');
} catch (error) {
console.error('Failed to initialize Zoho Payments:', error);
}
};Important: Payment session must be created from your backend server by calling the Zoho Payments API. Never create payment sessions directly from your mobile app for security reasons.
Backend API call example:
POST https://payments.zoho.in/api/v1/paymentsession
Content-Type: application/json
Authorization: Zoho-oauthtoken YOUR_ACCESS_TOKEN
{
"amount": 1000,
"currency": "INR",
"customer": {
"name": "John Doe",
"email": "john@example.com",
"phone": "9876543210"
}
}See Zoho Payments API Documentation for complete API reference.
Once you have the payment session ID from your backend, show the checkout widget:
const handlePayment = async () => {
try {
const result = await ZohoPayments.showCheckout({
paymentSessionId: 'session_id_from_backend',
description: 'Payment for Order #123',
invoiceNumber: 'INV-001',
referenceNumber: 'REF-001',
name: 'John Doe',
email: 'john@example.com',
phone: '9876543210',
paymentMethod: PaymentMethod.UPI, // Optional: pre-select payment method
});
// Payment successful
console.log('Payment successful:', result);
console.log('Payment ID:', result.paymentId);
console.log('Signature:', result.signature);
// Verify the payment on your backend
await verifyPaymentOnBackend(result.paymentId, result.signature);
} catch (error) {
// Payment failed or was cancelled
console.error('Payment failed:', error.message);
}
};Always verify the payment status on your backend server using the Payment Retrieve API:
GET https://payments.zoho.in/api/v1/payment/{paymentId}
Authorization: Zoho-oauthtoken YOUR_ACCESS_TOKENInitialize the Zoho Payments SDK.
Parameters:
apiKey(string, required): Your Zoho Payments API keyaccountId(string, required): Your Zoho Payments account ID
Returns: Promise<void>
Example:
await ZohoPayments.initialize('your_api_key', 'your_account_id');Show the Zoho Payments checkout widget.
Parameters:
options(object, required):paymentSessionId(string, required): Payment session ID obtained from backenddescription(string, optional): Description of the payment (max 500 characters)invoiceNumber(string, optional): Invoice number (max 50 characters)referenceNumber(string, optional): Reference number for the paymentname(string, optional): Customer nameemail(string, optional): Customer email addressphone(string, optional): Customer phone numberpaymentMethod(string, optional): Pre-selected payment method (see PaymentMethod enum)
Returns: Promise<PaymentResult>
PaymentResult Object:
{
paymentId: string, // Unique payment identifier
signature: string, // Payment signature for verification
status: 'success' // Payment status
}Throws: Error if payment fails or is cancelled
Example:
const result = await ZohoPayments.showCheckout({
paymentSessionId: 'session_id',
description: 'Premium subscription',
name: 'Jane Smith',
email: 'jane@example.com',
phone: '9876543210',
paymentMethod: PaymentMethod.CARD,
});Available payment methods:
PaymentMethod.CARD- Credit/Debit cardsPaymentMethod.NET_BANKING- Net bankingPaymentMethod.UPI- UPI payments
Example:
import { PaymentMethod } from 'react-native-zoho-payments';
// Use in showCheckout
await ZohoPayments.showCheckout({
// ... other options
paymentMethod: PaymentMethod.UPI,
});Here's a complete example of integrating Zoho Payments in your React Native app:
import React, { useState, useEffect } from 'react';
import { View, Button, Alert } from 'react-native';
import { ZohoPayments, PaymentMethod } from 'react-native-zoho-payments';
const PaymentScreen = () => {
const [isInitialized, setIsInitialized] = useState(false);
useEffect(() => {
initializeSDK();
}, []);
const initializeSDK = async () => {
try {
await ZohoPayments.initialize(
'your_api_key',
'your_account_id'
);
setIsInitialized(true);
} catch (error) {
Alert.alert('Error', 'Failed to initialize payment SDK');
}
};
const createPaymentSession = async () => {
// Call your backend API to create a payment session
const response = await fetch('https://your-backend.com/api/create-payment', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
amount: 1000,
currency: 'INR',
}),
});
const data = await response.json();
return data.paymentSessionId;
};
const handlePayment = async () => {
if (!isInitialized) {
Alert.alert('Error', 'SDK not initialized');
return;
}
try {
// Step 1: Get payment session from backend
const paymentSessionId = await createPaymentSession();
// Step 2: Show checkout
const result = await ZohoPayments.showCheckout({
paymentSessionId: paymentSessionId,
description: 'Product purchase',
name: 'Customer Name',
email: 'customer@example.com',
phone: '9876543210',
paymentMethod: PaymentMethod.UPI,
});
// Step 3: Verify on backend
await verifyPayment(result.paymentId, result.signature);
Alert.alert('Success', `Payment completed! ID: ${result.paymentId}`);
} catch (error) {
Alert.alert('Payment Failed', error.message);
}
};
const verifyPayment = async (paymentId, signature) => {
// Verify payment on your backend
await fetch('https://your-backend.com/api/verify-payment', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ paymentId, signature }),
});
};
return (
<View style={{ padding: 20 }}>
<Button
title="Pay Now"
onPress={handlePayment}
disabled={!isInitialized}
/>
</View>
);
};
export default PaymentScreen;The plugin throws errors with descriptive messages. Always wrap payment calls in try-catch blocks:
try {
await ZohoPayments.showCheckout(options);
} catch (error) {
switch (error.message) {
case 'PAYMENT_FAILED':
// Handle payment failure
break;
case 'ACTIVITY_ERROR':
// Android: Activity not available
break;
case 'VIEW_CONTROLLER_ERROR':
// iOS: View controller not available
break;
default:
// Handle other errors
console.error('Payment error:', error.message);
}
}- Never expose API keys in client code: Store them securely on your backend
- Create payment sessions on backend: Always create payment sessions from your secure server
- Verify signatures: Always verify payment signatures on your backend after successful payment
- Use HTTPS: Ensure all API calls to your backend use HTTPS
- Validate on server: Never trust client-side payment status alone; always verify with Zoho Payments API
Error: package com.zoho.payment.checkout does not exist
Solution: This is the most common issue. You MUST add the Zoho Maven repository to your project's android/build.gradle:
allprojects {
repositories {
maven { url 'https://maven.zohodl.com' } // Required!
}
}Then clean and rebuild:
cd android && ./gradlew clean && cd .. && npx react-native run-androidπ For detailed troubleshooting, see TROUBLESHOOTING.md
Issue: SDK initialization fails
Solution: Ensure the Zoho Payments Maven repository is accessible:
maven { url 'https://maven.zohodl.com' }Issue: Build fails with dependency conflicts
Solution: Check that your minSdkVersion is at least 26.
Issue: Pod install fails
Solution: Try the following:
cd ios
rm -rf Pods Podfile.lock
pod installIssue: Module not found
Solution: Clean and rebuild:
cd ios
xcodebuild clean
cd ..
npx react-native run-iosIssue: Payment widget doesn't show
Solution:
- Ensure SDK is initialized before calling
showCheckout() - Verify the payment session ID is valid
- Check that the current activity/view controller is available
Issue: "Another checkout is already in progress"
Solution: Only one checkout can be active at a time. Wait for the previous checkout to complete or fail.
A complete example app demonstrating the integration is available in the /example directory.
To run the example:
cd example
# Install dependencies
npm install
# Run on Android
npm run android
# Run on iOS
cd ios
pod install
cd ..
npm run iosContributions are welcome! Please feel free to submit a Pull Request.
- Zoho Payments Documentation
- Zoho Payments Android Integration
- Zoho Payments iOS Integration
- Zoho Payments API Reference
For issues related to:
- This plugin: Open an issue on GitHub
- Zoho Payments SDK: Contact Zoho Support at support@zohopayments.com or call 1800 309 8845 (India)
- Zoho Payments API: Refer to Zoho Payments API Documentation
MIT
This is an unofficial React Native plugin for Zoho Payments. It is not officially maintained or supported by Zoho Corporation. Use at your own discretion.
- Initial release
- Support for Android and iOS
- Support for Card, Net Banking, and UPI payment methods
- Promise-based API
- Example app included