@jimrising/easymerchantsdk-react-native 1.3.0 → 1.3.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/README.md +1 -1
- package/ios/Classes/EasyMerchantSdk.m +2 -2
- package/ios/easymerchantsdk.podspec +1 -1
- package/package.json +1 -1
- package/ios/Classes/dsd +0 -74
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#import "EasyMerchantSdk.h"
|
|
2
2
|
#import <React/RCTLog.h>
|
|
3
3
|
#import <React/RCTBridgeModule.h>
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
#import <easymerchantsdk/easymerchantsdk-Swift.h>
|
|
5
|
+
//#import <easymerchantsdk-Swift.h>
|
|
6
6
|
|
|
7
7
|
@implementation EasyMerchantSdk
|
|
8
8
|
|
package/package.json
CHANGED
package/ios/Classes/dsd
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
@objc public func billing(
|
|
2
|
-
_ amount: String,
|
|
3
|
-
billinginfo: String,
|
|
4
|
-
paymentMethods: [String],
|
|
5
|
-
themeConfiguration: [String: Any],
|
|
6
|
-
tokenOnly: Bool,
|
|
7
|
-
saveCard: Bool,
|
|
8
|
-
saveAccount: Bool,
|
|
9
|
-
authenticatedACH: Bool,
|
|
10
|
-
grailPayParams: [String: Any]?,
|
|
11
|
-
resolver: @escaping RCTPromiseResolveBlock,
|
|
12
|
-
rejecter: @escaping RCTPromiseRejectBlock
|
|
13
|
-
) {
|
|
14
|
-
guard let amountValue = Double(amount), amountValue > 0 else {
|
|
15
|
-
rejecter("INVALID_AMOUNT", "Amount must be a positive number", nil)
|
|
16
|
-
return
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
guard let billingInfoData = billinginfo.data(using: .utf8),
|
|
20
|
-
let _ = try? JSONSerialization.jsonObject(with: billingInfoData, options: []) else {
|
|
21
|
-
rejecter("INVALID_BILLING_INFO", "Billing info must be valid JSON", nil)
|
|
22
|
-
return
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
let methods: [PaymentMethod] = paymentMethods.compactMap {
|
|
26
|
-
switch $0.lowercased() {
|
|
27
|
-
case "card": return .Card
|
|
28
|
-
case "bank": return .Bank
|
|
29
|
-
case "crypto": return .Crypto
|
|
30
|
-
default: return nil
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
var grailParams: GrailPayRequest? = nil
|
|
35
|
-
if authenticatedACH, let params = grailPayParams {
|
|
36
|
-
grailParams = GrailPayRequest(
|
|
37
|
-
accessToken: params["accessToken"] as? String ?? "",
|
|
38
|
-
vendorId: params["vendorId"] as? String ?? "",
|
|
39
|
-
role: params["role"] as? String ?? "business",
|
|
40
|
-
timeout: params["timeout"] as? Int ?? 10,
|
|
41
|
-
isSandbox: params["isSandbox"] as? Bool ?? true,
|
|
42
|
-
brandingName: params["brandingName"] as? String ?? "Payments",
|
|
43
|
-
finderSubtitle: params["finderSubtitle"] as? String ?? "Find your bank",
|
|
44
|
-
searchPlaceholder: params["searchPlaceholder"] as? String ?? "Search"
|
|
45
|
-
)
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
let request = Request(
|
|
49
|
-
amount: amountValue,
|
|
50
|
-
billingInfoData: billingInfoData,
|
|
51
|
-
paymentMethods: methods,
|
|
52
|
-
themeConfiguration: themeConfiguration,
|
|
53
|
-
tokenOnly: tokenOnly,
|
|
54
|
-
saveCard: saveCard,
|
|
55
|
-
saveAccount: saveAccount,
|
|
56
|
-
authenticatedACH: authenticatedACH,
|
|
57
|
-
grailPayParams: grailParams
|
|
58
|
-
)
|
|
59
|
-
|
|
60
|
-
DispatchQueue.main.async {
|
|
61
|
-
let controller = EasyPayViewController(request: request, delegate: self)
|
|
62
|
-
if let vc = self.viewController {
|
|
63
|
-
vc.present(controller, animated: true) {
|
|
64
|
-
resolver("Payment UI presented")
|
|
65
|
-
}
|
|
66
|
-
} else if let rootVC = UIApplication.shared.windows.first(where: { $0.isKeyWindow })?.rootViewController {
|
|
67
|
-
rootVC.present(controller, animated: true) {
|
|
68
|
-
resolver("Payment UI presented (fallback)")
|
|
69
|
-
}
|
|
70
|
-
} else {
|
|
71
|
-
rejecter("NO_VIEW_CONTROLLER", "No view controller available to present payment screen.", nil)
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|