@connexup/react-native-square-mobile-payment-sdk 0.1.0

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 (161) hide show
  1. package/LICENSE +20 -0
  2. package/NativeSquareMobilePaymentSDK.podspec +23 -0
  3. package/README.md +66 -0
  4. package/android/build.gradle +81 -0
  5. package/android/gradle.properties +5 -0
  6. package/android/src/main/AndroidManifest.xml +2 -0
  7. package/android/src/main/java/com/connexup/square/mobilepayment/DateFormatUtils.java +29 -0
  8. package/android/src/main/java/com/connexup/square/mobilepayment/ErrorUtilities.kt +56 -0
  9. package/android/src/main/java/com/connexup/square/mobilepayment/MobilePaymentAuthorization.kt +185 -0
  10. package/android/src/main/java/com/connexup/square/mobilepayment/MobilePaymentException.kt +8 -0
  11. package/android/src/main/java/com/connexup/square/mobilepayment/MobilePaymentPayment.kt +542 -0
  12. package/android/src/main/java/com/connexup/square/mobilepayment/MobilePaymentReader.kt +344 -0
  13. package/android/src/main/java/com/connexup/square/mobilepayment/MobilePaymentSDK.kt +47 -0
  14. package/android/src/main/java/com/connexup/square/mobilepayment/MobilePaymentSDKPackage.kt +77 -0
  15. package/android/src/main/java/com/connexup/square/mobilepayment/MobilePaymentSetting.kt +144 -0
  16. package/android/src/main/java/com/connexup/square/mobilepayment/convert/AdditionalPaymentMethodConvert.kt +46 -0
  17. package/android/src/main/java/com/connexup/square/mobilepayment/convert/AuthorizationStateConvert.kt +26 -0
  18. package/android/src/main/java/com/connexup/square/mobilepayment/convert/CardConvert.kt +53 -0
  19. package/android/src/main/java/com/connexup/square/mobilepayment/convert/CardDetailsConvert.kt +74 -0
  20. package/android/src/main/java/com/connexup/square/mobilepayment/convert/CardEntryMethodConvert.kt +31 -0
  21. package/android/src/main/java/com/connexup/square/mobilepayment/convert/CashPaymentDetailsConvert.kt +18 -0
  22. package/android/src/main/java/com/connexup/square/mobilepayment/convert/CurrencyCodeConvert.kt +204 -0
  23. package/android/src/main/java/com/connexup/square/mobilepayment/convert/DelayActionConvert.kt +33 -0
  24. package/android/src/main/java/com/connexup/square/mobilepayment/convert/DeniedReasonConvert.kt +28 -0
  25. package/android/src/main/java/com/connexup/square/mobilepayment/convert/DigitalWalletDetailsConvert.kt +18 -0
  26. package/android/src/main/java/com/connexup/square/mobilepayment/convert/ErrorDetailsConvert.kt +32 -0
  27. package/android/src/main/java/com/connexup/square/mobilepayment/convert/ExternalPaymentDetailsConvert.kt +25 -0
  28. package/android/src/main/java/com/connexup/square/mobilepayment/convert/LocationConvert.kt +31 -0
  29. package/android/src/main/java/com/connexup/square/mobilepayment/convert/MoneyConvert.kt +31 -0
  30. package/android/src/main/java/com/connexup/square/mobilepayment/convert/OfflineStatusConvert.kt +21 -0
  31. package/android/src/main/java/com/connexup/square/mobilepayment/convert/PaymentConvert.kt +93 -0
  32. package/android/src/main/java/com/connexup/square/mobilepayment/convert/PaymentProcessingFeeConvert.kt +39 -0
  33. package/android/src/main/java/com/connexup/square/mobilepayment/convert/PaymentSettingsConvert.kt +26 -0
  34. package/android/src/main/java/com/connexup/square/mobilepayment/convert/ProcessingModeConvert.kt +28 -0
  35. package/android/src/main/java/com/connexup/square/mobilepayment/convert/ReaderBatteryStatusConvert.kt +19 -0
  36. package/android/src/main/java/com/connexup/square/mobilepayment/convert/ReaderChangeEventConvert.kt +75 -0
  37. package/android/src/main/java/com/connexup/square/mobilepayment/convert/ReaderConnectionTypeConvert.kt +17 -0
  38. package/android/src/main/java/com/connexup/square/mobilepayment/convert/ReaderInfoConvert.kt +51 -0
  39. package/android/src/main/java/com/connexup/square/mobilepayment/convert/ReaderModalConvert.kt +18 -0
  40. package/android/src/main/java/com/connexup/square/mobilepayment/convert/ReaderStateConvert.kt +51 -0
  41. package/android/src/main/java/com/connexup/square/mobilepayment/convert/ReaderStatusConvert.kt +51 -0
  42. package/android/src/main/java/com/connexup/square/mobilepayment/convert/SdkSettingsConvert.kt +30 -0
  43. package/android/src/main/java/com/connexup/square/mobilepayment/convert/SquareAccountDetailsConvert.kt +20 -0
  44. package/android/src/main/java/com/connexup/square/mobilepayment/convert/TrackingConsentStateConvert.kt +17 -0
  45. package/android/src/main/java/com/connexup/square/mobilepayment/convert/WalletBrandConvert.kt +41 -0
  46. package/ios/Converters/AdditionalPaymentMethod+Extension.swift +17 -0
  47. package/ios/Converters/AdditionalPaymentMethodType+Extension.swift +44 -0
  48. package/ios/Converters/AuthorizationState+Extension.swift +22 -0
  49. package/ios/Converters/BatteryLevel+Extension.swift +27 -0
  50. package/ios/Converters/Card+Extension.swift +33 -0
  51. package/ios/Converters/CardBrand+Extension.swift +47 -0
  52. package/ios/Converters/CardCoBrand+Extension.swift +24 -0
  53. package/ios/Converters/CardEntryMethod+Extension.swift +30 -0
  54. package/ios/Converters/CardInputMethods+Extension.swift +35 -0
  55. package/ios/Converters/CardInsertionStatus+Extension.swift +24 -0
  56. package/ios/Converters/CardPaymentDetails+Extensions.swift +31 -0
  57. package/ios/Converters/CardPaymentStatus+Extension.swift +28 -0
  58. package/ios/Converters/Currency+Extension.swift +50 -0
  59. package/ios/Converters/Location+Extension.swift +19 -0
  60. package/ios/Converters/MoneyAmount+Extension.swift +30 -0
  61. package/ios/Converters/Payment+Extension.swift +44 -0
  62. package/ios/Converters/PaymentSettings+Extension.swift +19 -0
  63. package/ios/Converters/PaymentStatus+Extension.swift +53 -0
  64. package/ios/Converters/ProcessingMode+Extension.swift +37 -0
  65. package/ios/Converters/ReaderBatteryStatus+Extension.swift +19 -0
  66. package/ios/Converters/ReaderChange+Extension.swift +41 -0
  67. package/ios/Converters/ReaderConnectionFailureInfo+Extension.swift +20 -0
  68. package/ios/Converters/ReaderConnectionFailureReason+Extension.swift +40 -0
  69. package/ios/Converters/ReaderConnectionFailureRecoverySuggestion+Extension.swift +30 -0
  70. package/ios/Converters/ReaderConnectionInfo+Extension.swift +18 -0
  71. package/ios/Converters/ReaderConnectionStatus+Extension.swift +26 -0
  72. package/ios/Converters/ReaderFirmwareInfo+Extension.swift +19 -0
  73. package/ios/Converters/ReaderInfo+Extension.swift +30 -0
  74. package/ios/Converters/ReaderModel+Extension.swift +28 -0
  75. package/ios/Converters/ReaderState+Extension.swift +30 -0
  76. package/ios/Converters/ReaderStatus+Extension.swift +60 -0
  77. package/ios/Converters/ReaderStatusInfo+Extension.swift +22 -0
  78. package/ios/Converters/SDKSettings+Extension.swift +25 -0
  79. package/ios/Converters/SourceType+Extension.swift +32 -0
  80. package/ios/Converters/TrackingConsentState+Extension.swift +25 -0
  81. package/ios/ErrorUtilities.swift +41 -0
  82. package/ios/MobilePaymentAuthorization.swift +154 -0
  83. package/ios/MobilePaymentDateFormatter.swift +15 -0
  84. package/ios/MobilePaymentPayment.swift +478 -0
  85. package/ios/MobilePaymentReader.swift +248 -0
  86. package/ios/MobilePaymentSDK.swift +36 -0
  87. package/ios/MobilePaymentSetting.swift +86 -0
  88. package/ios/MockReaderUIManage.swift +52 -0
  89. package/ios/Models/NativeErrorInfo.swift +22 -0
  90. package/ios/Models/RCTPaymentMoneyParameter.swift +20 -0
  91. package/ios/Models/RCTPaymentParameters.swift +50 -0
  92. package/ios/Models/RCTPromptParameters.swift +20 -0
  93. package/ios/NotificationKeys.swift +9 -0
  94. package/ios/NotificationUtils.swift +21 -0
  95. package/ios/RCTMobilePaymentAuthorization.h +12 -0
  96. package/ios/RCTMobilePaymentAuthorization.mm +78 -0
  97. package/ios/RCTMobilePaymentPayment.h +12 -0
  98. package/ios/RCTMobilePaymentPayment.mm +116 -0
  99. package/ios/RCTMobilePaymentReader.h +12 -0
  100. package/ios/RCTMobilePaymentReader.mm +114 -0
  101. package/ios/RCTMobilePaymentSetting.h +10 -0
  102. package/ios/RCTMobilePaymentSetting.mm +94 -0
  103. package/ios/UIColor+Extension.swift +81 -0
  104. package/lib/module/authorization/NativeMobilePaymentAuthorization.js +60 -0
  105. package/lib/module/authorization/NativeMobilePaymentAuthorization.js.map +1 -0
  106. package/lib/module/authorization/index.js +44 -0
  107. package/lib/module/authorization/index.js.map +1 -0
  108. package/lib/module/index.js +7 -0
  109. package/lib/module/index.js.map +1 -0
  110. package/lib/module/package.json +1 -0
  111. package/lib/module/payment/NativeMobilePaymentPayment.js +138 -0
  112. package/lib/module/payment/NativeMobilePaymentPayment.js.map +1 -0
  113. package/lib/module/payment/index.js +113 -0
  114. package/lib/module/payment/index.js.map +1 -0
  115. package/lib/module/reader/NativeMobilePaymentReader.js +151 -0
  116. package/lib/module/reader/NativeMobilePaymentReader.js.map +1 -0
  117. package/lib/module/reader/index.js +109 -0
  118. package/lib/module/reader/index.js.map +1 -0
  119. package/lib/module/setting/NativeMobilePaymentSetting.js +5 -0
  120. package/lib/module/setting/NativeMobilePaymentSetting.js.map +1 -0
  121. package/lib/module/setting/index.js +74 -0
  122. package/lib/module/setting/index.js.map +1 -0
  123. package/lib/module/type.js +27 -0
  124. package/lib/module/type.js.map +1 -0
  125. package/lib/module/util.js +32 -0
  126. package/lib/module/util.js.map +1 -0
  127. package/lib/typescript/package.json +1 -0
  128. package/lib/typescript/src/authorization/NativeMobilePaymentAuthorization.d.ts +82 -0
  129. package/lib/typescript/src/authorization/NativeMobilePaymentAuthorization.d.ts.map +1 -0
  130. package/lib/typescript/src/authorization/index.d.ts +14 -0
  131. package/lib/typescript/src/authorization/index.d.ts.map +1 -0
  132. package/lib/typescript/src/index.d.ts +5 -0
  133. package/lib/typescript/src/index.d.ts.map +1 -0
  134. package/lib/typescript/src/payment/NativeMobilePaymentPayment.d.ts +725 -0
  135. package/lib/typescript/src/payment/NativeMobilePaymentPayment.d.ts.map +1 -0
  136. package/lib/typescript/src/payment/index.d.ts +13 -0
  137. package/lib/typescript/src/payment/index.d.ts.map +1 -0
  138. package/lib/typescript/src/reader/NativeMobilePaymentReader.d.ts +318 -0
  139. package/lib/typescript/src/reader/NativeMobilePaymentReader.d.ts.map +1 -0
  140. package/lib/typescript/src/reader/index.d.ts +19 -0
  141. package/lib/typescript/src/reader/index.d.ts.map +1 -0
  142. package/lib/typescript/src/setting/NativeMobilePaymentSetting.d.ts +49 -0
  143. package/lib/typescript/src/setting/NativeMobilePaymentSetting.d.ts.map +1 -0
  144. package/lib/typescript/src/setting/index.d.ts +17 -0
  145. package/lib/typescript/src/setting/index.d.ts.map +1 -0
  146. package/lib/typescript/src/type.d.ts +23 -0
  147. package/lib/typescript/src/type.d.ts.map +1 -0
  148. package/lib/typescript/src/util.d.ts +3 -0
  149. package/lib/typescript/src/util.d.ts.map +1 -0
  150. package/package.json +178 -0
  151. package/src/authorization/NativeMobilePaymentAuthorization.ts +297 -0
  152. package/src/authorization/index.ts +60 -0
  153. package/src/index.ts +4 -0
  154. package/src/payment/NativeMobilePaymentPayment.ts +1220 -0
  155. package/src/payment/index.ts +161 -0
  156. package/src/reader/NativeMobilePaymentReader.ts +463 -0
  157. package/src/reader/index.ts +140 -0
  158. package/src/setting/NativeMobilePaymentSetting.ts +254 -0
  159. package/src/setting/index.ts +91 -0
  160. package/src/type.ts +35 -0
  161. package/src/util.ts +31 -0
