@jimrising/easymerchantsdk-react-native 1.4.2 → 1.4.4

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 (32) hide show
  1. package/README.md +15 -4
  2. package/android/build/.transforms/20e1216b87bd06eaab3c9e5c68d4267a/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/reactlibrary/RNEasymerchantsdkModule$1.dex +0 -0
  3. package/android/build/.transforms/20e1216b87bd06eaab3c9e5c68d4267a/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/reactlibrary/RNEasymerchantsdkModule$2.dex +0 -0
  4. package/android/build/.transforms/20e1216b87bd06eaab3c9e5c68d4267a/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/reactlibrary/RNEasymerchantsdkModule.dex +0 -0
  5. package/android/build/.transforms/e9a664a11ce12edf79cd87b1e07aa243/transformed/classes/classes_dex/classes.dex +0 -0
  6. package/android/build/intermediates/compile_library_classes_jar/debug/bundleLibCompileToJarDebug/classes.jar +0 -0
  7. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/reactlibrary/RNEasymerchantsdkModule$1.class +0 -0
  8. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/reactlibrary/RNEasymerchantsdkModule$2.class +0 -0
  9. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/reactlibrary/RNEasymerchantsdkModule.class +0 -0
  10. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/reactlibrary/RNEasymerchantsdkModule$1.class +0 -0
  11. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/reactlibrary/RNEasymerchantsdkModule$2.class +0 -0
  12. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/reactlibrary/RNEasymerchantsdkModule.class +0 -0
  13. package/android/build/intermediates/runtime_library_classes_jar/debug/bundleLibRuntimeToJarDebug/classes.jar +0 -0
  14. package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/RNEasymerchantsdkModule$1.class.uniqueId2 +0 -0
  15. package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/RNEasymerchantsdkModule$2.class.uniqueId0 +0 -0
  16. package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/RNEasymerchantsdkModule.class.uniqueId3 +0 -0
  17. package/android/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin +0 -0
  18. package/android/build.gradle +1 -1
  19. package/android/src/main/java/com/reactlibrary/RNEasymerchantsdkModule.java +0 -1
  20. package/ios/Classes/EasyMerchantSdk.m +4 -2
  21. package/ios/Classes/EasyMerchantSdk.swift +2 -0
  22. package/ios/Models/Request.swift +45 -54
  23. package/ios/Models/Result.swift +1 -0
  24. package/ios/Pods/ViewControllers/AdditionalInfoVC.swift +310 -88
  25. package/ios/Pods/ViewControllers/BillingInfoVC/BillingInfoVC.swift +289 -59
  26. package/ios/Pods/ViewControllers/EmailVerificationVC.swift +41 -86
  27. package/ios/Pods/ViewControllers/OTPVerificationVC.swift +208 -129
  28. package/ios/Pods/ViewControllers/PaymentInformation/PaymentInfoVC.swift +1304 -158
  29. package/ios/Pods/ViewControllers/ThreeDSecurePaymentDoneVC.swift +24 -258
  30. package/ios/easymerchantsdk.podspec +1 -1
  31. package/ios/easymerchantsdk.storyboard +93 -12
  32. package/package.json +1 -1
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.4.2"
10
+ "@jimrising/easymerchantsdk-react-native": "^1.4.4"
11
11
  },
