diff --git a/.jazzy.yaml b/.jazzy.yaml deleted file mode 100644 index 561a34f..0000000 --- a/.jazzy.yaml +++ /dev/null @@ -1,288 +0,0 @@ -sdk: iphoneos -theme: fullwidth -podspec: CloverConnector.podspec -module: CloverConnector -theme: apple -output: 3.0.0/docs -clean: true -github-url: https://github.com/clover/remote-pay-ios -swift-version: 4.2 -copyright: 'Copyright © 2018 Clover Network, Inc. All rights reserved.' -custom_categories: - - name: API - children: - - ICloverConnector - - CloverConnectorFactory - - ICloverConnectorListener - - DefaultCloverConnectorListsner - - WebSocketDeviceConfiguration - - NetworkDeviceConfiguration - - name: Payment - children: - - SaleRequest - - SaleResponse - - AuthRequest - - AuthResponse - - PreAuthRequest - - PreAuthResponse - - ManualRefundRequest - - ManualRefundResponse - - TipAdjustAuthRequest - - TipAdjustAuthResponse - - CapturePreAuthRequest - - CapturePreAuthResponse - - RefundPaymentRequest - - RefundPaymentResponse - - VoidPaymentRequest - - VoidPaymentResponse - - VoidPaymentRefund - - VoidPaymentRefundResponse - - RetreivePendingPaymentRequest - - RetrievePendingPaymentResponse - - RetrievePaymentRequest - - RetrievePaymentResponse - - CloseoutRequest - - CloseoutResponse - - ReadCardDataRequest - - ReadCardDataResponse - - VaultCardRequest - - VaultCardResponse - - ConfirmPaymentRequest - - VerifySignatureRequest - - Signature - - name: Device - children: - - MerchantInfo - - DeviceInfo - - DisplayOrder - - DisplayLineItem - - DisplayDiscount - - DisplayPayment - - PrintPaymentReceiptMessage - - PrintPaymentMerchantCopyReceiptMessage - - PrintRefundPaymentReceiptMessage - - PrintPaymentDeclineReceiptMessage - - PrintManualRefundReceiptMessage - - PrintManualRefundDeclineReceiptMessage - - ShowPaymentReceiptOptions - - RetrieveDeviceStatusRequest - - RetrieveDeviceStatusResponse - - SendDebugLog - - name: Custom Activities - children: - - CustomActivityRequest - - CustomActivityResponse - - MessageToActivity - - MessageFromActivity - - name: Pairing - children: - - PairingDeviceConfiguration -exclude: -- "../**/action/*.swift" -- "../**/operations/*.swift" -# - "../**/AddDiscountAction.swift" -# - "../**/AddLineItemAction.swift" -# - "../**/*Message.swift" -# - "../**/ActivityRequest.swift" -# - "../**/*Message.swift" -- "../**/Pairing*Message.swift" -# - "../**/TxStartRequestMessage.swift" -- "../**/remotepaylib/*.swift" -- "../**/TransformTypes.swift" -- "../**/*Transport.swift" -# - "../**/DisplayOrderMod*.swift" -- "../**/Initable.swift" -# - "../**/*Operation.swift" -- "../**/DefaultCloverConnectorListener.swift" -- "../**/ListWrapper.swift" -- "../**/CloverDeviceConfiguration.swift" -# - "../**/OrderActionResponse.swift" -- "../**/VoidCreditRe*.swift" - - -- "../**/Account.swift" -- "../**/AcknowledgementMessage.swift" -#- "../**/ActivityMessageFromActivity.swift" -#- "../**/ActivityMessageToActivity.swift" -- "../**/ActivityRequest.swift" -- "../**/ActivityResponseMessage.swift" -- "../**/AddDiscountAction.swift" -- "../**/AddLineItemAction.swift" -- "../**/Apps.swift" -#- "../**/AuthRequest.swift" -#- "../**/AuthResponse.swift" -- "../**/Base.swift" -#- "../**/BaseActivityMessage.swift" -#- "../**/BaseResponse.swift" -- "../**/BreakMessage.swift" -#- "../**/CapturePreAuthRequest.swift" -- "../**/CapturePreAuthRequestMessage.swift" -#- "../**/CapturePreAuthResponse.swift" -- "../**/CapturePreAuthResponseMessage.swift" -#- "../**/CardData.swift" -- "../**/CardDataRequestMessage.swift" -- "../**/CardDataResponseMessage.swift" -- "../**/Cash.swift" -- "../**/CashbackSelectedMessage.swift" -#- "../**/Challenge.swift" -# - "../**/CloseoutRequest.swift" -- "../**/CloseoutRequestMessage.swift" -#- "../**/CloseoutResponse.swift" -- "../**/CloseoutResponseMessage.swift" -# - "../**/CloverConnector.swift" -- "../**/CloverConnectorBroadcaster.swift" -# - "../**/CloverDevice.swift" -- "../**/CloverDeviceConfiguration.swift" -- "../**/CloverDeviceErrorEvent.swift" -- "../**/CloverDeviceEvent.swift" -- "../**/CloverDeviceFactory.swift" -- "../**/CloverDeviceObserver.swift" -- "../**/CloverTransport.swift" -- "../**/CloverTransportObserver.swift" -# - "../**/CLVModels.swift" -- "../**/ConfirmPaymentMessage.swift" -# - "../**/ConfirmPaymentRequest.swift" -# - "../**/CreditPrintMessage.swift" -# - "../**/CustomActivityRequest.swift" -# - "../**/CustomActivityResponse.swift" -# - "../**/Customers.swift" -# - "../**/DeclineCreditPrintMessage.swift" -# - "../**/DeclinePaymentPrintMessage.swift" -# - "../**/DefaultCloverConnectorListener.swift" -- "../**/DefaultCloverDevice.swift" -- "../**/Developer.swift" -- "../**/Device.swift" -# - "../**/DeviceStatusRequest.swift" -- "../**/DiscoveryRequestMessage.swift" -- "../**/DiscoveryResponseMessage.swift" -# - "../**/DisplayDiscount.swift" -# - "../**/DisplayLineItem.swift" -- "../**/DisplayModification.swift" -# - "../**/DisplayOrder.swift" -- "../**/DisplayOrderModifiedOperation.swift" -# - "../**/DisplayPayment.swift" -- "../**/Employees.swift" -# - "../**/ErrorCode.swift" -# - "../**/ExternalDeviceState.swift" -# - "../**/ExternalDeviceStateData.swift" -- "../**/FinishCancelMessage.swift" -- "../**/FinishOkMessage.swift" -- "../**/Hours.swift" -# - "../**/ICloverConnector.swift" -# - "../**/ICloverConnectorListener.swift" -- "../**/ImagePrintMessage.swift" -- "../**/Img.swift" -# - "../**/InputOption.swift" -- "../**/Inventory.swift" -# - "../**/KeyPress.swift" -- "../**/KeyPressMessage.swift" -- "../**/ListWrapper.swift" -# - "../**/ManualRefundRequest.swift" -# - "../**/ManualRefundResponse.swift" -- "../**/Merchant.swift" -# - "../**/MerchantInfo.swift" -- "../**/Message.swift" -# - "../**/MessageFromActivity.swift" -# - "../**/MessageToActivity.swift" -- "../**/Method.swift" -# - "../**/NetworkDeviceConfiguration" -- "../**/OpenCashDrawerMessage.swift" -# - "../**/Order.swift" -- "../**/OrderActionAddDiscountMessage.swift" -- "../**/OrderActionAddLineItemMessage.swift" -- "../**/OrderActionRemoveDiscountMessage.swift" -- "../**/OrderActionRemoveLineItemMessage.swift" -- "../**/OrderActionResponse.swift" -- "../**/OrderActionResponseMessage.swift" -- "../**/OrderUpdateMessage.swift" -- "../**/PairingCode.swift" -- "../**/PairingCodeMessage.swift" -# - "../**/PairingDeviceConfiguration.swift" -- "../**/PairingRequest.swift" -- "../**/PairingRequestMessage.swift" -- "../**/PairingResponse.swift" -# - "../**/PairingResponseMessage.swift" -- "../**/PartialAuthMessage.swift" -# - "../**/PayIntent.swift" -- "../**/PaymentConfirmedMessage.swift" -# - "../**/PaymentPrintMerchantCopyMessage.swift" -# - "../**/PaymentPrintMessage.swift" -# - "../**/PaymentResponse.swift" -# - "../**/Payments.swift" -- "../**/PaymentVoidedMessage.swift" -- "../**/PendingPaymentEntry.swift" -- "../**/Point.swift" -- "../**/Points.swift" -# - "../**/PreAuthRequest.swift" -# - "../**/PreAuthResponse.swift" -- "../**/Printer.swift" -# - "../**/PrintManualRefundDeclineReceiptMessage.swift" -# - "../**/PrintManualRefundReceiptMessage.swift" -# - "../**/PrintPaymentDeclineReceiptMessage.swift" -# - "../**/PrintPaymentMerchantCopyReceiptMessage.swift" -# - "../**/PrintPaymentReceiptMessage.swift" -# - "../**/PrintRefundPaymentReceiptMessage.swift" -# - "../**/ReadCardDataRequest.swift" -# - "../**/ReadCardDataResponse.swift" -- "../**/RefundPaymentPrintMessage.swift" -- "../**/RefundPaymentRequest.swift" -- "../**/RefundPaymentResponse.swift" -- "../**/RefundRequestMessage.swift" -- "../**/RefundResponseMessage.swift" -- "../**/RemoteMessage.swift" -- "../**/RemoteMessageType.swift" -- "../**/RemoveDiscountAction.swift" -- "../**/RemoveLineItemAction.swift" -# - "../**/ResetDeviceResponse.swift" -- "../**/ResetDeviceResponseMessage.swift" -# - "../**/ResultCode.swift" -# - "../**/ResultStatus.swift" -# - "../**/ResultStatusEnum.swift" -# - "../**/RetrieveDeviceStatusRequest.swift" -- "../**/RetrieveDeviceStatusRequestMessage.swift" -# - "../**/RetrieveDeviceStatusResponse.swift" -- "../**/RetrieveDeviceStatusResponseMessage.swift" -# - "../**/RetrievePaymentRequest.swift" -- "../**/RetrievePaymentRequestMessage.swift" -# - "../**/RetrievePaymentResponse.swift" -- "../**/RetrievePaymentResponseMessage.swift" -- "../**/RetrievePendingPaymentsRequestMessage.swift" -# - "../**/RetrievePendingPaymentsResponse.swift" -- "../**/RetrievePendingPaymentsResponseMessage.swift" -# - "../**/SaleRequest.swift" -# - "../**/SaleResponse.swift" -- "../**/ShowPaymentReceiptOptionsMessage.swift" -# - "../**/ShowPaymentReceiptOptionsRequest.swift" -- "../**/ShowThankYouScreenMessage.swift" -- "../**/ShowWelcomeScreenMessage.swift" -# - "../**/Signature.swift" -- "../**/SignatureVerifiedMessage.swift" -- "../**/TerminalMessage.swift" -- "../**/TextPrintMessage.swift" -# - "../**/TipAddedMessage.swift" -# - "../**/TipAdjustAuthRequest.swift" -# - "../**/TipAdjustAuthResponse.swift" -- "../**/TipAdjustMessage.swift" -- "../**/TipAdjustResponseMessage.swift" -# - "../**/TransactionRequest.swift" -# - "../**/TransactionType.swift" -- "../**/TransformTypes.swift" -- "../**/TxStartRequestMessage.swift" -- "../**/TxStartResponseMessage.swift" -- "../**/TxStartResponseResult.swift" -- "../**/TxState.swift" -- "../**/TxStateMessage.swift" -- "../**/UiStateMessage.swift" -- "../**/VaultCardMessage.swift" -# - "../**/VaultCardRequest.swift" -# - "../**/VaultCardResponse.swift" -- "../**/VaultCardResponseMessage.swift" -# - "../**/VerifySignatureRequest.swift" -- "../**/VoidCreditRequest.swift" -- "../**/VoidCreditResponse.swift" -- "../**/VoidPaymentMessage.swift" -# - "../**/VoidPaymentRequest.swift" -# - "../**/VoidPaymentResponse.swift" -# - "../**/VoidReason.swift" -- "../**/WebSocketCloverTransport.swift" -# - "../**/WebSocketDeviceConfiguration.swift" diff --git a/.swift-version b/.swift-version deleted file mode 100644 index 389f774..0000000 --- a/.swift-version +++ /dev/null @@ -1 +0,0 @@ -4.0 \ No newline at end of file diff --git a/CloverConnector.podspec b/CloverConnector.podspec index 665ddc8..4993036 100644 --- a/CloverConnector.podspec +++ b/CloverConnector.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = 'CloverConnector' - s.version = '3.0.0' + s.version = '3.0.1' s.summary = 'Provides an api for communicating with a Clover Mini as a customer facing payment device.' s.description = <<-DESC @@ -21,7 +21,8 @@ ICloverConnector - *voidPaymentRefund* - void a payment refund (Canada flows only) - *manualRefund* - provide a manual refund a.k.a. naked credit - *closeout* - posts a closeout request to the server to closeout open payments -- *displayPaymentReceiptOptions* - display the receipt selection screen +- *displayPaymentReceiptOptions* - (Deprecated) display the receipt selection screen +- *displayReceiptOptions* - Display the receipt selection screen for a payment, credit, or refund - *acceptSignature* - method to accept a signature when the Clover device sends a `verifySignatureRequest` - *rejectSignature* - method to reject a signature when the Clover device sends a `verifySignatureRequest` - *vaultCard* - reads a card and retrieves a multi-pay token @@ -75,6 +76,7 @@ ICloverConnectorListener - *onPrintPaymentDeclineReceipt* - called when a user requests a paper receipt for a declined Payment - *onPrintPaymentMerchantCopyReceipt* - called when a user requests a merchant copy of a Payment receipt - *onPrintRefundPaymentReceipt* - called when a user requests a paper receipt for a Payment Refund +- *onDisplayReceiptOptionsResponse* - called in response to a DisplayReceiptOptions request - *onRetrievePrintersResponse* - called at the completion of a retrievePrinters request - *onPrintJobStatusResponse* - called at the completion of a retrievePrintJobStatus - *onRetrievePendingPaymentsResponse* - called in response to a retrieve pending payments request. Returns a list of payments not yet submitted to the server diff --git a/CloverConnector/Classes/Models/Extensions/Payments.swift b/CloverConnector/Classes/Models/Extensions/Payments.swift index 70d771f..5510ade 100644 --- a/CloverConnector/Classes/Models/Extensions/Payments.swift +++ b/CloverConnector/Classes/Models/Extensions/Payments.swift @@ -423,6 +423,7 @@ extension CLVModels { public var avsResult: CLVModels.Payments.AVSResult? = nil public var cardholderName: String? public var token: String? + public var vaultedCard: VaultedCard? public func encode(with aCoder: NSCoder) { aCoder.encode(paymentRef, forKey: "paymentRef") @@ -442,6 +443,7 @@ extension CLVModels { aCoder.encode(avsResult?.rawValue, forKey: "avsResult") aCoder.encode(cardholderName, forKey: "cardholderName") aCoder.encode(token, forKey: "token") + aCoder.encode(token, forKey: "vaultedCard") } required public init(coder aDecoder: NSCoder) { @@ -472,6 +474,7 @@ extension CLVModels { } cardholderName = aDecoder.decodeObject(forKey: "cardholderName") as? String token = aDecoder.decodeObject(forKey: "token") as? String + vaultedCard = aDecoder.decodeObject(forKey: "vaultedCard") as? CLVModels.Payments.VaultedCard } override public init() {} @@ -498,6 +501,7 @@ extension CLVModels { avsResult <- map["avsResult"] cardholderName <- map["cardholderName"] token <- map["token"] + vaultedCard <- map["vaultedCard"] } } @@ -1399,6 +1403,8 @@ extension CLVModels { /// Additional charges associated with this transaction (Canada INTERAC) public var additionalCharges: CLVModels.Payments.AdditionalCharges? + public var transactionInfo: CLVModels.Payments.TransactionInfo? + public func encode(with aCoder: NSCoder) { aCoder.encode(id, forKey: "id") aCoder.encode(order, forKey: "order") @@ -1428,6 +1434,7 @@ extension CLVModels { aCoder.encode(germanInfo, forKey: "germanInfo") aCoder.encode(appTracking, forKey: "appTracking") aCoder.encode(additionalCharges, forKey: "additionalCharges") + aCoder.encode(transactionInfo, forKey: "transactionInfo") } required public init(coder aDecoder: NSCoder) { @@ -1463,6 +1470,7 @@ extension CLVModels { germanInfo = aDecoder.decodeObject(forKey: "germanInfo") as? CLVModels.Payments.GermanInfo appTracking = aDecoder.decodeObject(forKey: "appTracking") as? CLVModels.Apps.AppTracking additionalCharges = aDecoder.decodeObject(forKey: "additionalCharges") as? AdditionalCharges + transactionInfo = aDecoder.decodeObject(forKey: "transactionInfo") as? CLVModels.Payments.TransactionInfo } override public init() {} @@ -1500,6 +1508,7 @@ extension CLVModels { germanInfo <- map["germanInfo"] appTracking <- map["appTracking"] additionalCharges <- map["additionalCharges"] + transactionInfo <- map["transactionInfo"] } } @@ -1917,6 +1926,9 @@ extension CLVModels { public var forceOfflinePayment: Bool? + /// Any extra region specific data. Keys are referenced in RegionalExtras.swift + public var regionalExtras: [String: String]? + public func encode(with aCoder: NSCoder) { aCoder.encode(cardEntryMethods, forKey: "cardEntryMethods") aCoder.encode(disableCashBack, forKey: "disableCashBack") @@ -1934,6 +1946,7 @@ extension CLVModels { aCoder.encode(autoAcceptPaymentConfirmations, forKey: "autoAcceptPaymentConfirmations") aCoder.encode(autoAcceptSignature, forKey: "autoAcceptSignature") aCoder.encode(forceOfflinePayment, forKey: "forceOfflinePayment") + aCoder.encode(regionalExtras, forKey: "regionalExtras") } required public init(coder aDecoder: NSCoder) { @@ -1957,6 +1970,7 @@ extension CLVModels { autoAcceptPaymentConfirmations = aDecoder.decodeObject(forKey: "autoAcceptPaymentConfirmations") as? Bool autoAcceptSignature = aDecoder.decodeObject(forKey: "autoAcceptSignature") as? Bool forceOfflinePayment = aDecoder.decodeObject(forKey: "forceOfflinePayment") as? Bool + regionalExtras = aDecoder.decodeObject(forKey: "regionalExtras") as? [String: String] } override public init() {} @@ -1981,6 +1995,7 @@ extension CLVModels { autoAcceptPaymentConfirmations <- map["autoAcceptPaymentConfirmations"] autoAcceptSignature <- map["autoAcceptSignature"] forceOfflinePayment <- map["forceOfflinePayment"] + regionalExtras <- map["regionalExtras"] } } @@ -2127,5 +2142,159 @@ extension CLVModels { amount <- map["amount"] } } + + public class TransactionInfo: NSObject, Mappable { + /// Two character language used for the transaction. Deprecated in factor of transactionLocale. + public var languageIndicator: String? + /// Locale for the transaction (e.g. en-CA) + public var transactionLocale: String? + public var accountSelection: AccountType? + /// Consists of 4 digits prefix + 8 digits + public var fiscalInvoiceNumber: String? + /// AR Installments: number of installments + public var installmentsQuantity: Int32? + /// AR Installments: plan alphanum code + public var installmentsPlanCode: String? + /// AR Installments: selected plan id + public var installmentsPlanId: String? + /// AR Installments: selected plan desc + public var installmentsPlanDesc: String? + /// Card type label + public var cardTypeLabel: String? + /// STAN(System Audit Trace Number) + public var stan: Int32? + /// Customers identification number and type + public var identityDocument: IdentityDocument? + /// Transaction Batch Number + public var batchNumber: String? + /// Transaction Receipt Number + public var receiptNumber: String? + /// STAN for reversal + public var reversalStan: Int32? + /// MAC for reversal + public var reversalMac: String? + /// MAC KSN for reversal + public var reversalMacKsn: String? + /// Designates the unique location of a terminal at a merchant + public var terminalIdentification: String? + /// When concatenated with the Acquirer Identifier, uniquely identifies a given merchant + public var merchantIdentifier: String? + /// Indicates the name and location of the merchant + public var merchantNameLocation: String? + /// Masked track2 data + public var maskedTrack2: String? + /// Extra data for receipt + public var receiptExtraData: String? + /// Defines the Financial Service selected for the transaction + public var selectedService: SelectedService? + /// Result of the transaction + public var transactionResult: TransactionResult? + /// Contains a hex string with needed TLV tags for certification + public var transactionTags: String? + /// Contains the information how the data inside transactionTags should be coded - initially we cause default and nexo as formats + public var txFormat: TxFormat? + /// Contains the reason why the transaction should be reversed in the host. It has to be mapped in server with the expected value by the corresponding gateway + public var reversalReason: ReversalReason? + /// Contains a hex string with the information how the PAN on cardholder receipts shall be masked + public var panMask: String? + /// Counter maintained by the terminal that is incremented for each transaction at the beginning of the Perform Service function + public var transactionSequenceCounter: String? + /// Identifies and differentiates cards with the same PAN + public var applicationPanSequenceNumber: String? + + public required init?(map: Map) { } + + public func mapping(map: Map) { + languageIndicator <- map["languageIndicator"] + transactionLocale <- map["transactionLocale"] + accountSelection <- map["accountSelection"] + fiscalInvoiceNumber <- map["fiscalInvoiceNumber"] + installmentsQuantity <- map["installmentsQuantity"] + installmentsPlanCode <- map["installmentsPlanCode"] + installmentsPlanId <- map["installmentsPlanId"] + installmentsPlanDesc <- map["installmentsPlanDesc"] + cardTypeLabel <- map["cardTypeLabel"] + stan <- map["stan"] + identityDocument <- map["identityDocument"] + batchNumber <- map["batchNumber"] + receiptNumber <- map["receiptNumber"] + reversalStan <- map["reversalStan"] + reversalMac <- map["reversalMac"] + reversalMacKsn <- map["reversalMacKsn"] + terminalIdentification <- map["terminalIdentification"] + merchantIdentifier <- map["merchantIdentifier"] + merchantNameLocation <- map["merchantNameLocation"] + maskedTrack2 <- map["maskedTrack2"] + receiptExtraData <- map["receiptExtraData"] + selectedService <- map["selectedService"] + transactionResult <- map["transactionResult"] + transactionTags <- map["transactionTags"] + txFormat <- map["txFormat"] + reversalReason <- map["reversalReason"] + panMask <- map["panMask"] + transactionSequenceCounter <- map["transactionSequenceCounter"] + applicationPanSequenceNumber <- map["applicationPanSequenceNumber"] + } + } + + public enum AccountType: String { + case CREDIT + case DEBIT + case CHECKING + case SAVINGS + } + + public enum SelectedService: UInt8 { + case none = 0x00 + case payment = 0x01 + case refund = 0x02 + case cancellation = 0x03 + case preAuth = 0x04 + case updatePreAuth = 0x05 + case paymentCompletion = 0x06 + case cashAdvance = 0x07 + case deferredPayment = 0x08 + case deferredPaymentCompletion = 0x09 + case voiceAuthorization = 0x10 + case cardholderDetection = 0x11 + + // No NEXO-Services (default mode) + case tokenRequest = 0x50 + case verification = 0x51 + } + + public enum TransactionResult: UInt8 { + case approved = 0x00 + case declined = 0x01 + case aborted = 0x02 + case voiceAuthorization = 0x03 + case paymentPartOnly = 0x04 + case partiallyApproved = 0x05 + case none = 0x99 + } + + public enum TxFormat: String { + case DEFAULT + case NEXO + } + + public enum ReversalReason: String { + case CHIP_DECLINE + case CARDHOLDER_CANCELLATION + case COMMUNICATION_ERROR + case OTHER_REASON + } + + public class IdentityDocument: NSObject, Mappable { + var type: String? + var number: String? + + public required init?(map: Map) { } + + public func mapping(map: Map) { + type <- map["type"] + number <- map["number"] + } + } } } diff --git a/CloverConnector/Classes/cloverconnector/CloverConnectorBroadcaster.swift b/CloverConnector/Classes/cloverconnector/CloverConnectorBroadcaster.swift index 27741c1..99d92af 100644 --- a/CloverConnector/Classes/cloverconnector/CloverConnectorBroadcaster.swift +++ b/CloverConnector/Classes/cloverconnector/CloverConnectorBroadcaster.swift @@ -368,4 +368,13 @@ public class CloverConnectorBroadcaster { } } } + + public func notifyOnDisplayReceiptOptionsResponse(_ response: DisplayReceiptOptionsResponse) { + dispatchQueue.async { [weak self] in + guard let self = self else { return } + for listener in self.listeners { + listener.onDisplayReceiptOptionsResponse(response) + } + } + } } diff --git a/CloverConnector/Classes/cloverconnector/CloverDevice.swift b/CloverConnector/Classes/cloverconnector/CloverDevice.swift index f3844ca..b9a1682 100644 --- a/CloverConnector/Classes/cloverconnector/CloverDevice.swift +++ b/CloverConnector/Classes/cloverconnector/CloverDevice.swift @@ -79,7 +79,7 @@ class CloverDevice { func doSendDebugLog(_ message:String) {} - func doPaymentRefund(_ orderId:String, paymentId:String, amount:Int, fullRefund:Bool, disablePrinting:Bool?, disableReceiptSelection:Bool?) {} // manual refunds are handled via doTxStart + func doPaymentRefund(_ orderId:String, paymentId:String, amount:Int, fullRefund:Bool?, disablePrinting:Bool?, disableReceiptSelection:Bool?) {} // manual refunds are handled via doTxStart func doTipAdjustAuth(_ orderId:String, paymentId:String, amount:Int) {} @@ -91,6 +91,8 @@ class CloverDevice { func doShowPaymentReceiptScreen(_ orderId:String, paymentId:String) {} + func doShowReceiptScreen(orderId: String?, paymentId: String?, refundId: String?, creditId: String?, disablePrinting: Bool?) {} + func doShowThankYouScreen() {} func doOpenCashDrawer(_ reason:String, deviceId: String?) {} diff --git a/CloverConnector/Classes/cloverconnector/CloverDeviceObserver.swift b/CloverConnector/Classes/cloverconnector/CloverDeviceObserver.swift index cbc00f9..06fc723 100644 --- a/CloverConnector/Classes/cloverconnector/CloverDeviceObserver.swift +++ b/CloverConnector/Classes/cloverconnector/CloverDeviceObserver.swift @@ -89,6 +89,8 @@ protocol CloverDeviceObserver:AnyObject { func onResetDeviceResponse(_ result:ResultStatus, reason: String?, state: ExternalDeviceState) func onCustomerProvidedDataMessage(_ result:ResultStatus, eventId:String?, config:CLVModels.Loyalty.LoyaltyDataConfig?, data:String?) + + func onDisplayReceiptOptionsResponse(_ result: ResultStatus, reason: String?) } public class DefaultCloverDeviceObserver : CloverDeviceObserver { @@ -162,5 +164,6 @@ public class DefaultCloverDeviceObserver : CloverDeviceObserver { func onResetDeviceResponse(_ result:ResultStatus, reason: String?, state: ExternalDeviceState){} func onCustomerProvidedDataMessage(_ result:ResultStatus, eventId:String?, config:CLVModels.Loyalty.LoyaltyDataConfig?, data:String?) {} - + + func onDisplayReceiptOptionsResponse(_ result: ResultStatus, reason: String?) {} } diff --git a/CloverConnector/Classes/cloverconnector/DefaultCloverConnectorListener.swift b/CloverConnector/Classes/cloverconnector/DefaultCloverConnectorListener.swift index 450d2fb..9c4c8f8 100644 --- a/CloverConnector/Classes/cloverconnector/DefaultCloverConnectorListener.swift +++ b/CloverConnector/Classes/cloverconnector/DefaultCloverConnectorListener.swift @@ -166,4 +166,6 @@ open class DefaultCloverConnectorListener : NSObject, ICloverConnectorListener { open func onPrintJobStatusResponse(_ printJobStatusResponse:PrintJobStatusResponse) {} open func onRetrieveDeviceStatusResponse(_ response: RetrieveDeviceStatusResponse) {} + + open func onDisplayReceiptOptionsResponse(_ response: DisplayReceiptOptionsResponse) {} } diff --git a/CloverConnector/Classes/cloverconnector/DefaultCloverConnectorV2.swift b/CloverConnector/Classes/cloverconnector/DefaultCloverConnectorV2.swift index 4f69c3e..a38d5f6 100644 --- a/CloverConnector/Classes/cloverconnector/DefaultCloverConnectorV2.swift +++ b/CloverConnector/Classes/cloverconnector/DefaultCloverConnectorV2.swift @@ -249,9 +249,7 @@ class DefaultCloverConnectorV2 : NSObject, ICloverConnector { if let cardNotPresent = request.cardNotPresent { builder.isCardNotPresent = cardNotPresent } - if let disableRestartTransactionOnFail = request.disableRestartTransactionOnFail { - builder.disableRestartTransactionOnFail = disableRestartTransactionOnFail - } + builder.vaultedCard = request.vaultedCard builder.requiresRemoteConfirmation = true @@ -262,6 +260,12 @@ class DefaultCloverConnectorV2 : NSObject, ICloverConnector { tx.autoAcceptPaymentConfirmations = request.autoAcceptPaymentConfirmations tx.disableDuplicateCheck = request.disableDuplicateChecking tx.disableReceiptSelection = request.disableReceiptSelection + if let disableRestartTransactionOnFail = request.disableRestartTransactionOnFail { + tx.disableRestartTransactionOnFailure = disableRestartTransactionOnFail + } + + tx.regionalExtras = request.regionalExtras + builder.passThroughValues = request.extras if let transactionRequest = request as? TransactionRequest { tx.autoAcceptSignature = transactionRequest.autoAcceptSignature @@ -345,8 +349,8 @@ class DefaultCloverConnectorV2 : NSObject, ICloverConnector { public func refundPayment(_ refundPaymentRequest: RefundPaymentRequest) { if let device = checkDevice(from: #function) { - if !refundPaymentRequest.fullRefund && refundPaymentRequest.amount ?? 0 <= 0 { - let prr = RefundPaymentResponse(success:false, result:ResultCode.FAIL, reason: "Request Validation Error", message: "In RefundPayment : RefundPaymentRequest Amount must be greater than zero when FullRefund is set to false. ") + if refundPaymentRequest.fullRefund != true && (refundPaymentRequest.amount ?? 0) <= 0 { + let prr = RefundPaymentResponse(success:false, result:ResultCode.FAIL, reason: "Request Validation Error", message: "In RefundPayment : RefundPaymentRequest Amount must be greater than zero when FullRefund is not true. ") deviceObserver?.lastPRR = prr deviceObserver?.onFinishCancel(TxStartRequestMessage.REFUND_REQUEST) return @@ -455,10 +459,19 @@ class DefaultCloverConnectorV2 : NSObject, ICloverConnector { checkDevice(from: #function)?.doCloseout(closeoutRequest.allowOpenTabs, batchId: closeoutRequest.batchId) } + @available(*, deprecated, message: "Use new 'displayReceiptOptions()` function instead") public func displayPaymentReceiptOptions(orderId:String, paymentId:String) { checkDevice(from: #function)?.doShowPaymentReceiptScreen(orderId, paymentId:paymentId) } + public func displayReceiptOptions(_ receiptOptionsRequest: DisplayReceiptOptionsRequest) -> Void { + checkDevice(from: #function)?.doShowReceiptScreen(orderId: receiptOptionsRequest.orderId, + paymentId: receiptOptionsRequest.paymentId, + refundId: receiptOptionsRequest.refundId, + creditId: receiptOptionsRequest.creditId, + disablePrinting: receiptOptionsRequest.disablePrinting) + } + public func showMessage(_ message: String) { checkDevice(from: #function)?.doTerminalMessage(message) } @@ -480,7 +493,7 @@ class DefaultCloverConnectorV2 : NSObject, ICloverConnector { } public func openCashDrawer(_ request: OpenCashDrawerRequest) { - checkDevice(from: #function)?.doOpenCashDrawer(request.reason, deviceId: nil) + checkDevice(from: #function)?.doOpenCashDrawer(request.reason, deviceId: request.deviceId) } public func resetDevice() { @@ -1166,6 +1179,13 @@ class DefaultCloverConnectorV2 : NSObject, ICloverConnector { cloverConnector.broadcaster.notifyOnRetrievePrintersResponse(response) } + func onDisplayReceiptOptionsResponse(_ result: ResultStatus, reason: String?) { + let response = DisplayReceiptOptionsResponse(result, reason: reason) + response.result = (result == ResultStatus.SUCCESS ? ResultCode.SUCCESS : ResultCode.FAIL) + response.success = response.result == ResultCode.SUCCESS + cloverConnector.broadcaster.notifyOnDisplayReceiptOptionsResponse(response) + } + func onDeviceStatusResponse(_ result: ResultStatus, reason: String?, state: ExternalDeviceState, subState: ExternalDeviceSubState?, data: ExternalDeviceStateData?) { let success = result == .SUCCESS let result = success ? ResultCode.SUCCESS : ResultCode.CANCEL diff --git a/CloverConnector/Classes/cloverconnector/DefaultCloverDevice.swift b/CloverConnector/Classes/cloverconnector/DefaultCloverDevice.swift index 802acec..6102e0b 100644 --- a/CloverConnector/Classes/cloverconnector/DefaultCloverDevice.swift +++ b/CloverConnector/Classes/cloverconnector/DefaultCloverDevice.swift @@ -271,6 +271,11 @@ class DefaultCloverDevice : CloverDevice, CloverTransportObserver { if let rdrm = Mapper().map(JSONString: payload) { notifyDeviceResetResponse(rdrm) } + case Method.SHOW_RECEIPT_OPTIONS: break + case Method.SHOW_RECEIPT_OPTIONS_RESPONSE: + if let sprom = Mapper().map(JSONString: payload) { + notifyDisplayReceiptOptionsResponse(sprom) + } case Method.CAPTURE_PREAUTH: break case Method.CLOVER_DEVICE_LOG_REQUEST: break case Method.REGISTER_FOR_CUST_DATA: break @@ -337,6 +342,20 @@ class DefaultCloverDevice : CloverDevice, CloverTransportObserver { } } + override func doShowReceiptScreen(orderId: String?, paymentId: String?, refundId: String?, creditId: String?, disablePrinting: Bool?) { + let msg = ShowReceiptOptionsMessage() + msg.orderId = orderId + msg.paymentId = paymentId + msg.refundId = refundId + msg.creditId = creditId + msg.disableCloverPrinting = disablePrinting + msg.version = 2 + + if let msgJSON = Mapper().toJSONString(msg, prettyPrint: false) { + sendCommandMessage(payload: msgJSON, method: msg.method) + } + } + override func doTipAdjustAuth(_ orderId: String, paymentId: String, amount: Int) { let msg = TipAdjustMessage() msg.orderId = orderId @@ -531,7 +550,7 @@ class DefaultCloverDevice : CloverDevice, CloverTransportObserver { } } - override func doPaymentRefund(_ orderId: String, paymentId: String, amount: Int, fullRefund: Bool, disablePrinting: Bool?, disableReceiptSelection: Bool?) { + override func doPaymentRefund(_ orderId: String, paymentId: String, amount: Int, fullRefund: Bool?, disablePrinting: Bool?, disableReceiptSelection: Bool?) { let msg:RefundRequestMessage = RefundRequestMessage(orderId: orderId, paymentId:paymentId, amount:amount, fullRefund:fullRefund) msg.orderId = orderId msg.paymentId = paymentId @@ -823,7 +842,7 @@ class DefaultCloverDevice : CloverDevice, CloverTransportObserver { } else { // we DON'T need to fragment if let remoteMsg = Mapper().toJSONString(remoteMsg, prettyPrint: false) { - CCLog.d(remoteMsg) +// CCLog.d(remoteMsg) self.transport.sendMessage(remoteMsg) } else { CCLog.w("Couldn't send message. Couldn't serialize") @@ -837,7 +856,7 @@ class DefaultCloverDevice : CloverDevice, CloverTransportObserver { } if let remoteMsg = Mapper().toJSONString(remoteMsg, prettyPrint: false) { - CCLog.d(remoteMsg) +// CCLog.d(remoteMsg) self.transport.sendMessage(remoteMsg) } else { CCLog.w("Couldn't send message. Couldn't serialize") @@ -867,7 +886,7 @@ class DefaultCloverDevice : CloverDevice, CloverTransportObserver { fRemoteMessage.lastFragment = lastFragment if let remoteMsg = Mapper().toJSONString(fRemoteMessage, prettyPrint: false) { - CCLog.d("Sending Fragment " + String(index) + (lastFragment ? " " : "")) +// CCLog.d("Sending Fragment " + String(index) + (lastFragment ? " " : "")) self.transport.sendMessage(remoteMsg) } else { CCLog.w("Couldn't send message. Couldn't serialize") @@ -1212,6 +1231,14 @@ class DefaultCloverDevice : CloverDevice, CloverTransportObserver { } } + func notifyDisplayReceiptOptionsResponse(_ response: ShowReceiptOptionsResponseMessage) { + for listener in deviceObservers { + DispatchQueue.global(qos: DispatchQoS.QoSClass.default).async(execute: { + listener.onDisplayReceiptOptionsResponse(response.status, reason: response.reason) + }) + } + } + func notifyCustomerProvidedDataMessage(_ message:CustomerProvidedDataMessage) { for listener in deviceObservers { DispatchQueue.global(qos: DispatchQoS.QoSClass.default).async { diff --git a/CloverConnector/Classes/cloverconnector/ICloverConnector.swift b/CloverConnector/Classes/cloverconnector/ICloverConnector.swift index eea9c0f..3673f3b 100644 --- a/CloverConnector/Classes/cloverconnector/ICloverConnector.swift +++ b/CloverConnector/Classes/cloverconnector/ICloverConnector.swift @@ -96,8 +96,14 @@ public protocol ICloverConnector : AnyObject { /// the Clover device. /// - Parameter orderId: The ID of the Order associated with the receipt. /// - Parameter paymentId: The ID of the Payment associated with the receipt. + @available(*, deprecated, message: "Use the new 'displayReceiptOptions()' instead") func displayPaymentReceiptOptions(orderId:String, paymentId: String) -> Void + /// Display receipt options for a Credit, Refund, or Payment + /// + /// - Parameter receiptOptionsRequest: The request details for the credit, refund, or payment + func displayReceiptOptions(_ receiptOptionsRequest:DisplayReceiptOptionsRequest) -> Void + /// If a signature is captured during a transaction, this method accepts the signature /// as entered. /// - Parameter signatureVerifyRequest: The accepted VerifySignatureRequest the device passed to onVerifySignatureRequest(). diff --git a/CloverConnector/Classes/cloverconnector/ICloverConnectorListener.swift b/CloverConnector/Classes/cloverconnector/ICloverConnectorListener.swift index 498a8b8..7d87d8e 100644 --- a/CloverConnector/Classes/cloverconnector/ICloverConnectorListener.swift +++ b/CloverConnector/Classes/cloverconnector/ICloverConnectorListener.swift @@ -47,28 +47,28 @@ public protocol ICloverConnectorListener : AnyObject { func onTipAdjustAuthResponse ( _ tipAdjustAuthResponse:TipAdjustAuthResponse ) -> Void /// Called in response to a voidPayment() request. Contains a - /// [ResultCode](https://clover.github.io/remote-pay-ios/3.0.0/docs/Enums/ResultCode.html) + /// [ResultCode](https://clover.github.io/remote-pay-ios/3.0.1/docs/Enums/ResultCode.html) /// and a Success boolean. If successful, the response will also contain the /// paymentId for the voided Payment. /// - Parameter voidPaymentResponse: The response to the transaction request. func onVoidPaymentResponse ( _ voidPaymentResponse:VoidPaymentResponse ) -> Void /// Called in response to a RefundPayment() request. Contains a - /// [ResultCode](https://clover.github.io/remote-pay-ios/3.0.0/docs/Enums/ResultCode.html) + /// [ResultCode](https://clover.github.io/remote-pay-ios/3.0.1/docs/Enums/ResultCode.html) /// and a Success boolean. The response to a successful transaction will contain the /// Refund. The Refund includes the original paymentId as a reference. /// - Parameter refundPaymentResponse: The response to the transaction request. func onRefundPaymentResponse ( _ refundPaymentResponse:RefundPaymentResponse ) -> Void /// Called in response to a voidPaymentRefund() request. Contains a - /// [ResultCode](https://clover.github.io/remote-pay-ios/3.0.0/docs/Enums/ResultCode.html) + /// [ResultCode](https://clover.github.io/remote-pay-ios/3.0.1/docs/Enums/ResultCode.html) /// and a Success boolean. The response to a successful transaction will contain the /// Refund. The Refund includes the original paymentId as a reference. /// - Parameter VoidPaymentRefundResponse: The response to the transaction request. func onVoidPaymentRefundResponse(_ response: VoidPaymentRefundResponse) -> Void /// Called in response to a manualRefund() request. Contains a - /// [ResultCode](https://clover.github.io/remote-pay-ios/3.0.0/docs/Enums/ResultCode.html) + /// [ResultCode](https://clover.github.io/remote-pay-ios/3.0.1/docs/Enums/ResultCode.html) /// and a Success boolean. If successful, the ManualRefundResponse will have /// a Credit object associated with the relevant Payment information. /// - Parameter manualRefundResponse: The response to the transaction request. @@ -84,7 +84,7 @@ public protocol ICloverConnectorListener : AnyObject { func onVerifySignatureRequest ( _ signatureVerifyRequest:VerifySignatureRequest ) -> Void /// Called in response to a vaultCard() request. Contains a - /// [ResultCode](https://clover.github.io/remote-pay-ios/3.0.0/docs/Enums/ResultCode.html) + /// [ResultCode](https://clover.github.io/remote-pay-ios/3.0.1/docs/Enums/ResultCode.html) /// and a Success boolean. If successful, the response will contain a VaultedCard /// object with a token value that's unique for the card and merchant. The token /// can be used for future Sale() and Auth() requests. @@ -213,4 +213,9 @@ public protocol ICloverConnectorListener : AnyObject { /// Called in response to a RetrieveDeviceStatus() request. /// - Parameter response: The response to the request. func onRetrieveDeviceStatusResponse(_ response: RetrieveDeviceStatusResponse) -> Void + + /// Called in response to a DisplayReceiptOptionsRequest + /// + /// - Parameter response: Response object of type DisplayReceiptOptionsResponse + func onDisplayReceiptOptionsResponse(_ response: DisplayReceiptOptionsResponse) -> Void } diff --git a/CloverConnector/Classes/cloverconnector/api/BaseTransactionRequest.swift b/CloverConnector/Classes/cloverconnector/api/BaseTransactionRequest.swift index bfa5cc6..2c30ab6 100644 --- a/CloverConnector/Classes/cloverconnector/api/BaseTransactionRequest.swift +++ b/CloverConnector/Classes/cloverconnector/api/BaseTransactionRequest.swift @@ -38,6 +38,12 @@ public class BaseTransactionRequest : NSObject, Mappable { /// An id assigned by the POS that can be used to track a payment through the Clover system. public var externalId:String + + /// Extra pass-through data used by external systems. + public var extras: [String: String]? + + /// Any extra region specific data. Keys are referenced in RegionalExtras.swift + public var regionalExtras: [String: String]? /// A VaultedCard that has been acquired from a vaultCard call. public var vaultedCard:CLVModels.Payments.VaultedCard? @@ -72,6 +78,8 @@ public class BaseTransactionRequest : NSObject, Mappable { externalId <- map["externalId"] type <- map["type"] vaultedCard <- map["vaultedCard"] + extras <- map["extras"] + regionalExtras <- map["regionalExtras"] } diff --git a/CloverConnector/Classes/cloverconnector/api/DisplayReceiptOptionsRequest.swift b/CloverConnector/Classes/cloverconnector/api/DisplayReceiptOptionsRequest.swift new file mode 100644 index 0000000..3071902 --- /dev/null +++ b/CloverConnector/Classes/cloverconnector/api/DisplayReceiptOptionsRequest.swift @@ -0,0 +1,31 @@ +// +// DisplayReceiptOptionsRequest.swift +// CloverConnector +// +// +// + +import Foundation +import ObjectMapper + +public class DisplayReceiptOptionsRequest: NSObject, Mappable { + public var orderId: String? + public var paymentId: String? + public var refundId: String? + public var creditId: String? + public var disablePrinting: Bool? + + public override init() { + super.init() + } + + public required init?(map: Map) { } + + public func mapping(map: Map) { + orderId <- map["orderId"] + paymentId <- map["paymentId"] + refundId <- map["refundId"] + creditId <- map["creditId"] + disablePrinting <- map["disablePrinting"] + } +} diff --git a/CloverConnector/Classes/cloverconnector/api/DisplayReceiptOptionsResponse.swift b/CloverConnector/Classes/cloverconnector/api/DisplayReceiptOptionsResponse.swift new file mode 100644 index 0000000..8987bba --- /dev/null +++ b/CloverConnector/Classes/cloverconnector/api/DisplayReceiptOptionsResponse.swift @@ -0,0 +1,28 @@ +// +// DisplayReceiptOptionsResponse.swift +// CloverConnector +// +// +// + +import Foundation +import ObjectMapper + +public class DisplayReceiptOptionsResponse: BaseResponse { + public var resultStatus: ResultStatus? + + public init(_ status: ResultStatus, reason: String?) { + super.init() + self.resultStatus = status + self.reason = reason + } + + required public init?(map: Map) { + super.init() + } + + override public func mapping(map:Map) { + super.mapping(map: map) + resultStatus <- map["resultStatus"] + } +} diff --git a/CloverConnector/Classes/cloverconnector/api/RefundPaymentRequest.swift b/CloverConnector/Classes/cloverconnector/api/RefundPaymentRequest.swift index 96e8c8c..f879c0e 100644 --- a/CloverConnector/Classes/cloverconnector/api/RefundPaymentRequest.swift +++ b/CloverConnector/Classes/cloverconnector/api/RefundPaymentRequest.swift @@ -23,31 +23,34 @@ public class RefundPaymentRequest: NSObject, Mappable { public var paymentId:String public var disablePrinting: Bool = false public var disableReceiptSelection: Bool = false + + /// Extra pass-through data used by external systems. Currently unused. Full support coming in a future release. +// public var extras: [String: String]? + /** * if fullRefund is true, the amount will be ignored. If fullRefund is false, * the amount must be provided */ - public var fullRefund:Bool = true + public var fullRefund:Bool? public init(orderId:String, paymentId:String, amount:Int?, fullRefund:Bool?) { self.orderId = orderId self.paymentId = paymentId self.amount = amount - self.fullRefund = fullRefund ?? false + self.fullRefund = fullRefund } public init(orderId:String, paymentId:String, amount:Int) { self.orderId = orderId self.paymentId = paymentId self.amount = amount - self.fullRefund = false } public init(orderId: String, paymentId:String, fullRefund:Bool) { self.orderId = orderId self.paymentId = paymentId self.amount = nil - self.fullRefund = true + self.fullRefund = fullRefund } /// :nodoc: @@ -65,6 +68,7 @@ public class RefundPaymentRequest: NSObject, Mappable { fullRefund <- map["fullRefund"] disablePrinting <- map["disablePrinting"] disableReceiptSelection <- map["disableReceiptSelection"] +// extras <- map["extras"] } } diff --git a/CloverConnector/Classes/cloverconnector/api/RegionalExtras.swift b/CloverConnector/Classes/cloverconnector/api/RegionalExtras.swift new file mode 100644 index 0000000..953c5e0 --- /dev/null +++ b/CloverConnector/Classes/cloverconnector/api/RegionalExtras.swift @@ -0,0 +1,27 @@ +// +// RegionalExtras.swift +// CloverConnector +// +// +// + +import Foundation + +/// This class represents the key values that should be used when setting region specific +/// transaction data in a request using the setRegionalExtras(Map) in a +/// request. The values can be used in conjunction with keys to induce the desired effect during +/// the processing of a transaction on the Clover payment device. +public final class RegionalExtras { + + // As of now, these are Argentina specific keys + public static let FISCAL_INVOICE_NUMBER_KEY = "com.clover.regionalextras.ar.FISCAL_INVOICE_NUMBER_KEY"; + public static let INSTALLMENT_NUMBER_KEY = "com.clover.regionalextras.ar.INSTALLMENT_NUMBER_KEY"; + public static let INSTALLMENT_PLAN_KEY = "com.clover.regionalextras.ar.INSTALLMENT_PLAN_KEY"; + + // Values - can be used in conjunction with keys to induce the desired effect during + // the processing of a transaction on the Clover payment device. + // Use with FISCAL_INVOICE_NUMBER_KEY + public static let SKIP_FISCAL_INVOICE_NUMBER_SCREEN_VALUE = "com.clover.regionalextras.ar.SKIP_FISCAL_INVOICE_NUMBER_SCREEN_VALUE"; + // Use with INSTALLMENT_NUMBER_KEY + public static let INSTALLMENT_NUMBER_DEFAULT_VALUE = "1"; +} diff --git a/CloverConnector/Classes/cloverconnector/api/VoidPaymentRefundRequest.swift b/CloverConnector/Classes/cloverconnector/api/VoidPaymentRefundRequest.swift index 261ed79..6c8d647 100644 --- a/CloverConnector/Classes/cloverconnector/api/VoidPaymentRefundRequest.swift +++ b/CloverConnector/Classes/cloverconnector/api/VoidPaymentRefundRequest.swift @@ -16,6 +16,9 @@ public class VoidPaymentRefundRequest: NSObject, Mappable { var disablePrinting: Bool? var disableReceiptSelection: Bool? + /// Extra pass-through data used by external systems. Currently unused. Full support coming in a future release. +// public var extras: [String: String]? + public required init(refundId: String, employeeId: String?, orderId: String?, disablePrinting: Bool?, disableReceiptSelection: Bool?) { self.refundId = refundId self.employeeId = employeeId @@ -31,6 +34,7 @@ public class VoidPaymentRefundRequest: NSObject, Mappable { employeeId <- map["employeeId"] disablePrinting <- map["disablePrinting"] disableReceiptSelection <- map["disableReceiptSelection"] +// extras <- map["extras"] } //The required initializer to conform to . Probably won't ever be used because we'll use one of the other two initialiers diff --git a/CloverConnector/Classes/cloverconnector/api/VoidPaymentRequest.swift b/CloverConnector/Classes/cloverconnector/api/VoidPaymentRequest.swift index 1d45828..e246bd5 100644 --- a/CloverConnector/Classes/cloverconnector/api/VoidPaymentRequest.swift +++ b/CloverConnector/Classes/cloverconnector/api/VoidPaymentRequest.swift @@ -22,6 +22,9 @@ public class VoidPaymentRequest:NSObject, Mappable { public var disablePrinting: Bool = false public var disableReceiptSelection: Bool = false + /// Extra pass-through data used by external systems. Currently unused. Full support coming in a future release. +// public var extras: [String: String]? + public required init(orderId:String, paymentId:String, voidReason:VoidReason) { self.orderId = orderId self.paymentId = paymentId @@ -42,7 +45,7 @@ public class VoidPaymentRequest:NSObject, Mappable { voidReason <- map["voidReason"] disablePrinting <- map["disablePrinting"] disableReceiptSelection <- map["disableReceiptSelection"] +// extras <- map["extras"] } - } diff --git a/CloverConnector/Classes/remotepaylib/Method.swift b/CloverConnector/Classes/remotepaylib/Method.swift index 81c2d26..56b5096 100644 --- a/CloverConnector/Classes/remotepaylib/Method.swift +++ b/CloverConnector/Classes/remotepaylib/Method.swift @@ -85,6 +85,8 @@ public enum Method:String { case REGISTER_FOR_CUST_DATA = "REGISTER_FOR_CUST_DATA" case CUSTOMER_PROVIDED_DATA_MESSAGE = "CUSTOMER_PROVIDED_DATA_MESSAGE" case CUSTOMER_INFO_MESSAGE = "CUSTOMER_INFO_MESSAGE" + case SHOW_RECEIPT_OPTIONS = "SHOW_RECEIPT_OPTIONS" + case SHOW_RECEIPT_OPTIONS_RESPONSE = "SHOW_RECEIPT_OPTIONS_RESPONSE" } diff --git a/CloverConnector/Classes/remotepaylib/PayIntent.swift b/CloverConnector/Classes/remotepaylib/PayIntent.swift index f2b58f9..5780ba4 100644 --- a/CloverConnector/Classes/remotepaylib/PayIntent.swift +++ b/CloverConnector/Classes/remotepaylib/PayIntent.swift @@ -33,7 +33,6 @@ public class PayIntent:Mappable { public fileprivate(set) var remotePrint:Bool? public fileprivate(set) var transactionNo:String? public fileprivate(set) var isForceSwipePinEntry:Bool? - public fileprivate(set) var disableRestartTransactionOnFail:Bool? public fileprivate(set) var externalPaymentId:String? public fileprivate(set) var vaultedCard:CLVModels.Payments.VaultedCard? public fileprivate(set) var allowOfflinePayment:Bool? @@ -42,6 +41,9 @@ public class PayIntent:Mappable { public fileprivate(set) var applicationTracking:CLVModels.Apps.AppTracking? public fileprivate(set) var allowPartialAuth = true public fileprivate(set) var transactionSettings:CLVModels.Payments.TransactionSettings? + + /// Extra pass-through data used by external systems. + public fileprivate(set) var passThroughValues: [String: String]? public init(amount:Int, externalId:String) { self.amount = amount @@ -76,7 +78,6 @@ public class PayIntent:Mappable { remotePrint <- map["remotePrint"] transactionNo <- map["transactionNo"] isForceSwipePinEntry <- map["isForceSwipePinEntry"] - disableRestartTransactionOnFail <- map["disableRestartTransactionOnFail"] externalPaymentId <- map["externalPaymentId"] vaultedCard <- map["vaultedCard"] allowOfflinePayment <- map["allowOfflinePayment"] @@ -85,6 +86,7 @@ public class PayIntent:Mappable { applicationTracking <- map["applicationTracking"] allowPartialAuth <- map["allowPartialAuth"] transactionSettings <- map["transactionSettings"] + passThroughValues <- map["passThroughValues"] } @@ -108,7 +110,6 @@ public class PayIntent:Mappable { public var remotePrint = false public var transactionNo:String? public var isForceSwipePinEntry:Bool = false - public var disableRestartTransactionOnFail = false public var externalPaymentId:String? = nil public var vaultedCard:CLVModels.Payments.VaultedCard? public var allowOfflinePayment:Bool? @@ -117,6 +118,9 @@ public class PayIntent:Mappable { public var applicationTracking:CLVModels.Apps.AppTracking? public var allowPartialAuth = true public var transactionSettings:CLVModels.Payments.TransactionSettings? + + /// Extra pass-through data used by external systems. + public var passThroughValues: [String: String]? /// Use for requesting a new payment from the Clover Device public init(amount:Int, externalId:String) { @@ -150,7 +154,6 @@ public class PayIntent:Mappable { payIntent.remotePrint = self.remotePrint payIntent.transactionNo = self.transactionNo payIntent.isForceSwipePinEntry = self.isForceSwipePinEntry - payIntent.disableRestartTransactionOnFail = self.disableRestartTransactionOnFail payIntent.externalPaymentId = self.externalPaymentId payIntent.vaultedCard = self.vaultedCard payIntent.allowOfflinePayment = self.allowOfflinePayment @@ -159,6 +162,7 @@ public class PayIntent:Mappable { payIntent.applicationTracking = self.applicationTracking payIntent.allowPartialAuth = self.allowPartialAuth payIntent.transactionSettings = self.transactionSettings + payIntent.passThroughValues = self.passThroughValues return payIntent } diff --git a/CloverConnector/Classes/remotepaylib/ShowReceiptOptionsMessage.swift b/CloverConnector/Classes/remotepaylib/ShowReceiptOptionsMessage.swift new file mode 100644 index 0000000..36d3feb --- /dev/null +++ b/CloverConnector/Classes/remotepaylib/ShowReceiptOptionsMessage.swift @@ -0,0 +1,56 @@ +// +// ShowReceiptOptionsMessage.swift +// CloverConnector +// +// +// + +import Foundation +import ObjectMapper + +public class ShowReceiptOptionsMessage: Message { + public var orderId: String? + public var paymentId: String? + public var refundId: String? + public var creditId: String? + public var disableCloverPrinting: Bool? + public var payment: CLVModels.Payments.Payment? + public var credit: CLVModels.Payments.Credit? + public var refund: CLVModels.Payments.Refund? + public var isReprint: Bool? + + init(orderId: String?, paymentId: String?, refundId: String?, creditId: String?, disableCloverPrinting: Bool?, payment: CLVModels.Payments.Payment?, credit: CLVModels.Payments.Credit?, refund: CLVModels.Payments.Refund?, isReprint: Bool?) { + self.orderId = orderId + self.paymentId = paymentId + self.refundId = refundId + self.creditId = creditId + self.disableCloverPrinting = disableCloverPrinting + self.payment = payment + self.credit = credit + self.refund = refund + self.isReprint = isReprint + super.init(method: .SHOW_RECEIPT_OPTIONS) + } + + public init() { + super.init(method: .SHOW_RECEIPT_OPTIONS) + } + + public required init?(map: Map) { + super.init(method: .SHOW_RECEIPT_OPTIONS) + } + + public override func mapping(map: Map) { + super.mapping(map: map) + self.orderId <- map["orderId"] + self.paymentId <- map["paymentId"] + self.refundId <- map["refundId"] + self.creditId <- map["creditId"] + self.disableCloverPrinting <- map["disableCloverPrinting"] + self.payment <- map["payment"] + self.credit <- map["credit"] + self.refund <- map["refund"] + self.isReprint <- map["isReprint"] + } +} + diff --git a/CloverConnector/Classes/remotepaylib/ShowReceiptOptionsResponseMessage.swift b/CloverConnector/Classes/remotepaylib/ShowReceiptOptionsResponseMessage.swift new file mode 100644 index 0000000..099c1f3 --- /dev/null +++ b/CloverConnector/Classes/remotepaylib/ShowReceiptOptionsResponseMessage.swift @@ -0,0 +1,32 @@ +// +// ShowReceiptOptionsResponseMessage.swift +// CloverConnector +// +// +// + +import Foundation +import ObjectMapper + +public class ShowReceiptOptionsResponseMessage: Message { + public var status: ResultStatus + public var reason: String + + public init(status: ResultStatus, reason: String) { + self.status = status + self.reason = reason + super.init(method: .SHOW_RECEIPT_OPTIONS_RESPONSE) + } + + public required init?(map: Map) { + self.status = .FAIL + self.reason = "" + super.init(method: .SHOW_RECEIPT_OPTIONS_RESPONSE) + } + + public override func mapping(map:Map) { + super.mapping(map: map) + self.status <- map["status"] + self.reason <- map["reason"] + } +} diff --git a/README.md b/README.md index 4e004a1..e700b70 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,9 @@ A Swift implementation of the CloverConnector to enable iOS and MacOS to communi ## Version -Current version: 3.0.0 +Current version: 3.0.1 -NOTE: Full support for version 3.0.0 of the SDK requires version 208 or higher of the Pay Display app. +NOTE: Full support for version 3.0.1 of the SDK requires version 208 or higher of the Pay Display app. ### Dependencies - ObjectMapper - Provides JSON serialization and deserialization. @@ -20,9 +20,9 @@ NOTE: Full support for version 3.0.0 of the SDK requires version 208 or higher o This SDK is provided with an example implementation available at [https://github.com/clover/remote-pay-ios-examples](https://github.com/clover/remote-pay-ios-examples) ## Using CloverConnector in your project -* Update your Podspec to include the queuePriority branch of Starscream, 3.0.0 branch of CloverConnector, and the Swift 4.2 post_install script +* Update your Podspec to include the queuePriority branch of Starscream, 3.0.1 branch of CloverConnector, and the Swift 4.2 post_install script * pod 'Starscream', :git => 'https://github.com/clover/Starscream.git', :branch => 'queuePriority-2.0.0' - * pod 'CloverConnector', :git => 'https://github.com/clover/remote-pay-ios.git', :tag => '3.0.0' + * pod 'CloverConnector', :git => 'https://github.com/clover/remote-pay-ios.git', :tag => '3.0.1' * Add the post_install script (see example) to set the Swift version of the pods to 4.2 * Example cocoapod (http://cocoapods.org/) `Podfile` snippet --- @@ -37,7 +37,7 @@ target 'RegisterApp' do # Defining it here in the PodFile overrides the podspec dependency, which isn't allowed to specify a specific location and branch pod 'Starscream', :git => 'https://github.com/clover/Starscream.git', :branch => 'queuePriority-2.0.0' - pod 'CloverConnector', :git => 'https://github.com/clover/remote-pay-ios.git', :tag => '3.0.0' + pod 'CloverConnector', :git => 'https://github.com/clover/remote-pay-ios.git', :tag => '3.0.1' post_install do |installer| ['CloverConnector'].each do |targetName| @@ -153,8 +153,8 @@ class ConnectionManager : DefaultCloverConnectorListener, PairingDeviceConfigura * [Release Notes](https://github.com/clover/remote-pay-ios/releases) * [Example Implementation](https://github.com/clover/remote-pay-ios-examples) * [Tutorial for the iOS SDK](https://docs.clover.com/build/getting-started-with-clover-connector/?sdk=ios) -* [API Documentation](https://clover.github.io/remote-pay-ios/3.0.0/docs/index.html) +* [API Documentation](https://clover.github.io/remote-pay-ios/3.0.1/docs/index.html) * [Clover Developer Community](https://community.clover.com/index.html) ## License -Copyright © 2018 Clover Network, Inc. All rights reserved. +Copyright © 2019 Clover Network, Inc. All rights reserved.