@jimrising/easymerchantsdk-react-native 1.3.1 → 1.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -388,6 +388,17 @@
388
388
  <option name="screenX" value="1008" />
389
389
  <option name="screenY" value="2244" />
390
390
  </PersistentDeviceSelectionData>
391
+ <PersistentDeviceSelectionData>
392
+ <option name="api" value="35" />
393
+ <option name="brand" value="google" />
394
+ <option name="codename" value="komodo" />
395
+ <option name="id" value="komodo" />
396
+ <option name="manufacturer" value="Google" />
397
+ <option name="name" value="Pixel 9 Pro XL" />
398
+ <option name="screenDensity" value="360" />
399
+ <option name="screenX" value="1008" />
400
+ <option name="screenY" value="2244" />
401
+ </PersistentDeviceSelectionData>
391
402
  <PersistentDeviceSelectionData>
392
403
  <option name="api" value="33" />
393
404
  <option name="brand" value="google" />
@@ -46,12 +46,12 @@
46
46
  <change beforePath="$PROJECT_DIR$/ios/Pods/ViewControllers/BillingInfoVC/Cells/CountryListTVC.swift" beforeDir="false" />
47
47
  <change beforePath="$PROJECT_DIR$/ios/Pods/ViewControllers/BillingInfoVC/Cells/StateListTVC.swift" beforeDir="false" />
48
48
  <change beforePath="$PROJECT_DIR$/ios/Pods/ViewControllers/CountryListVC.swift" beforeDir="false" />
49
- <change beforePath="$PROJECT_DIR$/ios/Pods/ViewControllers/EmailVerificationVC.swift" beforeDir="false" />
50
- <change beforePath="$PROJECT_DIR$/ios/Pods/ViewControllers/OTPVerificationVC.swift" beforeDir="false" />
49
+ <change beforePath="$PROJECT_DIR$/ios/Pods/ViewControllers/EmailVerificationVC.swift" beforeDir="false" afterPath="$PROJECT_DIR$/ios/Pods/ViewControllers/EmailVerificationVC.swift" afterDir="false" />
50
+ <change beforePath="$PROJECT_DIR$/ios/Pods/ViewControllers/OTPVerificationVC.swift" beforeDir="false" afterPath="$PROJECT_DIR$/ios/Pods/ViewControllers/OTPVerificationVC.swift" afterDir="false" />
51
51
  <change beforePath="$PROJECT_DIR$/ios/Pods/ViewControllers/PaymentDoneVC.swift" beforeDir="false" />
52
52
  <change beforePath="$PROJECT_DIR$/ios/Pods/ViewControllers/PaymentErrorVC.swift" beforeDir="false" />
53
53
  <change beforePath="$PROJECT_DIR$/ios/Pods/ViewControllers/PaymentInformation/AccountTypeTVC.swift" beforeDir="false" />
54
- <change beforePath="$PROJECT_DIR$/ios/Pods/ViewControllers/PaymentInformation/PaymentInfoVC.swift" beforeDir="false" />
54
+ <change beforePath="$PROJECT_DIR$/ios/Pods/ViewControllers/PaymentInformation/PaymentInfoVC.swift" beforeDir="false" afterPath="$PROJECT_DIR$/ios/Pods/ViewControllers/PaymentInformation/PaymentInfoVC.swift" afterDir="false" />
55
55
  <change beforePath="$PROJECT_DIR$/ios/Pods/ViewControllers/PaymentInformation/PaymentInformationCVC.swift" beforeDir="false" />
56
56
  <change beforePath="$PROJECT_DIR$/ios/Pods/ViewControllers/PaymentInformation/SavedAccountsTVC/SavedAccountTVC.swift" beforeDir="false" />
57
57
  <change beforePath="$PROJECT_DIR$/ios/Pods/ViewControllers/PaymentInformation/SavedAccountsTVC/SavedAccountTVC.xib" beforeDir="false" />
@@ -127,7 +127,7 @@
127
127
  <change beforePath="$PROJECT_DIR$/ios/Resources/PrivacyInfo.xcprivacy" beforeDir="false" />
