@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.
- package/LICENSE +20 -0
- package/NativeSquareMobilePaymentSDK.podspec +23 -0
- package/README.md +66 -0
- package/android/build.gradle +81 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/DateFormatUtils.java +29 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/ErrorUtilities.kt +56 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/MobilePaymentAuthorization.kt +185 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/MobilePaymentException.kt +8 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/MobilePaymentPayment.kt +542 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/MobilePaymentReader.kt +344 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/MobilePaymentSDK.kt +47 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/MobilePaymentSDKPackage.kt +77 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/MobilePaymentSetting.kt +144 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/AdditionalPaymentMethodConvert.kt +46 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/AuthorizationStateConvert.kt +26 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/CardConvert.kt +53 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/CardDetailsConvert.kt +74 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/CardEntryMethodConvert.kt +31 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/CashPaymentDetailsConvert.kt +18 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/CurrencyCodeConvert.kt +204 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/DelayActionConvert.kt +33 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/DeniedReasonConvert.kt +28 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/DigitalWalletDetailsConvert.kt +18 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/ErrorDetailsConvert.kt +32 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/ExternalPaymentDetailsConvert.kt +25 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/LocationConvert.kt +31 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/MoneyConvert.kt +31 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/OfflineStatusConvert.kt +21 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/PaymentConvert.kt +93 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/PaymentProcessingFeeConvert.kt +39 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/PaymentSettingsConvert.kt +26 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/ProcessingModeConvert.kt +28 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/ReaderBatteryStatusConvert.kt +19 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/ReaderChangeEventConvert.kt +75 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/ReaderConnectionTypeConvert.kt +17 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/ReaderInfoConvert.kt +51 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/ReaderModalConvert.kt +18 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/ReaderStateConvert.kt +51 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/ReaderStatusConvert.kt +51 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/SdkSettingsConvert.kt +30 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/SquareAccountDetailsConvert.kt +20 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/TrackingConsentStateConvert.kt +17 -0
- package/android/src/main/java/com/connexup/square/mobilepayment/convert/WalletBrandConvert.kt +41 -0
- package/ios/Converters/AdditionalPaymentMethod+Extension.swift +17 -0
- package/ios/Converters/AdditionalPaymentMethodType+Extension.swift +44 -0
- package/ios/Converters/AuthorizationState+Extension.swift +22 -0
- package/ios/Converters/BatteryLevel+Extension.swift +27 -0
- package/ios/Converters/Card+Extension.swift +33 -0
- package/ios/Converters/CardBrand+Extension.swift +47 -0
- package/ios/Converters/CardCoBrand+Extension.swift +24 -0
- package/ios/Converters/CardEntryMethod+Extension.swift +30 -0
- package/ios/Converters/CardInputMethods+Extension.swift +35 -0
- package/ios/Converters/CardInsertionStatus+Extension.swift +24 -0
- package/ios/Converters/CardPaymentDetails+Extensions.swift +31 -0
- package/ios/Converters/CardPaymentStatus+Extension.swift +28 -0
- package/ios/Converters/Currency+Extension.swift +50 -0
- package/ios/Converters/Location+Extension.swift +19 -0
- package/ios/Converters/MoneyAmount+Extension.swift +30 -0
- package/ios/Converters/Payment+Extension.swift +44 -0
- package/ios/Converters/PaymentSettings+Extension.swift +19 -0
- package/ios/Converters/PaymentStatus+Extension.swift +53 -0
- package/ios/Converters/ProcessingMode+Extension.swift +37 -0
- package/ios/Converters/ReaderBatteryStatus+Extension.swift +19 -0
- package/ios/Converters/ReaderChange+Extension.swift +41 -0
- package/ios/Converters/ReaderConnectionFailureInfo+Extension.swift +20 -0
- package/ios/Converters/ReaderConnectionFailureReason+Extension.swift +40 -0
- package/ios/Converters/ReaderConnectionFailureRecoverySuggestion+Extension.swift +30 -0
- package/ios/Converters/ReaderConnectionInfo+Extension.swift +18 -0
- package/ios/Converters/ReaderConnectionStatus+Extension.swift +26 -0
- package/ios/Converters/ReaderFirmwareInfo+Extension.swift +19 -0
- package/ios/Converters/ReaderInfo+Extension.swift +30 -0
- package/ios/Converters/ReaderModel+Extension.swift +28 -0
- package/ios/Converters/ReaderState+Extension.swift +30 -0
- package/ios/Converters/ReaderStatus+Extension.swift +60 -0
- package/ios/Converters/ReaderStatusInfo+Extension.swift +22 -0
- package/ios/Converters/SDKSettings+Extension.swift +25 -0
- package/ios/Converters/SourceType+Extension.swift +32 -0
- package/ios/Converters/TrackingConsentState+Extension.swift +25 -0
- package/ios/ErrorUtilities.swift +41 -0
- package/ios/MobilePaymentAuthorization.swift +154 -0
- package/ios/MobilePaymentDateFormatter.swift +15 -0
- package/ios/MobilePaymentPayment.swift +478 -0
- package/ios/MobilePaymentReader.swift +248 -0
- package/ios/MobilePaymentSDK.swift +36 -0
- package/ios/MobilePaymentSetting.swift +86 -0
- package/ios/MockReaderUIManage.swift +52 -0
- package/ios/Models/NativeErrorInfo.swift +22 -0
- package/ios/Models/RCTPaymentMoneyParameter.swift +20 -0
- package/ios/Models/RCTPaymentParameters.swift +50 -0
- package/ios/Models/RCTPromptParameters.swift +20 -0
- package/ios/NotificationKeys.swift +9 -0
- package/ios/NotificationUtils.swift +21 -0
- package/ios/RCTMobilePaymentAuthorization.h +12 -0
- package/ios/RCTMobilePaymentAuthorization.mm +78 -0
- package/ios/RCTMobilePaymentPayment.h +12 -0
- package/ios/RCTMobilePaymentPayment.mm +116 -0
- package/ios/RCTMobilePaymentReader.h +12 -0
- package/ios/RCTMobilePaymentReader.mm +114 -0
- package/ios/RCTMobilePaymentSetting.h +10 -0
- package/ios/RCTMobilePaymentSetting.mm +94 -0
- package/ios/UIColor+Extension.swift +81 -0
- package/lib/module/authorization/NativeMobilePaymentAuthorization.js +60 -0
- package/lib/module/authorization/NativeMobilePaymentAuthorization.js.map +1 -0
- package/lib/module/authorization/index.js +44 -0
- package/lib/module/authorization/index.js.map +1 -0
- package/lib/module/index.js +7 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/payment/NativeMobilePaymentPayment.js +138 -0
- package/lib/module/payment/NativeMobilePaymentPayment.js.map +1 -0
- package/lib/module/payment/index.js +113 -0
- package/lib/module/payment/index.js.map +1 -0
- package/lib/module/reader/NativeMobilePaymentReader.js +151 -0
- package/lib/module/reader/NativeMobilePaymentReader.js.map +1 -0
- package/lib/module/reader/index.js +109 -0
- package/lib/module/reader/index.js.map +1 -0
- package/lib/module/setting/NativeMobilePaymentSetting.js +5 -0
- package/lib/module/setting/NativeMobilePaymentSetting.js.map +1 -0
- package/lib/module/setting/index.js +74 -0
- package/lib/module/setting/index.js.map +1 -0
- package/lib/module/type.js +27 -0
- package/lib/module/type.js.map +1 -0
- package/lib/module/util.js +32 -0
- package/lib/module/util.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/authorization/NativeMobilePaymentAuthorization.d.ts +82 -0
- package/lib/typescript/src/authorization/NativeMobilePaymentAuthorization.d.ts.map +1 -0
- package/lib/typescript/src/authorization/index.d.ts +14 -0
- package/lib/typescript/src/authorization/index.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +5 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/payment/NativeMobilePaymentPayment.d.ts +725 -0
- package/lib/typescript/src/payment/NativeMobilePaymentPayment.d.ts.map +1 -0
- package/lib/typescript/src/payment/index.d.ts +13 -0
- package/lib/typescript/src/payment/index.d.ts.map +1 -0
- package/lib/typescript/src/reader/NativeMobilePaymentReader.d.ts +318 -0
- package/lib/typescript/src/reader/NativeMobilePaymentReader.d.ts.map +1 -0
- package/lib/typescript/src/reader/index.d.ts +19 -0
- package/lib/typescript/src/reader/index.d.ts.map +1 -0
- package/lib/typescript/src/setting/NativeMobilePaymentSetting.d.ts +49 -0
- package/lib/typescript/src/setting/NativeMobilePaymentSetting.d.ts.map +1 -0
- package/lib/typescript/src/setting/index.d.ts +17 -0
- package/lib/typescript/src/setting/index.d.ts.map +1 -0
- package/lib/typescript/src/type.d.ts +23 -0
- package/lib/typescript/src/type.d.ts.map +1 -0
- package/lib/typescript/src/util.d.ts +3 -0
- package/lib/typescript/src/util.d.ts.map +1 -0
- package/package.json +178 -0
- package/src/authorization/NativeMobilePaymentAuthorization.ts +297 -0
- package/src/authorization/index.ts +60 -0
- package/src/index.ts +4 -0
- package/src/payment/NativeMobilePaymentPayment.ts +1220 -0
- package/src/payment/index.ts +161 -0
- package/src/reader/NativeMobilePaymentReader.ts +463 -0
- package/src/reader/index.ts +140 -0
- package/src/setting/NativeMobilePaymentSetting.ts +254 -0
- package/src/setting/index.ts +91 -0
- package/src/type.ts +35 -0
- package/src/util.ts +31 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
package com.connexup.square.mobilepayment.convert
|
|
2
|
+
|
|
3
|
+
import com.connexup.square.mobilepayment.DateFormatUtils
|
|
4
|
+
import com.facebook.react.bridge.ReadableMap
|
|
5
|
+
import com.facebook.react.bridge.WritableNativeArray
|
|
6
|
+
import com.facebook.react.bridge.WritableNativeMap
|
|
7
|
+
import com.squareup.sdk.mobilepayments.payment.Payment
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Description:
|
|
11
|
+
* @author lukechen@chancetop.com
|
|
12
|
+
* @date 2023/11/20
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
val Payment.readableMap: ReadableMap
|
|
17
|
+
get() {
|
|
18
|
+
val result = WritableNativeMap()
|
|
19
|
+
result.putString("createdAt", DateFormatUtils.formatISO8601UTC(this.createdAt))
|
|
20
|
+
result.putString("updatedAt", DateFormatUtils.formatISO8601UTC(this.updatedAt))
|
|
21
|
+
result.putMap("amountMoney", this.amountMoney.readableMap)
|
|
22
|
+
result.putMap("tipMoney", this.tipMoney?.readableMap)
|
|
23
|
+
result.putMap("appFeeMoney", this.appFeeMoney?.readableMap)
|
|
24
|
+
result.putMap("totalMoney", this.totalMoney.readableMap)
|
|
25
|
+
result.putString("locationID", this.locationId)
|
|
26
|
+
result.putString("orderId", this.orderId)
|
|
27
|
+
result.putString("referenceID", this.referenceId)
|
|
28
|
+
result.putString(
|
|
29
|
+
"sourceType", when (this.sourceType) {
|
|
30
|
+
Payment.SourceType.CARD -> "CARD"
|
|
31
|
+
Payment.SourceType.CASH -> "CASH"
|
|
32
|
+
Payment.SourceType.EXTERNAL -> "EXTERNAL"
|
|
33
|
+
Payment.SourceType.WALLET -> "WALLET"
|
|
34
|
+
Payment.SourceType.BANK_ACCOUNT -> "BANK_ACCOUNT"
|
|
35
|
+
Payment.SourceType.CARD_ON_FILE -> "CARD_ON_FILE"
|
|
36
|
+
Payment.SourceType.SQUARE_ACCOUNT -> "SQUARE_ACCOUNT"
|
|
37
|
+
}
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
result.putMap("cashDetails", this.cashDetails?.readableMap)
|
|
41
|
+
result.putMap("externalDetails", this.externalDetails?.readableMap)
|
|
42
|
+
|
|
43
|
+
when (this) {
|
|
44
|
+
is Payment.OfflinePayment -> {
|
|
45
|
+
result.putString("id", this.id)
|
|
46
|
+
result.putString("processingType", "OFFLINE")
|
|
47
|
+
result.putString("uploadedAt", DateFormatUtils.formatISO8601UTC(this.uploadedAt))
|
|
48
|
+
result.putString("localId", this.localId)
|
|
49
|
+
result.putString("offlineStatus", this.status.jsonValue)
|
|
50
|
+
result.putMap("cardDetails", this.cardDetails?.readableMap)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
is Payment.OnlinePayment -> {
|
|
54
|
+
result.putString("id", this.id)
|
|
55
|
+
result.putString("processingType", "ONLINE")
|
|
56
|
+
result.putArray("processingFee", this.processingFee.readableArray)
|
|
57
|
+
result.putString(
|
|
58
|
+
"status", when (this.status) {
|
|
59
|
+
Payment.Status.APPROVED -> "APPROVED"
|
|
60
|
+
Payment.Status.COMPLETED -> "COMPLETED"
|
|
61
|
+
Payment.Status.CANCELED -> "CANCELED"
|
|
62
|
+
Payment.Status.FAILED -> "FAILED"
|
|
63
|
+
Payment.Status.UNKNOWN -> "UNKNOWN"
|
|
64
|
+
}
|
|
65
|
+
)
|
|
66
|
+
result.putMap("cardDetails", this.cardDetails?.readableMap)
|
|
67
|
+
result.putString("customerID", this.customerId)
|
|
68
|
+
result.putString("note", this.note)
|
|
69
|
+
result.putString("statementDescription", this.statementDescription)
|
|
70
|
+
result.putString("teamMemberId", this.teamMemberId)
|
|
71
|
+
val capabilitiesArray = WritableNativeArray()
|
|
72
|
+
if (this.capabilities.allCapabilities.contains(Payment.Capabilities.EDIT_TIP_AMOUNT_UP)) {
|
|
73
|
+
capabilitiesArray.pushString("EDIT_TIP_AMOUNT_UP")
|
|
74
|
+
}
|
|
75
|
+
if (this.capabilities.allCapabilities.contains(Payment.Capabilities.EDIT_TIP_AMOUNT_DOWN)) {
|
|
76
|
+
capabilitiesArray.pushString("EDIT_TIP_AMOUNT_DOWN")
|
|
77
|
+
}
|
|
78
|
+
if (this.capabilities.allCapabilities.contains(Payment.Capabilities.EDIT_AMOUNT_UP)) {
|
|
79
|
+
capabilitiesArray.pushString("EDIT_AMOUNT_UP")
|
|
80
|
+
}
|
|
81
|
+
if (this.capabilities.allCapabilities.contains(Payment.Capabilities.EDIT_AMOUNT_DOWN)) {
|
|
82
|
+
capabilitiesArray.pushString("EDIT_AMOUNT_DOWN")
|
|
83
|
+
}
|
|
84
|
+
result.putArray("capabilities", capabilitiesArray)
|
|
85
|
+
result.putString("receiptNumber", this.receiptNumber)
|
|
86
|
+
result.putMap("remainingBalance", this.remainingBalance?.readableMap)
|
|
87
|
+
result.putMap("squareAccountDetails", this.squareAccountDetails?.readableMap)
|
|
88
|
+
result.putMap("digitalWalletDetails", this.digitalWalletDetails?.readableMap)
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return result
|
|
93
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
package com.connexup.square.mobilepayment.convert
|
|
2
|
+
|
|
3
|
+
import com.connexup.square.mobilepayment.DateFormatUtils
|
|
4
|
+
import com.facebook.react.bridge.ReadableArray
|
|
5
|
+
import com.facebook.react.bridge.ReadableMap
|
|
6
|
+
import com.facebook.react.bridge.WritableNativeArray
|
|
7
|
+
import com.facebook.react.bridge.WritableNativeMap
|
|
8
|
+
import com.squareup.sdk.mobilepayments.payment.PaymentProcessingFee
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Description:
|
|
12
|
+
* @author lukechen@chancetop.com
|
|
13
|
+
* @date 2023/11/20
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
val List<PaymentProcessingFee>.readableArray: ReadableArray
|
|
17
|
+
get() {
|
|
18
|
+
val result = WritableNativeArray()
|
|
19
|
+
this.forEach {
|
|
20
|
+
result.pushMap(
|
|
21
|
+
it.readableMap
|
|
22
|
+
)
|
|
23
|
+
}
|
|
24
|
+
return result
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
val PaymentProcessingFee.readableMap: ReadableMap
|
|
28
|
+
get() {
|
|
29
|
+
val result = WritableNativeMap()
|
|
30
|
+
result.putString("effectiveAt", DateFormatUtils.formatISO8601UTC(this.effectiveAt))
|
|
31
|
+
result.putString(
|
|
32
|
+
"type", when (this.type) {
|
|
33
|
+
PaymentProcessingFee.Type.INITIAL -> "INITIAL"
|
|
34
|
+
PaymentProcessingFee.Type.ADJUSTMENT -> "ADJUSTMENT"
|
|
35
|
+
}
|
|
36
|
+
)
|
|
37
|
+
result.putMap("amountMoney", this.amountMoney.readableMap)
|
|
38
|
+
return result
|
|
39
|
+
}
|
package/android/src/main/java/com/connexup/square/mobilepayment/convert/PaymentSettingsConvert.kt
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
package com.connexup.square.mobilepayment.convert
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReadableMap
|
|
4
|
+
import com.facebook.react.bridge.WritableMap
|
|
5
|
+
import com.facebook.react.bridge.WritableNativeMap
|
|
6
|
+
import com.squareup.sdk.mobilepayments.payment.PaymentSettings
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Description:
|
|
10
|
+
* @author lukechen@chancetop.com
|
|
11
|
+
* @date 2024/6/18
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
val PaymentSettings.readableMap: ReadableMap
|
|
15
|
+
get() {
|
|
16
|
+
return this.writableMap
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
val PaymentSettings.writableMap: WritableMap
|
|
20
|
+
get() {
|
|
21
|
+
val result = WritableNativeMap()
|
|
22
|
+
result.putBoolean("isOfflineProcessingAllowed", this.isOfflineProcessingAllowed)
|
|
23
|
+
result.putMap("offlineTransactionAmountLimit", this.offlineTransactionAmountLimit?.readableMap)
|
|
24
|
+
result.putMap("offlineTotalStoredAmountLimit", this.offlineTotalStoredAmountLimit?.readableMap)
|
|
25
|
+
return result
|
|
26
|
+
}
|
package/android/src/main/java/com/connexup/square/mobilepayment/convert/ProcessingModeConvert.kt
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
package com.connexup.square.mobilepayment.convert
|
|
2
|
+
|
|
3
|
+
import com.squareup.sdk.mobilepayments.payment.ProcessingMode
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Description:
|
|
8
|
+
* @author lukechen@chancetop.com
|
|
9
|
+
* @date 2023/11/20
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
val ProcessingMode.jsonValue: String
|
|
13
|
+
get() {
|
|
14
|
+
return when (this) {
|
|
15
|
+
ProcessingMode.ONLINE_ONLY -> "ONLINE_ONLY"
|
|
16
|
+
ProcessingMode.OFFLINE_ONLY -> "OFFLINE_ONLY"
|
|
17
|
+
ProcessingMode.AUTO_DETECT -> "AUTO_DETECT"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
fun String.toProcessingMode(): ProcessingMode? {
|
|
22
|
+
return when (this) {
|
|
23
|
+
"ONLINE_ONLY" -> ProcessingMode.ONLINE_ONLY
|
|
24
|
+
"OFFLINE_ONLY" -> ProcessingMode.OFFLINE_ONLY
|
|
25
|
+
"AUTO_DETECT" -> ProcessingMode.AUTO_DETECT
|
|
26
|
+
else -> null
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
package com.connexup.square.mobilepayment.convert
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReadableMap
|
|
4
|
+
import com.facebook.react.bridge.WritableNativeMap
|
|
5
|
+
import com.squareup.sdk.mobilepayments.cardreader.ReaderInfo
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Description:
|
|
9
|
+
* @author lukechen@chancetop.com
|
|
10
|
+
* @date 2023/11/17
|
|
11
|
+
*/
|
|
12
|
+
val ReaderInfo.BatteryStatus.readableMap: ReadableMap
|
|
13
|
+
get() {
|
|
14
|
+
val result = WritableNativeMap()
|
|
15
|
+
result.putInt("percentage", this.percent)
|
|
16
|
+
result.putBoolean("isCharging", this.isCharging)
|
|
17
|
+
//TODO level
|
|
18
|
+
return result
|
|
19
|
+
}
|
package/android/src/main/java/com/connexup/square/mobilepayment/convert/ReaderChangeEventConvert.kt
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
package com.connexup.square.mobilepayment.convert
|
|
2
|
+
|
|
3
|
+
import com.squareup.sdk.mobilepayments.cardreader.ReaderChangedEvent
|
|
4
|
+
import com.squareup.sdk.mobilepayments.cardreader.ReaderInfo
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
fun ReaderChangedEvent.getReaderChangeJsonValue(lastReaderState: ReaderInfo.State?): String? {
|
|
8
|
+
when (this.change) {
|
|
9
|
+
ReaderChangedEvent.Change.ADDED -> {
|
|
10
|
+
return null
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
ReaderChangedEvent.Change.CHANGED_STATE -> {
|
|
14
|
+
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
ReaderChangedEvent.Change.BATTERY_THRESHOLD -> {
|
|
18
|
+
return "BATTERY_LEVEL_DID_CHANGE"
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
ReaderChangedEvent.Change.BATTERY_CHARGING -> {
|
|
22
|
+
if (this.reader.batteryStatus?.isCharging == true) {
|
|
23
|
+
return "BATTERY_DID_BEGIN_CHARGING"
|
|
24
|
+
} else if (this.reader.batteryStatus?.isCharging == false) {
|
|
25
|
+
return "BATTERY_DID_END_CHARGING"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
ReaderChangedEvent.Change.FIRMWARE_PROGRESS -> {
|
|
30
|
+
return "FIRMWARE_UPDATE_PERCENT_DID_CHANGE"
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
ReaderChangedEvent.Change.REMOVED -> {
|
|
34
|
+
return null
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
//TODO improve this
|
|
39
|
+
if (lastReaderState != this.reader.state) {
|
|
40
|
+
when (this.reader.state) {
|
|
41
|
+
ReaderInfo.State.Connecting -> {
|
|
42
|
+
return "CONNECTION_STATE_DID_CHANGE"
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
ReaderInfo.State.Disabled -> {
|
|
46
|
+
return "CONNECTION_STATE_DID_CHANGE"
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
is ReaderInfo.State.Disconnected -> {
|
|
50
|
+
return "CONNECTION_STATE_DID_CHANGE"
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
is ReaderInfo.State.FailedToConnect -> {
|
|
54
|
+
return "CONNECTION_DID_FAIL"
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
ReaderInfo.State.Ready -> {
|
|
58
|
+
if (lastReaderState == ReaderInfo.State.Connecting
|
|
59
|
+
|| lastReaderState == ReaderInfo.State.Disabled
|
|
60
|
+
|| lastReaderState is ReaderInfo.State.Disconnected
|
|
61
|
+
|| lastReaderState is ReaderInfo.State.FailedToConnect
|
|
62
|
+
) {
|
|
63
|
+
return "CONNECTION_STATE_DID_CHANGE"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
ReaderInfo.State.UpdatingFirmware -> {
|
|
68
|
+
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
//TODO CARD_INSERTED CARD_REMOVED FIRMWARE_UPDATE_DID_FAIL
|
|
74
|
+
return "STATE_DID_CHANGE"
|
|
75
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
package com.connexup.square.mobilepayment.convert
|
|
2
|
+
|
|
3
|
+
import com.squareup.sdk.mobilepayments.cardreader.ReaderInfo.ConnectionType
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Description:
|
|
7
|
+
* @author lukechen@chancetop.com
|
|
8
|
+
* @date 2025/10/14
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
val ConnectionType.jsonValue: String
|
|
12
|
+
get() = when (this) {
|
|
13
|
+
ConnectionType.USB -> "USB"
|
|
14
|
+
ConnectionType.BLUETOOTH -> "BLUETOOTH"
|
|
15
|
+
ConnectionType.AUDIO -> "AUDIO"
|
|
16
|
+
ConnectionType.EMBEDDED -> "EMBEDDED"
|
|
17
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
package com.connexup.square.mobilepayment.convert
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReadableMap
|
|
4
|
+
import com.facebook.react.bridge.WritableNativeMap
|
|
5
|
+
import com.squareup.sdk.mobilepayments.cardreader.ReaderInfo
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Description:
|
|
9
|
+
* @author lukechen@chancetop.com
|
|
10
|
+
* @date 2023/11/17
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
val ReaderInfo.readableMap: ReadableMap
|
|
14
|
+
get() {
|
|
15
|
+
val result = WritableNativeMap()
|
|
16
|
+
result.putString("id", this.id)
|
|
17
|
+
result.putString("name", this.name)
|
|
18
|
+
result.putString("serialNumber", this.serialNumber)
|
|
19
|
+
result.putString("model", this.model.jsonValue)
|
|
20
|
+
result.putArray("supportedInputMethods", this.supportedCardEntryMethods.readableArray)
|
|
21
|
+
result.putMap("connectionInfo", this.state.connectInfoReadableMap)
|
|
22
|
+
result.putMap("firmwareInfo", this.firmwareInfoReadableMap)
|
|
23
|
+
result.putString("state", this.state.jsonValue)
|
|
24
|
+
result.putMap("status", this.status.jsonReadableMap)
|
|
25
|
+
result.putString("connectionType", this.connectionType.jsonValue)
|
|
26
|
+
result.putMap("batteryStatus", this.batteryStatus?.readableMap)
|
|
27
|
+
result.putBoolean("isBlinkable", this.isBlinkable)
|
|
28
|
+
result.putBoolean("isForgettable", this.isForgettable)
|
|
29
|
+
// result.putBoolean("isConnectionRetryable", this.canRetryConnection)
|
|
30
|
+
// result.putString("cardInsertionStatus",this.cardInsertionStatus)
|
|
31
|
+
//TODO canRetryConnection cardInsertionStatus
|
|
32
|
+
return result
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
val ReaderInfo.firmwareInfoReadableMap: ReadableMap
|
|
36
|
+
get() {
|
|
37
|
+
val result = WritableNativeMap()
|
|
38
|
+
result.putString("version", this.firmwareVersion)
|
|
39
|
+
if (this.firmwarePercent != null) {
|
|
40
|
+
result.putInt("updatePercentage", this.firmwarePercent ?: 0)
|
|
41
|
+
}
|
|
42
|
+
return result
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
fun ReaderInfo.mergeStateReadableMap(state: ReaderInfo.State): ReadableMap {
|
|
46
|
+
val result = WritableNativeMap()
|
|
47
|
+
result.merge(this.readableMap)
|
|
48
|
+
result.putMap("connectionInfo", state.connectInfoReadableMap)
|
|
49
|
+
result.putString("state", state.jsonValue)
|
|
50
|
+
return result
|
|
51
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
package com.connexup.square.mobilepayment.convert
|
|
2
|
+
|
|
3
|
+
import com.squareup.sdk.mobilepayments.cardreader.ReaderInfo
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Description:
|
|
8
|
+
* @author lukechen@chancetop.com
|
|
9
|
+
* @date 2023/11/17
|
|
10
|
+
*/
|
|
11
|
+
val ReaderInfo.Model.jsonValue: String
|
|
12
|
+
get() {
|
|
13
|
+
return when (this) {
|
|
14
|
+
ReaderInfo.Model.MAGSTRIPE -> "MAGSTRIPE"
|
|
15
|
+
ReaderInfo.Model.CONTACTLESS_AND_CHIP -> "CONTACTLESS_AND_CHIP"
|
|
16
|
+
ReaderInfo.Model.TAP_TO_PAY -> "TAP_TO_PAY"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
package com.connexup.square.mobilepayment.convert
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReadableMap
|
|
4
|
+
import com.facebook.react.bridge.WritableNativeMap
|
|
5
|
+
import com.squareup.sdk.mobilepayments.cardreader.ReaderInfo
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Description:
|
|
9
|
+
* @author lukechen@chancetop.com
|
|
10
|
+
* @date 2023/11/17
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
val ReaderInfo.State.jsonValue: String
|
|
14
|
+
get() = when (this) {
|
|
15
|
+
ReaderInfo.State.Connecting -> "CONNECTING"
|
|
16
|
+
ReaderInfo.State.Disabled -> "DISABLED"
|
|
17
|
+
is ReaderInfo.State.Disconnected -> "DISCONNECTED"
|
|
18
|
+
is ReaderInfo.State.FailedToConnect -> "FAILED_TO_CONNECT"
|
|
19
|
+
ReaderInfo.State.Ready -> "READY"
|
|
20
|
+
ReaderInfo.State.UpdatingFirmware -> "UPDATING_FIRMWARE"
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
val ReaderInfo.State.connectInfoReadableMap: ReadableMap
|
|
24
|
+
get() {
|
|
25
|
+
val result = WritableNativeMap()
|
|
26
|
+
|
|
27
|
+
//TODO check this logic
|
|
28
|
+
val connectState = when (this) {
|
|
29
|
+
ReaderInfo.State.Connecting -> "CONNECTING"
|
|
30
|
+
ReaderInfo.State.Disabled -> "FAILED_TO_CONNECT"
|
|
31
|
+
is ReaderInfo.State.Disconnected -> "NOT_CONNECTED"
|
|
32
|
+
is ReaderInfo.State.FailedToConnect -> "FAILED_TO_CONNECT"
|
|
33
|
+
ReaderInfo.State.Ready -> "CONNECTED"
|
|
34
|
+
ReaderInfo.State.UpdatingFirmware -> "CONNECTED"
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
var failureInfo: ReadableMap? = null
|
|
38
|
+
|
|
39
|
+
if (this is ReaderInfo.State.FailedToConnect) {
|
|
40
|
+
failureInfo = this.reason?.readableMap
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
//TODO handle disconnected error
|
|
44
|
+
|
|
45
|
+
result.putString("state", connectState)
|
|
46
|
+
if (failureInfo != null) {
|
|
47
|
+
result.putMap("failureInfo", failureInfo)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return result
|
|
51
|
+
}
|
package/android/src/main/java/com/connexup/square/mobilepayment/convert/ReaderStatusConvert.kt
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
package com.connexup.square.mobilepayment.convert
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReadableMap
|
|
4
|
+
import com.facebook.react.bridge.WritableNativeMap
|
|
5
|
+
import com.squareup.sdk.mobilepayments.cardreader.ReaderInfo
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Description:
|
|
9
|
+
* @author lukechen@chancetop.com
|
|
10
|
+
* @date 2025/10/14
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
val ReaderInfo.Status.jsonReadableMap: ReadableMap
|
|
14
|
+
get() {
|
|
15
|
+
val result = WritableNativeMap()
|
|
16
|
+
val status = when (this) {
|
|
17
|
+
ReaderInfo.Status.ConnectingToDevice -> "CONNECTING_TO_DEVICE"
|
|
18
|
+
ReaderInfo.Status.ConnectingToSquare -> "CONNECTING_TO_SQUARE"
|
|
19
|
+
ReaderInfo.Status.Faulty -> "FAULTY"
|
|
20
|
+
is ReaderInfo.Status.ReaderUnavailable -> "READER_UNAVAILABLE"
|
|
21
|
+
ReaderInfo.Status.Ready -> "READY"
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
result.putString("status", status)
|
|
25
|
+
if (this is ReaderInfo.Status.ReaderUnavailable) {
|
|
26
|
+
val reason = when (this.reason) {
|
|
27
|
+
ReaderInfo.Status.ReaderUnavailable.ReaderUnavailableReason.INTERNAL_ERROR -> "INTERNAL_ERROR"
|
|
28
|
+
ReaderInfo.Status.ReaderUnavailable.ReaderUnavailableReason.BLUETOOTH_DISABLED -> "BLUETOOTH_DISABLED"
|
|
29
|
+
ReaderInfo.Status.ReaderUnavailable.ReaderUnavailableReason.BLUETOOTH_FAILURE -> "BLUETOOTH_FAILURE"
|
|
30
|
+
ReaderInfo.Status.ReaderUnavailable.ReaderUnavailableReason.SECURE_CONNECTION_TO_SQUARE_FAILURE -> "SECURE_CONNECTION_TO_SQUARE_FAILURE"
|
|
31
|
+
ReaderInfo.Status.ReaderUnavailable.ReaderUnavailableReason.SECURE_CONNECTION_NETWORK_FAILURE -> "SECURE_CONNECTION_NETWORK_FAILURE"
|
|
32
|
+
ReaderInfo.Status.ReaderUnavailable.ReaderUnavailableReason.OFFLINE_SESSION_EXPIRED -> "OFFLINE_SESSION_EXPIRED"
|
|
33
|
+
ReaderInfo.Status.ReaderUnavailable.ReaderUnavailableReason.READER_UNAVAILABLE_OFFLINE -> "READER_UNAVAILABLE_OFFLINE"
|
|
34
|
+
ReaderInfo.Status.ReaderUnavailable.ReaderUnavailableReason.OFFLINE_MODE_DISABLED -> "OFFLINE_MODE_DISABLED"
|
|
35
|
+
ReaderInfo.Status.ReaderUnavailable.ReaderUnavailableReason.READER_UPDATE_FAILED -> "READER_UPDATE_FAILED"
|
|
36
|
+
ReaderInfo.Status.ReaderUnavailable.ReaderUnavailableReason.BLOCKING_UPDATE -> "BLOCKING_UPDATE"
|
|
37
|
+
ReaderInfo.Status.ReaderUnavailable.ReaderUnavailableReason.MERCHANT_SUSPENDED -> "MERCHANT_SUSPENDED"
|
|
38
|
+
ReaderInfo.Status.ReaderUnavailable.ReaderUnavailableReason.MERCHANT_INELIGIBLE -> "MERCHANT_INELIGIBLE"
|
|
39
|
+
ReaderInfo.Status.ReaderUnavailable.ReaderUnavailableReason.MERCHANT_NOT_ACTIVATED -> "MERCHANT_NOT_ACTIVATED"
|
|
40
|
+
ReaderInfo.Status.ReaderUnavailable.ReaderUnavailableReason.DEVICE_NOT_SUPPORTED -> "DEVICE_NOT_SUPPORTED"
|
|
41
|
+
ReaderInfo.Status.ReaderUnavailable.ReaderUnavailableReason.READER_FIRMWARE_UPDATE_REQUIRED -> "READER_FIRMWARE_UPDATE_REQUIRED"
|
|
42
|
+
ReaderInfo.Status.ReaderUnavailable.ReaderUnavailableReason.READER_NOT_SUPPORTED -> "READER_NOT_SUPPORTED"
|
|
43
|
+
ReaderInfo.Status.ReaderUnavailable.ReaderUnavailableReason.DEVICE_ROOTED -> "DEVICE_ROOTED"
|
|
44
|
+
ReaderInfo.Status.ReaderUnavailable.ReaderUnavailableReason.DEVICE_DEVELOPER_MODE -> "DEVICE_DEVELOPER_MODE"
|
|
45
|
+
ReaderInfo.Status.ReaderUnavailable.ReaderUnavailableReason.DISABLED -> "DISABLED"
|
|
46
|
+
}
|
|
47
|
+
result.putString("unavailableReason", reason)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return result
|
|
51
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
package com.connexup.square.mobilepayment.convert
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReadableMap
|
|
4
|
+
import com.facebook.react.bridge.WritableMap
|
|
5
|
+
import com.facebook.react.bridge.WritableNativeMap
|
|
6
|
+
import com.squareup.sdk.mobilepayments.settings.Environment
|
|
7
|
+
import com.squareup.sdk.mobilepayments.settings.SdkSettings
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Description:
|
|
11
|
+
* @author lukechen@chancetop.com
|
|
12
|
+
* @date 2024/6/18
|
|
13
|
+
*/
|
|
14
|
+
val SdkSettings.readableMap: ReadableMap
|
|
15
|
+
get() {
|
|
16
|
+
return this.writableMap
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
val SdkSettings.writableMap: WritableMap
|
|
20
|
+
get() {
|
|
21
|
+
val result = WritableNativeMap()
|
|
22
|
+
result.putString(
|
|
23
|
+
"environment", when (this.sdkEnvironment) {
|
|
24
|
+
Environment.PRODUCTION -> "PRODUCTION"
|
|
25
|
+
Environment.SANDBOX -> "SANDBOX"
|
|
26
|
+
}
|
|
27
|
+
)
|
|
28
|
+
result.putString("version", this.sdkVersion)
|
|
29
|
+
return result
|
|
30
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
package com.connexup.square.mobilepayment.convert
|
|
2
|
+
|
|
3
|
+
import com.connexup.square.mobilepayment.convert.readableArray
|
|
4
|
+
import com.facebook.react.bridge.ReadableMap
|
|
5
|
+
import com.facebook.react.bridge.WritableNativeMap
|
|
6
|
+
import com.squareup.sdk.mobilepayments.payment.SquareAccountDetails
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Description:
|
|
10
|
+
* @author lukechen@chancetop.com
|
|
11
|
+
* @date 2024/4/17
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
val SquareAccountDetails.readableMap: ReadableMap
|
|
15
|
+
get() {
|
|
16
|
+
val result = WritableNativeMap()
|
|
17
|
+
result.putString("paymentSourceToken", this.paymentSourceToken)
|
|
18
|
+
result.putArray("errors", this.errors?.readableArray)
|
|
19
|
+
return result
|
|
20
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
package com.connexup.square.mobilepayment.convert
|
|
2
|
+
|
|
3
|
+
import com.squareup.sdk.mobilepayments.settings.TrackingConsentState
|
|
4
|
+
import com.squareup.sdk.mobilepayments.settings.TrackingConsentState.*
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Description:
|
|
8
|
+
* @author lukechen@chancetop.com
|
|
9
|
+
* @date 2025/10/14
|
|
10
|
+
*/
|
|
11
|
+
val TrackingConsentState.jsonValue: String
|
|
12
|
+
get() = when (this) {
|
|
13
|
+
PENDING -> "PENDING"
|
|
14
|
+
GRANTED -> "GRANTED"
|
|
15
|
+
DENIED -> "DENIED"
|
|
16
|
+
NOT_REQUIRED -> "NOT_REQUIRED"
|
|
17
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
package com.connexup.square.mobilepayment.convert
|
|
2
|
+
|
|
3
|
+
import com.squareup.sdk.mobilepayments.payment.DigitalWalletDetails.WalletBrand
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Description:
|
|
8
|
+
* @author lukechen@chancetop.com
|
|
9
|
+
* @date 2024/4/17
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
val WalletBrand.jsonValue: String
|
|
14
|
+
get() {
|
|
15
|
+
return when (this) {
|
|
16
|
+
WalletBrand.CASH_APP -> "CashApp"
|
|
17
|
+
WalletBrand.PAYPAY -> "PayPay"
|
|
18
|
+
WalletBrand.ALIPAY -> "Alipay"
|
|
19
|
+
WalletBrand.AU_PAY -> "AuPay"
|
|
20
|
+
WalletBrand.D_BARAI -> "DBarai"
|
|
21
|
+
WalletBrand.MERPAY -> "MerPay"
|
|
22
|
+
WalletBrand.RAKUTEN_PAY -> "RakutenPay"
|
|
23
|
+
WalletBrand.WECHAT_PAY -> "WechatPay"
|
|
24
|
+
WalletBrand.UNKNOWN -> "Unknown"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
fun String.toWalletBrand(): WalletBrand? {
|
|
29
|
+
return when (this) {
|
|
30
|
+
"CashApp" -> WalletBrand.CASH_APP
|
|
31
|
+
"PayPay" -> WalletBrand.PAYPAY
|
|
32
|
+
"Alipay" -> WalletBrand.ALIPAY
|
|
33
|
+
"AuPay" -> WalletBrand.AU_PAY
|
|
34
|
+
"DBarai" -> WalletBrand.D_BARAI
|
|
35
|
+
"MerPay" -> WalletBrand.MERPAY
|
|
36
|
+
"RakutenPay" -> WalletBrand.RAKUTEN_PAY
|
|
37
|
+
"WechatPay" -> WalletBrand.WECHAT_PAY
|
|
38
|
+
"Unknown" -> WalletBrand.UNKNOWN
|
|
39
|
+
else -> null
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//
|
|
2
|
+
// AlternatePaymentMethod+Extension.swift
|
|
3
|
+
//
|
|
4
|
+
// Created by chancetio on 2023/9/13.
|
|
5
|
+
//
|
|
6
|
+
|
|
7
|
+
import Foundation
|
|
8
|
+
import SquareMobilePaymentsSDK
|
|
9
|
+
|
|
10
|
+
extension AdditionalPaymentMethod {
|
|
11
|
+
var jsonDictionary: [String: Any] {
|
|
12
|
+
var result: [String: Any] = [:]
|
|
13
|
+
result["type"] = self.type.jsonValue
|
|
14
|
+
result["name"] = self.name
|
|
15
|
+
return result
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
//
|
|
2
|
+
// AlternatePaymentMethodType+Extension.swift
|
|
3
|
+
//
|
|
4
|
+
// Created by chancetio on 2023/9/13.
|
|
5
|
+
//
|
|
6
|
+
|
|
7
|
+
import Foundation
|
|
8
|
+
import SquareMobilePaymentsSDK
|
|
9
|
+
|
|
10
|
+
extension AdditionalPaymentMethodType {
|
|
11
|
+
var jsonValue: String {
|
|
12
|
+
switch self {
|
|
13
|
+
case .keyed:
|
|
14
|
+
return "KEYED"
|
|
15
|
+
case .cardOnFile:
|
|
16
|
+
return "CARD_ON_FILE"
|
|
17
|
+
case .houseAccount:
|
|
18
|
+
return "HOUSE_ACCOUNT"
|
|
19
|
+
case .tapToPay:
|
|
20
|
+
return "TAP_TO_PAY"
|
|
21
|
+
case .cash:
|
|
22
|
+
return "CASH"
|
|
23
|
+
@unknown default:
|
|
24
|
+
return "UNKNOWN"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
static func make(from jsonValue: String) -> AdditionalPaymentMethodType? {
|
|
29
|
+
switch jsonValue {
|
|
30
|
+
case "KEYED":
|
|
31
|
+
return AdditionalPaymentMethodType.keyed
|
|
32
|
+
case "CARD_ON_FILE":
|
|
33
|
+
return AdditionalPaymentMethodType.cardOnFile
|
|
34
|
+
case "HOUSE_ACCOUNT":
|
|
35
|
+
return AdditionalPaymentMethodType.houseAccount
|
|
36
|
+
case "TAP_TO_PAY":
|
|
37
|
+
return AdditionalPaymentMethodType.tapToPay
|
|
38
|
+
case "CASH":
|
|
39
|
+
return AdditionalPaymentMethodType.cash
|
|
40
|
+
default:
|
|
41
|
+
return nil
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|