public final class Transaction extends ServiceConnector implements ITransaction
ServiceConnector.InternalServiceConnection
ACTION_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, isConnected
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
connect, disconnect, isConnected
public 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:
ITransaction
transaction = Transaction.getInstance(context); // Get the available currenciesList
<Currency
> currencies = transaction.getAvailableCurrencies(); // Check that EUR is available boolean euroIsAvailable = false; for (Currency
currency : currencies) { if (currency.getNumericCode() == 978L) { euroIsAvailable = true; break; } } if (euroIsAvailable) { // Do things with euro }
getAvailableCurrencies
in interface ITransaction
IngenicoException
public java.util.List<java.lang.Integer> getAvailableTransactionTypes() throws IngenicoException
Usage example:
ITransaction
transaction = Transaction.getInstance(context); // Get the available transaction typesList
<Integer
> transactionTypes = transaction.getAvailableTransactionTypes(); // Check that SALE is available boolean saleIsAvailable = false; for (Integer
transactionType : transactionTypes) { if (transactionType ==TransactionTypes
.SALE) { saleIsAvailable = true; break; } } if (saleIsAvailable) { // Ok, we can proceed with a transaction sale }
getAvailableTransactionTypes
in interface ITransaction
IngenicoException
TransactionTypes for predefined values
public java.util.List<TransactionType> getAvailableTransactionTypeList() throws IngenicoException
Usage example:
ITransaction
transaction = Transaction.getInstance(context); // Get the available transaction typesList
<TransactionType
> transactionTypes = transaction.getAvailableTransactionTypeList(); // Check that SALE is available boolean saleIsAvailable = false; for (TransactionType
transactionType : 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 ITransaction
IngenicoException
public java.util.List<java.lang.Integer> getAvailablePaymentMeans() throws IngenicoException
Usage example:
ITransaction
transaction = Transaction.getInstance(context); // Get the available payment meansList
<Integer
> paymentMeans = transaction.getAvailablePaymentMeans(); // Check that CONTACT_CHIP is available boolean contactChipIsAvailable = false; for (Integer
mean : paymentMeans) { if (mean ==PaymentMeans
.CONTACT_CHIP) { contactChipIsAvailable = true; break; } } if (contactChipIsAvailable) { // ok, we can process transactions with contact chip }
getAvailablePaymentMeans
in interface ITransaction
IngenicoException
PaymentMeans for predefined values
public 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 ITransaction
IngenicoException
public TransactionRequest start(TransactionInputData inputData) throws IngenicoException
start
in interface ITransaction
inputData
- transaction parametersIngenicoException
public TransactionResult recover(RecoveryInputData inputData) throws IngenicoException
recover
in interface ITransaction
inputData
- transaction recovering parametersIngenicoException
public void registerTransactionDoneListener(ITransactionDoneListener listener)
ITransaction
registerTransactionDoneListener
in interface ITransaction
public void unregisterTransactionDoneListener(ITransactionDoneListener listener)
ITransaction
unregisterTransactionDoneListener
in interface ITransaction
protected java.lang.String getServiceName()
ServiceConnector
getServiceName
in class ServiceConnector
protected void onServiceReady(android.os.IBinder service)
ServiceConnector
onServiceReady
in class ServiceConnector
protected void onServiceUnbinded()
ServiceConnector
onServiceUnbinded
in class ServiceConnector