128
128
  <change beforePath="$PROJECT_DIR$/ios/ThirdParty/Keyboad Handling/KeyboardObserver.swift" beforeDir="false" />
129
129
  <change beforePath="$PROJECT_DIR$/ios/easymerchantsdk.podspec" beforeDir="false" afterPath="$PROJECT_DIR$/ios/easymerchantsdk.podspec" afterDir="false" />
130
- <change beforePath="$PROJECT_DIR$/ios/easymerchantsdk.storyboard" beforeDir="false" />
130
+ <change beforePath="$PROJECT_DIR$/ios/easymerchantsdk.storyboard" beforeDir="false" afterPath="$PROJECT_DIR$/ios/easymerchantsdk.storyboard" afterDir="false" />
131
131
  <change beforePath="$PROJECT_DIR$/package-lock.json" beforeDir="false" afterPath="$PROJECT_DIR$/package-lock.json" afterDir="false" />
132
132
  <change beforePath="$PROJECT_DIR$/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/package.json" afterDir="false" />
133
133
  </list>
@@ -169,6 +169,7 @@
169
169
  <component name="RecentsManager">
170
170
  <key name="CopyFile.RECENT_KEYS">
171
171
  <recent name="$PROJECT_DIR$/ios/Pods/ViewControllers" />
172
+ <recent name="$PROJECT_DIR$/ios/Pods/ViewControllers/PaymentInformation" />
172
173
  <recent name="$PROJECT_DIR$/ios" />
173
174
  <recent name="$PROJECT_DIR$/ios/ThirdParty" />
174
175
  <recent name="$PROJECT_DIR$/ios/Example" />
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.1"
10
+ "@jimrising/easymerchantsdk-react-native": "^1.3.3"
11
11
  },
