@capawesome/capacitor-square-mobile-payments 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CapawesomeCapacitorSquareMobilePayments.podspec +17 -0
- package/Package.swift +30 -0
- package/README.md +1183 -0
- package/android/build.gradle +63 -0
- package/android/src/main/AndroidManifest.xml +7 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/SquareMobilePayments.java +774 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/SquareMobilePaymentsPlugin.java +460 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/CustomException.java +20 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/CustomExceptions.java +41 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/events/AvailableCardInputMethodsDidChangeEvent.java +27 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/events/PaymentDidCancelEvent.java +24 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/events/PaymentDidFailEvent.java +34 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/events/PaymentDidFinishEvent.java +22 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/events/ReaderDidChangeEvent.java +27 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/events/ReaderPairingDidFailEvent.java +28 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/events/ReaderWasAddedEvent.java +22 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/events/ReaderWasRemovedEvent.java +22 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/options/AuthorizeOptions.java +29 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/options/ForgetReaderOptions.java +29 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/options/InitializeOptions.java +29 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/options/Money.java +29 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/options/PaymentParameters.java +126 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/options/PromptParameters.java +47 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/options/RetryConnectionOptions.java +29 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/options/StartPaymentOptions.java +39 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/results/Card.java +51 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/results/CardPaymentDetails.java +30 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/results/GetAvailableCardInputMethodsResult.java +29 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/results/GetReadersResult.java +29 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/results/GetSettingsResult.java +28 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/results/IsAuthorizedResult.java +22 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/results/IsPairingInProgressResult.java +22 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/results/MoneyResult.java +27 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/results/Payment.java +87 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/results/ReaderInfo.java +82 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/classes/results/UnavailableReasonInfo.java +30 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/interfaces/Callback.java +5 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/interfaces/EmptyCallback.java +5 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/interfaces/NonEmptyCallback.java +7 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/interfaces/NonEmptyResultCallback.java +7 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/squaremobilepayments/interfaces/Result.java +7 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/docs.json +2999 -0
- package/dist/esm/definitions.d.ts +1468 -0
- package/dist/esm/definitions.js +519 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/web.d.ts +21 -0
- package/dist/esm/web.js +55 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +588 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +591 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Plugin/Classes/Options/AuthorizeOptions.swift +17 -0
- package/ios/Plugin/Classes/Options/ForgetReaderOptions.swift +17 -0
- package/ios/Plugin/Classes/Options/InitializeOptions.swift +17 -0
- package/ios/Plugin/Classes/Options/Money.swift +12 -0
- package/ios/Plugin/Classes/Options/PaymentParameters.swift +49 -0
- package/ios/Plugin/Classes/Options/PromptParameters.swift +17 -0
- package/ios/Plugin/Classes/Options/RetryConnectionOptions.swift +17 -0
- package/ios/Plugin/Classes/Options/StartPaymentOptions.swift +19 -0
- package/ios/Plugin/Classes/Results/Card.swift +34 -0
- package/ios/Plugin/Classes/Results/CardPaymentDetails.swift +34 -0
- package/ios/Plugin/Classes/Results/GetAvailableCardInputMethodsResult.swift +16 -0
- package/ios/Plugin/Classes/Results/GetReadersResult.swift +16 -0
- package/ios/Plugin/Classes/Results/GetSettingsResult.swift +19 -0
- package/ios/Plugin/Classes/Results/IsAuthorizedResult.swift +16 -0
- package/ios/Plugin/Classes/Results/IsPairingInProgressResult.swift +16 -0
- package/ios/Plugin/Classes/Results/MoneyResult.swift +19 -0
- package/ios/Plugin/Classes/Results/Payment.swift +58 -0
- package/ios/Plugin/Classes/Results/ReaderInfo.swift +46 -0
- package/ios/Plugin/Classes/Results/UnavailableReasonInfo.swift +19 -0
- package/ios/Plugin/Enums/CustomError.swift +81 -0
- package/ios/Plugin/Info.plist +24 -0
- package/ios/Plugin/Protocols/Result.swift +6 -0
- package/ios/Plugin/SquareMobilePayments.swift +632 -0
- package/ios/Plugin/SquareMobilePaymentsHelper.swift +212 -0
- package/ios/Plugin/SquareMobilePaymentsPlugin.swift +347 -0
- package/package.json +93 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Capacitor
|
|
3
|
+
|
|
4
|
+
@objc public class Money: NSObject {
|
|
5
|
+
let amount: Int
|
|
6
|
+
let currency: String
|
|
7
|
+
|
|
8
|
+
init(_ obj: JSObject) throws {
|
|
9
|
+
self.amount = obj["amount"] as? Int ?? 0
|
|
10
|
+
self.currency = obj["currency"] as? String ?? "USD"
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Capacitor
|
|
3
|
+
|
|
4
|
+
@objc public class PaymentParameters: NSObject {
|
|
5
|
+
let amountMoney: Money
|
|
6
|
+
let paymentAttemptId: String
|
|
7
|
+
let processingMode: String?
|
|
8
|
+
let referenceId: String?
|
|
9
|
+
let note: String?
|
|
10
|
+
let orderId: String?
|
|
11
|
+
let tipMoney: Money?
|
|
12
|
+
let applicationFee: Money?
|
|
13
|
+
let autocomplete: Bool?
|
|
14
|
+
let delayDuration: String?
|
|
15
|
+
let delayAction: String?
|
|
16
|
+
|
|
17
|
+
init(_ obj: JSObject) throws {
|
|
18
|
+
guard let amountMoneyObj = obj["amountMoney"] as? JSObject else {
|
|
19
|
+
throw CustomError.amountMoneyMissing
|
|
20
|
+
}
|
|
21
|
+
self.amountMoney = try Money(amountMoneyObj)
|
|
22
|
+
|
|
23
|
+
guard let paymentAttemptId = obj["paymentAttemptId"] as? String else {
|
|
24
|
+
throw CustomError.paymentAttemptIdMissing
|
|
25
|
+
}
|
|
26
|
+
self.paymentAttemptId = paymentAttemptId
|
|
27
|
+
|
|
28
|
+
self.processingMode = obj["processingMode"] as? String
|
|
29
|
+
self.referenceId = obj["referenceId"] as? String
|
|
30
|
+
self.note = obj["note"] as? String
|
|
31
|
+
self.orderId = obj["orderId"] as? String
|
|
32
|
+
|
|
33
|
+
if let tipMoneyObj = obj["tipMoney"] as? JSObject {
|
|
34
|
+
self.tipMoney = try Money(tipMoneyObj)
|
|
35
|
+
} else {
|
|
36
|
+
self.tipMoney = nil
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if let applicationFeeObj = obj["applicationFee"] as? JSObject {
|
|
40
|
+
self.applicationFee = try Money(applicationFeeObj)
|
|
41
|
+
} else {
|
|
42
|
+
self.applicationFee = nil
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
self.autocomplete = obj["autocomplete"] as? Bool
|
|
46
|
+
self.delayDuration = obj["delayDuration"] as? String
|
|
47
|
+
self.delayAction = obj["delayAction"] as? String
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Capacitor
|
|
3
|
+
|
|
4
|
+
@objc public class PromptParameters: NSObject {
|
|
5
|
+
let mode: String?
|
|
6
|
+
let additionalMethods: [String]
|
|
7
|
+
|
|
8
|
+
init(_ obj: JSObject) throws {
|
|
9
|
+
self.mode = obj["mode"] as? String
|
|
10
|
+
|
|
11
|
+
if let additionalMethodsArray = obj["additionalMethods"] as? [String] {
|
|
12
|
+
self.additionalMethods = additionalMethodsArray
|
|
13
|
+
} else {
|
|
14
|
+
self.additionalMethods = []
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Capacitor
|
|
3
|
+
|
|
4
|
+
@objc public class RetryConnectionOptions: NSObject {
|
|
5
|
+
let serialNumber: String
|
|
6
|
+
|
|
7
|
+
init(_ call: CAPPluginCall) throws {
|
|
8
|
+
self.serialNumber = try RetryConnectionOptions.getSerialNumberFromCall(call)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
private static func getSerialNumberFromCall(_ call: CAPPluginCall) throws -> String {
|
|
12
|
+
guard let serialNumber = call.getString("serialNumber") else {
|
|
13
|
+
throw CustomError.serialNumberMissing
|
|
14
|
+
}
|
|
15
|
+
return serialNumber
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Capacitor
|
|
3
|
+
|
|
4
|
+
@objc public class StartPaymentOptions: NSObject {
|
|
5
|
+
let paymentParameters: PaymentParameters
|
|
6
|
+
let promptParameters: PromptParameters
|
|
7
|
+
|
|
8
|
+
init(_ call: CAPPluginCall) throws {
|
|
9
|
+
guard let paymentParametersObj = call.getObject("paymentParameters") else {
|
|
10
|
+
throw CustomError.paymentParametersMissing
|
|
11
|
+
}
|
|
12
|
+
self.paymentParameters = try PaymentParameters(paymentParametersObj)
|
|
13
|
+
|
|
14
|
+
guard let promptParametersObj = call.getObject("promptParameters") else {
|
|
15
|
+
throw CustomError.promptParametersMissing
|
|
16
|
+
}
|
|
17
|
+
self.promptParameters = try PromptParameters(promptParametersObj)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Capacitor
|
|
3
|
+
|
|
4
|
+
@objc public class Card: NSObject, Result {
|
|
5
|
+
let brand: String
|
|
6
|
+
let lastFourDigits: String
|
|
7
|
+
let cardholderName: String?
|
|
8
|
+
let expirationMonth: Int?
|
|
9
|
+
let expirationYear: Int?
|
|
10
|
+
|
|
11
|
+
init(
|
|
12
|
+
brand: String,
|
|
13
|
+
lastFourDigits: String,
|
|
14
|
+
cardholderName: String?,
|
|
15
|
+
expirationMonth: Int?,
|
|
16
|
+
expirationYear: Int?
|
|
17
|
+
) {
|
|
18
|
+
self.brand = brand
|
|
19
|
+
self.lastFourDigits = lastFourDigits
|
|
20
|
+
self.cardholderName = cardholderName
|
|
21
|
+
self.expirationMonth = expirationMonth
|
|
22
|
+
self.expirationYear = expirationYear
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@objc public func toJSObject() -> AnyObject {
|
|
26
|
+
var result = JSObject()
|
|
27
|
+
result["brand"] = brand
|
|
28
|
+
result["lastFourDigits"] = lastFourDigits
|
|
29
|
+
result["cardholderName"] = cardholderName ?? NSNull()
|
|
30
|
+
result["expirationMonth"] = expirationMonth ?? NSNull()
|
|
31
|
+
result["expirationYear"] = expirationYear ?? NSNull()
|
|
32
|
+
return result as AnyObject
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Capacitor
|
|
3
|
+
|
|
4
|
+
@objc public class CardPaymentDetails: NSObject, Result {
|
|
5
|
+
let card: Card
|
|
6
|
+
let entryMethod: String
|
|
7
|
+
let authorizationCode: String?
|
|
8
|
+
let applicationName: String?
|
|
9
|
+
let applicationId: String?
|
|
10
|
+
|
|
11
|
+
init(
|
|
12
|
+
card: Card,
|
|
13
|
+
entryMethod: String,
|
|
14
|
+
authorizationCode: String?,
|
|
15
|
+
applicationName: String?,
|
|
16
|
+
applicationId: String?
|
|
17
|
+
) {
|
|
18
|
+
self.card = card
|
|
19
|
+
self.entryMethod = entryMethod
|
|
20
|
+
self.authorizationCode = authorizationCode
|
|
21
|
+
self.applicationName = applicationName
|
|
22
|
+
self.applicationId = applicationId
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@objc public func toJSObject() -> AnyObject {
|
|
26
|
+
var result = JSObject()
|
|
27
|
+
result["card"] = card.toJSObject() as? JSObject
|
|
28
|
+
result["entryMethod"] = entryMethod
|
|
29
|
+
result["authorizationCode"] = authorizationCode ?? NSNull()
|
|
30
|
+
result["applicationName"] = applicationName ?? NSNull()
|
|
31
|
+
result["applicationId"] = applicationId ?? NSNull()
|
|
32
|
+
return result as AnyObject
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Capacitor
|
|
3
|
+
|
|
4
|
+
@objc public class GetAvailableCardInputMethodsResult: NSObject, Result {
|
|
5
|
+
let cardInputMethods: [String]
|
|
6
|
+
|
|
7
|
+
init(cardInputMethods: [String]) {
|
|
8
|
+
self.cardInputMethods = cardInputMethods
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
@objc public func toJSObject() -> AnyObject {
|
|
12
|
+
var result = JSObject()
|
|
13
|
+
result["cardInputMethods"] = cardInputMethods
|
|
14
|
+
return result as AnyObject
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Capacitor
|
|
3
|
+
|
|
4
|
+
@objc public class GetReadersResult: NSObject, Result {
|
|
5
|
+
let readers: [ReaderInfo]
|
|
6
|
+
|
|
7
|
+
init(readers: [ReaderInfo]) {
|
|
8
|
+
self.readers = readers
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
@objc public func toJSObject() -> AnyObject {
|
|
12
|
+
var result = JSObject()
|
|
13
|
+
result["readers"] = readers.map { $0.toJSObject() }
|
|
14
|
+
return result as AnyObject
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Capacitor
|
|
3
|
+
|
|
4
|
+
@objc public class GetSettingsResult: NSObject, Result {
|
|
5
|
+
let version: String
|
|
6
|
+
let environment: String
|
|
7
|
+
|
|
8
|
+
init(version: String, environment: String) {
|
|
9
|
+
self.version = version
|
|
10
|
+
self.environment = environment
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@objc public func toJSObject() -> AnyObject {
|
|
14
|
+
var result = JSObject()
|
|
15
|
+
result["version"] = version
|
|
16
|
+
result["environment"] = environment
|
|
17
|
+
return result as AnyObject
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Capacitor
|
|
3
|
+
|
|
4
|
+
@objc public class IsAuthorizedResult: NSObject, Result {
|
|
5
|
+
let authorized: Bool
|
|
6
|
+
|
|
7
|
+
init(authorized: Bool) {
|
|
8
|
+
self.authorized = authorized
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
@objc public func toJSObject() -> AnyObject {
|
|
12
|
+
var result = JSObject()
|
|
13
|
+
result["authorized"] = authorized
|
|
14
|
+
return result as AnyObject
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Capacitor
|
|
3
|
+
|
|
4
|
+
@objc public class IsPairingInProgressResult: NSObject, Result {
|
|
5
|
+
let inProgress: Bool
|
|
6
|
+
|
|
7
|
+
init(inProgress: Bool) {
|
|
8
|
+
self.inProgress = inProgress
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
@objc public func toJSObject() -> AnyObject {
|
|
12
|
+
var result = JSObject()
|
|
13
|
+
result["inProgress"] = inProgress
|
|
14
|
+
return result as AnyObject
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Capacitor
|
|
3
|
+
|
|
4
|
+
@objc public class MoneyResult: NSObject, Result {
|
|
5
|
+
let amount: Int
|
|
6
|
+
let currency: String
|
|
7
|
+
|
|
8
|
+
init(amount: Int, currency: String) {
|
|
9
|
+
self.amount = amount
|
|
10
|
+
self.currency = currency
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@objc public func toJSObject() -> AnyObject {
|
|
14
|
+
var result = JSObject()
|
|
15
|
+
result["amount"] = amount
|
|
16
|
+
result["currency"] = currency
|
|
17
|
+
return result as AnyObject
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Capacitor
|
|
3
|
+
|
|
4
|
+
@objc public class Payment: NSObject, Result {
|
|
5
|
+
let id: String?
|
|
6
|
+
let type: String
|
|
7
|
+
let status: String
|
|
8
|
+
let amountMoney: MoneyResult
|
|
9
|
+
let tipMoney: MoneyResult?
|
|
10
|
+
let applicationFee: MoneyResult?
|
|
11
|
+
let referenceId: String?
|
|
12
|
+
let orderId: String?
|
|
13
|
+
let cardDetails: CardPaymentDetails?
|
|
14
|
+
let createdAt: String?
|
|
15
|
+
let updatedAt: String?
|
|
16
|
+
|
|
17
|
+
init(
|
|
18
|
+
id: String?,
|
|
19
|
+
type: String,
|
|
20
|
+
status: String,
|
|
21
|
+
amountMoney: MoneyResult,
|
|
22
|
+
tipMoney: MoneyResult?,
|
|
23
|
+
applicationFee: MoneyResult?,
|
|
24
|
+
referenceId: String?,
|
|
25
|
+
orderId: String?,
|
|
26
|
+
cardDetails: CardPaymentDetails?,
|
|
27
|
+
createdAt: String?,
|
|
28
|
+
updatedAt: String?
|
|
29
|
+
) {
|
|
30
|
+
self.id = id
|
|
31
|
+
self.type = type
|
|
32
|
+
self.status = status
|
|
33
|
+
self.amountMoney = amountMoney
|
|
34
|
+
self.tipMoney = tipMoney
|
|
35
|
+
self.applicationFee = applicationFee
|
|
36
|
+
self.referenceId = referenceId
|
|
37
|
+
self.orderId = orderId
|
|
38
|
+
self.cardDetails = cardDetails
|
|
39
|
+
self.createdAt = createdAt
|
|
40
|
+
self.updatedAt = updatedAt
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@objc public func toJSObject() -> AnyObject {
|
|
44
|
+
var result = JSObject()
|
|
45
|
+
result["id"] = id ?? NSNull()
|
|
46
|
+
result["type"] = type
|
|
47
|
+
result["status"] = status
|
|
48
|
+
result["amountMoney"] = amountMoney.toJSObject() as? JSObject
|
|
49
|
+
result["tipMoney"] = tipMoney != nil ? (tipMoney!.toJSObject() as? JSObject) : NSNull()
|
|
50
|
+
result["applicationFee"] = applicationFee != nil ? (applicationFee!.toJSObject() as? JSObject) : NSNull()
|
|
51
|
+
result["referenceId"] = referenceId ?? NSNull()
|
|
52
|
+
result["orderId"] = orderId ?? NSNull()
|
|
53
|
+
result["cardDetails"] = cardDetails != nil ? (cardDetails!.toJSObject() as? JSObject) : NSNull()
|
|
54
|
+
result["createdAt"] = createdAt ?? NSNull()
|
|
55
|
+
result["updatedAt"] = updatedAt ?? NSNull()
|
|
56
|
+
return result as AnyObject
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Capacitor
|
|
3
|
+
|
|
4
|
+
@objc public class ReaderInfo: NSObject, Result {
|
|
5
|
+
let serialNumber: String
|
|
6
|
+
let model: String
|
|
7
|
+
let status: String
|
|
8
|
+
let firmwareVersion: String?
|
|
9
|
+
let batteryLevel: Int?
|
|
10
|
+
let isCharging: Bool?
|
|
11
|
+
let supportedCardInputMethods: [String]
|
|
12
|
+
let unavailableReasonInfo: UnavailableReasonInfo?
|
|
13
|
+
|
|
14
|
+
init(
|
|
15
|
+
serialNumber: String,
|
|
16
|
+
model: String,
|
|
17
|
+
status: String,
|
|
18
|
+
firmwareVersion: String?,
|
|
19
|
+
batteryLevel: Int?,
|
|
20
|
+
isCharging: Bool?,
|
|
21
|
+
supportedCardInputMethods: [String],
|
|
22
|
+
unavailableReasonInfo: UnavailableReasonInfo?
|
|
23
|
+
) {
|
|
24
|
+
self.serialNumber = serialNumber
|
|
25
|
+
self.model = model
|
|
26
|
+
self.status = status
|
|
27
|
+
self.firmwareVersion = firmwareVersion
|
|
28
|
+
self.batteryLevel = batteryLevel
|
|
29
|
+
self.isCharging = isCharging
|
|
30
|
+
self.supportedCardInputMethods = supportedCardInputMethods
|
|
31
|
+
self.unavailableReasonInfo = unavailableReasonInfo
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@objc public func toJSObject() -> AnyObject {
|
|
35
|
+
var result = JSObject()
|
|
36
|
+
result["serialNumber"] = serialNumber
|
|
37
|
+
result["model"] = model
|
|
38
|
+
result["status"] = status
|
|
39
|
+
result["firmwareVersion"] = firmwareVersion ?? NSNull()
|
|
40
|
+
result["batteryLevel"] = batteryLevel ?? NSNull()
|
|
41
|
+
result["isCharging"] = isCharging ?? NSNull()
|
|
42
|
+
result["supportedCardInputMethods"] = supportedCardInputMethods
|
|
43
|
+
result["unavailableReasonInfo"] = unavailableReasonInfo != nil ? (unavailableReasonInfo!.toJSObject() as? JSObject) : NSNull()
|
|
44
|
+
return result as AnyObject
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Capacitor
|
|
3
|
+
|
|
4
|
+
@objc public class UnavailableReasonInfo: NSObject, Result {
|
|
5
|
+
let reason: String
|
|
6
|
+
let message: String?
|
|
7
|
+
|
|
8
|
+
init(reason: String, message: String?) {
|
|
9
|
+
self.reason = reason
|
|
10
|
+
self.message = message
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@objc public func toJSObject() -> AnyObject {
|
|
14
|
+
var result = JSObject()
|
|
15
|
+
result["reason"] = reason
|
|
16
|
+
result["message"] = message ?? NSNull()
|
|
17
|
+
return result as AnyObject
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
enum CustomError: Error {
|
|
4
|
+
case locationIdMissing
|
|
5
|
+
case accessTokenMissing
|
|
6
|
+
case serialNumberMissing
|
|
7
|
+
case paymentParametersMissing
|
|
8
|
+
case promptParametersMissing
|
|
9
|
+
case amountMoneyMissing
|
|
10
|
+
case paymentAttemptIdMissing
|
|
11
|
+
case notInitialized
|
|
12
|
+
case notAuthorized
|
|
13
|
+
case pairingAlreadyInProgress
|
|
14
|
+
case noPaymentInProgress
|
|
15
|
+
case readerNotFound
|
|
16
|
+
case privacyDescriptionsMissing
|
|
17
|
+
|
|
18
|
+
var code: String? {
|
|
19
|
+
switch self {
|
|
20
|
+
case .locationIdMissing:
|
|
21
|
+
return "LOCATION_ID_MISSING"
|
|
22
|
+
case .accessTokenMissing:
|
|
23
|
+
return "ACCESS_TOKEN_MISSING"
|
|
24
|
+
case .serialNumberMissing:
|
|
25
|
+
return "SERIAL_NUMBER_MISSING"
|
|
26
|
+
case .paymentParametersMissing:
|
|
27
|
+
return "PAYMENT_PARAMETERS_MISSING"
|
|
28
|
+
case .promptParametersMissing:
|
|
29
|
+
return "PROMPT_PARAMETERS_MISSING"
|
|
30
|
+
case .amountMoneyMissing:
|
|
31
|
+
return "AMOUNT_MONEY_MISSING"
|
|
32
|
+
case .paymentAttemptIdMissing:
|
|
33
|
+
return "PAYMENT_ATTEMPT_ID_MISSING"
|
|
34
|
+
case .notInitialized:
|
|
35
|
+
return "NOT_INITIALIZED"
|
|
36
|
+
case .notAuthorized:
|
|
37
|
+
return "NOT_AUTHORIZED"
|
|
38
|
+
case .pairingAlreadyInProgress:
|
|
39
|
+
return "PAIRING_ALREADY_IN_PROGRESS"
|
|
40
|
+
case .noPaymentInProgress:
|
|
41
|
+
return "NO_PAYMENT_IN_PROGRESS"
|
|
42
|
+
case .readerNotFound:
|
|
43
|
+
return "READER_NOT_FOUND"
|
|
44
|
+
case .privacyDescriptionsMissing:
|
|
45
|
+
return "PRIVACY_DESCRIPTIONS_MISSING"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
extension CustomError: LocalizedError {
|
|
51
|
+
public var errorDescription: String? {
|
|
52
|
+
switch self {
|
|
53
|
+
case .locationIdMissing:
|
|
54
|
+
return NSLocalizedString("locationId must be provided.", comment: "locationIdMissing")
|
|
55
|
+
case .accessTokenMissing:
|
|
56
|
+
return NSLocalizedString("accessToken must be provided.", comment: "accessTokenMissing")
|
|
57
|
+
case .serialNumberMissing:
|
|
58
|
+
return NSLocalizedString("serialNumber must be provided.", comment: "serialNumberMissing")
|
|
59
|
+
case .paymentParametersMissing:
|
|
60
|
+
return NSLocalizedString("paymentParameters must be provided.", comment: "paymentParametersMissing")
|
|
61
|
+
case .promptParametersMissing:
|
|
62
|
+
return NSLocalizedString("promptParameters must be provided.", comment: "promptParametersMissing")
|
|
63
|
+
case .amountMoneyMissing:
|
|
64
|
+
return NSLocalizedString("amountMoney must be provided.", comment: "amountMoneyMissing")
|
|
65
|
+
case .paymentAttemptIdMissing:
|
|
66
|
+
return NSLocalizedString("paymentAttemptId must be provided.", comment: "paymentAttemptIdMissing")
|
|
67
|
+
case .notInitialized:
|
|
68
|
+
return NSLocalizedString("The SDK is not initialized. Call initialize() first.", comment: "notInitialized")
|
|
69
|
+
case .notAuthorized:
|
|
70
|
+
return NSLocalizedString("The SDK is not authorized. Call authorize() first.", comment: "notAuthorized")
|
|
71
|
+
case .pairingAlreadyInProgress:
|
|
72
|
+
return NSLocalizedString("A pairing process is already in progress.", comment: "pairingAlreadyInProgress")
|
|
73
|
+
case .noPaymentInProgress:
|
|
74
|
+
return NSLocalizedString("No payment is currently in progress.", comment: "noPaymentInProgress")
|
|
75
|
+
case .readerNotFound:
|
|
76
|
+
return NSLocalizedString("Reader not found.", comment: "readerNotFound")
|
|
77
|
+
case .privacyDescriptionsMissing:
|
|
78
|
+
return NSLocalizedString("Privacy descriptions are missing in Info.plist.", comment: "privacyDescriptionsMissing")
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>CFBundleDevelopmentRegion</key>
|
|
6
|
+
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
|
7
|
+
<key>CFBundleExecutable</key>
|
|
8
|
+
<string>$(EXECUTABLE_NAME)</string>
|
|
9
|
+
<key>CFBundleIdentifier</key>
|
|
10
|
+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
|
11
|
+
<key>CFBundleInfoDictionaryVersion</key>
|
|
12
|
+
<string>6.0</string>
|
|
13
|
+
<key>CFBundleName</key>
|
|
14
|
+
<string>$(PRODUCT_NAME)</string>
|
|
15
|
+
<key>CFBundlePackageType</key>
|
|
16
|
+
<string>FMWK</string>
|
|
17
|
+
<key>CFBundleShortVersionString</key>
|
|
18
|
+
<string>1.0</string>
|
|
19
|
+
<key>CFBundleVersion</key>
|
|
20
|
+
<string>$(CURRENT_PROJECT_VERSION)</string>
|
|
21
|
+
<key>NSPrincipalClass</key>
|
|
22
|
+
<string></string>
|
|
23
|
+
</dict>
|
|
24
|
+
</plist>
|