I would like to be able to increase the waiting time before an error is displayed in my code of this script… but I don’t have much idea how to do it…
It is assumed that when opening the modal sometimes it opens very quickly and the server shows an error…
This opening modal is from a gateway in Ecuador…
JavaScript
x
125
125
1
<script>
2
3
$("#content-hook_order_confirmation").addClass("hide");
4
$("#content-hook_payment_return").addClass("hide");
5
$('#contenedor').insertBefore('#content');
6
7
var PaymentCheckout = new PaymentCheckout.modal({
8
client_app_code: "{$client_app_code}",
9
client_app_key: "{$client_app_key}",
10
locale: "es",
11
env_mode: "{$ambiente}",
12
onOpen: function() {
13
console.log("se abrio modal");
14
},
15
onClose: function() {
16
console.log("cerró modal");
17
},
18
onResponse: function(response) {
19
20
console.log(response);
21
announceTransaction(response);
22
if (response.transaction["status_detail"] == 3) {
23
24
showMessageSuccess();
25
26
} else {
27
showMessageError();
28
}
29
30
}
31
});
32
33
34
35
var btnOpenCheckout = document.querySelector(".Rot");
36
var btnOpenCheckoutDifCon = document.querySelector(".DifCon");
37
var btnOpenCheckoutDifSin = document.querySelector(".DifSin");
38
39
btnOpenCheckout.addEventListener("click", function(){
40
41
PaymentCheckout.open({
42
user_id: "{$uid}",
43
user_email: "{$email}",
44
user_phone: "{$telnumber}",
45
order_description: "{$descripcion}",
46
order_amount: {$order_amount},
47
order_reference: "{$dev_reference}",
48
order_vat: {$vat},
49
order_tax_percentage: {$tax_percentage},
50
order_taxable_amount: {$taxable_amount}
51
52
});
53
});
54
55
56
btnOpenCheckoutDifCon.addEventListener("click", function(){
57
58
PaymentCheckout.open({
59
user_id: "{$uid}",
60
user_email: "{$email}",
61
user_phone: "{$telnumber}",
62
order_description: "{$descripcion}",
63
order_amount: {$order_amount},
64
order_reference: "{$dev_reference}",
65
order_vat: {$vat},
66
order_tax_percentage: {$tax_percentage},
67
order_taxable_amount: {$taxable_amount},
68
order_installments_type: 2,
69
});
70
});
71
72
73
btnOpenCheckoutDifSin.addEventListener("click", function(){
74
75
PaymentCheckout.open({
76
user_id: "{$uid}",
77
user_email: "{$email}",
78
user_phone: "{$telnumber}",
79
order_description: "{$descripcion}",
80
order_amount: {$order_amount},
81
order_reference: "{$dev_reference}",
82
order_vat: {$vat},
83
order_tax_percentage: {$tax_percentage},
84
order_taxable_amount: {$taxable_amount},
85
order_installments_type: 3,
86
});
87
});
88
89
90
91
window.addEventListener("popstate", function() {
92
PaymentCheckout.close();
93
});
94
95
96
97
function showMessageSuccess() {
98
$("#message").addClass("hide");
99
$("#buttonspay").addClass("hide");
100
$("#messagetwo").removeClass("hide");
101
102
}
103
104
105
function showMessageError() {
106
107
$("#message").addClass("hide");
108
$("#buttonspay").addClass("hide");
109
$("#messagetres").removeClass("hide");
110
111
}
112
113
function announceTransaction(data) {
114
fetch("{$paymentez_hook}", {
115
method: "POST",
116
body: JSON.stringify(data)
117
}).then(function(response) {
118
console.log(response);
119
}).catch(function(myJson) {
120
console.log(myJson);
121
});
122
}
123
124
</script>
125
Advertisement
Answer
use setTimeOut function to wait for. An example of this can be
JavaScript
1
4
1
setTimeout(function(){
2
//your code
3
},5000)
4
5000 means 5 seconds