react-native-onepay-sdk
v1.1.5
Published
onepay
Maintainers
Readme
📲 react-native-onepay
react-native-onepay is a native React Native module built to integrate the OnePay payment gateway in Android apps using a unified SDK. This library provides a seamless interface to create orders, process payments, and fetch transaction details—all directly from your React Native app.
🚀 Features
- 🔐 Easy OnePay SDK initialization
- 🧾 Order creation with customer details
- 💳 Payment processing with secure flow
- 📊 Fetch transaction details for completed payments
- ⚙️ Built with TurboModules for maximum performance
📦 Installation
Step 1: Install the Package
Using Yarn:
yarn add react-native-onepay
Or using npm:
```bash
npm install react-native-onepay
```
### Step 2: Configure Native Modules
Since this is a native module, you must **rebuild the app**:
```bash
npx react-native run-android
```
> iOS support is not available in this version.
---
## 🧑💻 Usage
### 1. Import the SDK
```ts
import {
initialize,
createOrder,
processPayment,
getTransactionDetails,
} from 'react-native-onepay';
```
---
### 2. Initialize SDK
```ts
await initialize('your-api-key', 'your-secret-key', 'TEST'); // or 'LIVE'
```
- `apiKey`: Provided by OnePay
- `secret`: Provided by OnePay
- `environment`: `"TEST"` or `"LIVE"`
---
### 3. Create Order
```ts
const order = await createOrder({
amount: 100,
name: 'John Doe',
phone: '9876543210',
email: '[email protected]',
});
```
Returns:
```ts
{
id: string;
amount: number;
name: string;
phone: string;
email: string;
}
```
---
### 4. Process Payment
```ts
await processPayment(order.id);
```
Launches the native OnePay payment flow.
---
### 5. Get Transaction Details
```ts
const transaction = await getTransactionDetails(order.id);
```
Returns:
```ts
{
id: string;
orderId: string;
paymentStatus: string;
customerPhone: string;
customerName: string;
customerEmail: string;
createdAt: string;
amount: number;
}
```
---
## ✅ TypeScript Support
This library is written in TypeScript and includes types out-of-the-box.
---
## ⚠️ Requirements
- **React Native 0.65+**
- **Android Only**
- Native Android app must use `OnePay` SDK provided by Parish Softwares
---
## 📄 License
MIT © [Parish Softwares Private Limited](https://parishsoftwares.com)
---
## 🤝 Need Help?
If you need support integrating or using the SDK, please contact [[email protected]](mailto:[email protected]).
```