12
12
  ```
13
13
 
@@ -165,7 +165,7 @@ const App = () => {
165
165
 
166
166
  const handleBilling = async () => {
167
167
  const billingInfo = {
168
- visibility: { billing: true, additional: true },
168
+ visibility: { billing: false, additional: false },
169
169
  billing: {
170
170
  address: 'Mohali, Punjab',
171
171
  country: 'India',
@@ -211,6 +211,16 @@ const App = () => {
211
211
  fontFamily: '"Inter", sans-serif',
212
212
  };
213
213
 
214
+ const authConfig = {
215
+ accessToken: '251|uTijpDGfrS88UR2V1cZNMQ8S4hUJA0sVzsnsoUZF',
216
+ vendorId: '251',
217
+ role: 'business',
218
+ timeout: 10,
219
+ isSandbox: true,
220
+ brandingName: 'Lyfecycle Payments',
221
+ finderSubtitle: 'Search for your bank',
222
+ searchPlaceholder: 'Enter bank name',
223
+ };
214
224
  try {
215
225
  if (Platform.OS === 'android') {
216
226
  const result = await RNEasymerchantsdk.billing('72', null);
@@ -225,10 +235,11 @@ const App = () => {
225
235
  false, // tokenOnly
226
236
  true, // saveCard
227
237
  true, // saveAccount
228
- false, // authenticatedACH
229
- null, // grailPayParams
238
+ true, // authenticatedACH
239
+ authConfig, // grailPayParams
230
240
  'Submit',
231
241
  false, // isRecurring
242
+ 2, // if isRecurring == true then numOfCycle required
232
243
  ['weekly', 'monthly'],
233
244
  'custom',
234
245
  '07/07/2025',
@@ -39,7 +39,7 @@ repositories {
39
39
  }
40
40
 
41
41
  dependencies {
42
- implementation 'com.app:paysdk:1.2.2'
42
+ implementation 'com.app:paysdk:1.2.3'
43
43
  implementation 'com.hbb20:ccp:2.7.3'
44
44
  implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.1"
45
45
  implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.1"
@@ -102,7 +102,6 @@ public class RNEasymerchantsdkModule extends ReactContextBaseJavaModule {
102
102
  recurringInfo.put("intervals", intervals);
103
103
  recurringInfo.put("recurringStartType", recurringDataMap.getString("recurringStartType"));
104
104
  hashMap.put("recurringData", recurringInfo);
105
-
106
105
  hashMap.put("authenticateBank", hashMapConfig.getBoolean("authenticateBank"));
107
106
 
108
107
  // Handle GrailPayParams
@@ -2,8 +2,8 @@
2
2
  #import <React/RCTLog.h>
3
3
  #import <React/RCTBridgeModule.h>
4
4
 
5
- #import <easymerchantsdk-Swift.h>
6
- //#import <easymerchantsdk/easymerchantsdk-Swift.h>
5
+ //#import <easymerchantsdk-Swift.h>
6
+ #import <easymerchantsdk/easymerchantsdk-Swift.h>
7
7
 
8
8
  @interface EasyMerchantSdk ()
9
9
  @property (nonatomic, strong) EasyMerchantSdkPlugin *sdkPluginInstance;
@@ -40,6 +40,7 @@ RCT_EXPORT_METHOD(
40
40
  grailPayParams:(NSDictionary *)grailPayParams
41
41
  submitButtonText:(NSString *)submitButtonText
42
42
  isRecurring:(BOOL)isRecurring
43
+ numOfCycle:(int)numOfCycle
43
44
  recurringIntervals:(NSArray *)recurringIntervals
44
45
  recurringStartDateType:(NSString *)recurringStartDateType
45
46
  recurringStartDate:(NSString *)recurringStartDate
@@ -67,6 +68,7 @@ RCT_EXPORT_METHOD(
67
68
  grailPayParams:grailPayParams
68
69
  submitButtonText:submitButtonText
69
70
  isRecurring:isRecurring
71
+ numOfCycle:numOfCycle
70
72
  recurringIntervals:recurringIntervals
71
73
  recurringStartDateType:recurringStartDateType
72
74
  recurringStartDate:recurringStartDate
@@ -69,6 +69,7 @@ public class EasyMerchantSdkPlugin: NSObject, RCTBridgeModule {
69
69
  grailPayParams: [String: Any]?,
70
70
  submitButtonText: String?,
71
71
  isRecurring: Bool,
72
+ numOfCycle: Int,
72
73
  recurringIntervals: [String]?,
73
74
  recurringStartDateType: String?,
74
75
  recurringStartDate: String?,
@@ -215,6 +216,7 @@ public class EasyMerchantSdkPlugin: NSObject, RCTBridgeModule {
215
216
  authenticatedACH: authenticatedACH,
216
217
  grailPayParams: grailParams,
217
218
  is_recurring: isRecurring,
219
+ numOfCycle: numOfCycle,
218
220
  recurringIntervals: intervals,
219
221
  recurringStartDateType: startType,
220
222
  recurringStartDate: recurringStartDate,
@@ -106,14 +106,14 @@ public struct FieldItem: Codable {
106
106
  public let name: String
107
107
  public let required: Bool
108
108
  public var value: String
109
-
109
+
110
110
  // Overloaded initializer for BillingFieldName
111
111
  public init(name: BillingFieldName, required: Bool, value: String) {
112
112
  self.name = name.rawValue
113
113
  self.required = required
114
114
  self.value = value
115
115
  }
116
-
116
+
117
117
  // Overloaded initializer for AdditionalFieldName
118
118
  public init(name: AdditionalFieldName, required: Bool, value: String) {
119
119
  self.name = name.rawValue
@@ -125,7 +125,7 @@ public struct FieldItem: Codable {
125
125
  public struct FieldsVisibility: Codable {
126
126
  public let billing: Bool
127
127
  public let additional: Bool
128
-
128
+
129
129
  public init(billing: Bool, additional: Bool) {
130
130
  self.billing = billing
131
131
  self.additional = additional
@@ -136,7 +136,7 @@ public struct FieldSection: Codable {
136
136
  public let visibility: FieldsVisibility
137
137
  public var billing: [FieldItem]
138
138
  public var additional: [FieldItem]
139
-
139
+
140
140
  public init(visibility: FieldsVisibility, billing: [FieldItem], additional: [FieldItem]) {
141
141
  self.visibility = visibility
142
142
  self.billing = billing
@@ -158,6 +158,7 @@ public final class Request: NSObject {
158
158
  public let authenticatedACH: Bool?
159
159
  public let grailPayParams: GrailPayRequest?
160
160
  public var is_recurring: Bool?
161
+ public var numOfCycle: Int?
161
162
  public var recurringIntervals: [RecurringIntervals]?
162
163
  public var recurringStartDateType: RecurringStartDateType?
163
164
  public var recurringStartDate: String?
@@ -167,7 +168,7 @@ public final class Request: NSObject {
167
168
  public let showSubmitButton: Bool?
168
169
  public let referenceID: Bool?
169
170
  public let referenceToken: String?
170
-
171
+
171
172
  public init(
172
173
  amount: Double? = nil,
173
174
  currency: String? = nil,
@@ -181,6 +182,7 @@ public final class Request: NSObject {
181
182
  authenticatedACH: Bool = false,
182
183
  grailPayParams: GrailPayRequest? = nil,
183
184
  is_recurring: Bool = false,
185
+ numOfCycle: Int? = nil,
184
186
  recurringIntervals: [RecurringIntervals]? = nil,
185
187
  recurringStartDateType: RecurringStartDateType? = nil,
186
188
  recurringStartDate: String? = nil,
@@ -191,7 +193,6 @@ public final class Request: NSObject {
191
193
  referenceID: Bool = false,
192
194
  referenceToken: String? = nil
193
195
  ) {
194
-
195
196
  // Validate if amount is provided, must be ≥ 0.50
196
197
  if let amt = amount, amt < 0.50 {
197
198
  DispatchQueue.main.async {
@@ -223,6 +224,7 @@ public final class Request: NSObject {
223
224
  self.authenticatedACH = authenticatedACH
224
225
  self.grailPayParams = authenticatedACH ? grailPayParams : nil
225
226
  self.is_recurring = is_recurring
227
+ self.numOfCycle = numOfCycle
226
228
  self.recurringIntervals = recurringIntervals
227
229
  self.recurringStartDateType = recurringStartDateType
228
230
  self.recurringStartDate = recurringStartDate
@@ -236,11 +238,13 @@ public final class Request: NSObject {
236
238
  // Conditionally assign recurring fields only if is_recurring == true
237
239
  if is_recurring {
238
240
  self.is_recurring = true
241
+ self.numOfCycle = numOfCycle
239
242
  self.recurringIntervals = recurringIntervals
240
243
  self.recurringStartDateType = recurringStartDateType
241
244
  self.recurringStartDate = recurringStartDate
242
245
  } else {
243
246
  self.is_recurring = false
247
+ self.numOfCycle = nil
244
248
  self.recurringIntervals = nil
245
249
  self.recurringStartDateType = nil
246
250
  self.recurringStartDate = nil
@@ -304,7 +308,7 @@ public final class Request: NSObject {
304
308
  //MARK: - Payment Intent Api
305
309
  func paymentIntentApi(completion: @escaping (Bool) -> Void) {
306
310
  guard let serviceURL = URL(string: EnvironmentConfig.baseURL + EnvironmentConfig.Endpoints.paymentIntent.path()) else {
307
- print("Invalid URL")
311
+ showErrorAndDismiss(message: "Invalid payment URL.")
308
312
  completion(false)
309
313
  return
310
314
  }
@@ -315,31 +319,14 @@ public final class Request: NSObject {
315
319
  request.addValue(EnvironmentConfig.apiKey ?? "", forHTTPHeaderField: "X-Api-Key")
316
320
  request.addValue(EnvironmentConfig.apiSecret ?? "", forHTTPHeaderField: "X-Api-Secret")
317
321
 
318
- // Check if recurringStartDate is not in the past
322
+ // Recurring date validation
319
323
  if let startDateString = recurringStartDate,
320
324
  let startDate = DateFormatter.recurringDateFormatter.date(from: startDateString) {
321
-
322
325
  let today = Calendar.current.startOfDay(for: Date())
323
326
  let startDay = Calendar.current.startOfDay(for: startDate)
324
327
 
325
328
  if startDay < today {
326
- DispatchQueue.main.async {
327
- if let topVC = UIApplication.topViewController() {
328
- let alert = UIAlertController(title: "Invalid Date",
329
- message: "The recurring start date cannot be in the past. Please select today or a future date.",
330
- preferredStyle: .alert)
331
- alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { _ in
332
- if let easyPayVC = UIApplication.findEasyPayViewController(from: topVC) {
333
- easyPayVC.dismiss(animated: true)
334
- } else {
335
- // fallback: dismiss topVC itself if it's presented modally
336
- topVC.dismiss(animated: true)
337
- }
338
- }))
339
- topVC.present(alert, animated: true)
340
- }
341
- }
342
-
329
+ showErrorAndDismiss(message: "The recurring start date cannot be in the past. Please select today or a future date.")
343
330
  completion(false)
344
331
  return
345
332
  }
@@ -347,7 +334,8 @@ public final class Request: NSObject {
347
334
 
348
335
  let params: [String: Any] = [
349
336
  "amount": amount ?? 0,
350
- "allowed_cycles": String(recurringIntervals?.count ?? 0),
337
+ // "allowed_cycles": String(recurringIntervals?.count ?? 0),
338
+ "allowed_cycles": numOfCycle ?? 0,
351
339
  "intervals": recurringIntervals?.map { $0.rawValue } ?? [],
352
340
  "is_recurring": self.is_recurring ?? false,
353
341
  "recurring_start_date": recurringStartDate ?? "",
@@ -355,21 +343,16 @@ public final class Request: NSObject {
355
343
  ]
356
344
 
357
345
  do {
358
-
359
346
  request.httpBody = try JSONSerialization.data(withJSONObject: params, options: .prettyPrinted)
360
347
  } catch {
361
- print("Error creating JSON data: \(error)")
348
+ showErrorAndDismiss(message: "Failed to encode payment data.")
362
349
  completion(false)
363
350
  return
364
351
  }
365
352
 
366
353
  let task = URLSession.shared.dataTask(with: request) { data, response, error in
367
- DispatchQueue.main.async {
368
- // Stop loader when response is received
369
- }
370
-
371
354
  guard let httpResponse = response as? HTTPURLResponse, error == nil else {
372
- print("Error: \(error?.localizedDescription ?? "Unknown error")")
355
+ self.showErrorAndDismiss(message: error?.localizedDescription ?? "An unknown error occurred.")
373
356
  completion(false)
374
357
  return
375
358
  }
@@ -378,51 +361,60 @@ public final class Request: NSObject {
378
361
  if let data = data {
379
362
  do {
380
363
  if let responseObject = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any] {
381
- print("Response Data: \(responseObject)")
382
-
383
- // Save tokens
384
364
  if let clientToken = responseObject["client_token"] as? String {
385
365
  UserStoreSingleton.shared.clientToken = clientToken
386
- print("Client Token successfully saved: \(UserStoreSingleton.shared.clientToken ?? "None")")
387
366
  }
388
-
389
367
  if let paymentIntent = responseObject["payment_intent"] as? String {
390
368
  UserStoreSingleton.shared.paymentIntent = paymentIntent
391
369
  }
392
-
393
370
  self.hostedCheckoutsApi { success in
394
371
  completion(success)
395
372
  }
373
+ return
396
374
  } else {
397
- print("Invalid JSON format")
398
- completion(false)
375
+ self.showErrorAndDismiss(message: "Invalid response format.")
399
376
  }
400
377
  } catch {
401
- print("Error parsing JSON: \(error)")
402
- completion(false)
378
+ self.showErrorAndDismiss(message: "Failed to parse response.")
403
379
  }
404
380
  } else {
405
- print("No data received")
406
- completion(false)
381
+ self.showErrorAndDismiss(message: "No response data received.")
407
382
  }
408
383
  } else {
384
+ var message = "Payment request failed with status code: \(httpResponse.statusCode)"
409
385
  if let data = data,
410
386
  let responseObj = try? JSONSerialization.jsonObject(with: data, options: []) as? [String: Any],
411
- let message = responseObj["message"] as? String {
412
- print(message)
413
- } else {
414
- print("HTTP Status Code: \(httpResponse.statusCode)")
387
+ let msg = responseObj["message"] as? String {
388
+ message = msg
415
389
  }
416
-
417
- completion(false)
390
+ self.showErrorAndDismiss(message: message)
418
391
  }
392
+ completion(false)
419
393
  }
394
+
420
395
  task.resume()
421
396
  }
422
397
 
398
+ private func showErrorAndDismiss(message: String) {
399
+ DispatchQueue.main.async {
400
+ if let topVC = UIApplication.topViewController() {
401
+ let alert = UIAlertController(title: "Payment Error",
402
+ message: message,
403
+ preferredStyle: .alert)
404
+ alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { _ in
405
+ if let easyPayVC = UIApplication.findEasyPayViewController(from: topVC) {
406
+ easyPayVC.dismiss(animated: true)
407
+ } else {
408
+ topVC.dismiss(animated: true)
409
+ }
410
+ }))
411
+ topVC.present(alert, animated: true)
412
+ }
413
+ }
414
+ }
415
+
423
416
  // MARK: - Hosted Checkout API
424
417
  func hostedCheckoutsApi(completion: @escaping (Bool) -> Void) {
425
-
426
418
  // Build the URL using EnvironmentConfig
427
419
  guard let baseURL = URL(string: EnvironmentConfig.baseURL) else {
428
420
  print("Invalid base URL")
@@ -645,4 +637,3 @@ extension UIApplication {
645
637
  }
646
638
  }
647
639
 
648
-
@@ -47,3 +47,4 @@ public final class Result: NSObject {
47
47
  super.init()
48
48
  }
49
49
  }
50
+