react-native-payengine 1.0.5 → 1.0.6

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 (113) hide show
  1. package/android/.gradle/5.6.4/executionHistory/executionHistory.bin +0 -0
  2. package/android/.gradle/5.6.4/executionHistory/executionHistory.lock +0 -0
  3. package/android/.gradle/5.6.4/fileContent/fileContent.lock +0 -0
  4. package/android/.gradle/5.6.4/fileHashes/fileHashes.bin +0 -0
  5. package/android/.gradle/5.6.4/fileHashes/fileHashes.lock +0 -0
  6. package/android/.gradle/5.6.4/fileHashes/resourceHashesCache.bin +0 -0
  7. package/android/.gradle/5.6.4/javaCompile/classAnalysis.bin +0 -0
  8. package/android/.gradle/5.6.4/javaCompile/jarAnalysis.bin +0 -0
  9. package/android/.gradle/5.6.4/javaCompile/javaCompile.lock +0 -0
  10. package/android/.gradle/5.6.4/javaCompile/taskHistory.bin +0 -0
  11. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  12. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  13. package/android/.idea/compiler.xml +1 -1
  14. package/android/.idea/gradle.xml +1 -0
  15. package/android/.idea/misc.xml +1 -1
  16. package/android/build.gradle +24 -9
  17. package/android/src/legacy/AndroidManifest.xml +4 -0
  18. package/android/src/main/java/com/reactnativepayengine/GooglePayModule.java +196 -0
  19. package/android/src/main/java/com/reactnativepayengine/PayenginePackage.java +1 -0
  20. package/android/src/main/java/com/reactnativepayengine/collect/VGSCollectModule.java +22 -17
  21. package/android/src/main/java/com/reactnativepayengine/util/PaymentsUtil.java +113 -0
  22. package/ios/Payengine.m +18 -1
  23. package/ios/Payengine.swift +85 -2
  24. package/ios/Payengine.xcodeproj/project.pbxproj +16 -5
  25. package/ios/Payengine.xcodeproj/project.xcworkspace/xcuserdata/tringuyen.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  26. package/ios/Payengine.xcodeproj/xcuserdata/tringuyen.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +4 -4
  27. package/ios/Payengine.xcworkspace/xcuserdata/tringuyen.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  28. package/lib/commonjs/components/ApplePay/PayEngineApplePay.js +71 -0
  29. package/lib/commonjs/components/ApplePay/PayEngineApplePay.js.map +1 -0
  30. package/lib/commonjs/components/ApplePay/index.js +46 -0
  31. package/lib/commonjs/components/ApplePay/index.js.map +1 -0
  32. package/lib/commonjs/components/ApplePay/interfaces.js +2 -0
  33. package/lib/commonjs/components/ApplePay/interfaces.js.map +1 -0
  34. package/lib/commonjs/components/CreditCardForm/index.js +76 -0
  35. package/lib/commonjs/components/CreditCardForm/index.js.map +1 -0
  36. package/lib/commonjs/components/GooglePay/PayEngineGooglePay.js +65 -0
  37. package/lib/commonjs/components/GooglePay/PayEngineGooglePay.js.map +1 -0
  38. package/lib/commonjs/components/GooglePay/index.js +40 -0
  39. package/lib/commonjs/components/GooglePay/index.js.map +1 -0
  40. package/lib/commonjs/components/GooglePay/interfaces.js +2 -0
  41. package/lib/commonjs/components/GooglePay/interfaces.js.map +1 -0
  42. package/lib/commonjs/components/Legacy/CreditCardFormLegacy.js +323 -0
  43. package/lib/commonjs/components/Legacy/CreditCardFormLegacy.js.map +1 -0
  44. package/lib/commonjs/components/PayEngine.js.map +1 -1
  45. package/lib/commonjs/components/SecureFields/VGS/CollectManager.js +3 -8
  46. package/lib/commonjs/components/SecureFields/VGS/CollectManager.js.map +1 -1
  47. package/lib/commonjs/index.js +33 -4
  48. package/lib/commonjs/index.js.map +1 -1
  49. package/lib/commonjs/interfaces/index.js +6 -0
  50. package/lib/commonjs/interfaces/index.js.map +1 -0
  51. package/lib/commonjs/utils/index.js +20 -8
  52. package/lib/commonjs/utils/index.js.map +1 -1
  53. package/lib/module/components/ApplePay/PayEngineApplePay.js +58 -0
  54. package/lib/module/components/ApplePay/PayEngineApplePay.js.map +1 -0
  55. package/lib/module/components/ApplePay/index.js +35 -0
  56. package/lib/module/components/ApplePay/index.js.map +1 -0
  57. package/lib/module/components/ApplePay/interfaces.js +2 -0
  58. package/lib/module/components/ApplePay/interfaces.js.map +1 -0
  59. package/lib/module/components/CreditCardForm/index.js +60 -0
  60. package/lib/module/components/CreditCardForm/index.js.map +1 -0
  61. package/lib/module/components/GooglePay/PayEngineGooglePay.js +52 -0
  62. package/lib/module/components/GooglePay/PayEngineGooglePay.js.map +1 -0
  63. package/lib/module/components/GooglePay/index.js +29 -0
  64. package/lib/module/components/GooglePay/index.js.map +1 -0
  65. package/lib/module/components/GooglePay/interfaces.js +2 -0
  66. package/lib/module/components/GooglePay/interfaces.js.map +1 -0
  67. package/lib/module/components/Legacy/CreditCardFormLegacy.js +302 -0
  68. package/lib/module/components/Legacy/CreditCardFormLegacy.js.map +1 -0
  69. package/lib/module/components/PayEngine.js.map +1 -1
  70. package/lib/module/components/SecureFields/VGS/CollectManager.js +3 -8
  71. package/lib/module/components/SecureFields/VGS/CollectManager.js.map +1 -1
  72. package/lib/module/index.js +6 -5
  73. package/lib/module/index.js.map +1 -1
  74. package/lib/module/interfaces/index.js +2 -0
  75. package/lib/module/interfaces/index.js.map +1 -0
  76. package/lib/module/utils/index.js +14 -8
  77. package/lib/module/utils/index.js.map +1 -1
  78. package/lib/typescript/components/ApplePay/PayEngineApplePay.d.ts +12 -0
  79. package/lib/typescript/components/ApplePay/index.d.ts +7 -0
  80. package/lib/typescript/components/ApplePay/interfaces.d.ts +20 -0
  81. package/lib/typescript/components/CreditCardForm/index.d.ts +3 -0
  82. package/lib/typescript/components/GooglePay/PayEngineGooglePay.d.ts +10 -0
  83. package/lib/typescript/components/GooglePay/index.d.ts +7 -0
  84. package/lib/typescript/components/GooglePay/interfaces.d.ts +38 -0
  85. package/lib/typescript/components/Legacy/CreditCardFormLegacy.d.ts +4 -0
  86. package/lib/typescript/components/PayEngine.d.ts +1 -1
  87. package/lib/typescript/components/SecureFields/VGS/CollectManager.d.ts +1 -1
  88. package/lib/typescript/index.d.ts +6 -2
  89. package/lib/typescript/interfaces/index.d.ts +33 -0
  90. package/lib/typescript/utils/index.d.ts +5 -6
  91. package/package.json +6 -5
  92. package/react-native-payengine.podspec +2 -2
  93. package/src/components/ApplePay/PayEngineApplePay.ts +61 -0
  94. package/src/components/ApplePay/index.ts +32 -0
  95. package/src/components/ApplePay/interfaces.ts +25 -0
  96. package/src/components/CreditCardForm/index.tsx +43 -0
  97. package/src/components/GooglePay/PayEngineGooglePay.ts +48 -0
  98. package/src/components/GooglePay/index.ts +39 -0
  99. package/src/components/GooglePay/interfaces.ts +42 -0
  100. package/src/components/Legacy/CreditCardFormLegacy.tsx +292 -0
  101. package/src/components/LoadingIndicator.tsx +28 -0
  102. package/src/components/PayEngine.tsx +121 -0
  103. package/src/components/SecureFields/VGS/CVCField.tsx +21 -0
  104. package/src/components/SecureFields/VGS/CardHolderNameField.tsx +21 -0
  105. package/src/components/SecureFields/VGS/CardNumberField.tsx +21 -0
  106. package/src/components/SecureFields/VGS/CollectManager.tsx +74 -0
  107. package/src/components/SecureFields/VGS/ExpDateField.tsx +21 -0
  108. package/src/components/SecureFields/VGS/TextField.tsx +27 -0
  109. package/src/components/SecureFields/VGS/ZipCodeField.tsx +21 -0
  110. package/src/components/SecureFields/index.ts +17 -0
  111. package/src/index.tsx +37 -0
  112. package/src/interfaces/index.ts +38 -0
  113. package/src/utils/index.ts +107 -0
