Created
June 26, 2019 11:45
-
-
Save WirecardMobileServices/b0f05bcc76ac4303f797846ad663e00b to your computer and use it in GitHub Desktop.
ale Request for performing the EFT Card payment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let sdk: WDePOS = WDePOS.sharedInstance() | |
// Discover active terminals and use it - in this case we use the first one | |
// Alternatively use the one discovered previously and stored in an instance variable (or user preferences) | |
sdk.terminalManager.discoverDevices(WDExtensionTypeUUID.WDPosMateExtensionUUID) { (terminals: [WDTerminal]?, error: Error?) in | |
if let terminalsArr = terminals { | |
//Here we assume that at least one terminal is present | |
let terminal:WDTerminal! = terminalsArr.first | |
// Create the instance of the Sale Request | |
// Here the minimum data is depicted | |
let saleRequest = WDSaleRequest(uniqueId: "yourSaleUniqueID", // provide your unique ID to identify the Sale | |
location: nil, // provide the GPS location for this payment e.g. the mobile device location | |
inclusiveTaxes: true, // Tax inclusive/exclusive flag | |
currency: "EUR", // Currency to use for this Sale | |
note: "Test Sale", // Top level note for this sale | |
gratuityTaxRate: nil // Gratuity tax rate - nil if no gratuity to be set later in the payment flow | |
)! | |
// Create one item named "Item 1" costing 10.00 EUR at 20% Tax | |
saleRequest.addSaleItem(NSDecimalNumber(value: 10), // Item Unit price | |
quantity: NSDecimalNumber(value: 10), // Item Quantity | |
taxRate: NSDecimalNumber(value: 20), // Item Tax rate | |
itemDescription: "Item 1", // Item description | |
productId: nil, | |
externalProductId: nil // External product ID - in the case you are using ERP - such as SAP and wish to refer to the product | |
) | |
// Set this Sale to be settled by Card transaction | |
saleRequest.addEFTCardPayment(NSDecimalNumber.init(value: 10), terminal: terminal!) | |
// The total amount of Sale can be settled by more than on transaction type e.g. Cash and Card | |
// Should you wish to do so you would add additional transaction e.g. saleRequest.addCardPayment ... | |
// Create Payment Configuration to be used in the Pay API later | |
let paymentConfiguration:WDSaleRequestConfiguration! = WDSaleRequestConfiguration(saleRequest: saleRequest) | |
} | |
else{ | |
NSLog("No active terminal found") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment