nimbbl-mobile-react-native-sdk 1.0.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +569 -0
- package/android/build.gradle +86 -0
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +6 -0
- package/android/gradle.properties +4 -0
- package/android/gradlew +185 -0
- package/android/gradlew.bat +89 -0
- package/android/settings.gradle +1 -0
- package/android/src/main/AndroidManifest.xml +19 -0
- package/android/src/main/java/com/nimbbl/reactnative/NimbblCheckoutActivity.kt +224 -0
- package/android/src/main/java/com/nimbbl/reactnative/NimbblReactNativeSDKModule.kt +428 -0
- package/android/src/main/java/com/nimbbl/reactnative/NimbblReactNativeSDKPackage.kt +16 -0
- package/android/src/main/java/com/nimbbl/reactnative/TestActivity.kt +28 -0
- package/index.tsx +8 -0
- package/ios/NimbblReactNativeSDK.m +20 -0
- package/ios/NimbblReactNativeSDK.podspec +38 -0
- package/ios/NimbblReactNativeSDK.swift +199 -0
- package/lib/NimbblSDK.d.ts +108 -0
- package/lib/NimbblSDK.d.ts.map +1 -0
- package/lib/NimbblSDK.js +256 -0
- package/lib/NimbblSDK.js.map +1 -0
- package/lib/__tests__/__mocks__/react-native.d.ts +26 -0
- package/lib/__tests__/__mocks__/react-native.d.ts.map +1 -0
- package/lib/__tests__/__mocks__/react-native.js +23 -0
- package/lib/__tests__/__mocks__/react-native.js.map +1 -0
- package/lib/__tests__/setup.d.ts +1 -0
- package/lib/__tests__/setup.d.ts.map +1 -0
- package/lib/__tests__/setup.js +4 -0
- package/lib/__tests__/setup.js.map +1 -0
- package/lib/constants.d.ts +35 -0
- package/lib/constants.d.ts.map +1 -0
- package/lib/constants.js +44 -0
- package/lib/constants.js.map +1 -0
- package/lib/index.d.ts +14 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +32 -0
- package/lib/index.js.map +1 -0
- package/lib/types.d.ts +100 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +8 -0
- package/lib/types.js.map +1 -0
- package/nimbbl-mobile-react-native-sdk.podspec +27 -0
- package/package.json +90 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Nimbbl Tech
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,569 @@
|
|
|
1
|
+
# Nimbbl React Native SDK
|
|
2
|
+
|
|
3
|
+
A comprehensive React Native SDK for integrating Nimbbl payment gateway into your mobile applications. This SDK provides a seamless bridge between React Native and native payment functionality.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 🚀 **Easy Integration** - Simple setup and initialization
|
|
8
|
+
- 💳 **Multiple Payment Methods** - Support for cards, UPI, netbanking, wallets, EMI, and cash
|
|
9
|
+
- 🌐 **WebView Integration** - Built-in payment webview with customization options
|
|
10
|
+
- 🔗 **Bridge Module** - Robust native bridge for communication
|
|
11
|
+
- 📱 **Cross Platform** - Support for both iOS and Android
|
|
12
|
+
- 🛡️ **Type Safety** - Comprehensive TypeScript definitions
|
|
13
|
+
- 📊 **Analytics** - Built-in analytics and logging
|
|
14
|
+
- 🔄 **Event Handling** - Real-time payment status updates
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
### Option 1: Install from npm (Recommended for production)
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install nimbbl-mobile-react-native-sdk
|
|
22
|
+
# or
|
|
23
|
+
yarn add nimbbl-mobile-react-native-sdk
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Option 2: Local Development Setup
|
|
27
|
+
|
|
28
|
+
For local development and testing of the SDK itself:
|
|
29
|
+
|
|
30
|
+
1. Clone this repository
|
|
31
|
+
2. Navigate to your React Native project
|
|
32
|
+
3. Install the local SDK:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
npm run link:local
|
|
36
|
+
# or manually:
|
|
37
|
+
npm install path/to/nimbbl_mobile_kit_react_native_sdk
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Switching Between Local and NPM
|
|
41
|
+
|
|
42
|
+
Use the provided scripts in your sample app:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
# Link to local development version
|
|
46
|
+
npm run link:local
|
|
47
|
+
|
|
48
|
+
# Link to published npm version
|
|
49
|
+
npm run link:npm
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Compatibility
|
|
53
|
+
|
|
54
|
+
### NPM Version Support
|
|
55
|
+
|
|
56
|
+
The Nimbbl React Native SDK is compatible with the following npm versions:
|
|
57
|
+
|
|
58
|
+
| NPM Version | Support Status | Notes |
|
|
59
|
+
|-------------|----------------|-------|
|
|
60
|
+
| `^1.0.0-alpha.0` | ✅ Supported | Initial alpha release |
|
|
61
|
+
| `^1.0.0-alpha.1` | ✅ Supported | Bug fixes and improvements |
|
|
62
|
+
| `^1.0.0-alpha.2` | ✅ Supported | Enhanced error handling |
|
|
63
|
+
| `^1.0.0-alpha.3` | ✅ Supported | Latest alpha release |
|
|
64
|
+
| `^1.0.0` | 🔄 Coming Soon | Stable release |
|
|
65
|
+
| `^1.1.0` | 🔄 Coming Soon | Feature updates |
|
|
66
|
+
| `^2.0.0` | 🔄 Coming Soon | Major version with breaking changes |
|
|
67
|
+
|
|
68
|
+
### React Native Version Support
|
|
69
|
+
|
|
70
|
+
| React Native Version | Support Status | Notes |
|
|
71
|
+
|----------------------|----------------|-------|
|
|
72
|
+
| `^0.70.0` | ✅ Supported | Minimum supported version |
|
|
73
|
+
| `^0.71.0` | ✅ Supported | Recommended version |
|
|
74
|
+
| `^0.72.0` | ✅ Supported | Recommended version |
|
|
75
|
+
| `^0.73.0` | ✅ Supported | Latest stable version |
|
|
76
|
+
| `^0.74.0` | ✅ Supported | Latest stable version |
|
|
77
|
+
| `^0.75.0` | ✅ Supported | Latest stable version |
|
|
78
|
+
| `^0.76.0` | ✅ Supported | Latest stable version |
|
|
79
|
+
|
|
80
|
+
### Node.js Version Support
|
|
81
|
+
|
|
82
|
+
| Node.js Version | Support Status | Notes |
|
|
83
|
+
|-----------------|----------------|-------|
|
|
84
|
+
| `^16.0.0` | ✅ Supported | Minimum supported version |
|
|
85
|
+
| `^18.0.0` | ✅ Supported | Recommended version |
|
|
86
|
+
| `^20.0.0` | ✅ Supported | Latest LTS version |
|
|
87
|
+
| `^21.0.0` | ✅ Supported | Latest stable version |
|
|
88
|
+
|
|
89
|
+
### Platform Support
|
|
90
|
+
|
|
91
|
+
| Platform | Support Status | Minimum Version |
|
|
92
|
+
|----------|----------------|-----------------|
|
|
93
|
+
| **Android** | ✅ Supported | API Level 21 (Android 5.0) |
|
|
94
|
+
| **iOS** | ✅ Supported | iOS 13.0+ |
|
|
95
|
+
|
|
96
|
+
### Breaking Changes
|
|
97
|
+
|
|
98
|
+
- **Alpha Releases**: Alpha versions may contain breaking changes between releases
|
|
99
|
+
- **Stable Releases**: Breaking changes will be clearly documented in release notes
|
|
100
|
+
- **Migration Guide**: Migration guides will be provided for major version updates
|
|
101
|
+
|
|
102
|
+
### Versioning Strategy
|
|
103
|
+
|
|
104
|
+
- **Alpha Releases** (`1.0.0-alpha.X`): For testing and early adoption
|
|
105
|
+
- **Beta Releases** (`1.0.0-beta.X`): For feature-complete testing
|
|
106
|
+
- **Release Candidates** (`1.0.0-rc.X`): For final testing before stable release
|
|
107
|
+
- **Stable Releases** (`1.0.0`, `1.1.0`, etc.): For production use
|
|
108
|
+
|
|
109
|
+
## Quick Start
|
|
110
|
+
|
|
111
|
+
### Import the SDK
|
|
112
|
+
|
|
113
|
+
The import statement depends on whether you're using the npm package or local development version:
|
|
114
|
+
|
|
115
|
+
**For npm package (production use):**
|
|
116
|
+
```javascript
|
|
117
|
+
import { NimbblSDK } from 'nimbbl-mobile-react-native-sdk';
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
**For local development:**
|
|
121
|
+
```javascript
|
|
122
|
+
import { NimbblSDK } from '../nimbbl_mobile_kit_react_native_sdk/src/index';
|
|
123
|
+
// or if you've linked it locally:
|
|
124
|
+
import { NimbblSDK } from 'nimbbl-react-native-sdk';
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### 1. Initialize the SDK
|
|
128
|
+
|
|
129
|
+
```javascript
|
|
130
|
+
import { NimbblSDK } from 'nimbbl-mobile-react-native-sdk';
|
|
131
|
+
|
|
132
|
+
const nimbblSDK = NimbblSDK.getSharedInstance();
|
|
133
|
+
|
|
134
|
+
// Initialize the SDK (no credentials required - matches iOS pattern)
|
|
135
|
+
await nimbblSDK.initialize({
|
|
136
|
+
environment: 'sandbox' // or 'production'
|
|
137
|
+
});
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### 2. Create an Order
|
|
141
|
+
|
|
142
|
+
```javascript
|
|
143
|
+
const orderData = {
|
|
144
|
+
currency: 'INR',
|
|
145
|
+
amount: '1000', // Amount as string
|
|
146
|
+
productId: '11', // Product ID for header customization
|
|
147
|
+
orderLineItems: true,
|
|
148
|
+
checkoutExperience: 'redirect',
|
|
149
|
+
paymentMode: '', // Leave empty for all payment modes
|
|
150
|
+
subPaymentMode: 'all banks', // or specific bank
|
|
151
|
+
user: {
|
|
152
|
+
email: 'john@example.com',
|
|
153
|
+
name: 'John Doe',
|
|
154
|
+
mobile_number: '9876543210'
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
const order = await nimbblSDK.createShopOrder(
|
|
159
|
+
orderData.currency,
|
|
160
|
+
orderData.amount,
|
|
161
|
+
orderData.productId,
|
|
162
|
+
orderData.orderLineItems,
|
|
163
|
+
orderData.checkoutExperience,
|
|
164
|
+
orderData.paymentMode,
|
|
165
|
+
orderData.subPaymentMode,
|
|
166
|
+
orderData.user
|
|
167
|
+
);
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### 3. Process Payment
|
|
171
|
+
|
|
172
|
+
```javascript
|
|
173
|
+
// Process payment using checkout method (matching iOS pattern)
|
|
174
|
+
const checkoutResult = await nimbblSDK.checkout({
|
|
175
|
+
orderToken: order.data.token,
|
|
176
|
+
paymentModeCode: '', // Leave empty for all payment modes
|
|
177
|
+
bankCode: '', // Leave empty for all banks
|
|
178
|
+
walletCode: '', // Leave empty for all wallets
|
|
179
|
+
paymentFlow: '' // Leave empty for default flow (or 'phonepe', 'collect', 'intent' for UPI)
|
|
180
|
+
});
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### 4. Handle Payment Status
|
|
184
|
+
|
|
185
|
+
The SDK automatically handles payment status through event listeners. You don't need to manually check status.
|
|
186
|
+
|
|
187
|
+
## API Reference
|
|
188
|
+
|
|
189
|
+
### NimbblSDK
|
|
190
|
+
|
|
191
|
+
The main SDK class that provides all payment functionality.
|
|
192
|
+
|
|
193
|
+
#### Methods
|
|
194
|
+
|
|
195
|
+
- `getSharedInstance()` - Get shared SDK instance (singleton pattern)
|
|
196
|
+
- `initialize(config)` - Initialize the SDK with configuration
|
|
197
|
+
- `createShopOrder(currency, amount, productId, orderLineItems, checkoutExperience, paymentMode, subPaymentMode, user)` - Create a new payment order
|
|
198
|
+
- `checkout(options)` - Process payment with order token
|
|
199
|
+
- `testNativeModule()` - Test native module availability
|
|
200
|
+
- `addEventListener(eventName, callback)` - Add event listener
|
|
201
|
+
- `removeEventListener(eventName, callback)` - Remove event listener
|
|
202
|
+
- `removeAllEventListeners()` - Remove all event listeners
|
|
203
|
+
|
|
204
|
+
### Event Handling
|
|
205
|
+
|
|
206
|
+
```javascript
|
|
207
|
+
import { NimbblSDK, EVENTS } from 'nimbbl-react-native-sdk';
|
|
208
|
+
|
|
209
|
+
const nimbblSDK = NimbblSDK.getSharedInstance();
|
|
210
|
+
|
|
211
|
+
// Listen for payment events
|
|
212
|
+
nimbblSDK.addEventListener(EVENTS.PAYMENT_SUCCESS, (data) => {
|
|
213
|
+
console.log('Payment successful:', data);
|
|
214
|
+
// Handle success - navigate to success screen
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
nimbblSDK.addEventListener(EVENTS.PAYMENT_FAILED, (data) => {
|
|
218
|
+
console.log('Payment failed:', data);
|
|
219
|
+
// Handle failure - show error message
|
|
220
|
+
});
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
## Configuration
|
|
224
|
+
|
|
225
|
+
### SDK Configuration
|
|
226
|
+
|
|
227
|
+
```javascript
|
|
228
|
+
const config = {
|
|
229
|
+
environment: 'sandbox', // 'sandbox' or 'production'
|
|
230
|
+
options: {
|
|
231
|
+
timeout: 30000,
|
|
232
|
+
enable_logging: true,
|
|
233
|
+
enable_analytics: true,
|
|
234
|
+
api_base_url: 'https://api.nimbbl.tech/' // Optional: override default URL
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
## Constants
|
|
240
|
+
|
|
241
|
+
The SDK provides various constants for better development experience:
|
|
242
|
+
|
|
243
|
+
```javascript
|
|
244
|
+
import {
|
|
245
|
+
EVENTS,
|
|
246
|
+
ENVIRONMENTS,
|
|
247
|
+
ERROR_CODES,
|
|
248
|
+
ERROR_MESSAGES,
|
|
249
|
+
DEFAULT_CONFIG,
|
|
250
|
+
SDK_VERSION
|
|
251
|
+
} from 'nimbbl-react-native-sdk';
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
## Error Handling
|
|
255
|
+
|
|
256
|
+
```javascript
|
|
257
|
+
try {
|
|
258
|
+
const order = await nimbblSDK.createShopOrder(
|
|
259
|
+
'INR', '1000', '11', true, 'redirect', '', 'all banks',
|
|
260
|
+
{ email: 'john@example.com', name: 'John Doe', mobile_number: '9876543210' }
|
|
261
|
+
);
|
|
262
|
+
} catch (error) {
|
|
263
|
+
console.error('Error creating order:', error.message);
|
|
264
|
+
|
|
265
|
+
// Check error codes
|
|
266
|
+
if (error.code === ERROR_CODES.INVALID_AMOUNT) {
|
|
267
|
+
// Handle invalid amount error
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
## Platform Setup
|
|
273
|
+
|
|
274
|
+
### iOS
|
|
275
|
+
|
|
276
|
+
1. Install pods:
|
|
277
|
+
```bash
|
|
278
|
+
cd ios && pod install
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
2. Add to your `Info.plist`:
|
|
282
|
+
```xml
|
|
283
|
+
<key>NSAppTransportSecurity</key>
|
|
284
|
+
<dict>
|
|
285
|
+
<key>NSAllowsArbitraryLoads</key>
|
|
286
|
+
<true/>
|
|
287
|
+
</dict>
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
**Note:** The iOS implementation is written in Swift for modern, type-safe development.
|
|
291
|
+
|
|
292
|
+
### Android
|
|
293
|
+
|
|
294
|
+
1. Add to your `android/app/build.gradle`:
|
|
295
|
+
```gradle
|
|
296
|
+
android {
|
|
297
|
+
defaultConfig {
|
|
298
|
+
minSdkVersion 21
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
2. Add to your `android/app/src/main/AndroidManifest.xml`:
|
|
304
|
+
```xml
|
|
305
|
+
<uses-permission android:name="android.permission.INTERNET" />
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
**Note:** The Android implementation is written in Kotlin for modern, type-safe development.
|
|
309
|
+
|
|
310
|
+
## Examples
|
|
311
|
+
|
|
312
|
+
### Complete Payment Flow
|
|
313
|
+
|
|
314
|
+
```javascript
|
|
315
|
+
import { NimbblSDK, EVENTS } from 'nimbbl-react-native-sdk';
|
|
316
|
+
|
|
317
|
+
class PaymentManager {
|
|
318
|
+
constructor() {
|
|
319
|
+
this.nimbblSDK = NimbblSDK.getSharedInstance();
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
async initialize() {
|
|
323
|
+
await this.nimbblSDK.initialize({
|
|
324
|
+
environment: 'sandbox'
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
setupEventListeners() {
|
|
329
|
+
this.nimbblSDK.addEventListener(EVENTS.PAYMENT_SUCCESS, (data) => {
|
|
330
|
+
console.log('Payment successful:', data);
|
|
331
|
+
// Navigate to success screen
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
this.nimbblSDK.addEventListener(EVENTS.PAYMENT_FAILED, (data) => {
|
|
335
|
+
console.log('Payment failed:', data);
|
|
336
|
+
// Show error message
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
async processPayment(amount, customerDetails) {
|
|
341
|
+
try {
|
|
342
|
+
// Create order
|
|
343
|
+
const order = await this.nimbblSDK.createShopOrder(
|
|
344
|
+
'INR',
|
|
345
|
+
amount.toString(),
|
|
346
|
+
'11',
|
|
347
|
+
true,
|
|
348
|
+
'redirect',
|
|
349
|
+
'',
|
|
350
|
+
'all banks',
|
|
351
|
+
customerDetails
|
|
352
|
+
);
|
|
353
|
+
|
|
354
|
+
// Process payment using the order token
|
|
355
|
+
const result = await this.nimbblSDK.checkout({
|
|
356
|
+
orderToken: order.data.token,
|
|
357
|
+
paymentModeCode: '',
|
|
358
|
+
bankCode: '',
|
|
359
|
+
walletCode: '',
|
|
360
|
+
paymentFlow: ''
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
return { success: true, order, result };
|
|
364
|
+
} catch (error) {
|
|
365
|
+
return { success: false, error: error.message };
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
## Development Workflow
|
|
372
|
+
|
|
373
|
+
### Setting up for local development
|
|
374
|
+
|
|
375
|
+
1. **Clone the repository:**
|
|
376
|
+
```bash
|
|
377
|
+
git clone https://github.com/nimbbl-tech/nimbbl_mobile_kit_react_native_sdk.git
|
|
378
|
+
cd nimbbl_mobile_kit_react_native_sdk
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
2. **Install dependencies:**
|
|
382
|
+
```bash
|
|
383
|
+
npm install
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
3. **Build the SDK:**
|
|
387
|
+
```bash
|
|
388
|
+
npm run build
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
4. **Link to sample app:**
|
|
392
|
+
```bash
|
|
393
|
+
npm run example:local
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
### Integration with Sample App
|
|
397
|
+
|
|
398
|
+
The SDK is integrated into the sample app through the `PaymentService` class. Here's how it works:
|
|
399
|
+
|
|
400
|
+
1. **Configuration**: Update `src/constants/config.ts` with your Nimbbl credentials
|
|
401
|
+
2. **Payment Processing**: The `PaymentService` uses the Nimbbl SDK to:
|
|
402
|
+
- Initialize the SDK with your credentials
|
|
403
|
+
- Create orders using `NimbblSDK.createShopOrder()`
|
|
404
|
+
- Process payments using `NimbblSDK.checkout()`
|
|
405
|
+
- Handle payment events through event listeners
|
|
406
|
+
|
|
407
|
+
3. **Usage Flow**:
|
|
408
|
+
- User fills order details in the sample app
|
|
409
|
+
- Clicks "Pay" button
|
|
410
|
+
- `PaymentService.processPayment()` is called
|
|
411
|
+
- SDK creates order and opens payment WebView
|
|
412
|
+
- Payment events are handled through event listeners
|
|
413
|
+
|
|
414
|
+
### Sample App Structure
|
|
415
|
+
|
|
416
|
+
```
|
|
417
|
+
nimbbl_react_native_sample_app/
|
|
418
|
+
├── src/
|
|
419
|
+
│ ├── services/
|
|
420
|
+
│ │ └── PaymentService.ts # Integrated with Nimbbl SDK
|
|
421
|
+
│ ├── constants/
|
|
422
|
+
│ │ └── config.ts # SDK configuration
|
|
423
|
+
│ ├── screens/
|
|
424
|
+
│ │ └── MainScreen.tsx # Main payment screen
|
|
425
|
+
│ └── hooks/
|
|
426
|
+
│ └── usePayment.ts # Payment hook using PaymentService
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
### Development Scripts
|
|
430
|
+
|
|
431
|
+
```bash
|
|
432
|
+
# Build the SDK
|
|
433
|
+
npm run build
|
|
434
|
+
|
|
435
|
+
# Build in watch mode (rebuilds on changes)
|
|
436
|
+
npm run dev
|
|
437
|
+
|
|
438
|
+
# Clean build artifacts
|
|
439
|
+
npm run clean
|
|
440
|
+
|
|
441
|
+
# Run linter
|
|
442
|
+
npm run lint
|
|
443
|
+
|
|
444
|
+
# Fix linting issues
|
|
445
|
+
npm run lint:fix
|
|
446
|
+
|
|
447
|
+
# Type checking
|
|
448
|
+
npm run type-check
|
|
449
|
+
|
|
450
|
+
# Link sample app to local SDK
|
|
451
|
+
npm run example:local
|
|
452
|
+
|
|
453
|
+
# Link sample app to npm SDK
|
|
454
|
+
npm run example:npm
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
### Testing Your Changes
|
|
458
|
+
|
|
459
|
+
1. Make changes to the SDK source code
|
|
460
|
+
2. Run `npm run build` to compile TypeScript
|
|
461
|
+
3. Test in the sample app
|
|
462
|
+
4. The sample app should automatically pick up your changes
|
|
463
|
+
|
|
464
|
+
### Publishing
|
|
465
|
+
|
|
466
|
+
1. Update version in `package.json`
|
|
467
|
+
2. Run `npm run build`
|
|
468
|
+
3. Run `npm publish`
|
|
469
|
+
|
|
470
|
+
## Contributing
|
|
471
|
+
|
|
472
|
+
1. Fork the repository
|
|
473
|
+
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
|
|
474
|
+
3. Make your changes and test with local development setup
|
|
475
|
+
4. Commit your changes (`git commit -m 'Add some amazing feature'`)
|
|
476
|
+
5. Push to the branch (`git push origin feature/amazing-feature`)
|
|
477
|
+
6. Open a Pull Request
|
|
478
|
+
|
|
479
|
+
## License
|
|
480
|
+
|
|
481
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
482
|
+
|
|
483
|
+
## Support
|
|
484
|
+
|
|
485
|
+
For support, email support@nimbbl.tech or join our Slack channel.
|
|
486
|
+
|
|
487
|
+
## Version Migration
|
|
488
|
+
|
|
489
|
+
### Upgrading Between Alpha Versions
|
|
490
|
+
|
|
491
|
+
When upgrading between alpha versions, check the changelog for breaking changes:
|
|
492
|
+
|
|
493
|
+
```bash
|
|
494
|
+
# Check current version
|
|
495
|
+
npm list nimbbl-mobile-react-native-sdk
|
|
496
|
+
|
|
497
|
+
# Upgrade to latest alpha
|
|
498
|
+
npm install nimbbl-mobile-react-native-sdk@latest
|
|
499
|
+
|
|
500
|
+
# Or upgrade to specific version
|
|
501
|
+
npm install nimbbl-mobile-react-native-sdk@1.0.0-alpha.3
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
### Migration from Alpha to Stable
|
|
505
|
+
|
|
506
|
+
When the stable version is released:
|
|
507
|
+
|
|
508
|
+
```bash
|
|
509
|
+
# Upgrade from alpha to stable
|
|
510
|
+
npm install nimbbl-mobile-react-native-sdk@^1.0.0
|
|
511
|
+
|
|
512
|
+
# Update your package.json
|
|
513
|
+
# Change from: "nimbbl-mobile-react-native-sdk": "^1.0.0-alpha.3"
|
|
514
|
+
# To: "nimbbl-mobile-react-native-sdk": "^1.0.0"
|
|
515
|
+
```
|
|
516
|
+
|
|
517
|
+
### Breaking Changes Migration
|
|
518
|
+
|
|
519
|
+
For major version updates (e.g., 1.x to 2.x):
|
|
520
|
+
|
|
521
|
+
1. Check the migration guide in the release notes
|
|
522
|
+
2. Update your code according to the breaking changes
|
|
523
|
+
3. Test thoroughly before deploying to production
|
|
524
|
+
|
|
525
|
+
### Version Locking
|
|
526
|
+
|
|
527
|
+
For production applications, consider locking to specific versions:
|
|
528
|
+
|
|
529
|
+
```json
|
|
530
|
+
{
|
|
531
|
+
"dependencies": {
|
|
532
|
+
"nimbbl-mobile-react-native-sdk": "1.0.0-alpha.3"
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
```
|
|
536
|
+
|
|
537
|
+
### Deprecation Policy
|
|
538
|
+
|
|
539
|
+
- **Alpha versions**: Features may be deprecated without notice
|
|
540
|
+
- **Stable versions**: Deprecated features will be marked with warnings for at least one minor version
|
|
541
|
+
- **Major versions**: Breaking changes will be clearly documented
|
|
542
|
+
|
|
543
|
+
## Changelog
|
|
544
|
+
|
|
545
|
+
### 1.0.0-alpha.3
|
|
546
|
+
- Updated package name to `nimbbl-mobile-react-native-sdk`
|
|
547
|
+
- Enhanced compatibility documentation
|
|
548
|
+
- Improved version migration guides
|
|
549
|
+
- Fixed package-lock.json tracking issues
|
|
550
|
+
|
|
551
|
+
### 1.0.0-alpha.2
|
|
552
|
+
- Enhanced error handling
|
|
553
|
+
- Improved event communication
|
|
554
|
+
- Fixed IntentReceiver leak
|
|
555
|
+
- Standardized Activity Result communication
|
|
556
|
+
|
|
557
|
+
### 1.0.0-alpha.1
|
|
558
|
+
- Bug fixes and improvements
|
|
559
|
+
- Enhanced WebView integration
|
|
560
|
+
- Improved TypeScript definitions
|
|
561
|
+
|
|
562
|
+
### 1.0.0-alpha.0
|
|
563
|
+
- Initial alpha release
|
|
564
|
+
- Core payment functionality
|
|
565
|
+
- WebView integration
|
|
566
|
+
- Bridge module
|
|
567
|
+
- Type definitions
|
|
568
|
+
- Comprehensive documentation
|
|
569
|
+
- Unified payment result screen
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
buildscript {
|
|
2
|
+
repositories {
|
|
3
|
+
google()
|
|
4
|
+
mavenCentral()
|
|
5
|
+
}
|
|
6
|
+
dependencies {
|
|
7
|
+
classpath 'com.android.tools.build:gradle:8.1.0'
|
|
8
|
+
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.0'
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
apply plugin: 'com.android.library'
|
|
13
|
+
apply plugin: 'org.jetbrains.kotlin.android'
|
|
14
|
+
apply plugin: 'maven-publish'
|
|
15
|
+
|
|
16
|
+
allprojects {
|
|
17
|
+
repositories {
|
|
18
|
+
google()
|
|
19
|
+
mavenCentral()
|
|
20
|
+
maven { url 'https://jitpack.io' }
|
|
21
|
+
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
|
|
22
|
+
maven { url "$rootDir/../node_modules/react-native/android" }
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
group = 'com.nimbbl.reactnative'
|
|
27
|
+
version = '1.0.0'
|
|
28
|
+
|
|
29
|
+
android {
|
|
30
|
+
namespace 'com.nimbbl.reactnative'
|
|
31
|
+
compileSdkVersion 36
|
|
32
|
+
buildToolsVersion "36.0.0"
|
|
33
|
+
|
|
34
|
+
defaultConfig {
|
|
35
|
+
minSdkVersion 24
|
|
36
|
+
targetSdkVersion 36
|
|
37
|
+
versionCode 1
|
|
38
|
+
versionName "1.0.0"
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
buildTypes {
|
|
42
|
+
release {
|
|
43
|
+
minifyEnabled false
|
|
44
|
+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
compileOptions {
|
|
49
|
+
sourceCompatibility JavaVersion.VERSION_17
|
|
50
|
+
targetCompatibility JavaVersion.VERSION_17
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
kotlinOptions {
|
|
54
|
+
jvmTarget = '17'
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
lintOptions {
|
|
58
|
+
abortOnError false
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
dependencies {
|
|
63
|
+
// React Native dependencies (required for bridge)
|
|
64
|
+
compileOnly 'com.facebook.react:react-native:+'
|
|
65
|
+
implementation 'androidx.appcompat:appcompat:1.6.1'
|
|
66
|
+
|
|
67
|
+
// Nimbbl WebView SDK dependency (includes all necessary dependencies)
|
|
68
|
+
implementation 'com.github.nimbbl-tech:nimbbl_mobile_kit_android_webview_sdk:3.0.12'
|
|
69
|
+
|
|
70
|
+
// Add Retrofit and Coroutines dependencies for Android SDK
|
|
71
|
+
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
|
|
72
|
+
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4'
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
afterEvaluate {
|
|
76
|
+
publishing {
|
|
77
|
+
publications {
|
|
78
|
+
release(MavenPublication) {
|
|
79
|
+
from components.release
|
|
80
|
+
groupId = 'com.nimbbl.reactnative'
|
|
81
|
+
artifactId = 'nimbbl-react-native-sdk'
|
|
82
|
+
version = '1.0.0'
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
Binary file
|