12
12
  ```
13
13
 
@@ -32,6 +32,11 @@ class EmailVerificationVC: BaseVC {
32
32
 
33
33
  var isSavedForFuture: Bool = false
34
34
 
35
+ //GrailPay Params
36
+ var grailPayAccountID: String?
37
+ var selectedGrailPayAccountType: String?
38
+ var selectedGrailPayAccountName: String?
39
+
35
40
  override func viewDidLoad() {
36
41
  super.viewDidLoad()
37
42
 
@@ -41,11 +46,9 @@ class EmailVerificationVC: BaseVC {
41
46
  let tapGesture = UITapGestureRecognizer(target: self, action: #selector(dismissKeyboard))
42
47
  view.addGestureRecognizer(tapGesture)
43
48
 
44
- print(isSavedForFuture)
45
- print(cardNumber ?? "")
46
- print(expiryDate ?? "")
47
- print(cvv ?? "")
48
- print(nameOnCard ?? "")
49
+ print(grailPayAccountID ?? "")
50
+ print(selectedGrailPayAccountType ?? "")
51
+ print(selectedGrailPayAccountName ?? "")
49
52
  }
50
53
 
51
54
  func uiFinishingTouch() {
@@ -98,18 +101,7 @@ class EmailVerificationVC: BaseVC {
98
101
  // MARK: - Send OTP Email Verification Api
99
102
  func emailVerificationApi() {
100
103
  showLoadingIndicator()
101
- // var components = URLComponents()
102
- // components.scheme = "https"
103
- // components.host = "stage-api.stage-easymerchant.io"
104
- // components.path = "/api/v1/customer/send_otp"
105
- //
106
- // guard let serviceURL = components.url else {
107
- // print("Invalid URL")
108
- // hideLoadingIndicator()
109
- // return
110
- // }
111
-
112
- // Construct the full URL using baseURL from EnvironmentConfig and path from the endpoint
104
+
113
105
  let fullURL = EnvironmentConfig.baseURL + EnvironmentConfig.Endpoints.emailVerification.path()
114
106
 
115
107
  guard let serviceURL = URL(string: fullURL) else {
@@ -196,6 +188,17 @@ class EmailVerificationVC: BaseVC {
196
188
  self.navigationController?.pushViewController(vc, animated: true)
197
189
  }
198
190
  }
191
+ else if self.selectedPaymentMethod == "GrailPay" {
192
+ if let vc = self.storyboard?.instantiateViewController(withIdentifier: "OTPVerificationVC") as? OTPVerificationVC {
193
+ vc.selectedPaymentMethod = "GrailPay"
194
+ vc.easyPayDelegate = self.easyPayDelegate
195
+ vc.grailPayAccountID = self.grailPayAccountID
196
+ vc.selectedGrailPayAccountType = self.selectedGrailPayAccountType
197
+ vc.selectedGrailPayAccountName = self.selectedGrailPayAccountName
198
+ vc.email = self.txtFieldEmail.text
199
+ self.navigationController?.pushViewController(vc, animated: true)
200
+ }
201
+ }
199
202
  }
200
203
  } else {
201
204
  print("Invalid JSON format")
@@ -55,6 +55,11 @@ class OTPVerificationVC: BaseVC {
55
55
  private var timeRemaining = 180 // 3 minutes
56
56
  private var timer: Timer?
57
57
 
58
+ //GrailPay Params
59
+ var grailPayAccountID: String?
60
+ var selectedGrailPayAccountType: String?
61
+ var selectedGrailPayAccountName: String?
62
+
58
63
  override func viewDidLoad() {
59
64
  super.viewDidLoad()
60
65
 
@@ -215,18 +220,6 @@ class OTPVerificationVC: BaseVC {
215
220
  func otpVerificationApi() {
216
221
  showLoadingIndicator()
217
222
 
218
- // var components = URLComponents()
219
- // components.scheme = "https"
220
- // components.host = "stage-api.stage-easymerchant.io"
221
- // components.path = "/api/v1/customer/verify_otp"
222
- //
223
- // guard let serviceURL = components.url else {
224
- // print("Invalid URL")
225
- // hideLoadingIndicator()
226
- // return
227
- // }
228
-
229
- // Construct the full URL using baseURL from EnvironmentConfig and path from the endpoint
230
223
  let fullURL = EnvironmentConfig.baseURL + EnvironmentConfig.Endpoints.verifyOtp.path()
231
224
 
232
225
  guard let serviceURL = URL(string: fullURL) else {
@@ -322,6 +315,17 @@ class OTPVerificationVC: BaseVC {
322
315
  }
323
316
 
324
317
  }
318
+ else if self.selectedPaymentMethod == "GrailPay" {
319
+ if let dataSection = responseObject["data"] as? [String: Any],
320
+ let innerData = dataSection["data"] as? [String: Any],
321
+ let customerId = innerData["customer_id"] as? String {
322
+ print("Extracted customer_id: \(customerId)")
323
+ self.grailPayAccountChargeApi(customerId: customerId)
324
+ } else {
325
+ print("customer_id not found. Sending empty customerId.")
326
+ self.grailPayAccountChargeApi(customerId: nil)
327
+ }
328
+ }
325
329
  } else {
326
330
  print("Invalid JSON format")
327
331
  }
@@ -341,18 +345,7 @@ class OTPVerificationVC: BaseVC {
341
345
  //MARK: - Send OTP Email Verification Api
342
346
  func emailVerificationApi() {
343
347
  showLoadingIndicator()
344
- // var components = URLComponents()
345
- // components.scheme = "https"
346
- // components.host = "stage-api.stage-easymerchant.io"
347
- // components.path = "/api/v1/customer/send_otp"
348
- //
349
- // guard let serviceURL = components.url else {
350
- // print("Invalid URL")
351
- // hideLoadingIndicator()
352
- // return
353
- // }
354
-
355
- // Construct the full URL using baseURL from EnvironmentConfig and path from the endpoint
348
+
356
349
  let fullURL = EnvironmentConfig.baseURL + EnvironmentConfig.Endpoints.emailVerification.path()
357
350
 
358
351
  guard let serviceURL = URL(string: fullURL) else {
@@ -428,19 +421,7 @@ class OTPVerificationVC: BaseVC {
428
421
  //MARK: - Card Charge Api
429
422
  func paymentIntentApi(customerId: String?) {
430
423
  showLoadingIndicator()
431
-
432
- // var components = URLComponents()
433
- // components.scheme = "https"
434
- // components.host = "stage-api.stage-easymerchant.io"
435
- // components.path = "/api/v1/charges"
436
- //
437
- // guard let serviceURL = components.url else {
438
- // print("Invalid URL")
439
- // hideLoadingIndicator()
440
- // return
441
- // }
442
-
443
- // Construct the full URL using baseURL from EnvironmentConfig and path from the endpoint
424
+
444
425
  let fullURL = EnvironmentConfig.baseURL + EnvironmentConfig.Endpoints.charges.path()
445
426
 
446
427
  guard let serviceURL = URL(string: fullURL) else {
@@ -576,18 +557,6 @@ class OTPVerificationVC: BaseVC {
576
557
  func paymentIntentWithSavedCardApi(customerId: String?) {
577
558
  showLoadingIndicator()
578
559
 
579
- // var components = URLComponents()
580
- // components.scheme = "https"
581
- // components.host = "stage-api.stage-easymerchant.io"
582
- // components.path = "/api/v1/charges"
583
- //
584
- // guard let serviceURL = components.url else {
585
- // print("Invalid URL")
586
- // hideLoadingIndicator()
587
- // return
588
- // }
589
-
590
- // Construct the full URL using baseURL from EnvironmentConfig and path from the endpoint
591
560
  let fullURL = EnvironmentConfig.baseURL + EnvironmentConfig.Endpoints.charges.path()
592
561
 
593
562
  guard let serviceURL = URL(string: fullURL) else {
@@ -708,19 +677,7 @@ class OTPVerificationVC: BaseVC {
708
677
  //MARK: - Account Charge Api
709
678
  func accountChargeApi(customerId: String?) {
710
679
  showLoadingIndicator()
711
-
712
- // var components = URLComponents()
713
- // components.scheme = "https"
714
- // components.host = "stage-api.stage-easymerchant.io"
715
- // components.path = "/api/v1/ach/charge"
716
- //
717
- // guard let serviceURL = components.url else {
718
- // print("Invalid URL")
719
- // hideLoadingIndicator()
720
- // return
721
- // }
722
-
723
- // Construct the full URL using baseURL from EnvironmentConfig and path from the endpoint
680
+
724
681
  let fullURL = EnvironmentConfig.baseURL + EnvironmentConfig.Endpoints.achCharge.path()
725
682
 
726
683
  guard let serviceURL = URL(string: fullURL) else {
@@ -854,19 +811,7 @@ class OTPVerificationVC: BaseVC {
854
811
  //MARK: - Account Charge Api if billing info is nil and saved account
855
812
  func accountChargeWithSavedAccountApi(customerId: String?) {
856
813
  showLoadingIndicator()
857
-
858
- // var components = URLComponents()
859
- // components.scheme = "https"
860
- // components.host = "stage-api.stage-easymerchant.io"
861
- // components.path = "/api/v1/ach/charge"
862
- //
863
- // guard let serviceURL = components.url else {
864
- // print("Invalid URL")
865
- // hideLoadingIndicator()
866
- // return
867
- // }
868
-
869
- // Construct the full URL using baseURL from EnvironmentConfig and path from the endpoint
814
+
870
815
  let fullURL = EnvironmentConfig.baseURL + EnvironmentConfig.Endpoints.achCharge.path()
871
816
 
872
817
  guard let serviceURL = URL(string: fullURL) else {
@@ -973,6 +918,110 @@ class OTPVerificationVC: BaseVC {
973
918
  task.resume()
974
919
  }
975
920
 
921
+ //MARK: - GrailPay Account Charge Api if user saved account
922
+ func grailPayAccountChargeApi(customerId: String?) {
923
+ showLoadingIndicator()
924
+
925
+ let fullURL = EnvironmentConfig.baseURL + EnvironmentConfig.Endpoints.achCharge.path()
926
+
927
+ guard let serviceURL = URL(string: fullURL) else {
928
+ print("Invalid URL")
929
+ hideLoadingIndicator()
930
+ return
931
+ }
932
+
933
+ var request = URLRequest(url: serviceURL)
934
+ request.httpMethod = "POST"
935
+ request.addValue("application/json", forHTTPHeaderField: "Content-Type")
936
+
937
+ let token = UserStoreSingleton.shared.clientToken
938
+ print("Setting clientToken header: \(token ?? "None")")
939
+ request.addValue(token ?? "", forHTTPHeaderField: "Client-Token")
940
+
941
+ if let apiKey = EnvironmentConfig.apiKey {
942
+ request.addValue(apiKey, forHTTPHeaderField: "X-Api-Key")
943
+ }
944
+ if let apiSecret = EnvironmentConfig.apiSecret {
945
+ request.addValue(apiSecret, forHTTPHeaderField: "X-Api-Secret")
946
+ }
947
+
948
+ let params: [String: Any] = [
949
+ "account_id": self.grailPayAccountID ?? "",
950
+ "account_type": self.selectedGrailPayAccountType ?? "",
951
+ "name": self.selectedGrailPayAccountName ?? "",
952
+ "description": "payment checkout",
953
+ "save_account": 1,
954
+ "is_default": 1,
955
+ "customer_id": customerId ?? ""
956
+ ]
957
+
958
+ print(params)
959
+
960
+ do {
961
+ let jsonData = try JSONSerialization.data(withJSONObject: params, options: .prettyPrinted)
962
+ request.httpBody = jsonData
963
+ if let jsonString = String(data: jsonData, encoding: .utf8) {
964
+ print("JSON Payload: \(jsonString)")
965
+ }
966
+ } catch let error {
967
+ print("Error creating JSON data: \(error)")
968
+ hideLoadingIndicator()
969
+ return
970
+ }
971
+
972
+ let session = URLSession.shared
973
+ let task = session.dataTask(with: request) { (serviceData, serviceResponse, error) in
974
+
975
+ DispatchQueue.main.async {
976
+ self.hideLoadingIndicator() // Stop loader when response is received
977
+ }
978
+
979
+ if let error = error {
980
+ self.presentPaymentErrorVC(errorMessage: error.localizedDescription)
981
+ return
982
+ }
983
+
984
+ guard let httpResponse = serviceResponse as? HTTPURLResponse else {
985
+ self.presentPaymentErrorVC(errorMessage: "Invalid response")
986
+ return
987
+ }
988
+
989
+ if httpResponse.statusCode == 200 || httpResponse.statusCode == 201 {
990
+ if let data = serviceData {
991
+ do {
992
+ if let responseObject = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any] {
993
+ print("Response Data: \(responseObject)")
994
+
995
+ // Check if status is 0 and handle the error
996
+ if let status = responseObject["status"] as? Int, status == 0 {
997
+ let errorMessage = responseObject["message"] as? String ?? "Unknown error"
998
+ self.presentPaymentErrorVC(errorMessage: errorMessage)
999
+ } else {
1000
+ DispatchQueue.main.async {
1001
+ if let paymentDoneVC = self.storyboard?.instantiateViewController(withIdentifier: "PaymentDoneVC") as? PaymentDoneVC {
1002
+ paymentDoneVC.chargeData = responseObject
1003
+ paymentDoneVC.selectedPaymentMethod = self.selectedPaymentMethod
1004
+ paymentDoneVC.easyPayDelegate = self.easyPayDelegate
1005
+ self.navigationController?.pushViewController(paymentDoneVC, animated: true)
1006
+ }
1007
+ }
1008
+ }
1009
+ } else {
1010
+ self.presentPaymentErrorVC(errorMessage: "Invalid JSON format")
1011
+ }
1012
+ } catch let jsonError {
1013
+ self.presentPaymentErrorVC(errorMessage: "Error parsing JSON: \(jsonError)")
1014
+ }
1015
+ } else {
1016
+ self.presentPaymentErrorVC(errorMessage: "No data received")
1017
+ }
1018
+ } else {
1019
+ self.presentPaymentErrorVC(errorMessage: "HTTP Status Code: \(httpResponse.statusCode)")
1020
+ }
1021
+ }
1022
+ task.resume()
1023
+ }
1024
+
976
1025
  @IBAction func actionBtnCancel(_ sender: UIButton) {
977
1026
  stopTimer()
978
1027
  for viewController in self.navigationController?.viewControllers ?? [] {