@jimrising/easymerchantsdk-react-native 1.3.9 → 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.
Files changed (31) hide show
  1. package/.idea/caches/deviceStreaming.xml +77 -0
  2. package/README.md +140 -81
  3. package/android/.gradle/8.10/checksums/checksums.lock +0 -0
  4. package/android/.gradle/8.10/checksums/md5-checksums.bin +0 -0
  5. package/android/.gradle/8.10/checksums/sha1-checksums.bin +0 -0
  6. package/android/.gradle/8.10/fileHashes/fileHashes.lock +0 -0
  7. package/android/.gradle/8.9/checksums/checksums.lock +0 -0
  8. package/android/.gradle/8.9/checksums/md5-checksums.bin +0 -0
  9. package/android/.gradle/8.9/checksums/sha1-checksums.bin +0 -0
  10. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  11. package/android/.gradle/buildOutputCleanup/cache.properties +1 -1
  12. package/ios/Classes/EasyMerchantSdk.m +106 -55
  13. package/ios/Classes/EasyMerchantSdk.swift +199 -77
  14. package/ios/Classes/EasyPayViewController.swift +1 -1
  15. package/ios/CustomComponents/DatePickerHandler.swift +15 -4
  16. package/ios/EnvironmentConfig.swift +32 -30
  17. package/ios/Models/Request.swift +176 -14
  18. package/ios/Models/Result.swift +12 -5
  19. package/ios/Pods/ViewControllers/AdditionalInfoVC.swift +845 -358
  20. package/ios/Pods/ViewControllers/BaseVC.swift +39 -35
  21. package/ios/Pods/ViewControllers/BillingInfoVC/BillingInfoVC.swift +1975 -170
  22. package/ios/Pods/ViewControllers/CountryListVC.swift +0 -1
  23. package/ios/Pods/ViewControllers/EmailVerificationVC.swift +74 -5
  24. package/ios/Pods/ViewControllers/GrailPayVC.swift +131 -107
  25. package/ios/Pods/ViewControllers/OTPVerificationVC.swift +296 -106
  26. package/ios/Pods/ViewControllers/PaymentDoneVC.swift +21 -12
  27. package/ios/Pods/ViewControllers/PaymentInformation/PaymentInfoVC.swift +1273 -513
  28. package/ios/Pods/ViewControllers/ThreeDSecurePaymentDoneVC.swift +104 -12
  29. package/ios/easymerchantsdk.podspec +1 -1
  30. package/ios/easymerchantsdk.storyboard +467 -412
  31. package/package.json +1 -1
@@ -3,6 +3,17 @@
3
3
  <component name="DeviceStreaming">
4
4
  <option name="deviceSelectionList">
5
5
  <list>
6
+ <PersistentDeviceSelectionData>
7
+ <option name="api" value="34" />
8
+ <option name="brand" value="Sony" />
9
+ <option name="codename" value="A402SO" />
10
+ <option name="id" value="A402SO" />
11
+ <option name="manufacturer" value="Sony" />
12
+ <option name="name" value="Xperia 10" />
13
+ <option name="screenDensity" value="450" />
14
+ <option name="screenX" value="1080" />
15
+ <option name="screenY" value="2520" />
16
+ </PersistentDeviceSelectionData>
6
17
  <PersistentDeviceSelectionData>
7
18
  <option name="api" value="27" />
8
19
  <option name="brand" value="DOCOMO" />
@@ -190,6 +201,17 @@
190
201
  <option name="screenX" value="960" />
191
202
  <option name="screenY" value="2142" />
192
203
  </PersistentDeviceSelectionData>
204
+ <PersistentDeviceSelectionData>
205
+ <option name="api" value="35" />
206
+ <option name="brand" value="google" />
207
+ <option name="codename" value="caiman" />
208
+ <option name="id" value="caiman" />
209
+ <option name="manufacturer" value="Google" />
210
+ <option name="name" value="Pixel 9 Pro" />
211
+ <option name="screenDensity" value="360" />
212
+ <option name="screenX" value="960" />
213
+ <option name="screenY" value="2142" />
214
+ </PersistentDeviceSelectionData>
193
215
  <PersistentDeviceSelectionData>
194
216
  <option name="api" value="34" />
195
217
  <option name="brand" value="google" />
@@ -245,6 +267,17 @@
245
267
  <option name="screenX" value="1440" />
246
268
  <option name="screenY" value="3088" />
247
269
  </PersistentDeviceSelectionData>
