Integrate our products into your software. Let's make payment happen together!
Look at all the possibilitiesWhen a terminal was unable to send the response of a transaction to the SDK it will ask to recover the last payment. Therefore, this method was created.
The SDK has two specific error codes related to this situation. The first one is TERMINAL_CONNECTION_LOST and means that there was a send/read error or a send timeout during the transaction.
The second one is RESPONSE_TIMEOUT and indicates that there was a read timeout which means that the terminal didn’t send a response back in time.
When you receive one of these errors you need to perform a payment recovery to determine the status of the last performed transaction.
Automatic payment recovery will ask the terminal for it’s last message and will verify if the requestId of the Payment request and last message from the terminal are equal. When this is equal it will deliver the receipt of the last transaction which was not completed for some reason. The terminal will no longer require a recovery and can be used again for new transactions. \
When the payment recovery is successful you will receive a PaymentAdministrationResult in the onPaymentAdministrationSuccess delegate method. The PaymentAdministrationResult will consist of 2 results, the result of the RecoverPayment request and the result of the original transaction that is being recovered. All the information about the original transaction (transaction state, amount, requestId, timestamp…) can be found under PaymentAdministrationResult.result, this result is of the type PaymentResult. The information about the RecoverPayment request itself can be found within the PaymentAdministrationResult itself.
ExternalTerminal externalTerminal = ExternalTerminal.builder() .ipAddress(ipAddress) // can be found using getting-started guide .port(terminalPort) // 4100 for OPI-NL & 20002 for OPI-DE .compatibilityPort(compatibilityPort) // 4102 for OPI-NL & 20007 for OPI-DE .socketMode(socketMode) // Dual-Socket for OPI-NL & Single-Socket for OPI-DE & OPI-NL .terminalType(terminalType) // EnumType which contains terminal protocol combined attended/unattended type .cutPreviousConnection(true) // This option is only for OPI-DE terminals. This allows you to cancel an ongoing payment within the SDK, when starting a recoverPayment. This should only be used when experiencing a lot of issues, where you don't receive an answer from the terminal for a long period of time. .build(); String paymentRequestId; //RequestId of the payment you want to recover TerminalDelegate terminalDelegate = new TerminalDelegate() { @Override public void onPaymentAdministrationSuccess(PaymentAdministrationResult result) { //contains code which handles a successful ticket reprint //The result of the last transaction is embedded in the PaymentAdministrationResult, to get this result you can use the following code: (PaymentResult) result.result() } @Override public void onError(Error error) { //contains code which handles a failed reprint ticket } @Override public void printMerchantReceiptAndSignature(PaymentReceipt receipt) { //contains code which handles receiving a merchant receipt } @Override public void printCustomerReceiptAndSignature(PaymentReceipt receipt) { //contains code which handles receiving a customer receipt } @Override public void storeEJournal(String journal) { //contains code which handles storing a E-Journal } }; TerminalApi terminalService = new TerminalService(); terminalService.recoverPayment(externalTerminal, paymentRequestId, terminalDelegate);
ExternalTerminal externalTerminal = ExternalTerminal.builder() .ipAddress(ipAddress) // can be found using getting-started guide .port(terminalPort) // 4100 for OPI-NL & 20002 for OPI-DE .compatibilityPort(compatibilityPort) // 4102 for OPI-NL & 20007 for OPI-DE .socketMode(socketMode) // Dual-Socket for OPI-NL & Single-Socket for OPI-DE & OPI-NL .terminalType(terminalType) // EnumType which contains terminal protocol combined attended/unattended type .build(); TerminalDelegate terminalDelegate = new TerminalDelegate() { @Override public void onPaymentAdministrationSuccess(PaymentAdministrationResult result) { //contains code which handles a successful ticket reprint //The result of the last transaction is embedded in the PaymentAdministrationResult, to get this result you can use the following code: (PaymentResult) result.result() } @Override public void onError(Error error) { //contains code which handles a failed ticket reprint } }; TerminalApi terminalService = new TerminalService(); terminalService.repeatLastMessage(externalTerminal, terminalDelegate);
When the Payment Recovery was successful, but the Customer Receipt or EJournal were not retrieved you can retrieve them by performing a Reprint Last Ticket.