feat: qr payment flow update
This commit is contained in:
@@ -226,10 +226,10 @@
|
||||
<% mmqr = PaymentMethodSetting.find_by(payment_method: 'MMQR') %>
|
||||
<% if mmqr.present? && mmqr.is_active %>
|
||||
<div class="payment-card" id="dynamic_qr">
|
||||
<div class="payment-icon text-center">
|
||||
<img src="/image/mmqr.webp" width="100" height="100" />
|
||||
</div>
|
||||
<div class="payment-label text-center">Click here to pay with MMQR</div>
|
||||
<div class="payment-icon text-center">
|
||||
<img src="/image/mmqr.webp" width="100" height="100" />
|
||||
</div>
|
||||
<div class="payment-label text-center">Click here to pay with MMQR</div>
|
||||
</div>
|
||||
|
||||
<div class="text-center text-bold text-muted">
|
||||
@@ -282,43 +282,85 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
document.querySelector('.payment-card#dynamic_qr').addEventListener('click', function() {
|
||||
document.getElementById('fullpage-loading').style.display = 'flex';
|
||||
|
||||
setTimeout(function() {
|
||||
document.getElementById('fullpage-loading').style.display = 'none';
|
||||
}, 5000);
|
||||
initDynamicQrPay();
|
||||
setTimeout(function() {
|
||||
document.getElementById('fullpage-loading').style.display = 'none';
|
||||
}, 5000);
|
||||
precreateDynamicQrPay();
|
||||
// initDynamicQrPay();
|
||||
});
|
||||
|
||||
function precreateDynamicQrPay() {
|
||||
const paymentMethod = 'MMQR';
|
||||
const $serverMode = $('#server_mode');
|
||||
const $createOrderBtn = $('#create_order');
|
||||
const $createPayOrderBtn = $('#create_pay_order');
|
||||
|
||||
const params = {
|
||||
order_source: "food_court",
|
||||
order_type: "dine_in",
|
||||
customer_id: $("#customer_id").text(),
|
||||
guest_info: "",
|
||||
table_id: $("#table_id").text(),
|
||||
order_items: JSON.stringify(get_order_item_rows()),
|
||||
create_type: "create_pay",
|
||||
};
|
||||
|
||||
$.ajax({
|
||||
url: '/foodcourt/addorders/create',
|
||||
method: 'POST',
|
||||
contentType: 'application/json',
|
||||
headers: {
|
||||
'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content')
|
||||
},
|
||||
data: JSON.stringify(params),
|
||||
success: function(result) {
|
||||
const booking_id = result.booking_id;
|
||||
window.location.href = `/foodcourt/${result.sale_id}/qrpay/precreate`;
|
||||
if ($serverMode.val() !== "cloud" && $("#display_type").val() === "2") {
|
||||
// customer_display_view(null, "reload");
|
||||
}
|
||||
},
|
||||
error: function(xhr) {
|
||||
$('#oqs_loading_wrapper').hide();
|
||||
$createOrderBtn.prop('disabled', false);
|
||||
$createPayOrderBtn.prop('disabled', false);
|
||||
|
||||
const errorMsg = xhr.status ? `Status: ${xhr.status} - ${xhr.statusText}` : "Network error";
|
||||
swal("Error", errorMsg, "error");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function initDynamicQrPay() {
|
||||
const paymentMethod = 'MMQR';
|
||||
const $serverMode = $('#server_mode');
|
||||
const $createOrderBtn = $('#create_order');
|
||||
const $createPayOrderBtn = $('#create_pay_order');
|
||||
// function initDynamicQrPay() {
|
||||
// const paymentMethod = 'MMQR';
|
||||
// const $serverMode = $('#server_mode');
|
||||
// const $createOrderBtn = $('#create_order');
|
||||
// const $createPayOrderBtn = $('#create_pay_order');
|
||||
|
||||
$.ajax({
|
||||
url: '/foodcourt/qrpay/req_bill?order_id=' + $('#receipt_no').text().trim() + '&customer_id=' + $('input[name="customer_id"]').val(),
|
||||
method: 'GET',
|
||||
success: function(result) {
|
||||
console.log(result);
|
||||
if(! result.status) {
|
||||
alert('Something went wrong');
|
||||
return;
|
||||
}
|
||||
// $.ajax({
|
||||
// url: '/foodcourt/qrpay/req_bill?order_id=' + $('#receipt_no').text().trim() + '&customer_id=' + $('input[name="customer_id"]').val(),
|
||||
// method: 'GET',
|
||||
// success: function(result) {
|
||||
// console.log(result);
|
||||
// if(! result.status) {
|
||||
// alert('Something went wrong');
|
||||
// return;
|
||||
// }
|
||||
|
||||
window.location.href = `/foodcourt/${result.sale_id}/qrpay/init`;
|
||||
if ($serverMode.val() !== "cloud" && $("#display_type").val() === "2") {
|
||||
// customer_display_view(null, "reload");
|
||||
}
|
||||
},
|
||||
error: function(xhr) {
|
||||
$('#oqs_loading_wrapper').hide();
|
||||
$createOrderBtn.prop('disabled', false);
|
||||
$createPayOrderBtn.prop('disabled', false);
|
||||
// window.location.href = `/foodcourt/${result.sale_id}/qrpay/init`;
|
||||
// if ($serverMode.val() !== "cloud" && $("#display_type").val() === "2") {
|
||||
// // customer_display_view(null, "reload");
|
||||
// }
|
||||
// },
|
||||
// error: function(xhr) {
|
||||
// $('#oqs_loading_wrapper').hide();
|
||||
// $createOrderBtn.prop('disabled', false);
|
||||
// $createPayOrderBtn.prop('disabled', false);
|
||||
|
||||
const errorMsg = xhr.status ? `Status: ${xhr.status} - ${xhr.statusText}` : "Network error";
|
||||
swal("Error", errorMsg, "error");
|
||||
}
|
||||
});
|
||||
}
|
||||
// const errorMsg = xhr.status ? `Status: ${xhr.status} - ${xhr.statusText}` : "Network error";
|
||||
// swal("Error", errorMsg, "error");
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
});
|
||||
</script>
|
||||
|
||||
1356
app/views/foodcourt/qrpay/precreate.html.erb
Normal file
1356
app/views/foodcourt/qrpay/precreate.html.erb
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user