Skip to content

Instantly share code, notes, and snippets.

View WirecardMobileServices's full-sized avatar

WirecardMobileServices WirecardMobileServices

View GitHub Profile
import com.annimon.stream.Collectors;
import com.annimon.stream.Stream;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Currency;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
//We assume you have complete a Sale or retreived a Sale Response using History query/search.
//Note: having a valid Sale Response object is mandatory for the steps below.
let saleResponse: WDSaleResponse = WDSaleResponse() //In your code, instead of an empty sale, saleResponse is your actual sale response object
//Receipt for individual payments:
//If you want the receipt for a payment you know its id (instead of the whole Sale), you can get the saleResponse of that subPayment by using the function:
//let subPaymentResponse = saleResponse.paymentForReceipt:yourPaymentId
//subPaymentResponse.receipt(:showReturns:format:...
import com.jakewharton.rxrelay2.BehaviorRelay;
import com.jakewharton.rxrelay2.Relay;
import java.math.BigDecimal;
import de.wirecard.epos.model.sale.builder.ReferenceTerminalPreAuthorizationSupplementRequest;
import de.wirecard.epos.model.sale.builder.payment.CardTerminalPreAuthorizationSupplementPayment;
import de.wirecard.epos.model.with.With;
import de.wirecard.epos.model.with.WithBase;
import de.wirecard.epos.util.events.Event;
@WirecardMobileServices
WirecardMobileServices / WDePOS-SaleRequest-PreAuthorize-Supplement.swift
Created December 4, 2019 11:51
Sale Request PreAuthorization Supplement
let sdk:WDePOS = WDePOS.sharedInstance()
// Create the instance of the Sale Request
// Here the minimum data is depicted
let saleRequest:WDSaleRequest! = WDSaleRequest.init(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
@WirecardMobileServices
WirecardMobileServices / WDePOS-SaleRequest-PreAuthorize.m
Created November 5, 2019 07:43
Sale Request - PreAuthorization
//End of SDK Setup process
CurrentUserCompletion setupCompletion = ^( WDMerchantUser * _Nullable currentUser, WDMerchantCashier * _Nullable cashier, NSError * _Nullable error){
//Current User is returned upon successful login
//if the Cash Management is enabled and Cashier record exist for the current user then the Cashier is returned also
};
// The SDK is initialized as shared instance so can be accessed
// from multiple View Controllers
WDePOS *sdk = [WDePOS sharedInstance];
@WirecardMobileServices
WirecardMobileServices / WDePOS-SaleRequest-PreAuthorize.swift
Last active November 5, 2019 07:44
Sale Request PreAuthorization
let sdk:WDePOS = WDePOS.sharedInstance()
// Create the instance of the Sale Request
// Here the minimum data is depicted
let saleRequest:WDSaleRequest! = WDSaleRequest.init(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
@WirecardMobileServices
WirecardMobileServices / WDePOS-FileManager-GetAndDownloadFile.swift
Created September 16, 2019 13:17
Download a previously uploaded file by its ID
let sdk: WDePOS = WDePOS.sharedInstance()
//Example for getting a zip of receipt images previously uploaded
sdk.fileManager.files("merchantId", category: "receiptImages") { (files, error) in
if error != nil || files == nil {
//Unknown error when loading receipt images - \(error?.localizedDescription ?? "")")
return
}
guard let files = files, let file = files.first, let fileId = file.internalId, let fileName = file.originalFileName else {
import de.wirecard.epos.EposSDK;
import de.wirecard.epos.model.with.With;
import de.wirecard.epos.model.with.WithBase;
import de.wirecard.epos.model.with.WithFields;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
//handling FileRecords
WithFields withFields = With.fields().scheduler(Schedulers.newThread());
epos.fileManager()
import com.jakewharton.rxrelay2.BehaviorRelay;
import com.jakewharton.rxrelay2.Relay;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import de.wirecard.epos.model.sale.builder.PurchaseRequest;
import de.wirecard.epos.model.sale.builder.payment.EftCardPurchasePayment;
import de.wirecard.epos.model.sale.sales.SaleItem;
@WirecardMobileServices
WirecardMobileServices / WDePOS-SaleRequest-EFTCard.swift
Created June 26, 2019 11:45
ale Request for performing the EFT Card payment
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