preauthorisation and completion - AEVI-AppFlow/pos-android-sdk GitHub Wiki
Pre-authorisation is the process of holding or reserving a particular amount of money without actually charging it, and completion is the finalisation of a pre-authorisation where the customer is charged some actual amount. This process is commonly used for reservations such as hotels or cars and for starting a tab in a bar, etc.
For general information about initiating payments please see Implementing POS apps. For information about how to handle responses (regardless of type), see Handling Responses.
Payment
requests are built via the PaymentBuilder
. Below are the relevant parameters for a pre-authorisation.
String flowName = getPreAuthFlow(); // Optional, if the flow name is known and required
Amounts amounts = new Amounts(1000, "USD"); // $10.00
PaymentBuilder paymentBuilder = new PaymentBuilder()
.withPaymentFlow("preAuthorisation", flowName)
.withAmounts(amounts);
// If there is a basket
paymentBuilder.withBasket(basket);
// 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();
TransactionResponse preAuthResponse = getPreAuthResponse(); // Extract from the pre-auth PaymentResponse
String flowName = getPreAuthCompletionFlow(); // Optional, if the flow name is known and required
Amounts amounts = new Amounts(1000, "USD"); // $10.00
PaymentBuilder paymentBuilder = new PaymentBuilder()
.withPaymentFlow("preAuthCompletion", flowName)
.withAmounts(amounts)
.addAdditionalData(preAuthResponse.getReferences()); // Ensure you return all references from the original response so that the payment app can link this back to the previous pre-auth transaction
// If there is a basket
paymentBuilder.withBasket(basket);
// 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();