react-native-kalapa-zalo-miniapp-ekyc
v1.0.7
Published
React Native SDK for Kalapa eKYC integration
Downloads
3
Readme
react-native-kalapa-ekyc
React Native SDK for Kalapa eKYC integration, providing a seamless way to implement eKYC functionality in your React Native applications.
Installation
Using npm:
npm install react-native-kalapa-ekycUsing yarn:
yarn add react-native-kalapa-ekyciOS Setup
Add the following to your Podfile:
pod 'react-native-kalapa-ekyc', :path => '../node_modules/react-native-kalapa-ekyc'Then run:
cd ios && pod installBasic Usage
import KalapaEkyc from 'react-native-kalapa-ekyc';
// Initialize the SDK
const ekyc = new KalapaEkyc({
clientId: 'YOUR_CLIENT_ID',
clientSecret: 'YOUR_CLIENT_SECRET',
environment: 'sandbox' // or 'production'
});
// Start eKYC flow
try {
const result = await ekyc.startEkyc();
console.log('eKYC Result:', result);
} catch (error) {
console.error('eKYC Error:', error);
}WebView Integration
The SDK provides a WebView-based implementation:
import { WebViewScreen } from 'react-native-kalapa-ekyc';
// In your navigation/component
<WebViewScreen
clientId="YOUR_CLIENT_ID"
clientSecret="YOUR_CLIENT_SECRET"
onComplete={(result) => {
console.log('WebView eKYC completed:', result);
}}
onError={(error) => {
console.error('WebView eKYC error:', error);
}}
/>API Reference
KalapaEkyc Class
Constructor Options
interface KalapaEkycOptions {
clientId: string;
clientSecret: string;
environment: 'sandbox' | 'production';
timeout?: number;
language?: 'en' | 'vi';
}Methods
startEkyc(): Starts the eKYC flowgetSessionStatus(sessionId: string): Get status of an eKYC sessionvalidateSession(sessionId: string): Validate an eKYC session
WebViewScreen Component
Props
interface WebViewScreenProps {
clientId: string;
clientSecret: string;
onComplete: (result: EkycResult) => void;
onError: (error: Error) => void;
language?: 'en' | 'vi';
theme?: 'light' | 'dark';
}Response Types
interface EkycResult {
sessionId: string;
status: 'completed' | 'pending' | 'failed';
data?: {
idCard?: IdCardData;
face?: FaceData;
verification?: VerificationResult;
};
}
interface IdCardData {
type: string;
number: string;
name: string;
dob: string;
// ... other ID card fields
}Error Handling
The SDK throws typed errors that you can handle:
try {
await ekyc.startEkyc();
} catch (error) {
if (error instanceof KalapaEkycError) {
// Handle SDK-specific errors
console.error(error.code, error.message);
} else {
// Handle other errors
console.error(error);
}
}Configuration Options
| Option | Type | Description | Default | |--------|------|-------------|---------| | clientId | string | Your Kalapa client ID | Required | | clientSecret | string | Your Kalapa client secret | Required | | environment | string | 'sandbox' or 'production' | 'sandbox' | | timeout | number | Request timeout in ms | 30000 | | language | string | 'en' or 'vi' | 'en' |
Development
- Clone the repository
- Install dependencies:
yarn install- Run the example app:
yarn exampleContributing
See the contributing guide to learn how to contribute to the repository and the development workflow.
License
MIT
Support
For support, please contact [email protected] or visit our documentation.
