Example to send amount to a terminal and wait response
cyberweb-denis opened this issue · comments
cyberweb-denis commented
Dear,
Does anyone have a sample code to send an amount to a terminal and wait for the payment status?
Thank you in advance
thomashunziker commented
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.
cyberweb-denis commented
Ok And have you got a example in javascript ? because if i use the
script of the website, i have a error Uncaught ReferenceError:
TerminalTillConnection is not defined
|<script
src="https://app-wallee.com/assets/payment/terminal-till-connection.js"
type="text/javascript"></script>
<script>
var tillConnection = new TerminalTillConnection({url:
"wss://app-wallee.com/terminal-websocket",token:
"K/5LA1H7ajm+GhyM9LA+9SiBS3M/ABkYxoAJvDhgsY8="});
tillConnection.subscribe("notification", function(payload){
// Display the information on the till.
});
tillConnection.subscribe("question", function(payload, callback){
// Display the question on the till and allow the attendant to
chose one of the options.
// Call the callback method with the chosen option's identifier as
argument.
callback(optionIdentifier);
});
tillConnection.subscribe("charged", function(){
// The transaction has been successfully charged.
});
tillConnection.subscribe("canceled", function(){
// The payment was canceled.
});
tillConnection.subscribe("error", function(error){
// An error occurred during the process of a WebSocket request.
});
tillConnection.subscribe("connected", function(){
// The connection has been established.
});
tillConnection.subscribe("disconnected", function(){
// The connection has been disconnected or lost.
});
tillConnection.connect();|
Le 1/09/20 à 21:14, thomashunziker a écrit :
…
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.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#5 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AQ2TYFAX7SEOJGATVYGTWQLSDVBY5ANCNFSM4QR7FJSA>.
schurter-wallee commented
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);
}
cyberweb-denis commented
Hello
The javascript is loaded but always the same Uncaught ReferenceError:
TerminalTillConnection is not defined
It's very strange
Le 2/09/20 à 09:45, schurter-wallee a écrit :
…
Hi @cyberweb-denis <https://github.com/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);
}
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#5 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AQ2TYFESX553UWEOZQSJAWTSDXZZNANCNFSM4QR7FJSA>.