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
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import React
|
|
3
|
+
import nimbbl_mobile_kit_ios_webview_sdk
|
|
4
|
+
import UIKit
|
|
5
|
+
|
|
6
|
+
@objc(NimbblReactNativeSDK)
|
|
7
|
+
class NimbblReactNativeSDK: RCTEventEmitter, NimbblCheckoutSDKDelegate {
|
|
8
|
+
|
|
9
|
+
private var config: [String: Any] = [:]
|
|
10
|
+
private var isInitialized = false
|
|
11
|
+
|
|
12
|
+
override init() {
|
|
13
|
+
super.init()
|
|
14
|
+
NimbblCheckoutSDK.shared.delegate = self
|
|
15
|
+
print("NimbblReactNativeSDK initialized")
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
override func supportedEvents() -> [String]! {
|
|
19
|
+
return [
|
|
20
|
+
"payment_success",
|
|
21
|
+
"payment_failed"
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
override func constantsToExport() -> [AnyHashable: Any]! {
|
|
26
|
+
return [
|
|
27
|
+
"SDK_VERSION": "1.0.0",
|
|
28
|
+
"PLATFORM": "ios"
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
override static func requiresMainQueueSetup() -> Bool {
|
|
33
|
+
return false
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@objc
|
|
37
|
+
func testModule(_ resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
38
|
+
print("NimbblReactNativeSDK testModule called")
|
|
39
|
+
resolve(["status": "success", "message": "Module is working"])
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@objc
|
|
43
|
+
func initialize(_ config: [String: Any], resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
44
|
+
do {
|
|
45
|
+
print("Initializing Nimbbl SDK")
|
|
46
|
+
|
|
47
|
+
// Extract configuration
|
|
48
|
+
self.config.removeAll()
|
|
49
|
+
self.config["environment"] = config["environment"] as? String ?? "sandbox"
|
|
50
|
+
|
|
51
|
+
if let options = config["options"] as? [String: Any] {
|
|
52
|
+
self.config["timeout"] = options["timeout"] as? Int ?? 30000
|
|
53
|
+
self.config["enable_logging"] = options["enable_logging"] as? Bool ?? true
|
|
54
|
+
self.config["enable_analytics"] = options["enable_analytics"] as? Bool ?? true
|
|
55
|
+
self.config["api_base_url"] = options["api_base_url"] as? String ?? "https://api.nimbbl.tech"
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
isInitialized = true
|
|
59
|
+
|
|
60
|
+
let result: [String: Any] = [
|
|
61
|
+
"success": true,
|
|
62
|
+
"message": "SDK initialized successfully"
|
|
63
|
+
]
|
|
64
|
+
|
|
65
|
+
resolve(result)
|
|
66
|
+
|
|
67
|
+
} catch {
|
|
68
|
+
print("Error initializing SDK: \(error)")
|
|
69
|
+
reject("INITIALIZATION_FAILED", error.localizedDescription, error)
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
@objc
|
|
74
|
+
func createShopOrder(_ orderData: [String: Any], resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
75
|
+
do {
|
|
76
|
+
guard isInitialized else {
|
|
77
|
+
reject("NOT_INITIALIZED", "SDK must be initialized before creating orders", nil)
|
|
78
|
+
return
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
print("Creating shop order: \(orderData)")
|
|
82
|
+
print("Amount type: \(type(of: orderData["amount"]))")
|
|
83
|
+
print("Currency type: \(type(of: orderData["currency"]))")
|
|
84
|
+
print("Amount value: \(orderData["amount"] ?? "nil")")
|
|
85
|
+
print("Currency value: \(orderData["currency"] ?? "nil")")
|
|
86
|
+
|
|
87
|
+
// Validate required fields
|
|
88
|
+
guard let amount = orderData["amount"] as? String,
|
|
89
|
+
let currency = orderData["currency"] as? String else {
|
|
90
|
+
print("Validation failed - amount: \(orderData["amount"]), currency: \(orderData["currency"])")
|
|
91
|
+
reject("INVALID_ORDER_DATA", "Amount and currency are required", nil)
|
|
92
|
+
return
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Extract order data
|
|
96
|
+
let productId = orderData["product_id"] as? String ?? "11"
|
|
97
|
+
let orderLineItems = orderData["orderLineItems"] as? Bool ?? true
|
|
98
|
+
let checkoutExperience = orderData["checkout_experience"] as? String ?? "redirect"
|
|
99
|
+
let paymentMode = orderData["payment_mode"] as? String ?? ""
|
|
100
|
+
let subPaymentMode = orderData["subPaymentMode"] as? String ?? ""
|
|
101
|
+
|
|
102
|
+
// Handle user parameter - it might be undefined, empty object, or valid data from React Native
|
|
103
|
+
var user: [String: Any]? = nil
|
|
104
|
+
if let userData = orderData["user"] {
|
|
105
|
+
if userData is NSNull {
|
|
106
|
+
// user is null/undefined, pass nil to native SDK
|
|
107
|
+
user = nil
|
|
108
|
+
} else if let userDict = userData as? [String: Any] {
|
|
109
|
+
// Check if it's an empty object
|
|
110
|
+
if userDict.isEmpty {
|
|
111
|
+
user = nil // Empty object, pass nil to native SDK
|
|
112
|
+
} else {
|
|
113
|
+
user = userDict // Valid user data
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Create order using Nimbbl WebView SDK with correct parameter order
|
|
119
|
+
NimbblCheckoutSDK.shared.createShopOrder(
|
|
120
|
+
currency: currency,
|
|
121
|
+
amount: amount,
|
|
122
|
+
productId: productId,
|
|
123
|
+
orderLineItems: orderLineItems,
|
|
124
|
+
checkoutExperience: checkoutExperience,
|
|
125
|
+
paymentMode: paymentMode,
|
|
126
|
+
subPaymentMode: subPaymentMode,
|
|
127
|
+
user: user
|
|
128
|
+
) { result in
|
|
129
|
+
switch result {
|
|
130
|
+
case .success(let orderResult):
|
|
131
|
+
print("Order created successfully: \(orderResult)")
|
|
132
|
+
resolve(orderResult)
|
|
133
|
+
case .failure(let error):
|
|
134
|
+
print("Error creating order: \(error)")
|
|
135
|
+
reject("ORDER_CREATION_FAILED", error.localizedDescription, error)
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
} catch {
|
|
140
|
+
print("Error creating order: \(error)")
|
|
141
|
+
reject("ORDER_CREATION_FAILED", error.localizedDescription, error)
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
@objc
|
|
146
|
+
func checkout(_ options: [String: Any], resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
147
|
+
do {
|
|
148
|
+
print("Opening payment webview with options: \(options)")
|
|
149
|
+
|
|
150
|
+
// Extract options
|
|
151
|
+
guard let orderToken = options["order_token"] as? String else {
|
|
152
|
+
reject("INVALID_OPTIONS", "Order token is required", nil)
|
|
153
|
+
return
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
let paymentModeCode = options["payment_mode_code"] as? String
|
|
157
|
+
let bankCode = options["bank_code"] as? String
|
|
158
|
+
let walletCode = options["wallet_code"] as? String
|
|
159
|
+
let paymentFlow = options["payment_flow"] as? String
|
|
160
|
+
|
|
161
|
+
// Create checkout options with correct initialization
|
|
162
|
+
let checkoutOptions = NimbblCheckoutOptions(
|
|
163
|
+
orderToken: orderToken,
|
|
164
|
+
paymentModeCode: paymentModeCode,
|
|
165
|
+
bankCode: bankCode,
|
|
166
|
+
walletCode: walletCode,
|
|
167
|
+
paymentFlow: paymentFlow
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
// Get the root view controller
|
|
171
|
+
guard let rootViewController = UIApplication.shared.windows.first?.rootViewController else {
|
|
172
|
+
reject("NO_VIEW_CONTROLLER", "Could not find root view controller", nil)
|
|
173
|
+
return
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// Open checkout with correct parameter order
|
|
177
|
+
NimbblCheckoutSDK.shared.checkout(from: rootViewController, options: checkoutOptions)
|
|
178
|
+
|
|
179
|
+
// Resolve immediately since checkout is delegate-based
|
|
180
|
+
resolve(["status": "checkout_opened"])
|
|
181
|
+
|
|
182
|
+
} catch {
|
|
183
|
+
print("Error during checkout: \(error)")
|
|
184
|
+
reject("CHECKOUT_FAILED", error.localizedDescription, error)
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// MARK: - NimbblCheckoutSDKDelegate
|
|
189
|
+
|
|
190
|
+
func onPaymentSuccess(_ response: [AnyHashable : Any]) {
|
|
191
|
+
print("Payment success received with response: \(response)")
|
|
192
|
+
sendEvent(withName: "payment_success", body: response)
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
func onError(_ error: [AnyHashable : Any]) {
|
|
196
|
+
print("Payment error received: \(error)")
|
|
197
|
+
sendEvent(withName: "payment_failed", body: error)
|
|
198
|
+
}
|
|
199
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Main Nimbbl SDK for React Native
|
|
3
|
+
* @version 1.0.0
|
|
4
|
+
* @author Nimbbl Tech
|
|
5
|
+
*
|
|
6
|
+
* This is a wrapper around the native Android and iOS SDKs
|
|
7
|
+
*/
|
|
8
|
+
import { SDKConfig } from './types';
|
|
9
|
+
/**
|
|
10
|
+
* Main Nimbbl SDK Class
|
|
11
|
+
* Provides the primary interface for integrating Nimbbl payment functionality
|
|
12
|
+
* This wrapper matches the native iOS/Android SDK patterns
|
|
13
|
+
*/
|
|
14
|
+
export default class NimbblSDK {
|
|
15
|
+
private static shared;
|
|
16
|
+
private config;
|
|
17
|
+
private isInitialized;
|
|
18
|
+
private eventEmitter;
|
|
19
|
+
private eventListeners;
|
|
20
|
+
constructor();
|
|
21
|
+
/**
|
|
22
|
+
* Get shared instance (matching iOS pattern)
|
|
23
|
+
*/
|
|
24
|
+
static getSharedInstance(): NimbblSDK;
|
|
25
|
+
/**
|
|
26
|
+
* Test native module availability
|
|
27
|
+
*/
|
|
28
|
+
testNativeModule(): Promise<any>;
|
|
29
|
+
/**
|
|
30
|
+
* Initialize the SDK with configuration
|
|
31
|
+
* @param config - SDK configuration object
|
|
32
|
+
* @returns Promise resolving to initialization result
|
|
33
|
+
*/
|
|
34
|
+
initialize(config: SDKConfig): Promise<{
|
|
35
|
+
success: boolean;
|
|
36
|
+
message: string;
|
|
37
|
+
}>;
|
|
38
|
+
/**
|
|
39
|
+
* Set environment URL for the SDK
|
|
40
|
+
* @param url - Environment URL to set
|
|
41
|
+
*/
|
|
42
|
+
setEnvironmentUrl(url: string): void;
|
|
43
|
+
/**
|
|
44
|
+
* Create shop order (matching iOS SDK pattern)
|
|
45
|
+
* @param currency - Currency code
|
|
46
|
+
* @param amount - Order amount
|
|
47
|
+
* @param productId - Product ID for header customization
|
|
48
|
+
* @param orderLineItems - Whether to enable order line items
|
|
49
|
+
* @param checkoutExperience - Checkout experience type
|
|
50
|
+
* @param paymentMode - Payment mode code
|
|
51
|
+
* @param subPaymentMode - Sub payment mode code
|
|
52
|
+
* @param user - User details object
|
|
53
|
+
* @returns Promise resolving to order response
|
|
54
|
+
*/
|
|
55
|
+
createShopOrder(currency: string, amount: string, productId: string, orderLineItems: boolean, checkoutExperience: string, paymentMode: string, subPaymentMode: string, user?: Record<string, any>): Promise<{
|
|
56
|
+
success: boolean;
|
|
57
|
+
data?: any;
|
|
58
|
+
error?: any;
|
|
59
|
+
}>;
|
|
60
|
+
/**
|
|
61
|
+
* Checkout with options (matching iOS SDK pattern)
|
|
62
|
+
* @param options - Checkout options
|
|
63
|
+
* @returns Promise resolving to checkout result
|
|
64
|
+
*/
|
|
65
|
+
checkout(options: {
|
|
66
|
+
orderToken: string;
|
|
67
|
+
paymentModeCode?: string;
|
|
68
|
+
bankCode?: string;
|
|
69
|
+
walletCode?: string;
|
|
70
|
+
paymentFlow?: string;
|
|
71
|
+
}): Promise<{
|
|
72
|
+
success: boolean;
|
|
73
|
+
message?: string;
|
|
74
|
+
}>;
|
|
75
|
+
/**
|
|
76
|
+
* Add event listener for native events
|
|
77
|
+
* @param eventName - Event name to listen for
|
|
78
|
+
* @param listener - Event listener function
|
|
79
|
+
*/
|
|
80
|
+
addEventListener(eventName: string, listener: (event: any) => void): void;
|
|
81
|
+
/**
|
|
82
|
+
* Remove event listener
|
|
83
|
+
* @param eventName - Event name
|
|
84
|
+
* @param listener - Event listener function to remove
|
|
85
|
+
*/
|
|
86
|
+
removeEventListener(eventName: string, listener: (event: any) => void): void;
|
|
87
|
+
/**
|
|
88
|
+
* Remove all event listeners
|
|
89
|
+
*/
|
|
90
|
+
removeAllEventListeners(): void;
|
|
91
|
+
/**
|
|
92
|
+
* Get SDK configuration
|
|
93
|
+
* @returns Current SDK configuration
|
|
94
|
+
*/
|
|
95
|
+
getConfig(): SDKConfig | null;
|
|
96
|
+
/**
|
|
97
|
+
* Get initialization status
|
|
98
|
+
* @returns Whether the SDK is initialized
|
|
99
|
+
*/
|
|
100
|
+
isSDKInitialized(): boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Validate SDK configuration
|
|
103
|
+
* @param config - Configuration to validate
|
|
104
|
+
*/
|
|
105
|
+
private validateConfig;
|
|
106
|
+
}
|
|
107
|
+
export declare const nimbblSDK: NimbblSDK;
|
|
108
|
+
//# sourceMappingURL=NimbblSDK.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NimbblSDK.d.ts","sourceRoot":"","sources":["../src/NimbblSDK.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAepC;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,SAAS;IAC5B,OAAO,CAAC,MAAM,CAAC,MAAM,CAA0B;IAC/C,OAAO,CAAC,MAAM,CAAmB;IACjC,OAAO,CAAC,aAAa,CAAU;IAC/B,OAAO,CAAC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,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,GAAG,IAAI;IAoB5E;;OAEG;IACH,uBAAuB,IAAI,IAAI;IAc/B;;;OAGG;IACH,SAAS,IAAI,SAAS,GAAG,IAAI;IAI7B;;;OAGG;IACH,gBAAgB,IAAI,OAAO;IAI3B;;;OAGG;IACH,OAAO,CAAC,cAAc;CAYvB;AAGD,eAAO,MAAM,SAAS,WAAgC,CAAC"}
|
package/lib/NimbblSDK.js
ADDED
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview Main Nimbbl SDK for React Native
|
|
4
|
+
* @version 1.0.0
|
|
5
|
+
* @author Nimbbl Tech
|
|
6
|
+
*
|
|
7
|
+
* This is a wrapper around the native Android and iOS SDKs
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.nimbblSDK = void 0;
|
|
11
|
+
const react_native_1 = require("react-native");
|
|
12
|
+
const constants_1 = require("./constants");
|
|
13
|
+
const { NimbblReactNativeSDK } = react_native_1.NativeModules;
|
|
14
|
+
// Create event emitter for native events with null check
|
|
15
|
+
const eventEmitter = NimbblReactNativeSDK
|
|
16
|
+
? new react_native_1.NativeEventEmitter(NimbblReactNativeSDK)
|
|
17
|
+
: null;
|
|
18
|
+
/**
|
|
19
|
+
* Main Nimbbl SDK Class
|
|
20
|
+
* Provides the primary interface for integrating Nimbbl payment functionality
|
|
21
|
+
* This wrapper matches the native iOS/Android SDK patterns
|
|
22
|
+
*/
|
|
23
|
+
class NimbblSDK {
|
|
24
|
+
constructor() {
|
|
25
|
+
this.eventListeners = new Map();
|
|
26
|
+
if (!NimbblReactNativeSDK) {
|
|
27
|
+
throw new Error('NimbblReactNativeSDK native module is not available. Make sure you have properly linked the library.');
|
|
28
|
+
}
|
|
29
|
+
this.config = null;
|
|
30
|
+
this.isInitialized = false;
|
|
31
|
+
this.eventEmitter = eventEmitter;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Get shared instance (matching iOS pattern)
|
|
35
|
+
*/
|
|
36
|
+
static getSharedInstance() {
|
|
37
|
+
if (!NimbblSDK.shared) {
|
|
38
|
+
NimbblSDK.shared = new NimbblSDK();
|
|
39
|
+
}
|
|
40
|
+
return NimbblSDK.shared;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Test native module availability
|
|
44
|
+
*/
|
|
45
|
+
async testNativeModule() {
|
|
46
|
+
try {
|
|
47
|
+
if (!NimbblReactNativeSDK) {
|
|
48
|
+
throw new Error('NimbblReactNativeSDK native module is not available');
|
|
49
|
+
}
|
|
50
|
+
const result = await NimbblReactNativeSDK.testModule();
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
throw error;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Initialize the SDK with configuration
|
|
59
|
+
* @param config - SDK configuration object
|
|
60
|
+
* @returns Promise resolving to initialization result
|
|
61
|
+
*/
|
|
62
|
+
async initialize(config) {
|
|
63
|
+
try {
|
|
64
|
+
// Validate configuration
|
|
65
|
+
this.validateConfig(config);
|
|
66
|
+
// Merge with default configuration
|
|
67
|
+
this.config = {
|
|
68
|
+
...constants_1.DEFAULT_CONFIG,
|
|
69
|
+
...config,
|
|
70
|
+
options: {
|
|
71
|
+
timeout: constants_1.DEFAULT_CONFIG.timeout,
|
|
72
|
+
enable_logging: constants_1.DEFAULT_CONFIG.enable_logging,
|
|
73
|
+
enable_analytics: constants_1.DEFAULT_CONFIG.enable_analytics,
|
|
74
|
+
...config.options,
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
// Initialize native module
|
|
78
|
+
const result = await NimbblReactNativeSDK.initialize(this.config);
|
|
79
|
+
if (result.success) {
|
|
80
|
+
this.isInitialized = true;
|
|
81
|
+
}
|
|
82
|
+
return result;
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
console.error('SDK initialization failed:', error);
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Set environment URL for the SDK
|
|
91
|
+
* @param url - Environment URL to set
|
|
92
|
+
*/
|
|
93
|
+
setEnvironmentUrl(url) {
|
|
94
|
+
if (!this.isInitialized) {
|
|
95
|
+
throw new Error(constants_1.ERROR_MESSAGES[constants_1.ERROR_CODES.SDK_NOT_INITIALIZED]);
|
|
96
|
+
}
|
|
97
|
+
if (this.config) {
|
|
98
|
+
this.config.options = {
|
|
99
|
+
...this.config.options,
|
|
100
|
+
api_base_url: url,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Create shop order (matching iOS SDK pattern)
|
|
106
|
+
* @param currency - Currency code
|
|
107
|
+
* @param amount - Order amount
|
|
108
|
+
* @param productId - Product ID for header customization
|
|
109
|
+
* @param orderLineItems - Whether to enable order line items
|
|
110
|
+
* @param checkoutExperience - Checkout experience type
|
|
111
|
+
* @param paymentMode - Payment mode code
|
|
112
|
+
* @param subPaymentMode - Sub payment mode code
|
|
113
|
+
* @param user - User details object
|
|
114
|
+
* @returns Promise resolving to order response
|
|
115
|
+
*/
|
|
116
|
+
async createShopOrder(currency, amount, productId, orderLineItems, checkoutExperience, paymentMode, subPaymentMode, user) {
|
|
117
|
+
if (!this.isInitialized) {
|
|
118
|
+
throw new Error(constants_1.ERROR_MESSAGES[constants_1.ERROR_CODES.SDK_NOT_INITIALIZED]);
|
|
119
|
+
}
|
|
120
|
+
try {
|
|
121
|
+
// Build order data matching iOS sample app exactly
|
|
122
|
+
const orderData = {
|
|
123
|
+
currency,
|
|
124
|
+
amount, // Keep as string to match iOS
|
|
125
|
+
product_id: productId,
|
|
126
|
+
orderLineItems,
|
|
127
|
+
checkout_experience: checkoutExperience,
|
|
128
|
+
payment_mode: paymentMode,
|
|
129
|
+
subPaymentMode,
|
|
130
|
+
user: user || {}, // Always include user, empty object if not provided
|
|
131
|
+
};
|
|
132
|
+
const response = await NimbblReactNativeSDK.createShopOrder(orderData);
|
|
133
|
+
console.log('[DEBUG] createShopOrder response:', response);
|
|
134
|
+
console.log('[DEBUG] Response keys:', Object.keys(response));
|
|
135
|
+
return { success: true, data: response };
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
console.error('Error creating shop order:', error);
|
|
139
|
+
return { success: false, error };
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Checkout with options (matching iOS SDK pattern)
|
|
144
|
+
* @param options - Checkout options
|
|
145
|
+
* @returns Promise resolving to checkout result
|
|
146
|
+
*/
|
|
147
|
+
async checkout(options) {
|
|
148
|
+
if (!this.isInitialized) {
|
|
149
|
+
throw new Error(constants_1.ERROR_MESSAGES[constants_1.ERROR_CODES.SDK_NOT_INITIALIZED]);
|
|
150
|
+
}
|
|
151
|
+
try {
|
|
152
|
+
const checkoutPayload = {
|
|
153
|
+
order_token: options.orderToken,
|
|
154
|
+
payment_mode_code: options.paymentModeCode || '',
|
|
155
|
+
bank_code: options.bankCode || '',
|
|
156
|
+
wallet_code: options.walletCode || '',
|
|
157
|
+
payment_flow: options.paymentFlow || '',
|
|
158
|
+
};
|
|
159
|
+
console.log('[DEBUG] checkout payload:', checkoutPayload);
|
|
160
|
+
console.log('[DEBUG] orderToken value:', options.orderToken);
|
|
161
|
+
console.log('[DEBUG] About to call native checkout method...');
|
|
162
|
+
const result = await NimbblReactNativeSDK.checkout(checkoutPayload);
|
|
163
|
+
console.log('[DEBUG] Native checkout method returned:', result);
|
|
164
|
+
return { success: true, message: 'Checkout initiated successfully' };
|
|
165
|
+
}
|
|
166
|
+
catch (error) {
|
|
167
|
+
console.error('Error during checkout:', error);
|
|
168
|
+
return {
|
|
169
|
+
success: false,
|
|
170
|
+
message: error instanceof Error ? error.message : 'Checkout failed',
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Add event listener for native events
|
|
176
|
+
* @param eventName - Event name to listen for
|
|
177
|
+
* @param listener - Event listener function
|
|
178
|
+
*/
|
|
179
|
+
addEventListener(eventName, listener) {
|
|
180
|
+
if (!this.eventEmitter) {
|
|
181
|
+
console.warn(`Event emitter is not initialized. Cannot add listener for event: ${eventName}`);
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
if (!this.eventListeners.has(eventName)) {
|
|
185
|
+
this.eventListeners.set(eventName, []);
|
|
186
|
+
}
|
|
187
|
+
this.eventListeners.get(eventName).push(listener);
|
|
188
|
+
// Add native event listener
|
|
189
|
+
this.eventEmitter.addListener(eventName, listener);
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Remove event listener
|
|
193
|
+
* @param eventName - Event name
|
|
194
|
+
* @param listener - Event listener function to remove
|
|
195
|
+
*/
|
|
196
|
+
removeEventListener(eventName, listener) {
|
|
197
|
+
if (!this.eventEmitter) {
|
|
198
|
+
console.warn(`Event emitter is not initialized. Cannot remove listener for event: ${eventName}`);
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
const listeners = this.eventListeners.get(eventName);
|
|
202
|
+
if (listeners) {
|
|
203
|
+
const index = listeners.indexOf(listener);
|
|
204
|
+
if (index > -1) {
|
|
205
|
+
listeners.splice(index, 1);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
// Remove native event listener
|
|
209
|
+
this.eventEmitter.removeAllListeners(eventName);
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Remove all event listeners
|
|
213
|
+
*/
|
|
214
|
+
removeAllEventListeners() {
|
|
215
|
+
if (!this.eventEmitter) {
|
|
216
|
+
console.warn('Event emitter is not initialized. Cannot remove all listeners.');
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
this.eventListeners.forEach((_, eventName) => {
|
|
220
|
+
this.eventEmitter.removeAllListeners(eventName);
|
|
221
|
+
});
|
|
222
|
+
this.eventListeners.clear();
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Get SDK configuration
|
|
226
|
+
* @returns Current SDK configuration
|
|
227
|
+
*/
|
|
228
|
+
getConfig() {
|
|
229
|
+
return this.config;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Get initialization status
|
|
233
|
+
* @returns Whether the SDK is initialized
|
|
234
|
+
*/
|
|
235
|
+
isSDKInitialized() {
|
|
236
|
+
return this.isInitialized;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Validate SDK configuration
|
|
240
|
+
* @param config - Configuration to validate
|
|
241
|
+
*/
|
|
242
|
+
validateConfig(config) {
|
|
243
|
+
if (!config) {
|
|
244
|
+
throw new Error(constants_1.ERROR_MESSAGES[constants_1.ERROR_CODES.INVALID_CONFIG]);
|
|
245
|
+
}
|
|
246
|
+
if (!config.environment ||
|
|
247
|
+
!Object.values(constants_1.ENVIRONMENTS).includes(config.environment)) {
|
|
248
|
+
throw new Error('Invalid environment specified');
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
NimbblSDK.shared = null;
|
|
253
|
+
exports.default = NimbblSDK;
|
|
254
|
+
// Export shared instance
|
|
255
|
+
exports.nimbblSDK = NimbblSDK.getSharedInstance();
|
|
256
|
+
//# sourceMappingURL=NimbblSDK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NimbblSDK.js","sourceRoot":"","sources":["../src/NimbblSDK.tsx"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,+CAAiE;AAEjE,2CAKqB;AAErB,MAAM,EAAE,oBAAoB,EAAE,GAAG,4BAAa,CAAC;AAE/C,yDAAyD;AACzD,MAAM,YAAY,GAAG,oBAAoB;IACvC,CAAC,CAAC,IAAI,iCAAkB,CAAC,oBAAoB,CAAC;IAC9C,CAAC,CAAC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CAAC,EACzD,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;;AA/Rc,gBAAM,GAAqB,IAAI,AAAzB,CAA0B;kBAD5B,SAAS;AAmS9B,yBAAyB;AACZ,QAAA,SAAS,GAAG,SAAS,CAAC,iBAAiB,EAAE,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare const NativeModules: {
|
|
2
|
+
NimbblReactNativeSDK: {
|
|
3
|
+
initialize: jest.Mock<any, any, any>;
|
|
4
|
+
createShopOrder: jest.Mock<any, any, any>;
|
|
5
|
+
openPaymentWebView: jest.Mock<any, any, any>;
|
|
6
|
+
setEnvironmentUrl: jest.Mock<any, any, any>;
|
|
7
|
+
addListener: jest.Mock<any, any, any>;
|
|
8
|
+
removeListeners: jest.Mock<any, any, any>;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export declare const NativeEventEmitter: jest.Mock<any, any, any>;
|
|
12
|
+
declare const _default: {
|
|
13
|
+
NativeModules: {
|
|
14
|
+
NimbblReactNativeSDK: {
|
|
15
|
+
initialize: jest.Mock<any, any, any>;
|
|
16
|
+
createShopOrder: jest.Mock<any, any, any>;
|
|
17
|
+
openPaymentWebView: jest.Mock<any, any, any>;
|
|
18
|
+
setEnvironmentUrl: jest.Mock<any, any, any>;
|
|
19
|
+
addListener: jest.Mock<any, any, any>;
|
|
20
|
+
removeListeners: jest.Mock<any, any, any>;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
NativeEventEmitter: jest.Mock<any, any, any>;
|
|
24
|
+
};
|
|
25
|
+
export default _default;
|
|
26
|
+
//# sourceMappingURL=react-native.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react-native.d.ts","sourceRoot":"","sources":["../../../src/__tests__/__mocks__/react-native.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,aAAa;;;;;;;;;CASzB,CAAC;AAEF,eAAO,MAAM,kBAAkB,0BAG5B,CAAC;;;;;;;;;;;;;;AAEJ,wBAGE"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NativeEventEmitter = exports.NativeModules = void 0;
|
|
4
|
+
// Mock React Native for testing
|
|
5
|
+
exports.NativeModules = {
|
|
6
|
+
NimbblReactNativeSDK: {
|
|
7
|
+
initialize: jest.fn(),
|
|
8
|
+
createShopOrder: jest.fn(),
|
|
9
|
+
openPaymentWebView: jest.fn(),
|
|
10
|
+
setEnvironmentUrl: jest.fn(),
|
|
11
|
+
addListener: jest.fn(),
|
|
12
|
+
removeListeners: jest.fn(),
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
exports.NativeEventEmitter = jest.fn().mockImplementation(() => ({
|
|
16
|
+
addListener: jest.fn(),
|
|
17
|
+
removeAllListeners: jest.fn(),
|
|
18
|
+
}));
|
|
19
|
+
exports.default = {
|
|
20
|
+
NativeModules: exports.NativeModules,
|
|
21
|
+
NativeEventEmitter: exports.NativeEventEmitter,
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=react-native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react-native.js","sourceRoot":"","sources":["../../../src/__tests__/__mocks__/react-native.ts"],"names":[],"mappings":";;;AAAA,gCAAgC;AACnB,QAAA,aAAa,GAAG;IAC3B,oBAAoB,EAAE;QACpB,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE;QACrB,eAAe,EAAE,IAAI,CAAC,EAAE,EAAE;QAC1B,kBAAkB,EAAE,IAAI,CAAC,EAAE,EAAE;QAC7B,iBAAiB,EAAE,IAAI,CAAC,EAAE,EAAE;QAC5B,WAAW,EAAE,IAAI,CAAC,EAAE,EAAE;QACtB,eAAe,EAAE,IAAI,CAAC,EAAE,EAAE;KAC3B;CACF,CAAC;AAEW,QAAA,kBAAkB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC,kBAAkB,CAAC,GAAG,EAAE,CAAC,CAAC;IACpE,WAAW,EAAE,IAAI,CAAC,EAAE,EAAE;IACtB,kBAAkB,EAAE,IAAI,CAAC,EAAE,EAAE;CAC9B,CAAC,CAAC,CAAC;AAEJ,kBAAe;IACb,aAAa,EAAb,qBAAa;IACb,kBAAkB,EAAlB,0BAAkB;CACnB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=setup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/__tests__/setup.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../../src/__tests__/setup.ts"],"names":[],"mappings":";AAAA,kBAAkB;AAClB,oEAAoE"}
|