wallee-payment / php-sdk

Wallee PHP SDK

Home Page:https://wallee.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Example to send amount to a terminal and wait response

cyberweb-denis opened this issue · comments

Dear,

Does anyone have a sample code to send an amount to a terminal and wait for the payment status?

Thank you in advance

Dear Denis,

At the moment you would have to use websockets if you want to listen for the transaction state change. However websockets are not that simple to implement with PHP.

I would recommend to proceed with one of the following options:

  • You are using JavaScript in the browser for this. With JavaScript is the creation of websockets etc. relatively simple.
  • We are currently working on a way that you can create a transaction on the terminal and listen for the state change via long polling. This will simplify the integration. However this will take at least two months until this option is available.

Hi @cyberweb-denis

You need to make sure, that terminal-till-connection.js is loaded before you run the actual commands. You can do this by wrapping the calls in a function and invoke it after the DOM is ready:

function openConnection() {
    var tillConnection = new TerminalTillConnection(...);
    ...
}

if (document.readyState != 'loading'){
    openConnection();
} else {
    document.addEventListener('DOMContentLoaded', openConnection);
}