@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.
- package/README.md +15 -4
- package/android/build/.transforms/20e1216b87bd06eaab3c9e5c68d4267a/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/reactlibrary/RNEasymerchantsdkModule$1.dex +0 -0
- package/android/build/.transforms/20e1216b87bd06eaab3c9e5c68d4267a/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/reactlibrary/RNEasymerchantsdkModule$2.dex +0 -0
- package/android/build/.transforms/20e1216b87bd06eaab3c9e5c68d4267a/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/reactlibrary/RNEasymerchantsdkModule.dex +0 -0
- package/android/build/.transforms/e9a664a11ce12edf79cd87b1e07aa243/transformed/classes/classes_dex/classes.dex +0 -0
- package/android/build/intermediates/compile_library_classes_jar/debug/bundleLibCompileToJarDebug/classes.jar +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/reactlibrary/RNEasymerchantsdkModule$1.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/reactlibrary/RNEasymerchantsdkModule$2.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/reactlibrary/RNEasymerchantsdkModule.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/reactlibrary/RNEasymerchantsdkModule$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/reactlibrary/RNEasymerchantsdkModule$2.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/reactlibrary/RNEasymerchantsdkModule.class +0 -0
- package/android/build/intermediates/runtime_library_classes_jar/debug/bundleLibRuntimeToJarDebug/classes.jar +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/RNEasymerchantsdkModule$1.class.uniqueId2 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/RNEasymerchantsdkModule$2.class.uniqueId0 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/RNEasymerchantsdkModule.class.uniqueId3 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin +0 -0
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/reactlibrary/RNEasymerchantsdkModule.java +0 -1
- package/ios/Classes/EasyMerchantSdk.m +4 -2
- package/ios/Classes/EasyMerchantSdk.swift +2 -0
- package/ios/Models/Request.swift +45 -54
- package/ios/Models/Result.swift +1 -0
- package/ios/Pods/ViewControllers/AdditionalInfoVC.swift +310 -88
- package/ios/Pods/ViewControllers/BillingInfoVC/BillingInfoVC.swift +289 -59
- package/ios/Pods/ViewControllers/EmailVerificationVC.swift +41 -86
- package/ios/Pods/ViewControllers/OTPVerificationVC.swift +208 -129
- package/ios/Pods/ViewControllers/PaymentInformation/PaymentInfoVC.swift +1304 -158
- package/ios/Pods/ViewControllers/ThreeDSecurePaymentDoneVC.swift +24 -258
- package/ios/easymerchantsdk.podspec +1 -1
- package/ios/easymerchantsdk.storyboard +93 -12
- package/package.json +1 -1
|
@@ -72,8 +72,13 @@ class OTPVerificationVC: BaseVC {
|
|
|
72
72
|
var billingInfo: [FieldItem]?
|
|
73
73
|
var visibility: FieldsVisibility?
|
|
74
74
|
|
|
75
|
+
var amount: Int?
|
|
76
|
+
|
|
77
|
+
var isSavedNewCard: Bool = false
|
|
78
|
+
|
|
75
79
|
override func viewDidLoad() {
|
|
76
80
|
super.viewDidLoad()
|
|
81
|
+
emailVerificationApi()
|
|
77
82
|
|
|
78
83
|
uiFinishingTouchElements()
|
|
79
84
|
|
|
@@ -267,6 +272,89 @@ class OTPVerificationVC: BaseVC {
|
|
|
267
272
|
}
|
|
268
273
|
}
|
|
269
274
|
|
|
275
|
+
//MARK: - Send OTP Email Verification Api
|
|
276
|
+
func emailVerificationApi() {
|
|
277
|
+
showLoadingIndicator()
|
|
278
|
+
|
|
279
|
+
let fullURL = EnvironmentConfig.baseURL + EnvironmentConfig.Endpoints.emailVerification.path()
|
|
280
|
+
|
|
281
|
+
guard let serviceURL = URL(string: fullURL) else {
|
|
282
|
+
print("Invalid URL")
|
|
283
|
+
hideLoadingIndicator()
|
|
284
|
+
return
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
var request = URLRequest(url: serviceURL)
|
|
288
|
+
request.httpMethod = "POST"
|
|
289
|
+
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
|
|
290
|
+
|
|
291
|
+
let token = UserStoreSingleton.shared.clientToken
|
|
292
|
+
print("Setting clientToken header: \(token ?? "None")")
|
|
293
|
+
request.addValue(token ?? "", forHTTPHeaderField: "Client-Token")
|
|
294
|
+
|
|
295
|
+
// Add API headers
|
|
296
|
+
if let apiKey = EnvironmentConfig.apiKey,
|
|
297
|
+
let apiSecret = EnvironmentConfig.apiSecret {
|
|
298
|
+
request.addValue(apiKey, forHTTPHeaderField: "x-api-key")
|
|
299
|
+
request.addValue(apiSecret, forHTTPHeaderField: "x-api-secret")
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
let params: [String: Any] = [
|
|
303
|
+
"card_search_value": email ?? "",
|
|
304
|
+
"card_search_key": "email"
|
|
305
|
+
]
|
|
306
|
+
|
|
307
|
+
do {
|
|
308
|
+
let jsonData = try JSONSerialization.data(withJSONObject: params, options: .prettyPrinted)
|
|
309
|
+
request.httpBody = jsonData
|
|
310
|
+
if let jsonString = String(data: jsonData, encoding: .utf8) {
|
|
311
|
+
print("JSON Payload: \(jsonString)")
|
|
312
|
+
}
|
|
313
|
+
} catch let error {
|
|
314
|
+
print("Error creating JSON data: \(error)")
|
|
315
|
+
hideLoadingIndicator()
|
|
316
|
+
return
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
let session = URLSession.shared
|
|
320
|
+
let task = session.dataTask(with: request) { (serviceData, serviceResponse, error) in
|
|
321
|
+
|
|
322
|
+
DispatchQueue.main.async {
|
|
323
|
+
self.hideLoadingIndicator() // Stop loader when response is received
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
if let error = error {
|
|
327
|
+
print("Error: \(error.localizedDescription)")
|
|
328
|
+
return
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
guard let httpResponse = serviceResponse as? HTTPURLResponse else {
|
|
332
|
+
print("Invalid response")
|
|
333
|
+
return
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
if httpResponse.statusCode == 200 || httpResponse.statusCode == 201 {
|
|
337
|
+
if let data = serviceData {
|
|
338
|
+
do {
|
|
339
|
+
if let responseObject = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any] {
|
|
340
|
+
print("Response Data: \(responseObject)")
|
|
341
|
+
|
|
342
|
+
} else {
|
|
343
|
+
print("Invalid JSON format")
|
|
344
|
+
}
|
|
345
|
+
} catch let jsonError {
|
|
346
|
+
print("Error parsing JSON: \(jsonError)")
|
|
347
|
+
}
|
|
348
|
+
} else {
|
|
349
|
+
print("No data received")
|
|
350
|
+
}
|
|
351
|
+
} else {
|
|
352
|
+
print("HTTP Status Code: \(httpResponse.statusCode)")
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
task.resume()
|
|
356
|
+
}
|
|
357
|
+
|
|
270
358
|
//MARK: - OTP Verification Api
|
|
271
359
|
func otpVerificationApi() {
|
|
272
360
|
showLoadingIndicator()
|
|
@@ -334,7 +422,7 @@ class OTPVerificationVC: BaseVC {
|
|
|
334
422
|
do {
|
|
335
423
|
if let responseObject = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any] {
|
|
336
424
|
print("Response Data: \(responseObject)")
|
|
337
|
-
if self.selectedPaymentMethod == "Card"
|
|
425
|
+
if self.selectedPaymentMethod == "Card"{
|
|
338
426
|
if let dataSection = responseObject["data"] as? [String: Any],
|
|
339
427
|
let innerData = dataSection["data"] as? [String: Any],
|
|
340
428
|
let customerId = innerData["customer_id"] as? String {
|
|
@@ -359,7 +447,14 @@ class OTPVerificationVC: BaseVC {
|
|
|
359
447
|
}
|
|
360
448
|
} else {
|
|
361
449
|
print("customer_id not found in nested data. Falling back to nil.")
|
|
362
|
-
self.
|
|
450
|
+
if let request = self.request {
|
|
451
|
+
if request.secureAuthentication == true {
|
|
452
|
+
self.threeDSecurePaymentSavedCardApi(customerId: nil)
|
|
453
|
+
}
|
|
454
|
+
else {
|
|
455
|
+
self.paymentIntentApi(customerId: nil)
|
|
456
|
+
}
|
|
457
|
+
}
|
|
363
458
|
}
|
|
364
459
|
}
|
|
365
460
|
else if self.selectedPaymentMethod == "Bank" {
|
|
@@ -395,100 +490,17 @@ class OTPVerificationVC: BaseVC {
|
|
|
395
490
|
self.grailPayAccountChargeApi(customerId: nil)
|
|
396
491
|
}
|
|
397
492
|
}
|
|
398
|
-
else if self.selectedPaymentMethod == "NewGrailPayAccount" {
|
|
399
|
-
if let dataSection = responseObject["data"] as? [String: Any],
|
|
400
|
-
let innerData = dataSection["data"] as? [String: Any],
|
|
401
|
-
let customerId = innerData["customer_id"] as? String {
|
|
402
|
-
print("Extracted customer_id: \(customerId)")
|
|
403
|
-
self.grailPayAccountChargeApi(customerId: customerId)
|
|
404
|
-
} else {
|
|
405
|
-
print("customer_id not found. Sending empty customerId.")
|
|
406
|
-
self.grailPayAccountChargeApi(customerId: nil)
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
} else {
|
|
410
|
-
print("Invalid JSON format")
|
|
411
|
-
}
|
|
412
|
-
} catch let jsonError {
|
|
413
|
-
print("Error parsing JSON: \(jsonError)")
|
|
414
|
-
}
|
|
415
|
-
} else {
|
|
416
|
-
print("No data received")
|
|
417
|
-
}
|
|
418
|
-
} else {
|
|
419
|
-
print("HTTP Status Code: \(httpResponse.statusCode)")
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
task.resume()
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
//MARK: - Send OTP Email Verification Api
|
|
426
|
-
func emailVerificationApi() {
|
|
427
|
-
showLoadingIndicator()
|
|
428
|
-
|
|
429
|
-
let fullURL = EnvironmentConfig.baseURL + EnvironmentConfig.Endpoints.emailVerification.path()
|
|
430
|
-
|
|
431
|
-
guard let serviceURL = URL(string: fullURL) else {
|
|
432
|
-
print("Invalid URL")
|
|
433
|
-
hideLoadingIndicator()
|
|
434
|
-
return
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
var request = URLRequest(url: serviceURL)
|
|
438
|
-
request.httpMethod = "POST"
|
|
439
|
-
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
|
|
440
|
-
|
|
441
|
-
let token = UserStoreSingleton.shared.clientToken
|
|
442
|
-
print("Setting clientToken header: \(token ?? "None")")
|
|
443
|
-
request.addValue(token ?? "", forHTTPHeaderField: "Client-Token")
|
|
444
|
-
|
|
445
|
-
// Add API headers
|
|
446
|
-
if let apiKey = EnvironmentConfig.apiKey,
|
|
447
|
-
let apiSecret = EnvironmentConfig.apiSecret {
|
|
448
|
-
request.addValue(apiKey, forHTTPHeaderField: "x-api-key")
|
|
449
|
-
request.addValue(apiSecret, forHTTPHeaderField: "x-api-secret")
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
let params: [String: Any] = [
|
|
453
|
-
"card_search_value": email ?? "",
|
|
454
|
-
"card_search_key": "email"
|
|
455
|
-
]
|
|
456
|
-
|
|
457
|
-
do {
|
|
458
|
-
let jsonData = try JSONSerialization.data(withJSONObject: params, options: .prettyPrinted)
|
|
459
|
-
request.httpBody = jsonData
|
|
460
|
-
if let jsonString = String(data: jsonData, encoding: .utf8) {
|
|
461
|
-
print("JSON Payload: \(jsonString)")
|
|
462
|
-
}
|
|
463
|
-
} catch let error {
|
|
464
|
-
print("Error creating JSON data: \(error)")
|
|
465
|
-
hideLoadingIndicator()
|
|
466
|
-
return
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
let session = URLSession.shared
|
|
470
|
-
let task = session.dataTask(with: request) { (serviceData, serviceResponse, error) in
|
|
471
|
-
|
|
472
|
-
DispatchQueue.main.async {
|
|
473
|
-
self.hideLoadingIndicator() // Stop loader when response is received
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
if let error = error {
|
|
477
|
-
print("Error: \(error.localizedDescription)")
|
|
478
|
-
return
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
guard let httpResponse = serviceResponse as? HTTPURLResponse else {
|
|
482
|
-
print("Invalid response")
|
|
483
|
-
return
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
if httpResponse.statusCode == 200 || httpResponse.statusCode == 201 {
|
|
487
|
-
if let data = serviceData {
|
|
488
|
-
do {
|
|
489
|
-
if let responseObject = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any] {
|
|
490
|
-
print("Response Data: \(responseObject)")
|
|
491
|
-
|
|
493
|
+
// else if self.selectedPaymentMethod == "NewGrailPayAccount" {
|
|
494
|
+
// if let dataSection = responseObject["data"] as? [String: Any],
|
|
495
|
+
// let innerData = dataSection["data"] as? [String: Any],
|
|
496
|
+
// let customerId = innerData["customer_id"] as? String {
|
|
497
|
+
// print("Extracted customer_id: \(customerId)")
|
|
498
|
+
// self.grailPayAccountChargeApi(customerId: customerId)
|
|
499
|
+
// } else {
|
|
500
|
+
// print("customer_id not found. Sending empty customerId.")
|
|
501
|
+
// self.grailPayAccountChargeApi(customerId: nil)
|
|
502
|
+
// }
|
|
503
|
+
// }
|
|
492
504
|
} else {
|
|
493
505
|
print("Invalid JSON format")
|
|
494
506
|
}
|
|
@@ -1225,23 +1237,43 @@ class OTPVerificationVC: BaseVC {
|
|
|
1225
1237
|
uRLRequest.addValue(apiSecret, forHTTPHeaderField: "X-Api-Secret")
|
|
1226
1238
|
}
|
|
1227
1239
|
|
|
1240
|
+
let emailPrefix = userEmail?.components(separatedBy: "@").first ?? ""
|
|
1241
|
+
|
|
1228
1242
|
var params: [String: Any] = [
|
|
1229
1243
|
"account_id": self.grailPayAccountID ?? "",
|
|
1230
1244
|
"account_type": self.selectedGrailPayAccountType ?? "",
|
|
1231
1245
|
"name": self.selectedGrailPayAccountName ?? "",
|
|
1232
|
-
// "description": "payment checkout",
|
|
1233
1246
|
"save_account": 1,
|
|
1234
1247
|
"is_default": 1,
|
|
1235
1248
|
"customer_id": customerId ?? "",
|
|
1236
|
-
"email":
|
|
1249
|
+
"email": userEmail ?? "",
|
|
1250
|
+
"create_customer": "1",
|
|
1237
1251
|
]
|
|
1238
1252
|
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1253
|
+
if let customerId = customerId {
|
|
1254
|
+
params["customer"] = customerId
|
|
1255
|
+
} else {
|
|
1256
|
+
params["username"] = emailPrefix
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
// // Billing Info
|
|
1260
|
+
// if let visibility = visibility, visibility.billing == true,
|
|
1261
|
+
// let billing = billingInfo, !billing.isEmpty {
|
|
1262
|
+
// var billingDict: [String: Any] = [:]
|
|
1263
|
+
// billing.forEach { billingDict[$0.name] = $0.value }
|
|
1264
|
+
//
|
|
1265
|
+
// params["address"] = billingDict["address"] as? String ?? ""
|
|
1266
|
+
// params["country"] = billingDict["country"] as? String ?? ""
|
|
1267
|
+
// params["state"] = billingDict["state"] as? String ?? ""
|
|
1268
|
+
// params["city"] = billingDict["city"] as? String ?? ""
|
|
1269
|
+
// params["zip"] = billingDict["postal_code"] as? String ?? ""
|
|
1270
|
+
// }
|
|
1271
|
+
|
|
1272
|
+
// Always include Billing Info if available
|
|
1273
|
+
if let billing = billingInfo, !billing.isEmpty {
|
|
1242
1274
|
var billingDict: [String: Any] = [:]
|
|
1243
1275
|
billing.forEach { billingDict[$0.name] = $0.value }
|
|
1244
|
-
|
|
1276
|
+
|
|
1245
1277
|
params["address"] = billingDict["address"] as? String ?? ""
|
|
1246
1278
|
params["country"] = billingDict["country"] as? String ?? ""
|
|
1247
1279
|
params["state"] = billingDict["state"] as? String ?? ""
|
|
@@ -1249,18 +1281,34 @@ class OTPVerificationVC: BaseVC {
|
|
|
1249
1281
|
params["zip"] = billingDict["postal_code"] as? String ?? ""
|
|
1250
1282
|
}
|
|
1251
1283
|
|
|
1252
|
-
// Additional Info or default description
|
|
1253
|
-
var descriptionValue: String = "Hosted payment checkout" // default
|
|
1254
|
-
if let visibility = visibility, visibility.additional == true,
|
|
1255
|
-
let additional = additionalInfo, !additional.isEmpty {
|
|
1256
|
-
|
|
1284
|
+
// // Additional Info or default description
|
|
1285
|
+
// var descriptionValue: String = "Hosted payment checkout" // default
|
|
1286
|
+
// if let visibility = visibility, visibility.additional == true,
|
|
1287
|
+
// let additional = additionalInfo, !additional.isEmpty {
|
|
1288
|
+
//
|
|
1289
|
+
// var additionalDict: [String: Any] = [:]
|
|
1290
|
+
// additional.forEach { additionalDict[$0.name] = $0.value }
|
|
1291
|
+
//
|
|
1292
|
+
// if let desc = additionalDict["description"] as? String, !desc.isEmpty {
|
|
1293
|
+
// descriptionValue = desc
|
|
1294
|
+
// }
|
|
1295
|
+
//
|
|
1296
|
+
// if let phone = additionalDict["phone_number"] as? String, !phone.isEmpty {
|
|
1297
|
+
// params["phone_number"] = phone
|
|
1298
|
+
// }
|
|
1299
|
+
// }
|
|
1300
|
+
// params["description"] = descriptionValue
|
|
1301
|
+
|
|
1302
|
+
// Always include Additional Info if available
|
|
1303
|
+
var descriptionValue: String = "Hosted payment checkout"
|
|
1304
|
+
if let additional = additionalInfo, !additional.isEmpty {
|
|
1257
1305
|
var additionalDict: [String: Any] = [:]
|
|
1258
1306
|
additional.forEach { additionalDict[$0.name] = $0.value }
|
|
1259
|
-
|
|
1307
|
+
|
|
1260
1308
|
if let desc = additionalDict["description"] as? String, !desc.isEmpty {
|
|
1261
1309
|
descriptionValue = desc
|
|
1262
1310
|
}
|
|
1263
|
-
|
|
1311
|
+
|
|
1264
1312
|
if let phone = additionalDict["phone_number"] as? String, !phone.isEmpty {
|
|
1265
1313
|
params["phone_number"] = phone
|
|
1266
1314
|
}
|
|
@@ -1341,19 +1389,19 @@ class OTPVerificationVC: BaseVC {
|
|
|
1341
1389
|
// Conditionally pass raw FieldItem array
|
|
1342
1390
|
paymentDoneVC.visibility = self.visibility
|
|
1343
1391
|
|
|
1344
|
-
|
|
1392
|
+
// if self.visibility?.billing == true {
|
|
1345
1393
|
paymentDoneVC.billingInfoData = self.billingInfo
|
|
1346
1394
|
var billingDict: [String: Any] = [:]
|
|
1347
1395
|
self.billingInfo?.forEach { billingDict[$0.name] = $0.value }
|
|
1348
1396
|
paymentDoneVC.billingInfo = billingDict
|
|
1349
|
-
|
|
1397
|
+
// }
|
|
1350
1398
|
|
|
1351
|
-
|
|
1399
|
+
// if self.visibility?.additional == true {
|
|
1352
1400
|
paymentDoneVC.additionalInfoData = self.additionalInfo
|
|
1353
1401
|
var additionalDict: [String: Any] = [:]
|
|
1354
1402
|
self.additionalInfo?.forEach { additionalDict[$0.name] = $0.value }
|
|
1355
1403
|
paymentDoneVC.additionalInfo = additionalDict
|
|
1356
|
-
|
|
1404
|
+
// }
|
|
1357
1405
|
self.navigationController?.pushViewController(paymentDoneVC, animated: true)
|
|
1358
1406
|
}
|
|
1359
1407
|
}
|
|
@@ -1411,7 +1459,7 @@ class OTPVerificationVC: BaseVC {
|
|
|
1411
1459
|
|
|
1412
1460
|
var params: [String: Any] = [
|
|
1413
1461
|
"name": nameOnCard ?? "",
|
|
1414
|
-
"email":
|
|
1462
|
+
"email": userEmail ?? "",
|
|
1415
1463
|
"card_number": cardNumber?.replacingOccurrences(of: " ", with: "") ?? "",
|
|
1416
1464
|
"cardholder_name": nameOnCard ?? "",
|
|
1417
1465
|
"exp_month": expiryDate?.components(separatedBy: "/").first ?? "",
|
|
@@ -1565,12 +1613,42 @@ class OTPVerificationVC: BaseVC {
|
|
|
1565
1613
|
"customer_id": customerId ?? ""
|
|
1566
1614
|
]
|
|
1567
1615
|
|
|
1568
|
-
// Billing Info
|
|
1569
|
-
if let visibility = visibility, visibility.billing == true,
|
|
1570
|
-
let billing = billingInfo, !billing.isEmpty {
|
|
1616
|
+
// // Billing Info
|
|
1617
|
+
// if let visibility = visibility, visibility.billing == true,
|
|
1618
|
+
// let billing = billingInfo, !billing.isEmpty {
|
|
1619
|
+
// var billingDict: [String: Any] = [:]
|
|
1620
|
+
// billing.forEach { billingDict[$0.name] = $0.value }
|
|
1621
|
+
//
|
|
1622
|
+
// params["address"] = billingDict["address"] as? String ?? ""
|
|
1623
|
+
// params["country"] = billingDict["country"] as? String ?? ""
|
|
1624
|
+
// params["state"] = billingDict["state"] as? String ?? ""
|
|
1625
|
+
// params["city"] = billingDict["city"] as? String ?? ""
|
|
1626
|
+
// params["zip"] = billingDict["postal_code"] as? String ?? ""
|
|
1627
|
+
// }
|
|
1628
|
+
//
|
|
1629
|
+
// // Additional Info or default description
|
|
1630
|
+
// var descriptionValue: String = "Hosted payment checkout" // default
|
|
1631
|
+
// if let visibility = visibility, visibility.additional == true,
|
|
1632
|
+
// let additional = additionalInfo, !additional.isEmpty {
|
|
1633
|
+
//
|
|
1634
|
+
// var additionalDict: [String: Any] = [:]
|
|
1635
|
+
// additional.forEach { additionalDict[$0.name] = $0.value }
|
|
1636
|
+
//
|
|
1637
|
+
// if let desc = additionalDict["description"] as? String, !desc.isEmpty {
|
|
1638
|
+
// descriptionValue = desc
|
|
1639
|
+
// }
|
|
1640
|
+
//
|
|
1641
|
+
// if let phone = additionalDict["phone_number"] as? String, !phone.isEmpty {
|
|
1642
|
+
// params["phone_number"] = phone
|
|
1643
|
+
// }
|
|
1644
|
+
// }
|
|
1645
|
+
// params["description"] = descriptionValue
|
|
1646
|
+
|
|
1647
|
+
// Always include Billing Info if available
|
|
1648
|
+
if let billing = billingInfo, !billing.isEmpty {
|
|
1571
1649
|
var billingDict: [String: Any] = [:]
|
|
1572
1650
|
billing.forEach { billingDict[$0.name] = $0.value }
|
|
1573
|
-
|
|
1651
|
+
|
|
1574
1652
|
params["address"] = billingDict["address"] as? String ?? ""
|
|
1575
1653
|
params["country"] = billingDict["country"] as? String ?? ""
|
|
1576
1654
|
params["state"] = billingDict["state"] as? String ?? ""
|
|
@@ -1578,18 +1656,16 @@ class OTPVerificationVC: BaseVC {
|
|
|
1578
1656
|
params["zip"] = billingDict["postal_code"] as? String ?? ""
|
|
1579
1657
|
}
|
|
1580
1658
|
|
|
1581
|
-
// Additional Info
|
|
1582
|
-
var descriptionValue: String = "Hosted payment checkout"
|
|
1583
|
-
if let
|
|
1584
|
-
let additional = additionalInfo, !additional.isEmpty {
|
|
1585
|
-
|
|
1659
|
+
// Always include Additional Info if available
|
|
1660
|
+
var descriptionValue: String = "Hosted payment checkout"
|
|
1661
|
+
if let additional = additionalInfo, !additional.isEmpty {
|
|
1586
1662
|
var additionalDict: [String: Any] = [:]
|
|
1587
1663
|
additional.forEach { additionalDict[$0.name] = $0.value }
|
|
1588
|
-
|
|
1664
|
+
|
|
1589
1665
|
if let desc = additionalDict["description"] as? String, !desc.isEmpty {
|
|
1590
1666
|
descriptionValue = desc
|
|
1591
1667
|
}
|
|
1592
|
-
|
|
1668
|
+
|
|
1593
1669
|
if let phone = additionalDict["phone_number"] as? String, !phone.isEmpty {
|
|
1594
1670
|
params["phone_number"] = phone
|
|
1595
1671
|
}
|
|
@@ -1619,6 +1695,8 @@ class OTPVerificationVC: BaseVC {
|
|
|
1619
1695
|
params["interval"] = chosenPlan?.lowercased()
|
|
1620
1696
|
}
|
|
1621
1697
|
|
|
1698
|
+
print(params)
|
|
1699
|
+
|
|
1622
1700
|
do {
|
|
1623
1701
|
let jsonData = try JSONSerialization.data(withJSONObject: params, options: .prettyPrinted)
|
|
1624
1702
|
uRLRequest.httpBody = jsonData
|
|
@@ -1669,20 +1747,21 @@ class OTPVerificationVC: BaseVC {
|
|
|
1669
1747
|
// Pass billing and additional info
|
|
1670
1748
|
// Conditionally pass raw FieldItem array
|
|
1671
1749
|
paymentDoneVC.visibility = self.visibility
|
|
1750
|
+
paymentDoneVC.amount = self.amount
|
|
1672
1751
|
|
|
1673
|
-
|
|
1752
|
+
// if self.visibility?.billing == true {
|
|
1674
1753
|
paymentDoneVC.billingInfoData = self.billingInfo
|
|
1675
1754
|
var billingDict: [String: Any] = [:]
|
|
1676
1755
|
self.billingInfo?.forEach { billingDict[$0.name] = $0.value }
|
|
1677
1756
|
paymentDoneVC.billingInfo = billingDict
|
|
1678
|
-
|
|
1757
|
+
// }
|
|
1679
1758
|
|
|
1680
|
-
|
|
1759
|
+
// if self.visibility?.additional == true {
|
|
1681
1760
|
paymentDoneVC.additionalInfoData = self.additionalInfo
|
|
1682
1761
|
var additionalDict: [String: Any] = [:]
|
|
1683
1762
|
self.additionalInfo?.forEach { additionalDict[$0.name] = $0.value }
|
|
1684
1763
|
paymentDoneVC.additionalInfo = additionalDict
|
|
1685
|
-
|
|
1764
|
+
// }
|
|
1686
1765
|
self.navigationController?.pushViewController(paymentDoneVC, animated: true)
|
|
1687
1766
|
}
|
|
1688
1767
|
}
|