nimbbl-mobile-react-native-sdk 1.3.2 → 1.3.3

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.
@@ -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 (includes all necessary dependencies)
68
- implementation 'com.github.nimbbl-tech:nimbbl_mobile_kit_android_webview_sdk:v4.0.9'
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 Retrofit and Coroutines dependencies for Android SDK
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 {
@@ -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
- s.dependency "nimbbl_mobile_kit_ios_webview_sdk", "~> 2.0.16"
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.2",
3
+ "version": "1.3.3",
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://bitbucket.org/nimbbl-tech/nimbbl_mobile_kit_react_native_sdk",
44
+ "homepage": "https://github.com/nimbbl-tech/nimbbl_mobile_kit_react_native_sdk",
45
45
  "repository": {
46
46
  "type": "git",
47
- "url": "https://bitbucket.org/nimbbl-tech/nimbbl_mobile_kit_react_native_sdk.git"
47
+ "url": "https://github.com/nimbbl-tech/nimbbl_mobile_kit_react_native_sdk.git"
48
48
  },
49
49
  "bugs": {
50
- "url": "https://bitbucket.org/nimbbl-tech/nimbbl_mobile_kit_react_native_sdk/issues"
50
+ "url": "https://github.com/nimbbl-tech/nimbbl_mobile_kit_react_native_sdk/issues"
51
51
  },
52
52
  "publishConfig": {
53
53
  "access": "public"