sale - AEVI-AppFlow/pos-android-sdk GitHub Wiki

A sale is commonly also referred to as payment or purchase. It involves charging a customer for services or goods. As this is a payment flow type, it can go through a number of stages and be augmented by a number of flow services. That process is not detailed here, but rather how to initiate a sale with relevant parameters.

For general information about initiating payments please see Implementing POS apps. For information about how to handle responses (regardless of type), see Handling Responses.

Create sale request

Payment requests are built via the PaymentBuilder. Below are the relevant parameters for a sale.

String flowName = getSaleFlow(); // Optional, if the flow name is known and required
Amounts amounts = new Amounts(1000, "USD"); // $10.00
PaymentBuilder paymentBuilder = new PaymentBuilder()
        .withPaymentFlow("sale", flowName)
        .withAmounts(amounts);

// If there is a basket
paymentBuilder.withBasket(basket);

// If splitting the bill
paymentBuilder.withSplitEnabled(true);

// If you have a card token stored that should be used
paymentBuilder.withCardToken(token);

// If you have customer details
paymentBuilder.withCustomer(customer);

// If you want to add some bespoke data (values can be of any type)
paymentBuilder.addAdditionalData("myDataKey", "myDataValue");

// When done, build the payment
Payment payment = paymentBuilder.build();
⚠️ **GitHub.com Fallback** ⚠️