270
+ <PersistentDeviceSelectionData>
271
+ <option name="api" value="34" />
272
+ <option name="brand" value="motorola" />
273
+ <option name="codename" value="dubai" />
274
+ <option name="id" value="dubai" />
275
+ <option name="manufacturer" value="Motorola" />
276
+ <option name="name" value="edge 30" />
277
+ <option name="screenDensity" value="405" />
278
+ <option name="screenX" value="1080" />
279
+ <option name="screenY" value="2400" />
280
+ </PersistentDeviceSelectionData>
248
281
  <PersistentDeviceSelectionData>
249
282
  <option name="api" value="34" />
250
283
  <option name="brand" value="samsung" />
@@ -322,6 +355,17 @@
322
355
  <option name="screenX" value="720" />
323
356
  <option name="screenY" value="1600" />
324
357
  </PersistentDeviceSelectionData>
358
+ <PersistentDeviceSelectionData>
359
+ <option name="api" value="34" />
360
+ <option name="brand" value="motorola" />
361
+ <option name="codename" value="fogos" />
362
+ <option name="id" value="fogos" />
363
+ <option name="manufacturer" value="Motorola" />
364
+ <option name="name" value="moto g34 5G" />
365
+ <option name="screenDensity" value="280" />
366
+ <option name="screenX" value="720" />
367
+ <option name="screenY" value="1600" />
368
+ </PersistentDeviceSelectionData>
325
369
  <PersistentDeviceSelectionData>
326
370
  <option name="api" value="34" />
327
371
  <option name="brand" value="samsung" />
@@ -344,6 +388,17 @@
344
388
  <option name="screenX" value="1200" />
345
389
  <option name="screenY" value="1920" />
346
390
  </PersistentDeviceSelectionData>
391
+ <PersistentDeviceSelectionData>
392
+ <option name="api" value="33" />
393
+ <option name="brand" value="samsung" />
394
+ <option name="codename" value="gts7lwifi" />
395
+ <option name="id" value="gts7lwifi" />
396
+ <option name="manufacturer" value="Samsung" />
397
+ <option name="name" value="SM-T870" />
398
+ <option name="screenDensity" value="340" />
399
+ <option name="screenX" value="1600" />
400
+ <option name="screenY" value="2560" />
401
+ </PersistentDeviceSelectionData>
347
402
  <PersistentDeviceSelectionData>
348
403
  <option name="api" value="34" />
349
404
  <option name="brand" value="samsung" />
@@ -454,6 +509,17 @@
454
509
  <option name="screenX" value="1080" />
455
510
  <option name="screenY" value="2400" />
456
511
  </PersistentDeviceSelectionData>
512
+ <PersistentDeviceSelectionData>
513
+ <option name="api" value="34" />
514
+ <option name="brand" value="motorola" />
515
+ <option name="codename" value="manaus" />
516
+ <option name="id" value="manaus" />
517
+ <option name="manufacturer" value="Motorola" />
518
+ <option name="name" value="edge 40 neo" />
519
+ <option name="screenDensity" value="400" />
520
+ <option name="screenX" value="1080" />
521
+ <option name="screenY" value="2400" />
522
+ </PersistentDeviceSelectionData>
457
523
  <PersistentDeviceSelectionData>
458
524
  <option name="api" value="33" />
459
525
  <option name="brand" value="motorola" />
@@ -487,6 +553,17 @@
487
553
  <option name="screenX" value="1080" />
488
554
  <option name="screenY" value="2400" />
489
555
  </PersistentDeviceSelectionData>
556
+ <PersistentDeviceSelectionData>
557
+ <option name="api" value="35" />
558
+ <option name="brand" value="samsung" />
559
+ <option name="codename" value="pa3q" />
560
+ <option name="id" value="pa3q" />
561
+ <option name="manufacturer" value="Samsung" />
562
+ <option name="name" value="Galaxy S25 Ultra" />
563
+ <option name="screenDensity" value="600" />
564
+ <option name="screenX" value="1440" />
565
+ <option name="screenY" value="3120" />
566
+ </PersistentDeviceSelectionData>
490
567
  <PersistentDeviceSelectionData>
491
568
  <option name="api" value="33" />
