public final class Transaction extends ServiceConnector implements ITransaction
ServiceConnector.InternalServiceConnectionACTION_BIND_V2, SERVICES_PACKAGE| Modifier and Type | Method and Description |
|---|---|
boolean |
abortOngoingTransaction()
Abort the started transaction in case of any event happening at the cash register after a
start has been triggered but before the payment mean is detected.
|
java.util.List<Currency> |
getAvailableCurrencies()
Get the list of any available currencies supported by the Point Of Sale (POS) or payment
terminal.
|
java.util.List<java.lang.Integer> |
getAvailablePaymentMeans()
Get the list of any available payment means supported by the POS such as swipe, smart card,
contactless, QR Code...
|
java.util.List<TransactionType> |
getAvailableTransactionTypeList()
Get the list of any available transaction types supported by the POS.
|
java.util.List<java.lang.Integer> |
getAvailableTransactionTypes()
Get the list of any available transaction types supported by the POS.
|
static ITransaction |
getInstance(android.content.Context context)
Return a global instance of Transaction, which is the default implementation of
ITransaction, and instantiate it if needed. |
protected java.lang.String |
getServiceName()
Must be overrided to provide service class name used for binding.
|
protected void |
onServiceReady(android.os.IBinder service)
Internal callback when service is connected.
|
protected void |
onServiceUnbinded()
Internal callback when service is disconnected.
|
TransactionResult |
recover(RecoveryInputData inputData)
Start a transaction recovering to the parameter filled in recoverId field.
|
void |
registerTransactionDoneListener(ITransactionDoneListener listener)
Register a new listener for TransationDone event sent within a transaction result.
|
TransactionRequest |
start(TransactionInputData inputData)
Start a transaction according to the parameters filled in inputData field.
|
void |
unregisterTransactionDoneListener(ITransactionDoneListener listener)
Unregister an existing transaction listener.
|
connect, connectSync, disconnect, ensureServiceIsReady, getBindIntent, getContext, isConnectedclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitconnect, disconnect, isConnectedpublic static ITransaction getInstance(android.content.Context context)
ITransaction, and instantiate it if needed.
Be aware that only one instance will be created for the whole application, so the associated
context should not be a component which could be destroyed at some point, ie. an Activity.
Passing the Application to this method is preferred over other context types.
context - A valid context to initialize the instance.public java.util.List<Currency> getAvailableCurrencies() throws IngenicoException
Usage example:
ITransactiontransaction = Transaction.getInstance(context); // Get the available currenciesList<Currency> currencies = transaction.getAvailableCurrencies(); // Check that EUR is available boolean euroIsAvailable = false; for (Currencycurrency : currencies) { if (currency.getNumericCode() == 978L) { euroIsAvailable = true; break; } } if (euroIsAvailable) { // Do things with euro }
getAvailableCurrencies in interface ITransactionIngenicoExceptionpublic java.util.List<java.lang.Integer> getAvailableTransactionTypes()
throws IngenicoException
Usage example:
ITransactiontransaction = Transaction.getInstance(context); // Get the available transaction typesList<Integer> transactionTypes = transaction.getAvailableTransactionTypes(); // Check that SALE is available boolean saleIsAvailable = false; for (IntegertransactionType : transactionTypes) { if (transactionType ==TransactionTypes.SALE) { saleIsAvailable = true; break; } } if (saleIsAvailable) { // Ok, we can proceed with a transaction sale }
getAvailableTransactionTypes in interface ITransactionIngenicoExceptionTransactionTypes for predefined valuespublic java.util.List<TransactionType> getAvailableTransactionTypeList() throws IngenicoException
Usage example:
ITransactiontransaction = Transaction.getInstance(context); // Get the available transaction typesList<TransactionType> transactionTypes = transaction.getAvailableTransactionTypeList(); // Check that SALE is available boolean saleIsAvailable = false; for (TransactionTypetransactionType : transactionTypes) { if (transactionType.getValue() ==TransactionTypes.SALE && transactionType.getLabel().equals("Sale")) { saleIsAvailable = true; break; } } if (saleIsAvailable) { // Ok, we can proceed with a transaction sale }
getAvailableTransactionTypeList in interface ITransactionIngenicoExceptionpublic java.util.List<java.lang.Integer> getAvailablePaymentMeans()
throws IngenicoException
Usage example:
ITransactiontransaction = Transaction.getInstance(context); // Get the available payment meansList<Integer> paymentMeans = transaction.getAvailablePaymentMeans(); // Check that CONTACT_CHIP is available boolean contactChipIsAvailable = false; for (Integermean : paymentMeans) { if (mean ==PaymentMeans.CONTACT_CHIP) { contactChipIsAvailable = true; break; } } if (contactChipIsAvailable) { // ok, we can process transactions with contact chip }
getAvailablePaymentMeans in interface ITransactionIngenicoExceptionPaymentMeans for predefined valuespublic boolean abortOngoingTransaction()
throws IngenicoException
Usage example:
if (!transaction.abortOngoingTransaction()) {
// Could not abort the ongoing transaction
} else {
// Transaction aborted, the transaction done event status will state that the
// transaction was aborted
}
abortOngoingTransaction in interface ITransactionIngenicoExceptionpublic TransactionRequest start(TransactionInputData inputData) throws IngenicoException
start in interface ITransactioninputData - transaction parametersIngenicoExceptionpublic TransactionResult recover(RecoveryInputData inputData) throws IngenicoException
recover in interface ITransactioninputData - transaction recovering parametersIngenicoExceptionpublic void registerTransactionDoneListener(ITransactionDoneListener listener)
ITransactionregisterTransactionDoneListener in interface ITransactionpublic void unregisterTransactionDoneListener(ITransactionDoneListener listener)
ITransactionunregisterTransactionDoneListener in interface ITransactionprotected java.lang.String getServiceName()
ServiceConnectorgetServiceName in class ServiceConnectorprotected void onServiceReady(android.os.IBinder service)
ServiceConnectoronServiceReady in class ServiceConnectorprotected void onServiceUnbinded()
ServiceConnectoronServiceUnbinded in class ServiceConnector