@@ -219,39 +223,44 @@
const successElements = Array.from(document.getElementsByClassName('success'));
const failedElements = Array.from(document.getElementsByClassName('failed'));
- function handleResponse(response){
- console.log(response.target.response);
+ function handleResponse(response) {
+
const json = JSON.parse(response.target.response);
if (json.ready) {
clearInterval(interval);
- if(statusChangeButton !== null){
+
+ if (statusChangeButton !== null) {
statusChangeButton.style.display = 'none';
}
- loadingElements.forEach(function(element){
+
+ loadingElements.forEach(function (element) {
element.style.display = 'none';
});
+
returnButton.style.display = 'block';
- returnButton.href= json.redirectUrl;
- if(json.status === 'open' || json.status === 'paid'){
- successElements.forEach(function(element){
+ returnButton.href = json.redirectUrl;
+
+ if (json.success) {
+ successElements.forEach(function (element) {
element.style.display = 'block';
});
- }else{
- failedElements.forEach(function(element){
+ } else {
+ failedElements.forEach(function (element) {
element.style.display = 'block';
});
}
+ window.location.href = json.redirectUrl;
}
}
+
function requestStatus() {
const xhr = new XMLHttpRequest();
xhr.open('GET', '/mollie/pos/{{ swOrderId }}/{{ molliePaymentId }}/status');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.onload = handleResponse;
-
xhr.onerror = handleResponse;
xhr.send();
diff --git a/tests/Cypress/cypress/e2e/storefront/payment-methods/pos.cy.js b/tests/Cypress/cypress/e2e/storefront/payment-methods/pos.cy.js
index acd284892..bbf8727b2 100644
--- a/tests/Cypress/cypress/e2e/storefront/payment-methods/pos.cy.js
+++ b/tests/Cypress/cypress/e2e/storefront/payment-methods/pos.cy.js
@@ -65,7 +65,7 @@ describe('POS Terminals', () => {
shopware.prepareDomainChange();
checkout.placeOrderOnConfirm();
- cy.contains('waiting for payment');
+ cy.contains('Follow the instructions on the terminal');
})
})
})