nimbbl-mobile-react-native-sdk 1.3.2 → 1.3.4-alpha.0
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/README.md +9 -69
- package/android/build.gradle +4 -4
- package/android/src/main/java/com/nimbbl/reactnative/NimbblReactNativeSDKModule.kt +0 -122
- package/ios/NimbblReactNativeSDK.swift +0 -63
- package/lib/NimbblSDK.d.ts +0 -17
- package/lib/NimbblSDK.js +4 -35
- package/lib/types.d.ts +8 -1
- package/nimbbl-mobile-react-native-sdk.podspec +2 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Nimbbl React Native SDK
|
|
2
2
|
|
|
3
|
-
**✅ Stable Release v1.3.
|
|
3
|
+
**✅ Stable Release v1.3.4-alpha.0-alpha.0 - Production Ready!**
|
|
4
4
|
|
|
5
5
|
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, offering a unified API for both iOS and Android platforms.
|
|
6
6
|
|
|
@@ -14,7 +14,7 @@ A comprehensive React Native SDK for integrating Nimbbl payment gateway into you
|
|
|
14
14
|
- 🛡️ **Type Safety** - Comprehensive TypeScript definitions for better development experience
|
|
15
15
|
- 📊 **Production Ready** - Built-in analytics, logging, and error handling
|
|
16
16
|
- 🔄 **Unified Event Handling** - Single callback system for all payment responses
|
|
17
|
-
- 🎯 **Latest Native SDKs** - Built on iOS 2.0.
|
|
17
|
+
- 🎯 **Latest Native SDKs** - Built on iOS 2.0.17 and Android 4.0.13
|
|
18
18
|
|
|
19
19
|
## 🚀 Quick Start
|
|
20
20
|
|
|
@@ -101,7 +101,7 @@ await nimbblSDK.checkout({
|
|
|
101
101
|
- ✅ **Stable Release**: Production-ready SDK with comprehensive testing and bug fixes
|
|
102
102
|
- ✅ **Production Ready**: Thoroughly tested and optimized for production environments
|
|
103
103
|
- ✅ **Cross-Platform Consistency**: Identical behavior on iOS and Android
|
|
104
|
-
- ✅ **Latest Native SDKs**: Built on the most recent iOS (2.0.
|
|
104
|
+
- ✅ **Latest Native SDKs**: Built on the most recent iOS (2.0.17) and Android (4.0.13) SDKs
|
|
105
105
|
- ✅ **TypeScript First**: Full TypeScript support with comprehensive type definitions
|
|
106
106
|
- ✅ **Simple Integration**: Get started in minutes with our straightforward API
|
|
107
107
|
|
|
@@ -323,7 +323,7 @@ class PaymentManager {
|
|
|
323
323
|
**Problem**: WebView opens and closes, but payment status screen doesn't appear.
|
|
324
324
|
|
|
325
325
|
**Solution**:
|
|
326
|
-
- Ensure you're using the latest SDK version (`^1.3.
|
|
326
|
+
- Ensure you're using the latest SDK version (`^1.3.4-alpha.0`)
|
|
327
327
|
- The SDK automatically manages event listeners - no manual setup required
|
|
328
328
|
- Check that your app properly handles the payment success/failure events
|
|
329
329
|
|
|
@@ -419,26 +419,6 @@ npm install nimbbl-mobile-react-native-sdk@latest
|
|
|
419
419
|
npm install nimbbl-mobile-react-native-sdk@1.0.0-alpha.3
|
|
420
420
|
```
|
|
421
421
|
|
|
422
|
-
### Migration from Alpha to Stable
|
|
423
|
-
|
|
424
|
-
**✅ Stable version is now available!**
|
|
425
|
-
|
|
426
|
-
```bash
|
|
427
|
-
# Upgrade to latest stable version
|
|
428
|
-
npm install nimbbl-mobile-react-native-sdk@^1.3.2
|
|
429
|
-
|
|
430
|
-
# Update your package.json
|
|
431
|
-
# Change from: "nimbbl-mobile-react-native-sdk": "^1.0.0-alpha.12"
|
|
432
|
-
# To: "nimbbl-mobile-react-native-sdk": "^1.3.2"
|
|
433
|
-
```
|
|
434
|
-
|
|
435
|
-
**Key Changes in Stable Versions:**
|
|
436
|
-
- ✅ **Automatic Event Listener Management**: SDK automatically manages event listeners for optimal performance
|
|
437
|
-
- ✅ **Simplified Integration**: No need to manually add/remove event listeners
|
|
438
|
-
- ✅ **Enhanced Error Handling**: Improved error messages and debugging capabilities
|
|
439
|
-
- ✅ **Production Ready**: Fully tested and optimized for production use
|
|
440
|
-
- ✅ **Updated Native SDKs**: Latest iOS (2.0.16) and Android (4.0.9) SDK integrations
|
|
441
|
-
|
|
442
422
|
### Breaking Changes Migration
|
|
443
423
|
|
|
444
424
|
For major version updates (e.g., 1.x to 2.x):
|
|
@@ -454,33 +434,27 @@ For production applications, consider locking to specific versions:
|
|
|
454
434
|
```json
|
|
455
435
|
{
|
|
456
436
|
"dependencies": {
|
|
457
|
-
"nimbbl-mobile-react-native-sdk": "1.3.
|
|
437
|
+
"nimbbl-mobile-react-native-sdk": "1.3.4-alpha.0"
|
|
458
438
|
}
|
|
459
439
|
}
|
|
460
440
|
```
|
|
461
441
|
|
|
462
|
-
### Deprecation Policy
|
|
463
|
-
|
|
464
|
-
- **Alpha versions**: Features may be deprecated without notice
|
|
465
|
-
- **Stable versions**: Deprecated features will be marked with warnings for at least one minor version
|
|
466
|
-
- **Major versions**: Breaking changes will be clearly documented
|
|
467
|
-
|
|
468
442
|
## 📝 Release Notes
|
|
469
443
|
|
|
470
|
-
### v1.3.
|
|
444
|
+
### v1.3.4-alpha.0 - Stable Release ✅
|
|
471
445
|
|
|
472
446
|
**🚀 Stable Production-Ready React Native SDK for Nimbbl Payments**
|
|
473
447
|
|
|
474
448
|
#### 🔧 Updates & Fixes
|
|
475
|
-
- **Updated iOS Native SDK**: Upgraded to iOS SDK v2.0.
|
|
476
|
-
- **Updated Android Native SDK**: Upgraded to Android SDK v4.0.
|
|
449
|
+
- **Updated iOS Native SDK**: Upgraded to iOS SDK v2.0.17 for improved stability and features
|
|
450
|
+
- **Updated Android Native SDK**: Upgraded to Android SDK v4.0.13 for enhanced performance
|
|
477
451
|
- **Podspec Improvements**: Updated podspec configuration for better CocoaPods integration
|
|
478
452
|
- **Test Fixes**: Fixed test expectations to match actual SDK behavior
|
|
479
453
|
- **Code Quality**: Improved code formatting and linting compliance
|
|
480
454
|
|
|
481
455
|
#### ✨ Features
|
|
482
456
|
- **Unified API**: Single API for both iOS and Android platforms
|
|
483
|
-
- **Latest Native SDKs**: Built on iOS 2.0.
|
|
457
|
+
- **Latest Native SDKs**: Built on iOS 2.0.17 and Android 4.0.13
|
|
484
458
|
- **TypeScript Support**: Full TypeScript definitions for better development experience
|
|
485
459
|
- **Cross-Platform Consistency**: Identical behavior on iOS and Android
|
|
486
460
|
- **Production Ready**: Optimized for production environments with comprehensive error handling
|
|
@@ -497,40 +471,6 @@ For production applications, consider locking to specific versions:
|
|
|
497
471
|
- **Android**: API Level 21+ (Android 5.0) with Kotlin implementation
|
|
498
472
|
- **React Native**: 0.70.0+ support with 0.76.0 recommended
|
|
499
473
|
|
|
500
|
-
### v1.3.0 - Initial Stable Release 🎉
|
|
501
|
-
|
|
502
|
-
**🚀 Production-Ready React Native SDK for Nimbbl Payments**
|
|
503
|
-
|
|
504
|
-
#### ✨ Features
|
|
505
|
-
- **Unified API**: Single API for both iOS and Android platforms
|
|
506
|
-
- **Latest Native SDKs**: Built on iOS 2.0.7 and Android 4.0.4
|
|
507
|
-
- **TypeScript Support**: Full TypeScript definitions for better development experience
|
|
508
|
-
- **Cross-Platform Consistency**: Identical behavior on iOS and Android
|
|
509
|
-
- **Production Ready**: Optimized for production environments with comprehensive error handling
|
|
510
|
-
|
|
511
|
-
#### 🔧 Core Functionality
|
|
512
|
-
- **Easy Integration**: Simple setup with production-ready defaults
|
|
513
|
-
- **Multiple Payment Methods**: Support for cards, UPI, netbanking, wallets, EMI, and cash
|
|
514
|
-
- **WebView Integration**: Built-in payment webview with customization options
|
|
515
|
-
- **Unified Event Handling**: Single callback system for all payment responses
|
|
516
|
-
- **Robust Error Handling**: Comprehensive error handling and fallback mechanisms
|
|
517
|
-
|
|
518
|
-
#### 🛠️ Technical Highlights
|
|
519
|
-
- **Modern Architecture**: Built with React Native best practices
|
|
520
|
-
- **Native Bridge**: Seamless communication between React Native and native SDKs
|
|
521
|
-
- **Performance Optimized**: Efficient memory management and callback handling
|
|
522
|
-
- **Clean Codebase**: Production-ready code with no debug artifacts
|
|
523
|
-
- **Comprehensive Testing**: Full test coverage with 20+ test cases
|
|
524
|
-
|
|
525
|
-
## 🎯 What's Next?
|
|
526
|
-
|
|
527
|
-
Future releases will include:
|
|
528
|
-
|
|
529
|
-
- 🔄 **Enhanced Features**: Additional payment methods and customization options
|
|
530
|
-
- 🚀 **Performance Improvements**: Optimizations based on real-world usage
|
|
531
|
-
- 🛠️ **Developer Experience**: Enhanced debugging tools and documentation
|
|
532
|
-
- 📱 **Platform Updates**: Support for new React Native versions and platform features
|
|
533
|
-
|
|
534
474
|
## 🤝 Contributing
|
|
535
475
|
|
|
536
476
|
We welcome contributions! Please see our [Contributing Guidelines](CONTRIBUTING.md) for details.
|
package/android/build.gradle
CHANGED
|
@@ -64,11 +64,11 @@ dependencies {
|
|
|
64
64
|
compileOnly 'com.facebook.react:react-native:+'
|
|
65
65
|
implementation 'androidx.appcompat:appcompat:1.6.1'
|
|
66
66
|
|
|
67
|
-
// Nimbbl WebView SDK dependency
|
|
68
|
-
|
|
67
|
+
// Nimbbl WebView SDK dependency - aligned with Flutter WebView SDK
|
|
68
|
+
// Uses Maven coordinate tech.nimbbl:webview-sdk:4.0.13 (same as Flutter)
|
|
69
|
+
implementation 'tech.nimbbl:webview-sdk:4.0.13'
|
|
69
70
|
|
|
70
|
-
// Add
|
|
71
|
-
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
|
|
71
|
+
// Add Coroutines dependency for Android SDK
|
|
72
72
|
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4'
|
|
73
73
|
}
|
|
74
74
|
|
|
@@ -4,12 +4,9 @@ import android.app.Activity
|
|
|
4
4
|
import android.content.Intent
|
|
5
5
|
import com.facebook.react.bridge.*
|
|
6
6
|
import tech.nimbbl.webviewsdk.core.NimbblCheckoutSDK
|
|
7
|
-
import tech.nimbbl.webviewsdk.core.NimbblShopOrderCreation
|
|
8
7
|
import tech.nimbbl.webviewsdk.models.NimbblCheckoutOptions
|
|
9
8
|
import tech.nimbbl.webviewsdk.models.interfaces.NimbblCheckoutPaymentListener
|
|
10
9
|
import kotlinx.coroutines.*
|
|
11
|
-
import retrofit2.Response
|
|
12
|
-
import java.io.Serializable
|
|
13
10
|
import org.json.JSONObject
|
|
14
11
|
import org.json.JSONException
|
|
15
12
|
|
|
@@ -171,125 +168,6 @@ class NimbblReactNativeSDKModule(private val reactContext: ReactApplicationConte
|
|
|
171
168
|
}
|
|
172
169
|
}
|
|
173
170
|
|
|
174
|
-
@ReactMethod
|
|
175
|
-
fun createShopOrder(orderData: ReadableMap, promise: Promise) {
|
|
176
|
-
try {
|
|
177
|
-
if (!isInitialized) {
|
|
178
|
-
promise.reject("NOT_INITIALIZED", "SDK must be initialized before creating orders")
|
|
179
|
-
return
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
// Extract order data
|
|
183
|
-
val currency = orderData.getString("currency") ?: "INR"
|
|
184
|
-
val amountString = orderData.getString("amount") ?: "0"
|
|
185
|
-
val amount = amountString.toDoubleOrNull() ?: 0.0
|
|
186
|
-
val productId = orderData.getString("product_id") ?: "11"
|
|
187
|
-
val paymentMode = orderData.getString("payment_mode") ?: ""
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
// Validate required fields
|
|
191
|
-
if (amountString.isEmpty() || currency.isEmpty()) {
|
|
192
|
-
promise.reject("INVALID_ORDER_DATA", "Amount and currency are required")
|
|
193
|
-
return
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
// Handle user parameter - it might be undefined, null, or valid data from React Native
|
|
197
|
-
val userMap = orderData.getMap("user")
|
|
198
|
-
val user: Map<String, Any>? = if (userMap != null && !userMap.toHashMap().isEmpty()) {
|
|
199
|
-
userMap.toHashMap()
|
|
200
|
-
} else {
|
|
201
|
-
null
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
// Use the actual Nimbbl Android SDK to create order
|
|
205
|
-
// Set environment URL if provided
|
|
206
|
-
val apiBaseUrl = config["api_base_url"] as? String
|
|
207
|
-
if (!apiBaseUrl.isNullOrEmpty()) {
|
|
208
|
-
NimbblCheckoutSDK.getInstance().setEnvironmentUrl(apiBaseUrl)
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
// Extract user details for order creation
|
|
212
|
-
val userEmail = user?.get("email") as? String ?: ""
|
|
213
|
-
val userName = user?.get("name") as? String ?: ""
|
|
214
|
-
val userMobile = user?.get("mobile_number") as? String ?: ""
|
|
215
|
-
|
|
216
|
-
// Try to use the actual Android SDK for order creation
|
|
217
|
-
try {
|
|
218
|
-
// Get the API base URL from config
|
|
219
|
-
val orderApiBaseUrl = config["api_base_url"] as? String ?: "https://api.nimbbl.tech/"
|
|
220
|
-
|
|
221
|
-
// Use direct method call with coroutine (since createOrder is a suspend function)
|
|
222
|
-
// Convert amount string to int
|
|
223
|
-
val amountInt = amountString.toIntOrNull() ?: 0
|
|
224
|
-
|
|
225
|
-
// Use coroutine to call suspend function
|
|
226
|
-
val orderResult = runBlocking {
|
|
227
|
-
NimbblShopOrderCreation.createShopOrder(
|
|
228
|
-
orderApiBaseUrl,
|
|
229
|
-
amountInt, // Use amount as int
|
|
230
|
-
userEmail,
|
|
231
|
-
userName,
|
|
232
|
-
userMobile,
|
|
233
|
-
productId,
|
|
234
|
-
paymentMode, // Use paymentMode as paymentModeCode
|
|
235
|
-
"" // bankCode (empty for now)
|
|
236
|
-
)
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
// The result should be a Response object
|
|
240
|
-
if (orderResult != null) {
|
|
241
|
-
// Check if the response is successful
|
|
242
|
-
if (orderResult.isSuccessful) {
|
|
243
|
-
// Get the response body
|
|
244
|
-
val responseBody = orderResult.body()
|
|
245
|
-
|
|
246
|
-
if (responseBody != null) {
|
|
247
|
-
// Extract token from response body
|
|
248
|
-
val token = responseBody.token
|
|
249
|
-
val orderId = responseBody.orderId
|
|
250
|
-
|
|
251
|
-
if (!token.isNullOrEmpty()) {
|
|
252
|
-
val result = Arguments.createMap().apply {
|
|
253
|
-
putString("order_id", orderId)
|
|
254
|
-
putString("token", token)
|
|
255
|
-
putString("status", "created")
|
|
256
|
-
putDouble("amount", amount)
|
|
257
|
-
putString("currency", currency)
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
promise.resolve(result)
|
|
261
|
-
return
|
|
262
|
-
} else {
|
|
263
|
-
promise.reject("INVALID_RESPONSE", "Token is null or empty in response")
|
|
264
|
-
return
|
|
265
|
-
}
|
|
266
|
-
} else {
|
|
267
|
-
promise.reject("INVALID_RESPONSE", "Response body is null")
|
|
268
|
-
return
|
|
269
|
-
}
|
|
270
|
-
} else {
|
|
271
|
-
// Get error body for logging
|
|
272
|
-
val errorBody = orderResult.errorBody()
|
|
273
|
-
promise.reject("ORDER_CREATION_FAILED", "Order creation failed: $errorBody")
|
|
274
|
-
return
|
|
275
|
-
}
|
|
276
|
-
} else {
|
|
277
|
-
promise.reject("ORDER_CREATION_FAILED", "Order creation result is null")
|
|
278
|
-
return
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
} catch (e: Exception) {
|
|
282
|
-
promise.reject("ORDER_CREATION_FAILED", "Android SDK order creation failed: ${e.message}")
|
|
283
|
-
return
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
} catch (e: Exception) {
|
|
287
|
-
promise.reject("ORDER_CREATION_FAILED", e.message)
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
171
|
@ReactMethod
|
|
294
172
|
fun checkout(options: ReadableMap, promise: Promise) {
|
|
295
173
|
try {
|
|
@@ -71,69 +71,6 @@ class NimbblReactNativeSDK: RCTEventEmitter, NimbblCheckoutSDKDelegate {
|
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
@objc
|
|
75
|
-
func createShopOrder(_ orderData: [String: Any], resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
76
|
-
do {
|
|
77
|
-
guard isInitialized else {
|
|
78
|
-
reject("NOT_INITIALIZED", "SDK must be initialized before creating orders", nil)
|
|
79
|
-
return
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
// Validate required fields
|
|
84
|
-
guard let amount = orderData["amount"] as? String,
|
|
85
|
-
let currency = orderData["currency"] as? String else {
|
|
86
|
-
reject("INVALID_ORDER_DATA", "Amount and currency are required", nil)
|
|
87
|
-
return
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// Extract order data
|
|
91
|
-
let productId = orderData["product_id"] as? String ?? "11"
|
|
92
|
-
let orderLineItems = orderData["orderLineItems"] as? Bool ?? true
|
|
93
|
-
let checkoutExperience = orderData["checkout_experience"] as? String ?? "redirect"
|
|
94
|
-
let paymentMode = orderData["payment_mode"] as? String ?? ""
|
|
95
|
-
let subPaymentMode = orderData["subPaymentMode"] as? String ?? ""
|
|
96
|
-
|
|
97
|
-
// Handle user parameter - it might be undefined, empty object, or valid data from React Native
|
|
98
|
-
var user: [String: Any]? = nil
|
|
99
|
-
if let userData = orderData["user"] {
|
|
100
|
-
if userData is NSNull {
|
|
101
|
-
// user is null/undefined, pass nil to native SDK
|
|
102
|
-
user = nil
|
|
103
|
-
} else if let userDict = userData as? [String: Any] {
|
|
104
|
-
// Check if it's an empty object
|
|
105
|
-
if userDict.isEmpty {
|
|
106
|
-
user = nil // Empty object, pass nil to native SDK
|
|
107
|
-
} else {
|
|
108
|
-
user = userDict // Valid user data
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
// Create order using Nimbbl WebView SDK with correct parameter order
|
|
114
|
-
NimbblCheckoutSDK.shared.createShopOrder(
|
|
115
|
-
currency: currency,
|
|
116
|
-
amount: amount,
|
|
117
|
-
productId: productId,
|
|
118
|
-
orderLineItems: orderLineItems,
|
|
119
|
-
checkoutExperience: checkoutExperience,
|
|
120
|
-
paymentMode: paymentMode,
|
|
121
|
-
subPaymentMode: subPaymentMode,
|
|
122
|
-
user: user
|
|
123
|
-
) { result in
|
|
124
|
-
switch result {
|
|
125
|
-
case .success(let orderResult):
|
|
126
|
-
resolve(orderResult)
|
|
127
|
-
case .failure(let error):
|
|
128
|
-
reject("ORDER_CREATION_FAILED", error.localizedDescription, error)
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
} catch {
|
|
133
|
-
reject("ORDER_CREATION_FAILED", error.localizedDescription, error)
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
74
|
@objc
|
|
138
75
|
func checkout(_ options: [String: Any], resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
139
76
|
do {
|
package/lib/NimbblSDK.d.ts
CHANGED
|
@@ -29,23 +29,6 @@ export default class NimbblSDK {
|
|
|
29
29
|
success: boolean;
|
|
30
30
|
message: string;
|
|
31
31
|
}>;
|
|
32
|
-
/**
|
|
33
|
-
* Create shop order (matching iOS SDK pattern)
|
|
34
|
-
* @param currency - Currency code
|
|
35
|
-
* @param amount - Order amount
|
|
36
|
-
* @param productId - Product ID for header customization
|
|
37
|
-
* @param orderLineItems - Whether to enable order line items
|
|
38
|
-
* @param checkoutExperience - Checkout experience type
|
|
39
|
-
* @param paymentMode - Payment mode code
|
|
40
|
-
* @param subPaymentMode - Sub payment mode code
|
|
41
|
-
* @param user - User details object
|
|
42
|
-
* @returns Promise resolving to order response
|
|
43
|
-
*/
|
|
44
|
-
createShopOrder(currency: string, amount: string, productId: string, orderLineItems: boolean, checkoutExperience: string, paymentMode: string, subPaymentMode: string, user?: Record<string, any>): Promise<{
|
|
45
|
-
success: boolean;
|
|
46
|
-
data?: any;
|
|
47
|
-
error?: any;
|
|
48
|
-
}>;
|
|
49
32
|
/**
|
|
50
33
|
* Checkout with options (matching iOS SDK pattern)
|
|
51
34
|
* @param options - Checkout options
|
package/lib/NimbblSDK.js
CHANGED
|
@@ -53,41 +53,6 @@ class NimbblSDK {
|
|
|
53
53
|
}
|
|
54
54
|
return result;
|
|
55
55
|
}
|
|
56
|
-
/**
|
|
57
|
-
* Create shop order (matching iOS SDK pattern)
|
|
58
|
-
* @param currency - Currency code
|
|
59
|
-
* @param amount - Order amount
|
|
60
|
-
* @param productId - Product ID for header customization
|
|
61
|
-
* @param orderLineItems - Whether to enable order line items
|
|
62
|
-
* @param checkoutExperience - Checkout experience type
|
|
63
|
-
* @param paymentMode - Payment mode code
|
|
64
|
-
* @param subPaymentMode - Sub payment mode code
|
|
65
|
-
* @param user - User details object
|
|
66
|
-
* @returns Promise resolving to order response
|
|
67
|
-
*/
|
|
68
|
-
async createShopOrder(currency, amount, productId, orderLineItems, checkoutExperience, paymentMode, subPaymentMode, user) {
|
|
69
|
-
if (!this.isInitialized) {
|
|
70
|
-
throw new Error(constants_1.ERROR_MESSAGES[constants_1.ERROR_CODES.SDK_NOT_INITIALIZED]);
|
|
71
|
-
}
|
|
72
|
-
try {
|
|
73
|
-
// Build order data matching iOS sample app exactly
|
|
74
|
-
const orderData = {
|
|
75
|
-
currency,
|
|
76
|
-
amount, // Keep as string to match iOS
|
|
77
|
-
product_id: productId,
|
|
78
|
-
orderLineItems,
|
|
79
|
-
checkout_experience: checkoutExperience,
|
|
80
|
-
payment_mode: paymentMode,
|
|
81
|
-
subPaymentMode,
|
|
82
|
-
user: user || {}, // Always include user, empty object if not provided
|
|
83
|
-
};
|
|
84
|
-
const response = await NimbblReactNativeSDK.createShopOrder(orderData);
|
|
85
|
-
return { success: true, data: response };
|
|
86
|
-
}
|
|
87
|
-
catch (error) {
|
|
88
|
-
return { success: false, error };
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
56
|
/**
|
|
92
57
|
* Checkout with options (matching iOS SDK pattern)
|
|
93
58
|
* @param options - Checkout options
|
|
@@ -104,6 +69,10 @@ class NimbblSDK {
|
|
|
104
69
|
bank_code: options.bankCode || '',
|
|
105
70
|
wallet_code: options.walletCode || '',
|
|
106
71
|
payment_flow: options.paymentFlow || '',
|
|
72
|
+
checkout_experience: options.checkoutExperience || 'redirect',
|
|
73
|
+
upi_id: options.upiId || '',
|
|
74
|
+
upi_app_code: options.upiAppCode || '',
|
|
75
|
+
emi_code: options.emiCode || '',
|
|
107
76
|
};
|
|
108
77
|
// Use callback-based approach - SDK will always return a response
|
|
109
78
|
return new Promise((resolve) => {
|
package/lib/types.d.ts
CHANGED
|
@@ -17,7 +17,6 @@ export interface SDKConfig {
|
|
|
17
17
|
*/
|
|
18
18
|
export interface NimbblReactNativeSDKInterface {
|
|
19
19
|
initialize(config: any): Promise<any>;
|
|
20
|
-
createShopOrder(options: any): Promise<any>;
|
|
21
20
|
checkout(options: any): Promise<any>;
|
|
22
21
|
setCheckoutCallback(callback: (result: any) => void): void;
|
|
23
22
|
addListener(eventName: string): void;
|
|
@@ -32,5 +31,13 @@ export interface CheckoutOptions {
|
|
|
32
31
|
bankCode?: string;
|
|
33
32
|
walletCode?: string;
|
|
34
33
|
paymentFlow?: string;
|
|
34
|
+
/** Checkout experience type: 'pop_up' or 'redirect' */
|
|
35
|
+
checkoutExperience?: string;
|
|
36
|
+
/** UPI collect flow VPA */
|
|
37
|
+
upiId?: string;
|
|
38
|
+
/** UPI intent app code (e.g. 'phonepe', 'gpay') */
|
|
39
|
+
upiAppCode?: string;
|
|
40
|
+
/** EMI type (e.g. 'debit', 'credit', 'cardless') */
|
|
41
|
+
emiCode?: string;
|
|
35
42
|
}
|
|
36
43
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -23,5 +23,6 @@ Pod::Spec.new do |s|
|
|
|
23
23
|
s.swift_version = "5.0"
|
|
24
24
|
|
|
25
25
|
# Nimbbl iOS SDK dependency
|
|
26
|
-
|
|
26
|
+
# Align with Flutter WebView SDK, which currently uses 2.0.17 snapshot
|
|
27
|
+
s.dependency "nimbbl_mobile_kit_ios_webview_sdk", "2.0.17"
|
|
27
28
|
end
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nimbbl-mobile-react-native-sdk",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.4-alpha.0",
|
|
4
4
|
"description": "Nimbbl React Native SDK for payment integration",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -41,13 +41,13 @@
|
|
|
41
41
|
],
|
|
42
42
|
"author": "Nimbbl Tech",
|
|
43
43
|
"license": "MIT",
|
|
44
|
-
"homepage": "https://
|
|
44
|
+
"homepage": "https://github.com/nimbbl-tech/nimbbl_mobile_kit_react_native_sdk",
|
|
45
45
|
"repository": {
|
|
46
46
|
"type": "git",
|
|
47
|
-
"url": "https://
|
|
47
|
+
"url": "https://github.com/nimbbl-tech/nimbbl_mobile_kit_react_native_sdk.git"
|
|
48
48
|
},
|
|
49
49
|
"bugs": {
|
|
50
|
-
"url": "https://
|
|
50
|
+
"url": "https://github.com/nimbbl-tech/nimbbl_mobile_kit_react_native_sdk/issues"
|
|
51
51
|
},
|
|
52
52
|
"publishConfig": {
|
|
53
53
|
"access": "public"
|