@@ -1,11 +1,18 @@
1
1
  import VGSCollectSDK
2
2
  import UIKit
3
+ import PassKit
3
4
 
4
5
  let borderColor = UIColor.gray
5
6
  let errorBorderColor = UIColor.red
6
7
 
8
+ var publicKey = ""
7
9
  var vgsCollect = VGSCollect(id: "vauiltId", environment: .sandbox)
8
10
 
11
+ func hexStringFromData(data: Data?) -> String? {
12
+ // Returns hexadecimal string of NSData. Empty string if data is empty.
13
+ return data?.map { String(format: "%02lx", $0) }.joined()
14
+ }
15
+
9
16
  @objc(Payengine)
10
17
  class Payengine: NSObject {
11
18
 
@@ -16,6 +23,78 @@ class Payengine: NSObject {
16
23
  }
17
24
 
18
25
 
26
+ @objc(ApplePay)
27
+ class ApplePay: UIViewController {
28
+ private var rootViewController: UIViewController = UIApplication.shared.keyWindow!.rootViewController!
29
+ private var request: PKPaymentRequest = PKPaymentRequest()
30
+ private var resolve: RCTPromiseResolveBlock?
31
+ private var paymentNetworks: [PKPaymentNetwork]?
32
+
33
+
34
+ @objc(invokeApplePay:details:)
35
+ private func invokeApplePay(method: NSDictionary, details: NSDictionary) -> Void {
36
+ self.paymentNetworks = method["supportedNetworks"] as? [PKPaymentNetwork]
37
+ guard PKPaymentAuthorizationViewController.canMakePayments(usingNetworks: paymentNetworks!) else {
38
+ print("Can not make payment")
39
+ return
40
+ }
41
+ let total = details["total"] as! NSDictionary
42
+ let paymentItem = PKPaymentSummaryItem.init(label: total["label"] as! String, amount: NSDecimalNumber(value: total["amount"] as! Double))
43
+ request.currencyCode = method["currencyCode"] as! String
44
+ request.countryCode = method["countryCode"] as! String
45
+ request.merchantIdentifier = method["merchantIdentifier"] as! String
46
+ request.merchantCapabilities = PKMerchantCapability.capability3DS
47
+ request.supportedNetworks = self.paymentNetworks!
48
+ request.paymentSummaryItems = [paymentItem]
49
+ }
50
+
51
+ @objc(initApplePay:withRejecter:)
52
+ func initApplePay(resolve: @escaping RCTPromiseResolveBlock,reject:RCTPromiseRejectBlock) -> Void {
53
+ guard PKPaymentAuthorizationViewController.canMakePayments(usingNetworks: paymentNetworks!) else {
54
+ print("Can not make payment")
55
+ return
56
+ }
57
+ self.resolve = resolve
58
+ if let controller = PKPaymentAuthorizationViewController(paymentRequest: request) {
59
+ controller.delegate = self
60
+ DispatchQueue.main.async {
61
+ self.rootViewController.present(controller, animated: true, completion: nil)
62
+ }
63
+ }
64
+ }
65
+
66
+ @objc(canMakePayments:withRejecter:)
67
+ func canMakePayments(resolve: RCTPromiseResolveBlock,reject:RCTPromiseRejectBlock) -> Void {
68
+ if PKPaymentAuthorizationViewController.canMakePayments(usingNetworks: paymentNetworks!) {
69
+ resolve(true)
70
+ } else {
71
+ resolve(false)
72
+ }
73
+ }
74
+ }
75
+
76
+ extension ApplePay: PKPaymentAuthorizationViewControllerDelegate {
77
+ func paymentAuthorizationViewControllerDidFinish(_ controller: PKPaymentAuthorizationViewController) {
78
+ controller.dismiss(animated: true, completion: nil)
79
+ }
80
+
81
+ func paymentAuthorizationViewController(_ controller: PKPaymentAuthorizationViewController, didAuthorizePayment payment: PKPayment, completion: @escaping (PKPaymentAuthorizationStatus) -> Void) {
82
+
83
+ let hexStringData = hexStringFromData(data: payment.token.paymentData)
84
+
85
+ let token = String(decoding: payment.token.paymentData, as: UTF8.self)
86
+ if token != nil {
87
+ self.resolve!(hexStringData)
88
+ completion(.success)
89
+ } else {
90
+ self.resolve!("COULD_NOT_FIND_TOKEN")
91
+ completion(.failure)
92
+ }
93
+ }
94
+ }
95
+
96
+
97
+
19
98
  @objc(VGSCollectManager)
20
99
  class VGSCollectManager: NSObject {
21
100
 
@@ -37,8 +116,9 @@ class VGSCollectManager: NSObject {
37
116
  return true
38
117
  }
39
118
 
40
- @objc(setConfiguration:environment:hostname:satellitePort:)
41
- func setConfiguration(_ vaultId: String, environment: String, hostname: String, satellitePort: Int) -> Void {
119
+ @objc(setConfiguration:vaultId:environment:hostname:satellitePort:)
120
+ func setConfiguration(_ pKey: String, vaultId: String, environment: String, hostname: String, satellitePort: Int) -> Void {
121
+ publicKey = pKey
42
122
  vgsCollect = VGSCollect(id: vaultId, environment: environment)
43
123
  // , hostname: hostname, satellitePort: satellitePort
44
124
  }
@@ -82,6 +162,9 @@ class VGSCollectManager: NSObject {
82
162
  }
83
163
  }
84
164
 
165
+ vgsCollect.customHeaders = [
166
+ "Authorization": "Signature key=\"\(publicKey)\",algorithm=\"hmac-sha256\",identifier=\"secure-fields\",signature=\"\""
167
+ ]
85
168
  // Send data to your Vault
86
169
  vgsCollect.sendData(path: path, extraData: extraData) { (response) in
87
170
 
@@ -8,6 +8,7 @@
8
8
 
9
9
  /* Begin PBXBuildFile section */
10
10
  F45965C128D879900039BFB1 /* VGSCollectSDK in Frameworks */ = {isa = PBXBuildFile; productRef = F45965C028D879900039BFB1 /* VGSCollectSDK */; };
11
+ F490697528EDB75300FB544D /* Payengine.m in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* Payengine.m */; };
11
12
  F4FF95D7245B92E800C19C63 /* Payengine.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4FF95D6245B92E800C19C63 /* Payengine.swift */; };
12
13
  /* End PBXBuildFile section */
13
14
 
@@ -89,7 +90,7 @@
89
90
  58B511D31A9E6C8500147676 /* Project object */ = {
90
91
  isa = PBXProject;
91
92
  attributes = {
92
- LastUpgradeCheck = 0920;
93
+ LastUpgradeCheck = 1320;
93
94
  ORGANIZATIONNAME = Facebook;
94
95
  TargetAttributes = {
95
96
  58B511DA1A9E6C8500147676 = {
@@ -99,11 +100,11 @@
99
100
  };
100
101
  buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "Payengine" */;
101
102
  compatibilityVersion = "Xcode 3.2";
102
- developmentRegion = English;
103
+ developmentRegion = en;
103
104
  hasScannedForEncodings = 0;
104
105
  knownRegions = (
105
- English,
106
106
  en,
107
+ Base,
107
108
  );
108
109
  mainGroup = 58B511D21A9E6C8500147676;
109
110
  packageReferences = (
@@ -124,6 +125,7 @@
124
125
  isa = PBXSourcesBuildPhase;
125
126
  buildActionMask = 2147483647;
126
127
  files = (
128
+ F490697528EDB75300FB544D /* Payengine.m in Sources */,
127
129
  F4FF95D7245B92E800C19C63 /* Payengine.swift in Sources */,
128
130
  );
129
131
  runOnlyForDeploymentPostprocessing = 0;
@@ -135,6 +137,7 @@
135
137
  isa = XCBuildConfiguration;
136
138
  buildSettings = {
137
139
  ALWAYS_SEARCH_USER_PATHS = NO;
140
+ CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
138
141
  CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
139
142
  CLANG_CXX_LIBRARY = "libc++";
140
143
  CLANG_ENABLE_MODULES = YES;
@@ -143,14 +146,17 @@
143
146
  CLANG_WARN_BOOL_CONVERSION = YES;
144
147
  CLANG_WARN_COMMA = YES;
145
148
  CLANG_WARN_CONSTANT_CONVERSION = YES;
149
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
146
150
  CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
147
151
  CLANG_WARN_EMPTY_BODY = YES;
148
152
  CLANG_WARN_ENUM_CONVERSION = YES;
149
153
  CLANG_WARN_INFINITE_RECURSION = YES;
150
154
  CLANG_WARN_INT_CONVERSION = YES;
151
155
  CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
156
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
152
157
  CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
153
158
  CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
159
+ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
154
160
  CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
155
161
  CLANG_WARN_STRICT_PROTOTYPES = YES;
156
162
  CLANG_WARN_SUSPICIOUS_MOVE = YES;
@@ -175,7 +181,7 @@
175
181
  GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
176
182
  GCC_WARN_UNUSED_FUNCTION = YES;
177
183
  GCC_WARN_UNUSED_VARIABLE = YES;
178
- IPHONEOS_DEPLOYMENT_TARGET = 8.0;
184
+ IPHONEOS_DEPLOYMENT_TARGET = 12.0;
179
185
  MTL_ENABLE_DEBUG_INFO = YES;
180
186
  ONLY_ACTIVE_ARCH = YES;
181
187
  SDKROOT = iphoneos;
@@ -186,6 +192,7 @@
186
192
  isa = XCBuildConfiguration;
187
193
  buildSettings = {
188
194
  ALWAYS_SEARCH_USER_PATHS = NO;
195
+ CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
189
196
  CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
190
197
  CLANG_CXX_LIBRARY = "libc++";
191
198
  CLANG_ENABLE_MODULES = YES;
@@ -194,14 +201,17 @@
194
201
  CLANG_WARN_BOOL_CONVERSION = YES;
195
202
  CLANG_WARN_COMMA = YES;
196
203
  CLANG_WARN_CONSTANT_CONVERSION = YES;
204
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
197
205
  CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
198
206
  CLANG_WARN_EMPTY_BODY = YES;
199
207
  CLANG_WARN_ENUM_CONVERSION = YES;
200
208
  CLANG_WARN_INFINITE_RECURSION = YES;
201
209
  CLANG_WARN_INT_CONVERSION = YES;
202
210
  CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
211
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
203
212
  CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
204
213
  CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
214
+ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
205
215
  CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
206
216
  CLANG_WARN_STRICT_PROTOTYPES = YES;
207
217
  CLANG_WARN_SUSPICIOUS_MOVE = YES;
@@ -219,9 +229,10 @@
219
229
  GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
220
230
  GCC_WARN_UNUSED_FUNCTION = YES;
221
231
  GCC_WARN_UNUSED_VARIABLE = YES;
222
- IPHONEOS_DEPLOYMENT_TARGET = 8.0;
232
+ IPHONEOS_DEPLOYMENT_TARGET = 12.0;
223
233
  MTL_ENABLE_DEBUG_INFO = NO;
224
234
  SDKROOT = iphoneos;
235
+ SWIFT_COMPILATION_MODE = wholemodule;
225
236
  VALIDATE_PRODUCT = YES;
226
237
  };
227
238
  name = Release;
@@ -14,10 +14,10 @@
14
14
  filePath = "Payengine.swift"
15
15
  startingColumnNumber = "9223372036854775807"
16
16
  endingColumnNumber = "9223372036854775807"
17
- startingLineNumber = "207"
18
- endingLineNumber = "207"
19
- landmarkName = "unknown"
20
- landmarkType = "0">
17
+ startingLineNumber = "282"
18
+ endingLineNumber = "282"
19
+ landmarkName = "VGSCardNumberFieldManager"
20
+ landmarkType = "3">
21
21
  </BreakpointContent>
22
22
  </BreakpointProxy>
23
23
  </Breakpoints>
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.PayEngineApplePay = void 0;
7
+
8
+ var _ = _interopRequireDefault(require("."));
9
+
10
+ var _utils = require("../../utils");
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
14
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
15
+
16
+ class PayEngineApplePay {
17
+ constructor(payEngineConfig) {
18
+ _defineProperty(this, "applePay", void 0);
19
+
20
+ _defineProperty(this, "payEngineConfig", void 0);
21
+
22
+ _defineProperty(this, "config", void 0);
23
+
24
+ _defineProperty(this, "method", void 0);
25
+
26
+ _defineProperty(this, "details", void 0);
27
+
28
+ this.payEngineConfig = payEngineConfig;
29
+ this.applePay = new _.default();
30
+ }
31
+
32
+ async canMakePayments(merchantId, paymentConfig) {
33
+ const client = (0, _utils.createHttpClient)(this.payEngineConfig);
34
+ const {
35
+ data
36
+ } = await client.get(`/api/mobile-payment/config?merchant_id=${merchantId}`);
37
+ this.config = data.data;
38
+ console.log('config', this.config);
39
+ this.method = {
40
+ countryCode: paymentConfig.countryCode ?? this.config.country,
41
+ currencyCode: paymentConfig.currencyCode ?? this.config.currency,
42
+ merchantIdentifier: 'merchant.payengine.tunnel3000cc',
43
+ supportedNetworks: ['Visa', 'MasterCard', 'AmEx']
44
+ };
45
+ this.details = {
46
+ total: {
47
+ label: this.config.apple_pay.merchantName,
48
+ amount: 1.00
49
+ }
50
+ };
51
+ return await this.applePay.canMakePayments(this.method, this.details);
52
+ }
53
+
54
+ async start() {
55
+ if (!this.config) {
56
+ throw new Error('You must call `canMakePayments` first');
57
+ }
58
+
59
+ const result = await this.applePay.start();
60
+
61
+ try {
62
+ return JSON.parse(result);
63
+ } catch {
64
+ return result;
65
+ }
66
+ }
67
+
68
+ }
69
+
70
+ exports.PayEngineApplePay = PayEngineApplePay;
71
+ //# sourceMappingURL=PayEngineApplePay.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["PayEngineApplePay","constructor","payEngineConfig","applePay","ApplePay","canMakePayments","merchantId","paymentConfig","client","createHttpClient","data","get","config","console","log","method","countryCode","country","currencyCode","currency","merchantIdentifier","supportedNetworks","details","total","label","apple_pay","merchantName","amount","start","Error","result","JSON","parse"],"sources":["PayEngineApplePay.ts"],"sourcesContent":["import ApplePay from '.';\nimport type {\n IPayEngineConfig,\n MobilePaymentConfig,\n PaymentRequest,\n} from '../../interfaces';\nimport { createHttpClient } from '../../utils';\nimport type {\n ApplePayDetailsData,\n ApplePayMethodData,\n IApplePay,\n} from './interfaces';\n\nexport class PayEngineApplePay implements IApplePay {\n private applePay: ApplePay;\n private payEngineConfig: IPayEngineConfig;\n private config?: MobilePaymentConfig;\n private method?: ApplePayMethodData;\n private details?: ApplePayDetailsData;\n\n constructor(payEngineConfig: IPayEngineConfig) {\n this.payEngineConfig = payEngineConfig;\n this.applePay = new ApplePay();\n }\n\n public async canMakePayments(merchantId: string, paymentConfig: PaymentRequest) {\n const client = createHttpClient(this.payEngineConfig);\n const { data } = await client.get(\n `/api/mobile-payment/config?merchant_id=${merchantId}`\n );\n this.config = data.data;\n console.log('config', this.config);\n this.method = {\n countryCode: paymentConfig.countryCode ?? this.config!.country,\n currencyCode: paymentConfig.currencyCode ?? this.config!.currency,\n merchantIdentifier: 'merchant.payengine.tunnel3000cc',\n supportedNetworks: ['Visa', 'MasterCard', 'AmEx'],\n };\n\n this.details = {\n total: {\n label: this.config!.apple_pay.merchantName,\n amount: 1.00,\n },\n };\n return await this.applePay.canMakePayments(this.method, this.details);\n }\n\n public async start() {\n if (!this.config) {\n throw new Error('You must call `canMakePayments` first');\n }\n\n const result = await this.applePay.start();\n try {\n return JSON.parse(result);\n } catch {\n return result;\n }\n }\n}\n"],"mappings":";;;;;;;AAAA;;AAMA;;;;;;AAOO,MAAMA,iBAAN,CAA6C;EAOlDC,WAAW,CAACC,eAAD,EAAoC;IAAA;;IAAA;;IAAA;;IAAA;;IAAA;;IAC7C,KAAKA,eAAL,GAAuBA,eAAvB;IACA,KAAKC,QAAL,GAAgB,IAAIC,SAAJ,EAAhB;EACD;;EAE2B,MAAfC,eAAe,CAACC,UAAD,EAAqBC,aAArB,EAAoD;IAC9E,MAAMC,MAAM,GAAG,IAAAC,uBAAA,EAAiB,KAAKP,eAAtB,CAAf;IACA,MAAM;MAAEQ;IAAF,IAAW,MAAMF,MAAM,CAACG,GAAP,CACpB,0CAAyCL,UAAW,EADhC,CAAvB;IAGA,KAAKM,MAAL,GAAcF,IAAI,CAACA,IAAnB;IACAG,OAAO,CAACC,GAAR,CAAY,QAAZ,EAAsB,KAAKF,MAA3B;IACA,KAAKG,MAAL,GAAc;MACZC,WAAW,EAAET,aAAa,CAACS,WAAd,IAA6B,KAAKJ,MAAL,CAAaK,OAD3C;MAEZC,YAAY,EAAEX,aAAa,CAACW,YAAd,IAA8B,KAAKN,MAAL,CAAaO,QAF7C;MAGZC,kBAAkB,EAAE,iCAHR;MAIZC,iBAAiB,EAAE,CAAC,MAAD,EAAS,YAAT,EAAuB,MAAvB;IAJP,CAAd;IAOA,KAAKC,OAAL,GAAe;MACbC,KAAK,EAAE;QACLC,KAAK,EAAE,KAAKZ,MAAL,CAAaa,SAAb,CAAuBC,YADzB;QAELC,MAAM,EAAE;MAFH;IADM,CAAf;IAMA,OAAO,MAAM,KAAKxB,QAAL,CAAcE,eAAd,CAA8B,KAAKU,MAAnC,EAA2C,KAAKO,OAAhD,CAAb;EACD;;EAEiB,MAALM,KAAK,GAAG;IACnB,IAAI,CAAC,KAAKhB,MAAV,EAAkB;MAChB,MAAM,IAAIiB,KAAJ,CAAU,uCAAV,CAAN;IACD;;IAED,MAAMC,MAAM,GAAG,MAAM,KAAK3B,QAAL,CAAcyB,KAAd,EAArB;;IACA,IAAI;MACF,OAAOG,IAAI,CAACC,KAAL,CAAWF,MAAX,CAAP;IACD,CAFD,CAEE,MAAM;MACN,OAAOA,MAAP;IACD;EACF;;AA9CiD"}
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _reactNative = require("react-native");
9
+
10
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
11
+
12
+ const {
13
+ ApplePay: RNApplePay
14
+ } = _reactNative.NativeModules;
15
+
16
+ class ApplePay {
17
+ constructor() {
18
+ _defineProperty(this, "isReady", false);
19
+
20
+ if (_reactNative.Platform.OS === 'ios') {
21
+ if (!RNApplePay) {
22
+ throw new Error('ApplePay is not defined');
23
+ }
24
+ } else {
25
+ throw new Error('Apple Pay is supported (iOS only)');
26
+ }
27
+ }
28
+
29
+ async start() {
30
+ if (!this.isReady) {
31
+ throw new Error('Apple Pay is not ready');
32
+ }
33
+
34
+ return await RNApplePay.initApplePay();
35
+ }
36
+
37
+ async canMakePayments(method, details) {
38
+ RNApplePay.invokeApplePay(method, details);
39
+ this.isReady = await RNApplePay.canMakePayments();
40
+ return this.isReady;
41
+ }
42
+
43
+ }
44
+
45
+ exports.default = ApplePay;
46
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ApplePay","RNApplePay","NativeModules","constructor","Platform","OS","Error","start","isReady","initApplePay","canMakePayments","method","details","invokeApplePay"],"sources":["index.ts"],"sourcesContent":["import { NativeModules, Platform } from 'react-native';\nimport type { ApplePayDetailsData, ApplePayMethodData, IApplePay } from './interfaces';\n\nconst { ApplePay: RNApplePay } = NativeModules;\n\nexport default class ApplePay implements IApplePay {\n private isReady = false;\n\n constructor() {\n if (Platform.OS === 'ios') {\n if (!RNApplePay) {\n throw new Error('ApplePay is not defined');\n }\n } else {\n throw new Error('Apple Pay is supported (iOS only)');\n }\n }\n\n public async start() {\n if (!this.isReady) {\n throw new Error('Apple Pay is not ready')\n }\n\n return await RNApplePay.initApplePay();\n }\n\n public async canMakePayments(method: ApplePayMethodData, details: ApplePayDetailsData) {\n RNApplePay.invokeApplePay(method, details);\n this.isReady = await RNApplePay.canMakePayments();\n return this.isReady\n }\n}\n"],"mappings":";;;;;;;AAAA;;;;AAGA,MAAM;EAAEA,QAAQ,EAAEC;AAAZ,IAA2BC,0BAAjC;;AAEe,MAAMF,QAAN,CAAoC;EAGjDG,WAAW,GAAG;IAAA,iCAFI,KAEJ;;IACZ,IAAIC,qBAAA,CAASC,EAAT,KAAgB,KAApB,EAA2B;MACzB,IAAI,CAACJ,UAAL,EAAiB;QACf,MAAM,IAAIK,KAAJ,CAAU,yBAAV,CAAN;MACD;IACF,CAJD,MAIO;MACL,MAAM,IAAIA,KAAJ,CAAU,mCAAV,CAAN;IACD;EACF;;EAEiB,MAALC,KAAK,GAAG;IACnB,IAAI,CAAC,KAAKC,OAAV,EAAmB;MACjB,MAAM,IAAIF,KAAJ,CAAU,wBAAV,CAAN;IACD;;IAED,OAAO,MAAML,UAAU,CAACQ,YAAX,EAAb;EACD;;EAE2B,MAAfC,eAAe,CAACC,MAAD,EAA6BC,OAA7B,EAA2D;IACrFX,UAAU,CAACY,cAAX,CAA0BF,MAA1B,EAAkCC,OAAlC;IACA,KAAKJ,OAAL,GAAe,MAAMP,UAAU,CAACS,eAAX,EAArB;IACA,OAAO,KAAKF,OAAZ;EACD;;AAzBgD"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=interfaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["interfaces.ts"],"sourcesContent":["export interface IApplePay {\n canMakePayments: (...args: any) => Promise<boolean>\n start: (...args: any) => Promise<any>\n}\n\n\ntype Network = 'Visa' | 'MasterCard' | 'AmEx';\n\nexport interface ApplePayMethodData {\n countryCode: string;\n currencyCode: string;\n supportedNetworks: Network[];\n merchantIdentifier: string;\n}\n\nexport interface ApplePayDetail {\n label: string;\n amount: number;\n}\n\nexport interface ApplePayDetailsData {\n total: ApplePayDetail;\n}\n\nexport type ApplePayTransactionIdentifier = string;\n"],"mappings":""}
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.CreditCardForm = void 0;
7
+
8
+ var React = _interopRequireWildcard(require("react"));
9
+
10
+ var _reactNative = require("react-native");
11
+
12
+ var _SecureFields = require("../SecureFields");
13
+
14
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
15
+
16
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
+
18
+ const CreditCardForm = /*#__PURE__*/React.forwardRef((props, ref) => {
19
+ React.useImperativeHandle(ref, () => ({
20
+ createCard: async merchantId => {
21
+ var _secureFieldRef$curre;
22
+
23
+ return await ((_secureFieldRef$curre = secureFieldRef.current) === null || _secureFieldRef$curre === void 0 ? void 0 : _secureFieldRef$curre.createCard(props.merchantId ?? merchantId));
24
+ }
25
+ }));
26
+ const secureFieldRef = /*#__PURE__*/React.createRef();
27
+ return /*#__PURE__*/React.createElement(_reactNative.View, {
28
+ style: [styles.container, props.style]
29
+ }, /*#__PURE__*/React.createElement(_SecureFields.SecureFields.CollectManager, {
30
+ ref: secureFieldRef,
31
+ config: props.config
32
+ }, /*#__PURE__*/React.createElement(_SecureFields.SecureFields.CardHolderNameField, {
33
+ placeholder: "Card holder name",
34
+ style: styles.field
35
+ }), /*#__PURE__*/React.createElement(_SecureFields.SecureFields.CardNumberField, {
36
+ placeholder: "Card number",
37
+ style: styles.field
38
+ }), /*#__PURE__*/React.createElement(_reactNative.View, {
39
+ style: {
40
+ display: 'flex',
41
+ flexDirection: "row",
42
+ width: '100%',
43
+ height: 50,
44
+ margin: 8
45
+ }
46
+ }, /*#__PURE__*/React.createElement(_SecureFields.SecureFields.ExpDateTextField, {
47
+ style: [styles.field, {
48
+ flex: 1,
49
+ margin: 0,
50
+ marginRight: 10
51
+ }]
52
+ }), /*#__PURE__*/React.createElement(_SecureFields.SecureFields.CVCField, {
53
+ style: [styles.field, {
54
+ flex: 1,
55
+ margin: 0
56
+ }]
57
+ })), props.showZipCode ? /*#__PURE__*/React.createElement(_SecureFields.SecureFields.ZipCodeField, {
58
+ placeholder: "Zip code",
59
+ style: styles.field
60
+ }) : /*#__PURE__*/React.createElement(React.Fragment, null)));
61
+ });
62
+ exports.CreditCardForm = CreditCardForm;
63
+
64
+ const styles = _reactNative.StyleSheet.create({
65
+ container: {
66
+ width: '100%',
67
+ padding: 20
68
+ },
69
+ field: {
70
+ width: '100%',
71
+ height: 50,
72
+ margin: 8,
73
+ padding: 5
74
+ }
75
+ });
76
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["CreditCardForm","React","forwardRef","props","ref","useImperativeHandle","createCard","merchantId","secureFieldRef","current","createRef","styles","container","style","config","field","display","flexDirection","width","height","margin","flex","marginRight","showZipCode","StyleSheet","create","padding"],"sources":["index.tsx"],"sourcesContent":["import * as React from 'react';\nimport { View, StyleSheet } from 'react-native';\nimport { SecureFields } from '../SecureFields';\nimport type { CreditCardFormMethods, CreditCardFormProps } from '../../interfaces/index';\n\nexport const CreditCardForm = React.forwardRef<CreditCardFormMethods, CreditCardFormProps>((props, ref) => {\n\n React.useImperativeHandle(ref, () => ({\n createCard: async (merchantId?: string) => {\n return await secureFieldRef.current?.createCard(props.merchantId ?? merchantId)\n },\n }));\n\n const secureFieldRef = React.createRef<any>()\n\n return (\n <View style={[styles.container, props.style]}>\n <SecureFields.CollectManager ref={secureFieldRef} config={props.config}>\n <SecureFields.CardHolderNameField placeholder=\"Card holder name\" style={styles.field} />\n <SecureFields.CardNumberField placeholder=\"Card number\" style={styles.field} />\n <View style={{ display: 'flex', flexDirection: \"row\", width: '100%', height: 50, margin: 8 }}>\n <SecureFields.ExpDateTextField style={[styles.field, { flex: 1, margin: 0, marginRight: 10 }]} />\n <SecureFields.CVCField style={[styles.field, { flex: 1, margin: 0 }]} />\n </View>\n {props.showZipCode ? <SecureFields.ZipCodeField placeholder=\"Zip code\" style={styles.field} /> : <></>}\n </SecureFields.CollectManager>\n </View>\n );\n});\n\nconst styles = StyleSheet.create({\n container: {\n width: '100%',\n padding: 20,\n },\n field: {\n width: '100%',\n height: 50,\n margin: 8,\n padding: 5\n }\n});\n\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;;;AAGO,MAAMA,cAAc,gBAAGC,KAAK,CAACC,UAAN,CAA6D,CAACC,KAAD,EAAQC,GAAR,KAAgB;EAEzGH,KAAK,CAACI,mBAAN,CAA0BD,GAA1B,EAA+B,OAAO;IACpCE,UAAU,EAAE,MAAOC,UAAP,IAA+B;MAAA;;MACzC,OAAO,gCAAMC,cAAc,CAACC,OAArB,0DAAM,sBAAwBH,UAAxB,CAAmCH,KAAK,CAACI,UAAN,IAAoBA,UAAvD,CAAN,CAAP;IACD;EAHmC,CAAP,CAA/B;EAMA,MAAMC,cAAc,gBAAGP,KAAK,CAACS,SAAN,EAAvB;EAEA,oBACE,oBAAC,iBAAD;IAAM,KAAK,EAAE,CAACC,MAAM,CAACC,SAAR,EAAmBT,KAAK,CAACU,KAAzB;EAAb,gBACE,oBAAC,0BAAD,CAAc,cAAd;IAA6B,GAAG,EAAEL,cAAlC;IAAkD,MAAM,EAAEL,KAAK,CAACW;EAAhE,gBACE,oBAAC,0BAAD,CAAc,mBAAd;IAAkC,WAAW,EAAC,kBAA9C;IAAiE,KAAK,EAAEH,MAAM,CAACI;EAA/E,EADF,eAEE,oBAAC,0BAAD,CAAc,eAAd;IAA8B,WAAW,EAAC,aAA1C;IAAwD,KAAK,EAAEJ,MAAM,CAACI;EAAtE,EAFF,eAGE,oBAAC,iBAAD;IAAM,KAAK,EAAE;MAAEC,OAAO,EAAE,MAAX;MAAmBC,aAAa,EAAE,KAAlC;MAAyCC,KAAK,EAAE,MAAhD;MAAwDC,MAAM,EAAE,EAAhE;MAAoEC,MAAM,EAAE;IAA5E;EAAb,gBACE,oBAAC,0BAAD,CAAc,gBAAd;IAA+B,KAAK,EAAE,CAACT,MAAM,CAACI,KAAR,EAAe;MAAEM,IAAI,EAAE,CAAR;MAAWD,MAAM,EAAE,CAAnB;MAAsBE,WAAW,EAAE;IAAnC,CAAf;EAAtC,EADF,eAEE,oBAAC,0BAAD,CAAc,QAAd;IAAuB,KAAK,EAAE,CAACX,MAAM,CAACI,KAAR,EAAe;MAAEM,IAAI,EAAE,CAAR;MAAWD,MAAM,EAAE;IAAnB,CAAf;EAA9B,EAFF,CAHF,EAOGjB,KAAK,CAACoB,WAAN,gBAAoB,oBAAC,0BAAD,CAAc,YAAd;IAA2B,WAAW,EAAC,UAAvC;IAAkD,KAAK,EAAEZ,MAAM,CAACI;EAAhE,EAApB,gBAAgG,yCAPnG,CADF,CADF;AAaD,CAvB6B,CAAvB;;;AAyBP,MAAMJ,MAAM,GAAGa,uBAAA,CAAWC,MAAX,CAAkB;EAC/Bb,SAAS,EAAE;IACTM,KAAK,EAAE,MADE;IAETQ,OAAO,EAAE;EAFA,CADoB;EAK/BX,KAAK,EAAE;IACLG,KAAK,EAAE,MADF;IAELC,MAAM,EAAE,EAFH;IAGLC,MAAM,EAAE,CAHH;IAILM,OAAO,EAAE;EAJJ;AALwB,CAAlB,CAAf"}
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.PayEngineGooglePay = void 0;
7
+
8
+ var _ = _interopRequireDefault(require("."));
9
+
10
+ var _utils = require("../../utils");
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
14
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
15
+
16
+ class PayEngineGooglePay {
17
+ constructor(payEngineConfig) {
18
+ _defineProperty(this, "googlePay", void 0);
19
+
20
+ _defineProperty(this, "payEngineConfig", void 0);
21
+
22
+ _defineProperty(this, "config", void 0);
23
+
24
+ this.payEngineConfig = payEngineConfig;
25
+ this.googlePay = new _.default();
26
+ }
27
+
28
+ async canMakePayments(merchantId) {
29
+ const client = (0, _utils.createHttpClient)(this.payEngineConfig);
30
+ const {
31
+ data
32
+ } = await client.get(`/api/mobile-payment/config?merchant_id=${merchantId}`);
33
+ this.config = data.data;
34
+ await this.googlePay.setProduction(Boolean(this.config.google_pay.production));
35
+ return await this.googlePay.canMakePayments(this.config.google_pay.cardPaymentMethod.allowedCardNetworks, this.config.google_pay.cardPaymentMethod.allowedCardAuthMethods);
36
+ }
37
+
38
+ async start(paymentConfig) {
39
+ if (!this.config) {
40
+ throw new Error('You must call `canMakePayments` first');
41
+ }
42
+
43
+ const payload = {
44
+ cardPaymentMethod: this.config.google_pay.cardPaymentMethod,
45
+ transaction: {
46
+ totalPrice: String(paymentConfig.amount),
47
+ totalPriceStatus: 'FINAL',
48
+ currencyCode: paymentConfig.currencyCode ?? this.config.currency,
49
+ countryCode: paymentConfig.countryCode ?? this.config.country
50
+ },
51
+ merchantName: this.config.google_pay.merchantName
52
+ };
53
+ const result = await this.googlePay.start(payload);
54
+
55
+ try {
56
+ return JSON.parse(result);
57
+ } catch {
58
+ return result;
59
+ }
60
+ }
61
+
62
+ }
63
+
64
+ exports.PayEngineGooglePay = PayEngineGooglePay;
65
+ //# sourceMappingURL=PayEngineGooglePay.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["PayEngineGooglePay","constructor","payEngineConfig","googlePay","GooglePay","canMakePayments","merchantId","client","createHttpClient","data","get","config","setProduction","Boolean","google_pay","production","cardPaymentMethod","allowedCardNetworks","allowedCardAuthMethods","start","paymentConfig","Error","payload","transaction","totalPrice","String","amount","totalPriceStatus","currencyCode","currency","countryCode","country","merchantName","result","JSON","parse"],"sources":["PayEngineGooglePay.ts"],"sourcesContent":["import GooglePay from '.';\nimport type { IPayEngineConfig, MobilePaymentConfig, PaymentRequest } from '../../interfaces';\nimport { createHttpClient } from '../../utils';\nimport type { GooglePayRequestData, IGooglePay } from './interfaces';\n\nexport class PayEngineGooglePay implements IGooglePay {\n\n private googlePay: GooglePay;\n private payEngineConfig: IPayEngineConfig;\n private config?: MobilePaymentConfig;\n\n constructor(payEngineConfig: IPayEngineConfig) {\n this.payEngineConfig = payEngineConfig;\n this.googlePay = new GooglePay()\n }\n\n public async canMakePayments(merchantId: string) {\n const client = createHttpClient(this.payEngineConfig);\n const { data } = await client.get(`/api/mobile-payment/config?merchant_id=${merchantId}`)\n this.config = data.data\n await this.googlePay.setProduction(Boolean(this.config!.google_pay.production))\n return await this.googlePay.canMakePayments(this.config!.google_pay.cardPaymentMethod.allowedCardNetworks, this.config!.google_pay.cardPaymentMethod.allowedCardAuthMethods)\n }\n\n public async start(paymentConfig: PaymentRequest) {\n if (!this.config) {\n throw new Error('You must call `canMakePayments` first')\n }\n\n const payload: GooglePayRequestData = {\n cardPaymentMethod: this.config!.google_pay.cardPaymentMethod,\n transaction: {\n totalPrice: String(paymentConfig.amount),\n totalPriceStatus: 'FINAL',\n currencyCode: paymentConfig.currencyCode ?? this.config!.currency,\n countryCode: paymentConfig.countryCode ?? this.config!.country\n },\n merchantName: this.config!.google_pay.merchantName\n }\n\n const result = await this.googlePay.start(payload);\n try {\n return JSON.parse(result)\n } catch {\n return result;\n }\n }\n}\n"],"mappings":";;;;;;;AAAA;;AAEA;;;;;;AAGO,MAAMA,kBAAN,CAA+C;EAMpDC,WAAW,CAACC,eAAD,EAAoC;IAAA;;IAAA;;IAAA;;IAC7C,KAAKA,eAAL,GAAuBA,eAAvB;IACA,KAAKC,SAAL,GAAiB,IAAIC,SAAJ,EAAjB;EACD;;EAE2B,MAAfC,eAAe,CAACC,UAAD,EAAqB;IAC/C,MAAMC,MAAM,GAAG,IAAAC,uBAAA,EAAiB,KAAKN,eAAtB,CAAf;IACA,MAAM;MAAEO;IAAF,IAAW,MAAMF,MAAM,CAACG,GAAP,CAAY,0CAAyCJ,UAAW,EAAhE,CAAvB;IACA,KAAKK,MAAL,GAAcF,IAAI,CAACA,IAAnB;IACA,MAAM,KAAKN,SAAL,CAAeS,aAAf,CAA6BC,OAAO,CAAC,KAAKF,MAAL,CAAaG,UAAb,CAAwBC,UAAzB,CAApC,CAAN;IACA,OAAO,MAAM,KAAKZ,SAAL,CAAeE,eAAf,CAA+B,KAAKM,MAAL,CAAaG,UAAb,CAAwBE,iBAAxB,CAA0CC,mBAAzE,EAA8F,KAAKN,MAAL,CAAaG,UAAb,CAAwBE,iBAAxB,CAA0CE,sBAAxI,CAAb;EACD;;EAEiB,MAALC,KAAK,CAACC,aAAD,EAAgC;IAChD,IAAI,CAAC,KAAKT,MAAV,EAAkB;MAChB,MAAM,IAAIU,KAAJ,CAAU,uCAAV,CAAN;IACD;;IAED,MAAMC,OAA6B,GAAG;MACpCN,iBAAiB,EAAE,KAAKL,MAAL,CAAaG,UAAb,CAAwBE,iBADP;MAEpCO,WAAW,EAAE;QACXC,UAAU,EAAEC,MAAM,CAACL,aAAa,CAACM,MAAf,CADP;QAEXC,gBAAgB,EAAE,OAFP;QAGXC,YAAY,EAAER,aAAa,CAACQ,YAAd,IAA8B,KAAKjB,MAAL,CAAakB,QAH9C;QAIXC,WAAW,EAAEV,aAAa,CAACU,WAAd,IAA6B,KAAKnB,MAAL,CAAaoB;MAJ5C,CAFuB;MAQpCC,YAAY,EAAE,KAAKrB,MAAL,CAAaG,UAAb,CAAwBkB;IARF,CAAtC;IAWA,MAAMC,MAAM,GAAG,MAAM,KAAK9B,SAAL,CAAegB,KAAf,CAAqBG,OAArB,CAArB;;IACA,IAAI;MACF,OAAOY,IAAI,CAACC,KAAL,CAAWF,MAAX,CAAP;IACD,CAFD,CAEE,MAAM;MACN,OAAOA,MAAP;IACD;EACF;;AAzCmD"}
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _reactNative = require("react-native");
9
+
10
+ const {
11
+ GooglePay: RNGooglePay
12
+ } = _reactNative.NativeModules;
13
+
14
+ class GooglePay {
15
+ constructor() {
16
+ if (_reactNative.Platform.OS === 'android') {
17
+ if (!RNGooglePay) {
18
+ throw new Error('GooglePay is not defined');
19
+ }
20
+ } else {
21
+ throw new Error('Google Pay is not supported (Android only)');
22
+ }
23
+ }
24
+
25
+ async setProduction(isProduction) {
26
+ return RNGooglePay.setEnvironment(isProduction ? 1 : 3);
27
+ }
28
+
29
+ async canMakePayments(allowedCardNetworks, allowedCardAuthMethods) {
30
+ return await RNGooglePay.isReadyToPay(allowedCardNetworks, allowedCardAuthMethods);
31
+ }
32
+
33
+ async start(requestData) {
34
+ return await RNGooglePay.requestPayment(requestData);
35
+ }
36
+
37
+ }
38
+
39
+ exports.default = GooglePay;
40
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["GooglePay","RNGooglePay","NativeModules","constructor","Platform","OS","Error","setProduction","isProduction","setEnvironment","canMakePayments","allowedCardNetworks","allowedCardAuthMethods","isReadyToPay","start","requestData","requestPayment"],"sources":["index.ts"],"sourcesContent":["import { NativeModules, Platform } from 'react-native';\nimport type {\n GooglePayAllowedCardAuthMethods,\n GooglePayAllowedCardNetworks,\n GooglePayRequestData,\n IGooglePay,\n} from './interfaces';\n\nconst { GooglePay: RNGooglePay } = NativeModules;\n\nexport default class GooglePay implements IGooglePay {\n constructor() {\n if (Platform.OS === 'android') {\n if (!RNGooglePay) {\n throw new Error('GooglePay is not defined');\n }\n } else {\n throw new Error('Google Pay is not supported (Android only)');\n }\n }\n\n public async setProduction(isProduction: boolean) {\n return RNGooglePay.setEnvironment(isProduction ? 1 : 3);\n }\n\n public async canMakePayments(\n allowedCardNetworks: GooglePayAllowedCardNetworks,\n allowedCardAuthMethods: GooglePayAllowedCardAuthMethods\n ) {\n return await RNGooglePay.isReadyToPay(\n allowedCardNetworks,\n allowedCardAuthMethods\n );\n }\n\n public async start(requestData: GooglePayRequestData) {\n return await RNGooglePay.requestPayment(requestData);\n }\n}\n"],"mappings":";;;;;;;AAAA;;AAQA,MAAM;EAAEA,SAAS,EAAEC;AAAb,IAA6BC,0BAAnC;;AAEe,MAAMF,SAAN,CAAsC;EACnDG,WAAW,GAAG;IACZ,IAAIC,qBAAA,CAASC,EAAT,KAAgB,SAApB,EAA+B;MAC7B,IAAI,CAACJ,WAAL,EAAkB;QAChB,MAAM,IAAIK,KAAJ,CAAU,0BAAV,CAAN;MACD;IACF,CAJD,MAIO;MACL,MAAM,IAAIA,KAAJ,CAAU,4CAAV,CAAN;IACD;EACF;;EAEyB,MAAbC,aAAa,CAACC,YAAD,EAAwB;IAChD,OAAOP,WAAW,CAACQ,cAAZ,CAA2BD,YAAY,GAAG,CAAH,GAAO,CAA9C,CAAP;EACD;;EAE2B,MAAfE,eAAe,CAC1BC,mBAD0B,EAE1BC,sBAF0B,EAG1B;IACA,OAAO,MAAMX,WAAW,CAACY,YAAZ,CACXF,mBADW,EAEXC,sBAFW,CAAb;EAID;;EAEiB,MAALE,KAAK,CAACC,WAAD,EAAoC;IACpD,OAAO,MAAMd,WAAW,CAACe,cAAZ,CAA2BD,WAA3B,CAAb;EACD;;AA3BkD"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=interfaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["interfaces.ts"],"sourcesContent":["export interface IGooglePay {\n canMakePayments: (...args: any) => Promise<boolean>\n start: (...args: any) => Promise<any>\n}\n\ntype NetworkType = 'AMEX' | 'DISCOVER' | 'JCB' | 'MASTERCARD' | 'VISA';\ntype MethodType = 'PAN_ONLY' | 'CRYPTOGRAM_3DS';\n\nexport type GooglePayAllowedCardNetworks = NetworkType[];\n\nexport type GooglePayAllowedCardAuthMethods = MethodType[];\n\nexport type TokenizationSpecificationType = 'PAYMENT_GATEWAY' | 'DIRECT';\n\nexport interface GooglePayRequestData {\n production?: boolean,\n cardPaymentMethod: {\n tokenizationSpecification: {\n type: TokenizationSpecificationType;\n /** only with type: PAYMENT_GATEWAY */\n gateway?: string;\n /** only with type: PAYMENT_GATEWAY */\n gatewayMerchantId?: string;\n /** only with gateway: stripe */\n stripe?: {\n publishableKey: string;\n version: string;\n };\n /** only with type: DIRECT */\n publicKey?: string;\n };\n allowedCardNetworks: GooglePayAllowedCardNetworks;\n allowedCardAuthMethods: GooglePayAllowedCardAuthMethods;\n };\n transaction: {\n totalPrice: string;\n totalPriceStatus: string;\n currencyCode: string;\n countryCode: string;\n };\n merchantName: string;\n}\n"],"mappings":""}