@@ -0,0 +1,138 @@
1
+ "use strict";
2
+
3
+ import { TurboModuleRegistry } from 'react-native';
4
+ export const NativeMobilePaymentPayment = TurboModuleRegistry.getEnforcing('NativeMobilePaymentPayment');
5
+
6
+ /**
7
+ * ios:UIFont
8
+ */
9
+ //TODO more params
10
+
11
+ /**
12
+ * AUTOMATIC:
13
+ * Reader SDK will choose an appropriate presentation style based on the current environment.
14
+ * For example, on iPad the payment flow may be displayed as an overlay instead of fullscreen.
15
+ *
16
+ * ALWAYS_FULLSCREEN:
17
+ * Shows the payment flow over the entire window of the screen.
18
+ */
19
+
20
+ // A representation of a payment.
21
+ // See (https://developer.squareup.com/reference/square/payments-api/create-payment) for more information.
22
+
23
+ //The authorized payment is completed, taking payment from the buyer.
24
+
25
+ //n AUTO_DETECT mode, we will verify the status of the network and Square systems health before processing the payment and determine whether it needs to be processed online or offline.
26
+
27
+ //Square Server processed your offline payment successfully, you can now see it in your merchant dashboard.
28
+
29
+ //only ios
30
+
31
+ //only android
32
+ // export interface ExternalPaymentSource extends BasePaymentSource {
33
+ // type: "EXTERNAL";
34
+ // externalTenderTyp: ExternalTenderType;
35
+ // source: string;
36
+ // sourceId?: string | null;
37
+ // sourceFeeMoney?: Money | null;
38
+ // }
39
+
40
+ // A type not listed here.
41
+
42
+ /**
43
+ * Detailed errors to explain a failure.
44
+ * Typically these are returned from Square's Connect v2 REST APIs,
45
+ * and are documented here[https://developer.squareup.com/reference/square/objects/Error].
46
+ * However, there may be conditions where an error is generated by the SDK itself,
47
+ * for example to explain errors that prevented server or cardreader communication.
48
+ */
49
+
50
+ /**
51
+ * Reader SDK could not connect to the network.
52
+ */
53
+ export const PaymentErrorNoNetwork = 'PAYMENT_ERROR_NO_NETWORK';
54
+
55
+ /**
56
+ * Reader SDK is not currently authorized with a Square Seller account.
57
+ */
58
+ export const PaymentErrorNotAuthorized = 'PAYMENT_ERROR_NOT_AUTHORIZED';
59
+ /**
60
+ * Invalid payment parameters were provided.
61
+ */
62
+ export const PaymentErrorInvalidPaymentParameters = 'PaymentErrorInvalidPaymentParameters';
63
+ /**
64
+ * The payment timed out.
65
+ */
66
+ export const PaymentErrorTimedOut = 'PAYMENT_ERROR_TIMED_OUT';
67
+ /**
68
+ * Location permission is needed.
69
+ */
70
+ export const PaymentErrorLocationPermissionNeeded = 'PAYMENT_ERROR_LOCATION_PERMISSION_NEEDED';
71
+ /**
72
+ * Payment is already in progress.
73
+ */
74
+ export const PaymentErrorPaymentAlreadyInProgress = 'PAYMENT_ERROR_PAYMENT_ALREADY_IN_PROGRESS';
75
+ /**
76
+ * Idempotency key already in use.
77
+ */
78
+ export const PaymentErrorIdempotencyKeyReused = 'PAYMENT_ERROR_IDEMPOTENCY_KEY_REUSED';
79
+ /**
80
+ * Invalid Payment Source Provided
81
+ */
82
+ export const PaymentErrorInvalidPaymentSource = 'PAYMENT_ERROR_INVALID_PAYMENT_SOURCE';
83
+
84
+ /**
85
+ * Error that is thrown if a merchant is not opted into offline processing
86
+ */
87
+ export const PaymentErrorMerchantNotOptedIntoOfflineProcessing = 'PAYMENT_ERROR_MERCHANT_NOT_OPTED_INTO_OFFLINE_PROCESSING';
88
+
89
+ /**
90
+ * Error thrown when payment amount is too big and exceeds limit for offline processing
91
+ */
92
+ export const PaymentErrorOfflineTransactionAmountExceeded = 'PAYMENT_ERROR_OFFLINE_TRANSACTION_AMOUNT_EXCEEDED';
93
+
94
+ /**
95
+ * The total stored in the database if this payment is taken offline will exceed the total allowed in offline mode.
96
+ */
97
+ export const PaymentErrorOfflineStoredAmountExceeded = 'PAYMENT_ERROR_OFFLINE_STORED_AMOUNT_EXCEEDED';
98
+
99
+ /**
100
+ * Offline processing is unsupported in sandbox environment
101
+ */
102
+ export const PaymentErrorSandboxUnsupportedForOfflineProcessing = 'PAYMENT_ERROR_SANDBOX_UNSUPPORTED_FOR_OFFLINE_PROCESSING';
103
+
104
+ /**
105
+ * Unexpected Error Returned
106
+ */
107
+ export const PaymentErrorUnexpected = 'PAYMENT_ERROR_UNEXPECTED';
108
+
109
+ /**
110
+ * The device clock is skewed and not matching the server time.
111
+ */
112
+ export const PaymentDeviceClockSkewed = 'PAYMENT_DEVICE_CLOCK_SKEWED';
113
+
114
+ /**
115
+ * Unsupported mode for taking a payment; for example, multitasking mode is not allowed on iPad
116
+ */
117
+ export const PaymentErrorUnsupportedMode = 'PAYMENT_ERROR_UNSUPPORTED_MODE';
118
+
119
+ /**
120
+ * Merchant is in a market that requires consent for analytics and consent has not been provided
121
+ */
122
+ export const PaymentConsentNotProvided = 'PAYMENT_CONSENT_NOT_PROVIDED';
123
+
124
+ /**
125
+ * Consent is required for tracking purposes and the tracking consent selection is pending and waiting on user.
126
+ */
127
+ export const PaymentTrackingConsentIsPending = 'PAYMENT_TRACKING_CONSENT_IS_PENDING';
128
+
129
+ /**
130
+ * Your application provided idempotencyKey in a market where Square will create and manage idempotency keys. Please use paymentAttemptId instead.
131
+ */
132
+ export const PaymentAttemptIdRequiredForSca = 'PAYMENT_ATTEMPT_ID_REQUIRED_FOR_SCA';
133
+
134
+ /**
135
+ * The payment attempt id used for this payment has already been used. Review previous payments to ensure you are not processing a duplicate payment, and then try again with a new payment attempt id.
136
+ */
137
+ export const PaymentAttemptIdReused = 'PAYMENT_ATTEMPT_ID_REUSED';
138
+ //# sourceMappingURL=NativeMobilePaymentPayment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["TurboModuleRegistry","NativeMobilePaymentPayment","getEnforcing","PaymentErrorNoNetwork","PaymentErrorNotAuthorized","PaymentErrorInvalidPaymentParameters","PaymentErrorTimedOut","PaymentErrorLocationPermissionNeeded","PaymentErrorPaymentAlreadyInProgress","PaymentErrorIdempotencyKeyReused","PaymentErrorInvalidPaymentSource","PaymentErrorMerchantNotOptedIntoOfflineProcessing","PaymentErrorOfflineTransactionAmountExceeded","PaymentErrorOfflineStoredAmountExceeded","PaymentErrorSandboxUnsupportedForOfflineProcessing","PaymentErrorUnexpected","PaymentDeviceClockSkewed","PaymentErrorUnsupportedMode","PaymentConsentNotProvided","PaymentTrackingConsentIsPending","PaymentAttemptIdRequiredForSca","PaymentAttemptIdReused"],"sourceRoot":"../../../src","sources":["payment/NativeMobilePaymentPayment.ts"],"mappings":";;AAAA,SAGEA,mBAAmB,QACd,cAAc;AA+BrB,OAAO,MAAMC,0BAA0B,GACrCD,mBAAmB,CAACE,YAAY,CAAO,4BAA4B,CAAC;;AAyKtE;AACA;AACA;AACA;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAkIA;AACA;;AA0XgB;;AAKG;;AAUF;;AA2BjB;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAqBa;;AAgRb;AACA;AACA;AACA;AACA;AACA;AACA;;AAkCA;AACA;AACA;AACA,OAAO,MAAMC,qBAAqB,GAAG,0BAA0B;;AAE/D;AACA;AACA;AACA,OAAO,MAAMC,yBAAyB,GAAG,8BAA8B;AACvE;AACA;AACA;AACA,OAAO,MAAMC,oCAAoC,GAC/C,sCAAsC;AACxC;AACA;AACA;AACA,OAAO,MAAMC,oBAAoB,GAAG,yBAAyB;AAC7D;AACA;AACA;AACA,OAAO,MAAMC,oCAAoC,GAC/C,0CAA0C;AAC5C;AACA;AACA;AACA,OAAO,MAAMC,oCAAoC,GAC/C,2CAA2C;AAC7C;AACA;AACA;AACA,OAAO,MAAMC,gCAAgC,GAC3C,sCAAsC;AACxC;AACA;AACA;AACA,OAAO,MAAMC,gCAAgC,GAC3C,sCAAsC;;AAExC;AACA;AACA;AACA,OAAO,MAAMC,iDAAiD,GAC5D,0DAA0D;;AAE5D;AACA;AACA;AACA,OAAO,MAAMC,4CAA4C,GACvD,mDAAmD;;AAErD;AACA;AACA;AACA,OAAO,MAAMC,uCAAuC,GAClD,8CAA8C;;AAEhD;AACA;AACA;AACA,OAAO,MAAMC,kDAAkD,GAC7D,0DAA0D;;AAE5D;AACA;AACA;AACA,OAAO,MAAMC,sBAAsB,GAAG,0BAA0B;;AAEhE;AACA;AACA;AACA,OAAO,MAAMC,wBAAwB,GAAG,6BAA6B;;AAErE;AACA;AACA;AACA,OAAO,MAAMC,2BAA2B,GAAG,gCAAgC;;AAE3E;AACA;AACA;AACA,OAAO,MAAMC,yBAAyB,GAAG,8BAA8B;;AAEvE;AACA;AACA;AACA,OAAO,MAAMC,+BAA+B,GAC1C,qCAAqC;;AAEvC;AACA;AACA;AACA,OAAO,MAAMC,8BAA8B,GACzC,qCAAqC;;AAEvC;AACA;AACA;AACA,OAAO,MAAMC,sBAAsB,GAAG,2BAA2B","ignoreList":[]}
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+
3
+ import { createMobilePaymentError, createMobilePaymentErrorFromCallback } from "../util.js";
4
+ import { NativeMobilePaymentPayment } from "./NativeMobilePaymentPayment.js";
5
+ class MobilePaymentPaymentImpl {
6
+ constructor(paymentManage) {
7
+ this.paymentManage = paymentManage;
8
+ }
9
+ async startPayment(paymentParameters, promptParameters, callback) {
10
+ this.paymentFlowSubscription?.remove();
11
+ this.paymentFlowSubscription = null;
12
+ const listener = event => {
13
+ switch (event.name) {
14
+ case 'didStart':
15
+ if (callback?.didStart) {
16
+ callback.didStart(event?.payment ?? null);
17
+ }
18
+ break;
19
+ case 'didFinish':
20
+ if (callback?.didFinish) {
21
+ callback.didFinish(event.payment);
22
+ }
23
+ // this.paymentFlowSubscription?.remove();
24
+ break;
25
+ case 'didFail':
26
+ if (callback?.didFail) {
27
+ callback.didFail(event?.payment ?? null, createMobilePaymentErrorFromCallback(event.error));
28
+ }
29
+ // this.paymentFlowSubscription?.remove();
30
+ break;
31
+ case 'didCancel':
32
+ if (callback?.didCancel) {
33
+ callback.didCancel(event?.payment ?? null);
34
+ }
35
+ // this.paymentFlowSubscription?.remove();
36
+ break;
37
+ case 'willFinish':
38
+ if (callback?.willFinish) {
39
+ callback.willFinish(event?.payment ?? null);
40
+ }
41
+ break;
42
+ case 'willCancel':
43
+ if (callback?.willCancel) {
44
+ callback.willCancel(event?.payment ?? null);
45
+ }
46
+ break;
47
+ }
48
+ };
49
+ this.paymentFlowSubscription = this.paymentManage.onPaymentFlowStatusChange(event => {
50
+ listener(event);
51
+ });
52
+ try {
53
+ await this.paymentManage.startPayment(paymentParameters, promptParameters);
54
+ return new PaymentHandleImpl(this.paymentManage);
55
+ } catch (e) {
56
+ this.paymentFlowSubscription?.remove();
57
+ this.paymentFlowSubscription = null;
58
+ throw createMobilePaymentError(e);
59
+ }
60
+ }
61
+ availableCardInputMethods() {
62
+ try {
63
+ return this.paymentManage.availableCardInputMethods();
64
+ } catch (e) {
65
+ throw createMobilePaymentError(e);
66
+ }
67
+ }
68
+ addAvailableCardInputMethodsChangeListener(listener) {
69
+ return this.paymentManage.onAvailableCardInputMethodsChange(listener);
70
+ }
71
+ }
72
+ class PaymentHandleImpl {
73
+ constructor(paymentManage) {
74
+ this.paymentManage = paymentManage;
75
+ }
76
+ additionalPaymentMethods() {
77
+ try {
78
+ return this.paymentManage.additionalPaymentMethods();
79
+ } catch (e) {
80
+ throw createMobilePaymentError(e);
81
+ }
82
+ }
83
+ async cancelPayment() {
84
+ try {
85
+ return await this.paymentManage.cancelCurrentPayment();
86
+ } catch (e) {
87
+ throw createMobilePaymentError(e);
88
+ }
89
+ }
90
+ isPaymentCancelable() {
91
+ try {
92
+ return this.paymentManage.isCurrentPaymentCancelable();
93
+ } catch (e) {
94
+ throw createMobilePaymentError(e);
95
+ }
96
+ }
97
+ payment() {
98
+ try {
99
+ return this.paymentManage.currentPayment();
100
+ } catch (e) {
101
+ throw createMobilePaymentError(e);
102
+ }
103
+ }
104
+ async triggerPaymentWithPaymentSource(paymentSource) {
105
+ try {
106
+ return await this.paymentManage.triggerPaymentWithAdditionalPaymentMethod(paymentSource);
107
+ } catch (e) {
108
+ throw createMobilePaymentError(e);
109
+ }
110
+ }
111
+ }
112
+ export const mobilePaymentPayment = new MobilePaymentPaymentImpl(NativeMobilePaymentPayment);
113
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createMobilePaymentError","createMobilePaymentErrorFromCallback","NativeMobilePaymentPayment","MobilePaymentPaymentImpl","constructor","paymentManage","startPayment","paymentParameters","promptParameters","callback","paymentFlowSubscription","remove","listener","event","name","didStart","payment","didFinish","didFail","error","didCancel","willFinish","willCancel","onPaymentFlowStatusChange","PaymentHandleImpl","e","availableCardInputMethods","addAvailableCardInputMethodsChangeListener","onAvailableCardInputMethodsChange","additionalPaymentMethods","cancelPayment","cancelCurrentPayment","isPaymentCancelable","isCurrentPaymentCancelable","currentPayment","triggerPaymentWithPaymentSource","paymentSource","triggerPaymentWithAdditionalPaymentMethod","mobilePaymentPayment"],"sourceRoot":"../../../src","sources":["payment/index.ts"],"mappings":";;AAWA,SACEA,wBAAwB,EACxBC,oCAAoC,QAC/B,YAAS;AAChB,SAASC,0BAA0B,QAAQ,iCAA8B;AAGzE,MAAMC,wBAAwB,CAAiC;EAI7DC,WAAWA,CAACC,aAAmB,EAAE;IAC/B,IAAI,CAACA,aAAa,GAAGA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C3B,aAAa,CAAC4B,0BAA0B,CAAC,CAAC;IACxD,CAAC,CAAC,OAAOR,CAAC,EAAE;MACV,MAAMzB,wBAAwB,CAACyB,CAAC,CAAC;IACnC;EACF;EAEAT,OAAOA,CAAA,EAAuC;IAC5C,IAAI;MACF,OAAO,IAAI,CAACX,aAAa,CAAC6B,cAAc,CAAC,CAAC;IAC5C,CAAC,CAAC,OAAOT,CAAC,EAAE;MACV,MAAMzB,wBAAwB,CAACyB,CAAC,CAAC;IACnC;EACF;EAEA,MAAMU,+BAA+BA,CACnCC,aAA4B,EACmC;IAC/D,IAAI;MACF,OAAO,MAAM,IAAI,CAAC/B,aAAa,CAACgC,yCAAyC,CACvED,aACF,CAAC;IACH,CAAC,CAAC,OAAOX,CAAC,EAAE;MACV,MAAMzB,wBAAwB,CAACyB,CAAC,CAAC;IACnC;EACF;AACF;AAEA,OAAO,MAAMa,oBAAoB,GAAG,IAAInC,wBAAwB,CAC9DD,0BACF,CAAC","ignoreList":[]}
@@ -0,0 +1,151 @@
1
+ "use strict";
2
+
3
+ import { TurboModuleRegistry } from 'react-native';
4
+ export const NativeMobilePaymentReader = TurboModuleRegistry.getEnforcing('NativeMobilePaymentReader');
5
+
6
+ /**
7
+ * CONNECTION_DID_FAIL
8
+ * Indicates the connection to the device has failed and .state.failureInfo may have more information
9
+ */
10
+
11
+ /**
12
+ * NO_SUGGESTION.
13
+ * The .localizedTitle and .localizedDescription fields may provide more information on how to recover.
14
+ *
15
+ * RETRY
16
+ * The connection issue may be transient and we suggest retrying.
17
+ *
18
+ * ACTIVATE_ACCOUNT
19
+ * Reader failed to connect because the user’s account requires activation to process cards.
20
+ *
21
+ * CONTACT_SUPPORT
22
+ * There is a specific issue around your account, reader, or device that may require you to contact Square support.
23
+ *
24
+ * REVIEW_TAP_TO_PAY_GUIDELINES
25
+ * Refer to the Apple Tap to Pay documentation for guidance on resolving this error.
26
+ *
27
+ * ENABLE_PASSCODE_TO_USE_TAP_TO_PAY
28
+ * This error appears when a passcode is not enabled on the device. Set an iPhone passcode to use Tap to Pay on iPhone.
29
+ */
30
+
31
+ /**
32
+ * DISCONNECTED
33
+ * The reader is unavailable, but known.
34
+ * If a reader is not connected to a power supply,
35
+ * the reader may fall asleep and needs to be woken up by pressing the power button.
36
+ *
37
+ * CONNECTING
38
+ * The reader is actively being connected
39
+ *
40
+ * READY
41
+ * The reader is connected and ready to be used.
42
+ *
43
+ * UPDATING_FIRMWARE
44
+ * The reader is being updated and cannot be used.
45
+ *
46
+ * FAILED_TO_CONNECT
47
+ * Connection to the reader failed; forget it and try again. .connectionState may contain more details.
48
+ *
49
+ * DISABLED
50
+ * This reader is unusable; contact support.
51
+ */
52
+
53
+ /**
54
+ * CRITICALLY_LOW
55
+ * Battery is extremely low. Plug in device immediately.
56
+ */
57
+
58
+ /**
59
+ * UNKNOWN
60
+ * Indicates card insertion status is unknown (Default for magstripe readers).
61
+ */
62
+
63
+ export const PairingErrorAlreadyInProgress = 'PAIRING_ERROR_ALREADY_IN_PROGRESS';
64
+ /**
65
+ * Reader SDK is not currently authorized with a Square Seller account.
66
+ */
67
+ export const PairingErrorNotAuthorized = 'PAIRING_ERROR_NOT_AUTHORIZED';
68
+ /**
69
+ * Reader Pairing not supported in sandbox environment
70
+ */
71
+ export const PairingErrorNotSupported = 'PAIRING_ERROR_NOT_SUPPORTED';
72
+ export const PairingErrorSandboxNotSupported = 'PAIRING_ERROR_SANDBOX_NOT_SUPPORTED';
73
+ export const PairingErrorSimulatorNotSupported = 'PAIRING_ERROR_SIMULATOR_NOT_SUPPORTED';
74
+ /**
75
+ * Pairing did not complete in a reasonable time.
76
+ */
77
+ export const PairingErrorTimedOut = 'PAIRING_ERROR_TIMED_OUT';
78
+ /**
79
+ * There is already an active pairing in progress.
80
+ */
81
+ export const PairingErrorReaderAlreadyPairing = 'PAIRING_ERROR_READER_ALREADY_PAIRING';
82
+ /**
83
+ * Reader was unable to pair.
84
+ */
85
+ export const PairingErrorFailedToConnect = 'PAIRING_ERROR_FAILED_TO_CONNECT';
86
+ /**
87
+ * The bluetooth connection on the device is disabled.
88
+ */
89
+ export const PairingErrorBluetoothDisabled = 'PAIRING_ERROR_BLUETOOTH_DISABLED';
90
+ /**
91
+ * The SDK is requiring an update to occur.
92
+ */
93
+ export const PairingErrorUpdateRequired = 'PAIRING_ERROR_UPDATE_REQUIRED';
94
+ /**
95
+ * Bluetooth permission has not been determined.
96
+ */
97
+ export const PairingErrorBluetoothPermissionNotDetermined = 'PAIRING_ERROR_BLUETOOTH_PERMISSION_NOT_DETERMINED';
98
+ /**
99
+ * Bluetooth permission is restricted.
100
+ */
101
+ export const PairingErrorBluetoothPermissionRestricted = 'PAIRING_ERROR_BLUETOOTH_PERMISSION_RESTRICTED';
102
+ /**
103
+ * Bluetooth permission has been denied.
104
+ */
105
+ export const PairingErrorBluetoothPermissionDenied = 'PAIRING_ERROR_BLUETOOTH_PERMISSION_DENIED';
106
+ /**
107
+ * Bluetooth permission is unknown.
108
+ */
109
+ export const PairingErrorBluetoothPermissionUnknownCase = 'PAIRING_ERROR_BLUETOOTH_PERMISSION_UNKNOWN_CASE';
110
+ /**
111
+ * Bluetooth is not supported.
112
+ */
113
+ export const PairingErrorBluetoothNotSupported = 'PAIRING_ERROR_BLUETOOTH_NOT_SUPPORTED';
114
+ /**
115
+ * Bluetooth is not ready.
116
+ */
117
+ export const PairingErrorBluetoothNotReady = 'PAIRING_ERROR_BLUETOOTH_NOT_READY';
118
+ /**
119
+ * Bluetooth is resetting.
120
+ */
121
+ export const PairingErrorBluetoothResetting = 'PAIRING_ERROR_BLUETOOTH_RESETTING';
122
+ /**
123
+ * Error displayed when pairing info is removed by the OS.
124
+ * To fix this force quit the app and then go to iOS bluetooth settings and forget the square reader and then re-pair the Square reader.
125
+ */
126
+ export const PairingErrorBondingRemoved = 'PAIRING_ERROR_BONDING_REMOVED';
127
+ /**
128
+ * Bluetooth has encountered an unknown error.
129
+ */
130
+ export const PairingErrorBluetoothUnknownError = 'PAIRING_ERROR_BLUETOOTH_UNKNOWN_ERROR';
131
+
132
+ /**
133
+ * App version is incompatible with reader firmware and requires an update.
134
+ */
135
+ export const PairingErrorPairingErrorAppUpdateRequired = 'PAIRING_ERROR_PAIRING_ERROR_APP_UPDATE_REQUIRED';
136
+
137
+ /**
138
+ * Unable to create a Bluetooth bond with the reader device.
139
+ */
140
+ export const PairingErrorBondFailed = 'PAIRING_ERROR_BOND_FAILED';
141
+
142
+ /**
143
+ * An internal firmware error occurred on the reader device.
144
+ */
145
+ export const PairingErrorInternalFirmwareError = 'PAIRING_ERROR_INTERNAL_FIRMWARE_ERROR';
146
+
147
+ /**
148
+ * An unknown error occurred while attempting to pair with the reader.
149
+ */
150
+ export const PairingErrorUnknownError = 'PAIRING_ERROR_UNKNOWN_ERROR';
151
+ //# sourceMappingURL=NativeMobilePaymentReader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["TurboModuleRegistry","NativeMobilePaymentReader","getEnforcing","PairingErrorAlreadyInProgress","PairingErrorNotAuthorized","PairingErrorNotSupported","PairingErrorSandboxNotSupported","PairingErrorSimulatorNotSupported","PairingErrorTimedOut","PairingErrorReaderAlreadyPairing","PairingErrorFailedToConnect","PairingErrorBluetoothDisabled","PairingErrorUpdateRequired","PairingErrorBluetoothPermissionNotDetermined","PairingErrorBluetoothPermissionRestricted","PairingErrorBluetoothPermissionDenied","PairingErrorBluetoothPermissionUnknownCase","PairingErrorBluetoothNotSupported","PairingErrorBluetoothNotReady","PairingErrorBluetoothResetting","PairingErrorBondingRemoved","PairingErrorBluetoothUnknownError","PairingErrorPairingErrorAppUpdateRequired","PairingErrorBondFailed","PairingErrorInternalFirmwareError","PairingErrorUnknownError"],"sourceRoot":"../../../src","sources":["reader/NativeMobilePaymentReader.ts"],"mappings":";;AAAA,SAGEA,mBAAmB,QACd,cAAc;AAsBrB,OAAO,MAAMC,yBAAyB,GAAGD,mBAAmB,CAACE,YAAY,CACvE,2BACF,CAAC;;AAkHD;AACA;AACA;AACA;;AAiFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAsDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAyBA;AACA;AACA;AACA;;AASA;AACA;AACA;AACA;;AAGA,OAAO,MAAMC,6BAA6B,GACxC,mCAAmC;AACrC;AACA;AACA;AACA,OAAO,MAAMC,yBAAyB,GAAG,8BAA8B;AACvE;AACA;AACA;AACA,OAAO,MAAMC,wBAAwB,GAAG,6BAA6B;AACrE,OAAO,MAAMC,+BAA+B,GAC1C,qCAAqC;AACvC,OAAO,MAAMC,iCAAiC,GAC5C,uCAAuC;AACzC;AACA;AACA;AACA,OAAO,MAAMC,oBAAoB,GAAG,yBAAyB;AAC7D;AACA;AACA;AACA,OAAO,MAAMC,gCAAgC,GAC3C,sCAAsC;AACxC;AACA;AACA;AACA,OAAO,MAAMC,2BAA2B,GAAG,iCAAiC;AAC5E;AACA;AACA;AACA,OAAO,MAAMC,6BAA6B,GAAG,kCAAkC;AAC/E;AACA;AACA;AACA,OAAO,MAAMC,0BAA0B,GAAG,+BAA+B;AACzE;AACA;AACA;AACA,OAAO,MAAMC,4CAA4C,GACvD,mDAAmD;AACrD;AACA;AACA;AACA,OAAO,MAAMC,yCAAyC,GACpD,+CAA+C;AACjD;AACA;AACA;AACA,OAAO,MAAMC,qCAAqC,GAChD,2CAA2C;AAC7C;AACA;AACA;AACA,OAAO,MAAMC,0CAA0C,GACrD,iDAAiD;AACnD;AACA;AACA;AACA,OAAO,MAAMC,iCAAiC,GAC5C,uCAAuC;AACzC;AACA;AACA;AACA,OAAO,MAAMC,6BAA6B,GACxC,mCAAmC;AACrC;AACA;AACA;AACA,OAAO,MAAMC,8BAA8B,GACzC,mCAAmC;AACrC;AACA;AACA;AACA;AACA,OAAO,MAAMC,0BAA0B,GAAG,+BAA+B;AACzE;AACA;AACA;AACA,OAAO,MAAMC,iCAAiC,GAC5C,uCAAuC;;AAEzC;AACA;AACA;AACA,OAAO,MAAMC,yCAAyC,GACpD,iDAAiD;;AAEnD;AACA;AACA;AACA,OAAO,MAAMC,sBAAsB,GAAG,2BAA2B;;AAEjE;AACA;AACA;AACA,OAAO,MAAMC,iCAAiC,GAC5C,uCAAuC;;AAEzC;AACA;AACA;AACA,OAAO,MAAMC,wBAAwB,GAAG,6BAA6B","ignoreList":[]}
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+
3
+ import { createMobilePaymentError, createMobilePaymentErrorFromCallback } from "../util.js";
4
+ import { NativeMobilePaymentReader } from "./NativeMobilePaymentReader.js";
5
+ class MobilePaymentReader {
6
+ constructor(readerManage) {
7
+ this.readerManage = readerManage;
8
+ }
9
+ async bink(readerId) {
10
+ try {
11
+ return await this.readerManage.bink(readerId);
12
+ } catch (e) {
13
+ throw createMobilePaymentError(e);
14
+ }
15
+ }
16
+ async forget(readerId) {
17
+ try {
18
+ return await this.readerManage.forget(readerId);
19
+ } catch (e) {
20
+ throw createMobilePaymentError(e);
21
+ }
22
+ }
23
+ readers() {
24
+ try {
25
+ return this.readerManage.readers();
26
+ } catch (e) {
27
+ throw createMobilePaymentError(e);
28
+ }
29
+ }
30
+ async retryConnection(readerId) {
31
+ try {
32
+ return await this.readerManage.retryConnection(readerId);
33
+ } catch (e) {
34
+ throw createMobilePaymentError(e);
35
+ }
36
+ }
37
+ async startPairing(listener) {
38
+ this.pairingSubscription?.remove();
39
+ this.pairingSubscription = null;
40
+ if (listener) {
41
+ this.pairingSubscription = this.addPairingStatusListener(listener);
42
+ }
43
+ try {
44
+ return await this.readerManage.startPairing();
45
+ } catch (e) {
46
+ this.pairingSubscription?.remove();
47
+ this.pairingSubscription = null;
48
+ throw createMobilePaymentError(e);
49
+ }
50
+ }
51
+ async stopPairing() {
52
+ try {
53
+ return await this.readerManage.stopPairing();
54
+ } catch (e) {
55
+ throw createMobilePaymentError(e);
56
+ }
57
+ }
58
+ isPairingInProgress() {
59
+ try {
60
+ return this.readerManage.isPairingInProgress();
61
+ } catch (e) {
62
+ throw createMobilePaymentError(e);
63
+ }
64
+ }
65
+ addReaderListener(listener) {
66
+ return this.readerManage.onReaderChange(event => {
67
+ switch (event.name) {
68
+ case 'readerWasAdded':
69
+ if (listener.readerWasAdded) {
70
+ listener.readerWasAdded(event.readerInfo);
71
+ }
72
+ break;
73
+ case 'readerWasRemoved':
74
+ if (listener.readerWasRemoved) {
75
+ listener.readerWasRemoved(event.readerInfo);
76
+ }
77
+ break;
78
+ case 'readerDidChange':
79
+ if (listener.readerDidChange) {
80
+ listener.readerDidChange(event.readerInfo, event.readerChange);
81
+ }
82
+ break;
83
+ }
84
+ });
85
+ }
86
+ addPairingStatusListener(listener) {
87
+ return this.readerManage.onReaderPairingStatus(event => {
88
+ switch (event.name) {
89
+ case 'didBegin':
90
+ if (listener.didBegin) {
91
+ listener.didBegin();
92
+ }
93
+ break;
94
+ case 'didSucceed':
95
+ if (listener.didSucceed) {
96
+ listener.didSucceed();
97
+ }
98
+ break;
99
+ case 'didFail':
100
+ if (listener.didFail) {
101
+ listener.didFail(createMobilePaymentErrorFromCallback(event.error));
102
+ }
103
+ break;
104
+ }
105
+ });
106
+ }
107
+ }
108
+ export const mobilePaymentReader = new MobilePaymentReader(NativeMobilePaymentReader);
109
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createMobilePaymentError","createMobilePaymentErrorFromCallback","NativeMobilePaymentReader","MobilePaymentReader","constructor","readerManage","bink","readerId","e","forget","readers","retryConnection","startPairing","listener","pairingSubscription","remove","addPairingStatusListener","stopPairing","isPairingInProgress","addReaderListener","onReaderChange","event","name","readerWasAdded","readerInfo","readerWasRemoved","readerDidChange","readerChange","onReaderPairingStatus","didBegin","didSucceed","didFail","error","mobilePaymentReader"],"sourceRoot":"../../../src","sources":["reader/index.ts"],"mappings":";;AACA,SACEA,wBAAwB,EACx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3E,OAAO,IAAI,CAACR,YAAY,CAACuB,qBAAqB,CAC3CP,KAA+B,IAAK;MACnC,QAAQA,KAAK,CAACC,IAAI;QAChB,KAAK,UAAU;UACb,IAAIT,QAAQ,CAACgB,QAAQ,EAAE;YACrBhB,QAAQ,CAACgB,QAAQ,CAAC,CAAC;UACrB;UACA;QACF,KAAK,YAAY;UACf,IAAIhB,QAAQ,CAACiB,UAAU,EAAE;YACvBjB,QAAQ,CAACiB,UAAU,CAAC,CAAC;UACvB;UACA;QACF,KAAK,SAAS;UACZ,IAAIjB,QAAQ,CAACkB,OAAO,EAAE;YACpBlB,QAAQ,CAACkB,OAAO,CACd9B,oCAAoC,CAACoB,KAAK,CAACW,KAAK,CAClD,CAAC;UACH;UACA;MACJ;IACF,CACF,CAAC;EACH;AACF;AAEA,OAAO,MAAMC,mBAAmB,GAAG,IAAI9B,mBAAmB,CACxDD,yBACF,CAAC","ignoreList":[]}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ import { TurboModuleRegistry } from 'react-native';
4
+ export const NativeMobilePaymentSetting = TurboModuleRegistry.getEnforcing('NativeMobilePaymentSetting');
5
+ //# sourceMappingURL=NativeMobilePaymentSetting.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["TurboModuleRegistry","NativeMobilePaymentSetting","getEnforcing"],"sourceRoot":"../../../src","sources":["setting/NativeMobilePaymentSetting.ts"],"mappings":";;AAAA,SAA2BA,mBAAmB,QAAQ,cAAc;AAuBpE,OAAO,MAAMC,0BAA0B,GACrCD,mBAAmB,CAACE,YAAY,CAAO,4BAA4B,CAAC","ignoreList":[]}
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+
3
+ import { NativeMobilePaymentSetting } from "./NativeMobilePaymentSetting.js";
4
+ import { createMobilePaymentError } from "../util.js";
5
+ class MobilePaymentSetting {
6
+ constructor(settingsManage) {
7
+ this.settingsManage = settingsManage;
8
+ }
9
+ async initialize(applicationId) {
10
+ try {
11
+ return await this.settingsManage.initialize(applicationId);
12
+ } catch (e) {
13
+ throw createMobilePaymentError(e);
14
+ }
15
+ }
16
+ applicationId() {
17
+ try {
18
+ return this.settingsManage.applicationId();
19
+ } catch (e) {
20
+ throw createMobilePaymentError(e);
21
+ }
22
+ }
23
+ sdkSettings() {
24
+ try {
25
+ return this.settingsManage.sdkSettings();
26
+ } catch (e) {
27
+ throw createMobilePaymentError(e);
28
+ }
29
+ }
30
+ paymentSettings() {
31
+ try {
32
+ return this.settingsManage.paymentSettings();
33
+ } catch (e) {
34
+ throw createMobilePaymentError(e);
35
+ }
36
+ }
37
+ trackingConsentState() {
38
+ try {
39
+ return this.settingsManage.trackingConsentState();
40
+ } catch (e) {
41
+ throw createMobilePaymentError(e);
42
+ }
43
+ }
44
+ async updateTrackingConsent(granted) {
45
+ try {
46
+ return await this.settingsManage.updateTrackingConsent(granted);
47
+ } catch (e) {
48
+ throw createMobilePaymentError(e);
49
+ }
50
+ }
51
+ async presentSettings() {
52
+ try {
53
+ return await this.settingsManage.presentSettings();
54
+ } catch (e) {
55
+ throw createMobilePaymentError(e);
56
+ }
57
+ }
58
+ async presentMockReaderUI() {
59
+ try {
60
+ return await this.settingsManage.presentMockReaderUI();
61
+ } catch (e) {
62
+ throw createMobilePaymentError(e);
63
+ }
64
+ }
65
+ async dismissMockReaderUI() {
66
+ try {
67
+ return await this.settingsManage.dismissMockReaderUI();
68
+ } catch (e) {
69
+ throw createMobilePaymentError(e);
70
+ }
71
+ }
72
+ }
73
+ export const mobilePaymentSetting = new MobilePaymentSetting(NativeMobilePaymentSetting);
74
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["NativeMobilePaymentSetting","createMobilePaymentError","MobilePaymentSetting","constructor","settingsManage","initialize","applicationId","e","sdkSettings","paymentSettings","trackingConsentState","updateTrackingConsent","granted","presentSettings","presentMockReaderUI","dismissMockReaderUI","mobilePaymentSetting"],"sourceRoot":"../../../src","sources":["setting/index.ts"],"mappings":";;AAAA,SAAS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CAAC,CAAC,OAAOL,CAAC,EAAE;MACV,MAAMN,wBAAwB,CAACM,CAAC,CAAC;IACnC;EACF;EAEA,MAAMM,eAAeA,CAAA,EAAkB;IACrC,IAAI;MACF,OAAO,MAAM,IAAI,CAACT,cAAc,CAACS,eAAe,CAAC,CAAC;IACpD,CAAC,CAAC,OAAON,CAAC,EAAE;MACV,MAAMN,wBAAwB,CAACM,CAAC,CAAC;IACnC;EACF;EAEA,MAAMO,mBAAmBA,CAAA,EAAkB;IACzC,IAAI;MACF,OAAO,MAAM,IAAI,CAACV,cAAc,CAACU,mBAAmB,CAAC,CAAC;IACxD,CAAC,CAAC,OAAOP,CAAC,EAAE;MACV,MAAMN,wBAAwB,CAACM,CAAC,CAAC;IACnC;EACF;EAEA,MAAMQ,mBAAmBA,CAAA,EAAkB;IACzC,IAAI;MACF,OAAO,MAAM,IAAI,CAACX,cAAc,CAACW,mBAAmB,CAAC,CAAC;IACxD,CAAC,CAAC,OAAOR,CAAC,EAAE;MACV,MAAMN,wBAAwB,CAACM,CAAC,CAAC;IACnC;EACF;AACF;AAEA,OAAO,MAAMS,oBAAoB,GAAG,IAAId,oBAAoB,CAC1DF,0BACF,CAAC","ignoreList":[]}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ export const PARAMS_ERROR = 'PARAMS_ERROR';
4
+ export const UNKNOWN_ERROR = 'UNKNOWN_ERROR';
5
+ export class Exception {
6
+ /**
7
+ * @param message is JavaScript original message, in English usually.
8
+ * In prod environment, you are not advised to display the error message directly to end-user.
9
+ */
10
+ constructor(message) {
11
+ this.message = message;
12
+ }
13
+ }
14
+ export class SquareException extends Exception {
15
+ constructor({
16
+ message,
17
+ code,
18
+ debugCode,
19
+ debugMessage
20
+ }) {
21
+ super(message);
22
+ this.code = code;
23
+ this.debugCode = debugCode;
24
+ this.debugMessage = debugMessage;
25
+ }
26
+ }
27
+ //# sourceMappingURL=type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["PARAMS_ERROR","UNKNOWN_ERROR","Exception","constructor","message","SquareException","code","debugCode","debugMessage"],"sourceRoot":"../../src","sources":["type.ts"],"mappings":";;AAAA,OAAO,MAAMA,YAAY,GAAG,cAAc;AAC1C,OAAO,MAAMC,aAAa,GAAG,eAAe;AAE5C,OAAO,MAAeC,SAAS,CAAC;EAC9B;AACF;AACA;AACA;EACYC,WAAWA,CAAQC,OAAe,EAAE;IAAA,KAAjBA,OAAe,GAAfA,OAAe;EAAG;AACjD;AASA,OAAO,MAAMC,eAAe,SAASH,SAAS,CAAC;EAK7CC,WAAWA,CAAC;IACVC,OAAO;IACPE,IAAI;IACJC,SAAS;IACTC;EACoB,CAAC,EAAE;IACvB,KAAK,CAACJ,OAAO,CAAC;IACd,IAAI,CAACE,IAAI,GAAGA,IAAI;IAChB,IAAI,CAACC,SAAS,GAAGA,SAAS;IAC1B,IAAI,CAACC,YAAY,GAAGA,YAAY;EAClC;AACF","ignoreList":[]}