@jimrising/easymerchantsdk-react-native 1.3.8 → 1.4.1
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/.idea/caches/deviceStreaming.xml +714 -0
- package/.idea/em-MobileCheckoutSDK-ReactNative.iml +9 -0
- package/.idea/misc.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/vcs.xml +6 -0
- package/README.md +140 -81
- package/android/.gradle/8.10/checksums/checksums.lock +0 -0
- package/android/.gradle/8.10/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/8.10/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/8.10/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.9/checksums/checksums.lock +0 -0
- package/android/.gradle/8.9/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/8.9/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -2
- package/ios/Classes/EasyMerchantSdk.m +106 -55
- package/ios/Classes/EasyMerchantSdk.swift +232 -117
- package/ios/Classes/EasyPayViewController.swift +1 -1
- package/ios/CustomComponents/DatePickerHandler.swift +15 -4
- package/ios/EnvironmentConfig.swift +32 -30
- package/ios/Models/Request.swift +176 -14
- package/ios/Models/Result.swift +15 -35
- package/ios/Pods/ViewControllers/AdditionalInfoVC.swift +851 -342
- package/ios/Pods/ViewControllers/BaseVC.swift +39 -35
- package/ios/Pods/ViewControllers/BillingInfoVC/BillingInfoVC.swift +1975 -170
- package/ios/Pods/ViewControllers/CountryListVC.swift +0 -1
- package/ios/Pods/ViewControllers/EmailVerificationVC.swift +74 -5
- package/ios/Pods/ViewControllers/GrailPayVC.swift +131 -107
- package/ios/Pods/ViewControllers/OTPVerificationVC.swift +305 -107
- package/ios/Pods/ViewControllers/PaymentDoneVC.swift +61 -14
- package/ios/Pods/ViewControllers/PaymentInformation/PaymentInfoVC.swift +1277 -501
- package/ios/Pods/ViewControllers/ThreeDSecurePaymentDoneVC.swift +133 -2
- package/ios/easymerchantsdk.podspec +1 -1
- package/ios/easymerchantsdk.storyboard +713 -590
- package/package.json +2 -2
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="JAVA_MODULE" version="4">
|
|
3
|
+
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
|
4
|
+
<exclude-output />
|
|
5
|
+
<content url="file://$MODULE_DIR$" />
|
|
6
|
+
<orderEntry type="inheritedJdk" />
|
|
7
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
8
|
+
</component>
|
|
9
|
+
</module>
|
package/.idea/misc.xml
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="ProjectModuleManager">
|
|
4
|
+
<modules>
|
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/em-MobileCheckoutSDK-ReactNative.iml" filepath="$PROJECT_DIR$/.idea/em-MobileCheckoutSDK-ReactNative.iml" />
|
|
6
|
+
</modules>
|
|
7
|
+
</component>
|
|
8
|
+
</project>
|
package/.idea/vcs.xml
ADDED
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ To add the path of sdk in your project. Open your `package.json` file and inside
|
|
|
7
7
|
|
|
8
8
|
```json
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@jimrising/easymerchantsdk-react-native": "^1.
|
|
10
|
+
"@jimrising/easymerchantsdk-react-native": "^1.4.1"
|
|
11
11
|
},
|
|
12
12
|
```
|
|
13
13
|
|
|
@@ -120,6 +120,7 @@ import {
|
|
|
120
120
|
StyleSheet,
|
|
121
121
|
Platform,
|
|
122
122
|
NativeModules,
|
|
123
|
+
ScrollView,
|
|
123
124
|
} from 'react-native';
|
|
124
125
|
|
|
125
126
|
const { RNEasymerchantsdk, EasyMerchantSdk } = NativeModules;
|
|
@@ -127,21 +128,22 @@ const { RNEasymerchantsdk, EasyMerchantSdk } = NativeModules;
|
|
|
127
128
|
const App = () => {
|
|
128
129
|
const [version, setVersion] = useState('');
|
|
129
130
|
const [response, setResponse] = useState('');
|
|
131
|
+
const [referenceToken, setReferenceToken] = useState('');
|
|
130
132
|
|
|
131
133
|
useEffect(() => {
|
|
132
134
|
const setup = async () => {
|
|
133
135
|
try {
|
|
134
136
|
if (Platform.OS === 'ios') {
|
|
135
137
|
await EasyMerchantSdk.setViewController();
|
|
136
|
-
EasyMerchantSdk.configureEnvironment(
|
|
137
|
-
'staging',
|
|
138
|
-
'
|
|
139
|
-
'
|
|
138
|
+
await EasyMerchantSdk.configureEnvironment(
|
|
139
|
+
'staging',
|
|
140
|
+
'mobilesdk1980IUuCzwWl',
|
|
141
|
+
'mobilesdk1980LVHnN0Oh'
|
|
140
142
|
);
|
|
141
143
|
}
|
|
142
144
|
} catch (err) {
|
|
143
145
|
console.error('Initialization Error:', err);
|
|
144
|
-
setResponse(`❌ Initialization Error: ${err.message || err}`);
|
|
146
|
+
setResponse(`❌ Initialization Error: ${err.message || JSON.stringify(err)}`);
|
|
145
147
|
}
|
|
146
148
|
};
|
|
147
149
|
|
|
@@ -156,98 +158,154 @@ const App = () => {
|
|
|
156
158
|
: await EasyMerchantSdk.getPlatformVersion();
|
|
157
159
|
setVersion(ver);
|
|
158
160
|
} catch (err) {
|
|
159
|
-
setVersion('Error
|
|
160
|
-
console.error(err);
|
|
161
|
+
setVersion('Error: Could not fetch version');
|
|
162
|
+
console.error('Platform version error:', err);
|
|
161
163
|
}
|
|
162
164
|
};
|
|
163
165
|
|
|
164
166
|
const handleBilling = async () => {
|
|
165
|
-
const amount = '72';
|
|
166
167
|
const billingInfo = {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
168
|
+
visibility: { billing: true, additional: true },
|
|
169
|
+
billing: {
|
|
170
|
+
address: 'Mohali, Punjab',
|
|
171
|
+
country: 'India',
|
|
172
|
+
state: 'Punjab',
|
|
173
|
+
city: 'Anandpur Sahib',
|
|
174
|
+
postal_code: '140118',
|
|
175
|
+
},
|
|
176
|
+
billingRequired: {
|
|
177
|
+
address: true,
|
|
178
|
+
country: true,
|
|
179
|
+
state: true,
|
|
180
|
+
city: false,
|
|
181
|
+
postal_code: true,
|
|
182
|
+
},
|
|
183
|
+
additional: {
|
|
173
184
|
name: 'Test User',
|
|
174
|
-
|
|
175
|
-
phone_number: '
|
|
176
|
-
|
|
177
|
-
|
|
185
|
+
email_address: 'test@gmail.com',
|
|
186
|
+
phone_number: '9465351125',
|
|
187
|
+
description: 'Test',
|
|
188
|
+
},
|
|
189
|
+
additionalRequired: {
|
|
190
|
+
name: true,
|
|
191
|
+
email_address: true,
|
|
192
|
+
phone_number: true,
|
|
193
|
+
description: false,
|
|
178
194
|
},
|
|
179
195
|
};
|
|
180
196
|
|
|
181
197
|
const themeConfiguration = {
|
|
182
|
-
bodyBackgroundColor: '#
|
|
183
|
-
containerBackgroundColor: '#
|
|
184
|
-
primaryFontColor: '#
|
|
185
|
-
secondaryFontColor: '#
|
|
186
|
-
primaryButtonBackgroundColor: '#
|
|
187
|
-
primaryButtonHoverColor: '#
|
|
198
|
+
bodyBackgroundColor: '#121212',
|
|
199
|
+
containerBackgroundColor: '#1E1E1E',
|
|
200
|
+
primaryFontColor: '#FFFFFF',
|
|
201
|
+
secondaryFontColor: '#B0B0B0',
|
|
202
|
+
primaryButtonBackgroundColor: '#2563EB',
|
|
203
|
+
primaryButtonHoverColor: '#1D4ED8',
|
|
188
204
|
primaryButtonFontColor: '#FFFFFF',
|
|
189
|
-
secondaryButtonBackgroundColor: '#
|
|
190
|
-
secondaryButtonHoverColor: '#
|
|
191
|
-
secondaryButtonFontColor: '#
|
|
192
|
-
borderRadius: '
|
|
193
|
-
fontSize: '
|
|
205
|
+
secondaryButtonBackgroundColor: '#374151',
|
|
206
|
+
secondaryButtonHoverColor: '#4B5563',
|
|
207
|
+
secondaryButtonFontColor: '#E5E7EB',
|
|
208
|
+
borderRadius: '8',
|
|
209
|
+
fontSize: '14',
|
|
210
|
+
fontWeight: 500,
|
|
211
|
+
fontFamily: '"Inter", sans-serif',
|
|
194
212
|
};
|
|
195
213
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
214
|
+
try {
|
|
215
|
+
if (Platform.OS === 'android') {
|
|
216
|
+
const result = await RNEasymerchantsdk.billing('72', null);
|
|
217
|
+
setResponse(`✅ Android Payment Success: ${result}`);
|
|
218
|
+
} else {
|
|
219
|
+
const result = await EasyMerchantSdk.billing(
|
|
220
|
+
'99',
|
|
221
|
+
'usd',
|
|
222
|
+
billingInfo,
|
|
223
|
+
['card', 'bank'],
|
|
224
|
+
themeConfiguration,
|
|
225
|
+
false, // tokenOnly
|
|
226
|
+
true, // saveCard
|
|
227
|
+
true, // saveAccount
|
|
228
|
+
false, // authenticatedACH
|
|
229
|
+
null, // grailPayParams
|
|
230
|
+
'Submit',
|
|
231
|
+
false, // isRecurring
|
|
232
|
+
['weekly', 'monthly'],
|
|
233
|
+
'custom',
|
|
234
|
+
'07/07/2025',
|
|
235
|
+
true, // secureAuthentication
|
|
236
|
+
true, // showReceipt
|
|
237
|
+
true, // showTotal
|
|
238
|
+
true // showSubmitButton
|
|
239
|
+
);
|
|
240
|
+
|
|
241
|
+
console.log('Billing success (full response):', JSON.stringify(result, null, 2));
|
|
242
|
+
|
|
243
|
+
try {
|
|
244
|
+
const refToken = result?.additionalInfo?.threeDSecureStatus?.data?.ref_token;
|
|
245
|
+
if (refToken) {
|
|
246
|
+
setReferenceToken(refToken);
|
|
247
|
+
setResponse(`✅ Ref Token: ${refToken}\nFull Response:\n${JSON.stringify(result, null, 2)}`);
|
|
248
|
+
} else {
|
|
249
|
+
setResponse(`✅ iOS Payment Success (no ref_token):\n${JSON.stringify(result, null, 2)}`);
|
|
250
|
+
}
|
|
251
|
+
} catch (err) {
|
|
252
|
+
console.error('Error parsing ref_token:', err);
|
|
253
|
+
setResponse(`✅ iOS Payment Success (error parsing ref_token):\n${JSON.stringify(result, null, 2)}`);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
} catch (error) {
|
|
257
|
+
console.error('Billing Error:', error);
|
|
258
|
+
let errorMessage = 'Unknown error';
|
|
259
|
+
if (error.code && error.message) {
|
|
260
|
+
errorMessage = `Code: ${error.code}, Message: ${error.message}`;
|
|
261
|
+
} else if (error.message) {
|
|
262
|
+
errorMessage = error.message;
|
|
263
|
+
}
|
|
264
|
+
setResponse(`❌ Billing Error: ${errorMessage}`);
|
|
265
|
+
}
|
|
266
|
+
};
|
|
206
267
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
const result = await EasyMerchantSdk.billing(
|
|
213
|
-
amount,
|
|
214
|
-
JSON.stringify(billingInfo),
|
|
215
|
-
['card', 'bank', 'crypto'],
|
|
216
|
-
themeConfiguration,
|
|
217
|
-
false, // tokenOnly
|
|
218
|
-
false, // saveCard
|
|
219
|
-
false, // saveAccount
|
|
220
|
-
true, // authenticatedACH if it is true only then pass authConfig params
|
|
221
|
-
authConfig,
|
|
222
|
-
"Submit",
|
|
223
|
-
true, // is_recurring == true ? must need to send below 4 params
|
|
224
|
-
['weekly', 'monthly'], // recurringIntervals
|
|
225
|
-
'custom', // recurringStartDateType
|
|
226
|
-
"05/30/2025", /// Format MM/dd/yyyy, must be today or future date
|
|
227
|
-
true // enable3DS :- must send it true for 3DS card payment.
|
|
228
|
-
);
|
|
229
|
-
|
|
230
|
-
console.log("Billing success:", result);
|
|
231
|
-
setResponse(`✅ iOS Payment Success: ${JSON.stringify(result)}`);
|
|
232
|
-
}
|
|
233
|
-
} catch (error) {
|
|
234
|
-
console.error('Billing Error:', error);
|
|
235
|
-
setResponse(`❌ Billing Error: ${error.message || JSON.stringify(error)}`);
|
|
236
|
-
}
|
|
268
|
+
const handlePaymentReference = async () => {
|
|
269
|
+
if (!referenceToken) {
|
|
270
|
+
setResponse('❌ No reference token available from billing');
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
237
273
|
|
|
274
|
+
try {
|
|
275
|
+
if (Platform.OS === 'android') {
|
|
276
|
+
setResponse('❌ Payment Reference not supported on Android');
|
|
277
|
+
} else {
|
|
278
|
+
const result = await EasyMerchantSdk.paymentReference(referenceToken);
|
|
279
|
+
console.log('Payment Reference success:', JSON.stringify(result, null, 2));
|
|
280
|
+
setResponse(`✅ iOS Payment Reference Success:\n${JSON.stringify(result, null, 2)}`);
|
|
281
|
+
}
|
|
282
|
+
} catch (error) {
|
|
283
|
+
console.error('Payment Reference Error:', error);
|
|
284
|
+
let errorMessage = 'Unknown error';
|
|
285
|
+
if (error.code && error.message) {
|
|
286
|
+
errorMessage = `Code: ${error.code}, Message: ${error.message}`;
|
|
287
|
+
} else if (error.message) {
|
|
288
|
+
errorMessage = error.message;
|
|
289
|
+
}
|
|
290
|
+
setResponse(`❌ Payment Reference Error: ${errorMessage}`);
|
|
291
|
+
}
|
|
238
292
|
};
|
|
239
293
|
|
|
240
294
|
return (
|
|
241
295
|
<View style={styles.container}>
|
|
242
|
-
<
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
296
|
+
<ScrollView contentContainerStyle={styles.scrollContent}>
|
|
297
|
+
<Text style={styles.title}>EasyMerchant SDK</Text>
|
|
298
|
+
<Text style={styles.version}>Platform Version: {version}</Text>
|
|
299
|
+
|
|
300
|
+
<Button title="Get Platform Version" onPress={getPlatformVersion} />
|
|
301
|
+
<View style={styles.space} />
|
|
302
|
+
<Button title="Start Billing" onPress={handleBilling} />
|
|
303
|
+
<View style={styles.space} />
|
|
304
|
+
<Button title="Start Payment Reference" onPress={handlePaymentReference} />
|
|
305
|
+
<View style={styles.space} />
|
|
306
|
+
|
|
307
|
+
<Text style={styles.response}>{response}</Text>
|
|
308
|
+
</ScrollView>
|
|
251
309
|
</View>
|
|
252
310
|
);
|
|
253
311
|
};
|
|
@@ -258,6 +316,9 @@ const styles = StyleSheet.create({
|
|
|
258
316
|
container: {
|
|
259
317
|
flex: 1,
|
|
260
318
|
backgroundColor: '#F9FAFB',
|
|
319
|
+
},
|
|
320
|
+
scrollContent: {
|
|
321
|
+
flexGrow: 1,
|
|
261
322
|
alignItems: 'center',
|
|
262
323
|
justifyContent: 'center',
|
|
263
324
|
padding: 24,
|
|
@@ -284,8 +345,6 @@ const styles = StyleSheet.create({
|
|
|
284
345
|
});
|
|
285
346
|
|
|
286
347
|
|
|
287
|
-
|
|
288
|
-
|
|
289
348
|
```
|
|
290
349
|
|
|
291
350
|
You can send `null` if billing info not available.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
#Tue
|
|
2
|
-
gradle.version=8.
|
|
1
|
+
#Tue Jun 03 14:11:22 IST 2025
|
|
2
|
+
gradle.version=8.9
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#import "EasyMerchantSdk.h"
|
|
2
2
|
#import <React/RCTLog.h>
|
|
3
3
|
#import <React/RCTBridgeModule.h>
|
|
4
|
-
//#import <easymerchantsdk/easymerchantsdk-Swift.h>
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
//#import <easymerchantsdk-Swift.h>
|
|
6
|
+
#import <easymerchantsdk/easymerchantsdk-Swift.h>
|
|
7
7
|
|
|
8
|
-
@interface EasyMerchantSdk()
|
|
8
|
+
@interface EasyMerchantSdk ()
|
|
9
9
|
@property (nonatomic, strong) EasyMerchantSdkPlugin *sdkPluginInstance;
|
|
10
10
|
@end
|
|
11
11
|
|
|
@@ -20,78 +20,129 @@ RCT_EXPORT_METHOD(configureEnvironment:(NSString *)env
|
|
|
20
20
|
if (!self.sdkPluginInstance) {
|
|
21
21
|
self.sdkPluginInstance = [[EasyMerchantSdkPlugin alloc] init];
|
|
22
22
|
}
|
|
23
|
-
|
|
23
|
+
@try {
|
|
24
|
+
[self.sdkPluginInstance configureEnvironment:env apiKey:apiKey apiSecret:apiSecret];
|
|
25
|
+
} @catch (NSException *exception) {
|
|
26
|
+
RCTLogError(@"Failed to call configureEnvironment: %@", exception.reason);
|
|
27
|
+
}
|
|
24
28
|
}
|
|
25
29
|
|
|
26
30
|
RCT_EXPORT_METHOD(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
31
|
+
billing:(NSString *)amount
|
|
32
|
+
currency:(NSString *)currency
|
|
33
|
+
billingInfo:(NSDictionary *)billingInfo
|
|
34
|
+
paymentMethods:(NSArray *)paymentMethods
|
|
35
|
+
themeConfiguration:(NSDictionary *)themeConfiguration
|
|
36
|
+
tokenOnly:(BOOL)tokenOnly
|
|
37
|
+
saveCard:(BOOL)saveCard
|
|
38
|
+
saveAccount:(BOOL)saveAccount
|
|
39
|
+
authenticatedACH:(BOOL)authenticatedACH
|
|
40
|
+
grailPayParams:(NSDictionary *)grailPayParams
|
|
41
|
+
submitButtonText:(NSString *)submitButtonText
|
|
42
|
+
isRecurring:(BOOL)isRecurring
|
|
43
|
+
recurringIntervals:(NSArray *)recurringIntervals
|
|
44
|
+
recurringStartDateType:(NSString *)recurringStartDateType
|
|
45
|
+
recurringStartDate:(NSString *)recurringStartDate
|
|
46
|
+
secureAuthentication:(BOOL)secureAuthentication
|
|
47
|
+
showReceipt:(BOOL)showReceipt
|
|
48
|
+
showTotal:(BOOL)showTotal
|
|
49
|
+
showSubmitButton:(BOOL)showSubmitButton
|
|
50
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
51
|
+
rejecter:(RCTPromiseRejectBlock)reject
|
|
44
52
|
)
|
|
45
53
|
{
|
|
46
54
|
if (!self.sdkPluginInstance) {
|
|
47
55
|
self.sdkPluginInstance = [[EasyMerchantSdkPlugin alloc] init];
|
|
48
56
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
57
|
+
@try {
|
|
58
|
+
[self.sdkPluginInstance billing:amount
|
|
59
|
+
currency:currency
|
|
60
|
+
billingInfo:billingInfo
|
|
61
|
+
paymentMethods:paymentMethods
|
|
62
|
+
themeConfiguration:themeConfiguration
|
|
63
|
+
tokenOnly:tokenOnly
|
|
64
|
+
saveCard:saveCard
|
|
65
|
+
saveAccount:saveAccount
|
|
66
|
+
authenticatedACH:authenticatedACH
|
|
67
|
+
grailPayParams:grailPayParams
|
|
68
|
+
submitButtonText:submitButtonText
|
|
69
|
+
isRecurring:isRecurring
|
|
70
|
+
recurringIntervals:recurringIntervals
|
|
71
|
+
recurringStartDateType:recurringStartDateType
|
|
72
|
+
recurringStartDate:recurringStartDate
|
|
73
|
+
secureAuthentication:secureAuthentication
|
|
74
|
+
showReceipt:showReceipt
|
|
75
|
+
showTotal:showTotal
|
|
76
|
+
showSubmitButton:showSubmitButton
|
|
77
|
+
enable3DS:secureAuthentication
|
|
78
|
+
resolver:^(id result) {
|
|
79
|
+
resolve(result);
|
|
80
|
+
self.sdkPluginInstance = nil;
|
|
81
|
+
}
|
|
82
|
+
rejecter:^(NSString *code, NSString *message, NSError *error) {
|
|
83
|
+
reject(code, message, error);
|
|
84
|
+
self.sdkPluginInstance = nil;
|
|
85
|
+
}];
|
|
86
|
+
} @catch (NSException *exception) {
|
|
87
|
+
reject(@"BRIDGE_ERROR", [NSString stringWithFormat:@"Failed to call billing: %@", exception.reason], nil);
|
|
88
|
+
}
|
|
73
89
|
}
|
|
74
90
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
91
|
+
RCT_EXPORT_METHOD(
|
|
92
|
+
paymentReference:(NSString *)referenceToken
|
|
93
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
94
|
+
rejecter:(RCTPromiseRejectBlock)reject
|
|
95
|
+
)
|
|
96
|
+
{
|
|
97
|
+
if (!self.sdkPluginInstance) {
|
|
98
|
+
self.sdkPluginInstance = [[EasyMerchantSdkPlugin alloc] init];
|
|
99
|
+
}
|
|
100
|
+
@try {
|
|
101
|
+
[self.sdkPluginInstance paymentReference:referenceToken
|
|
102
|
+
resolver:^(id result) {
|
|
103
|
+
resolve(result);
|
|
104
|
+
self.sdkPluginInstance = nil;
|
|
105
|
+
}
|
|
106
|
+
rejecter:^(NSString *code, NSString *message, NSError *error) {
|
|
107
|
+
reject(code, message, error);
|
|
108
|
+
self.sdkPluginInstance = nil;
|
|
109
|
+
}];
|
|
110
|
+
} @catch (NSException *exception) {
|
|
111
|
+
reject(@"BRIDGE_ERROR", [NSString stringWithFormat:@"Failed to call paymentReference: %@", exception.reason], nil);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
78
114
|
|
|
79
115
|
RCT_REMAP_METHOD(setViewController,
|
|
80
116
|
setViewControllerWithResolver:(RCTPromiseResolveBlock)resolve
|
|
81
117
|
rejecter:(RCTPromiseRejectBlock)reject)
|
|
82
118
|
{
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
119
|
+
@try {
|
|
120
|
+
UIViewController *rootVC = [UIApplication sharedApplication].delegate.window.rootViewController;
|
|
121
|
+
if (!rootVC) {
|
|
122
|
+
reject(@"NO_ROOT_VC", @"No root view controller found", nil);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
EasyMerchantSdkPlugin *sdkPlugin = [[EasyMerchantSdkPlugin alloc] init];
|
|
126
|
+
[sdkPlugin setViewController:rootVC];
|
|
127
|
+
resolve(@"ViewController set");
|
|
128
|
+
} @catch (NSException *exception) {
|
|
129
|
+
reject(@"BRIDGE_ERROR", [NSString stringWithFormat:@"Failed to set view controller: %@", exception.reason], nil);
|
|
130
|
+
}
|
|
87
131
|
}
|
|
88
132
|
|
|
89
|
-
|
|
90
133
|
RCT_EXPORT_METHOD(getPlatformVersion:(RCTPromiseResolveBlock)resolve
|
|
91
134
|
rejecter:(RCTPromiseRejectBlock)reject)
|
|
92
135
|
{
|
|
93
|
-
|
|
94
|
-
|
|
136
|
+
@try {
|
|
137
|
+
EasyMerchantSdkPlugin *sdkPlugin = [[EasyMerchantSdkPlugin alloc] init];
|
|
138
|
+
[sdkPlugin getPlatformVersion:^(id result) {
|
|
139
|
+
resolve(result);
|
|
140
|
+
} rejecter:^(NSString *code, NSString *message, NSError *error) {
|
|
141
|
+
reject(code, message, error);
|
|
142
|
+
}];
|
|
143
|
+
} @catch (NSException *exception) {
|
|
144
|
+
reject(@"BRIDGE_ERROR", [NSString stringWithFormat:@"Failed to get platform version: %@", exception.reason], nil);
|
|
145
|
+
}
|
|
95
146
|
}
|
|
96
147
|
|
|
97
148
|
@end
|