492
569
  <option name="brand" value="google" />
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.3.9"
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', // Options: sandbox, staging, production
138
- '14fbf8a186091763e59c289c1',
139
- 'f90863e7a853539f8ace8d6de'
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 fetching version');
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
- address: 'Test',
168
- country: 'test',
169
- state: 'test',
170
- city: 'test',
171
- postal_code: '234132',
172
- additional_info: {
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
- email: 'test@gmail.com',
175
- phone_number: '7888821587',
176
- country_code: '91',
177
- description: 'SDK Test',
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: '#FFEEEE',
183
- containerBackgroundColor: '#FFCCCC',
184
- primaryFontColor: '#B30000',
185
- secondaryFontColor: '#660000',
186
- primaryButtonBackgroundColor: '#D50000',
187
- primaryButtonHoverColor: '#9C0000',
198
+ bodyBackgroundColor: '#121212',
199
+ containerBackgroundColor: '#1E1E1E',
200
+ primaryFontColor: '#FFFFFF',
201
+ secondaryFontColor: '#B0B0B0',
202
+ primaryButtonBackgroundColor: '#2563EB',
203
+ primaryButtonHoverColor: '#1D4ED8',
188
204
  primaryButtonFontColor: '#FFFFFF',
189
- secondaryButtonBackgroundColor: '#FF6666',
190
- secondaryButtonHoverColor: '#FF4D4D',
191
- secondaryButtonFontColor: '#FFFFFF',
192
- borderRadius: '12',
193
- fontSize: '16',
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
- const authConfig = {
197
- accessToken: '251|uTijpDGfrS88UR2V1cZNMQ8S4hUJA0sVzsnsoUZF',
198
- vendorId: '251',
199
- role: 'business',
200
- timeout: 10,
201
- isSandbox: true,
202
- brandingName: 'Lyfecycle Payments',
203
- finderSubtitle: 'Search for your bank',
204
- searchPlaceholder: 'Enter bank name',
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
- try {
208
- if (Platform.OS === 'android') {
209
- const result = await RNEasymerchantsdk.billing(amount, null);
210
- setResponse(`✅ Android Payment Success: ${result}`);
211
- } else {
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
- <Text style={styles.title}>EasyMerchant SDK</Text>
243
- <Text style={styles.version}>Platform Version: {version}</Text>
244
-
245
- <Button title="Get Platform Version" onPress={getPlatformVersion} />
246
- <View style={styles.space} />
247
- <Button title="Start Billing" onPress={handleBilling} />
248
- <View style={styles.space} />
249
-
250
- <Text style={styles.response}>{response}</Text>
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.
@@ -1,2 +1,2 @@
1
- #Wed May 28 13:58:36 IST 2025
1
+ #Tue Jun 03 14:11:22 IST 2025
2
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
- // #import <easymerchantsdk-Swift.h>
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
- [self.sdkPluginInstance configureEnvironment:env apiKey:apiKey apiSecret:apiSecret];
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
- billing:(NSString *)amount
28
- billingInfo:(NSString *)billingInfo
29
- paymentMethods:(NSArray *)paymentMethods
30
- themeConfiguration:(NSDictionary *)themeConfiguration
31
- tokenOnly:(BOOL)tokenOnly
32
- saveCard:(BOOL)saveCard
33
- saveAccount:(BOOL)saveAccount
34
- authenticatedACH:(BOOL)authenticatedACH
35
- grailPayParams:(NSDictionary *)grailPayParams
36
- submitButtonText:(NSString *)submitButtonText
37
- isRecurring:(BOOL)isRecurring
38
- recurringIntervals:(NSArray *)recurringIntervals
39
- recurringStartDateType:(NSString *)recurringStartDateType
40
- recurringStartDate:(NSString *)recurringStartDate
41
- enable3DS:(BOOL)enable3DS
42
- resolver:(RCTPromiseResolveBlock)resolve
43
- rejecter:(RCTPromiseRejectBlock)reject
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
- [self.sdkPluginInstance billing:amount
51
- billinginfo:billingInfo
52
- paymentMethods:paymentMethods
53
- themeConfiguration:themeConfiguration
54
- tokenOnly:tokenOnly
55
- saveCard:saveCard
56
- saveAccount:saveAccount
57
- authenticatedACH:authenticatedACH
58
- grailPayParams:grailPayParams
59
- submitButtonText:submitButtonText
60
- isRecurring:isRecurring
61
- recurringIntervals:recurringIntervals
62
- recurringStartDateType:recurringStartDateType
63
- recurringStartDate:recurringStartDate
64
- enable3DS:enable3DS
65
- resolver:^(id result) {
66
- resolve(result);
67
- self.sdkPluginInstance = nil;
68
- }
69
- rejecter:^(NSString *code, NSString *message, NSError *error) {
70
- reject(code, message, error);
71
- self.sdkPluginInstance = nil;
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
- UIViewController *rootVC = [UIApplication sharedApplication].delegate.window.rootViewController;
84
- EasyMerchantSdkPlugin *sdkPlugin = [[EasyMerchantSdkPlugin alloc] init];
85
- [sdkPlugin setViewController:rootVC];
86
- resolve(@"ViewController set");
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
- NSString *platformVersion = [NSString stringWithFormat:@"iOS %@", [[UIDevice currentDevice] systemVersion]];
94
- resolve(platformVersion);
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