CB ECR Integration
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
<div class="container-fluid">
|
||||
<div id="loading_wrapper" style="display:none;">
|
||||
<div id="loading"></div>
|
||||
</div>
|
||||
|
||||
<div class='row clearfix'>
|
||||
<div class='col-md-10'>
|
||||
<h1><%= t :close_cashier %></h1>
|
||||
@@ -27,6 +31,27 @@
|
||||
<div class="col-lg-2 col-md-2 col-sm-2">
|
||||
<button type="button" class="btn bg-default btn-block" id='back'><i class="material-icons">reply</i> <%= t("views.btn.back") %> </button>
|
||||
<button type="button" class="btn bg-blue btn-block green" id='close_cashier'> <%= t("views.btn.close_cashier") %> </button>
|
||||
<button type="button" class="btn bg-blue btn-block green" id="card_settlement"> <%= t("views.btn.card_settle") %> </button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="cardSettleModal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="cardSettleModal">Select Device: </h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<select class="form-control show-tick sel_com_port" id="sel_com_port" >
|
||||
|
||||
</select>
|
||||
</div>
|
||||
<div class="modal-footer p-r-30">
|
||||
<button type="button" class="btn btn-link btn-danger waves-effect" data-dismiss="modal">CLOSE</button>
|
||||
|
||||
<button type="button" class="btn btn-link bg-blue waves-effect" id="card_settle">OK</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -42,8 +67,175 @@
|
||||
window.location.href = '/';
|
||||
}
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
$('#back').on('click',function(){
|
||||
window.location.href = '/origami';
|
||||
})
|
||||
});
|
||||
|
||||
/** start CB Card Settle process **/
|
||||
$("#card_settlement").on('click', function(){
|
||||
if(typeof code2lab != 'undefined'){
|
||||
$('#cardSettleModal').modal({ keyboard: false, backdrop: false });
|
||||
code2lab.getCommPorts();
|
||||
}else{
|
||||
swal({
|
||||
title: 'Oops',
|
||||
text: 'Settlement can not print out in browser!',
|
||||
type: 'error',
|
||||
html: true,
|
||||
closeOnConfirm: false,
|
||||
closeOnCancel: false,
|
||||
allowOutsideClick: false
|
||||
}, function () {
|
||||
window.location.href = '/origami/shift/close';
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
//CB Bank payment settlement ECR integration
|
||||
function setCommPorts(comPortLists) {
|
||||
// alert(comPortLists);
|
||||
$('#sel_com_port').html("");
|
||||
var jsonPortLists = $.parseJSON(comPortLists);
|
||||
if((jsonPortLists!=undefined && jsonPortLists!='') && (jsonPortLists.length > 0)){
|
||||
$.each(jsonPortLists,function(key,value){
|
||||
$('#sel_com_port').append("<option value='"+value+"'>"+value+"</option>");
|
||||
});
|
||||
}
|
||||
else{
|
||||
swal({
|
||||
title: 'Oops',
|
||||
text: 'Payment can not pay in browser!',
|
||||
type: 'error',
|
||||
html: true,
|
||||
closeOnConfirm: false,
|
||||
closeOnCancel: false,
|
||||
allowOutsideClick: false
|
||||
}, function () {
|
||||
window.location.href = '/origami/shift/close';
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
$("#card_settle").on('click', function () {
|
||||
$("#loading_wrapper").show();
|
||||
$('#cardSettleModal').modal('hide');
|
||||
reqCBBankMPUSettlement();
|
||||
});
|
||||
|
||||
//add req data to card_settle_trans table
|
||||
function reqCardSettleTrans(cmd_type,payment_type,com_port) {
|
||||
var jobj = {"cmd_type" : cmd_type, "payment_type" : payment_type};
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/origami/bank_integration/settle_trans",
|
||||
data: {type:"request", data: jobj},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
if (data.status == "success"){
|
||||
resCardSettleTrans(data.card_settle_trans_id,cmd_type,payment_type,com_port);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//add res data to card_settle_trans table
|
||||
function resCardSettleTrans(card_settle_trans_id,cmd_type,payment_type,com_port) {
|
||||
var resMsg = "";
|
||||
if($("#loading_wrapper").is(':visible')){
|
||||
resMsg = code2lab.reqBankPayment(cmd_type, payment_type, 1, "", com_port);
|
||||
}
|
||||
|
||||
if(resMsg.includes("STATUS")){
|
||||
var jobj = $.parseJSON(resMsg);
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/origami/bank_integration/settle_trans",
|
||||
data: {type:"response", card_settle_trans_id: card_settle_trans_id, data: jobj},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
if(data.status == "success"){
|
||||
if(payment_type == "MPU"){
|
||||
reqCBBankVMJSettlement();
|
||||
}
|
||||
else if(payment_type == "VMJ"){
|
||||
reqCBBankJCBSettlement();
|
||||
}
|
||||
else if(payment_type == "JCB"){
|
||||
reqCBBankCUPSettlement();
|
||||
}
|
||||
else if(payment_type == "CUP"){
|
||||
$("#loading_wrapper").hide();
|
||||
// reqCBBankAlipaySettlement();
|
||||
}
|
||||
// else if(payment_type == "Alipay"){
|
||||
// reqCBBankIPPSettlement();
|
||||
// $('#loading').hide();
|
||||
// }
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else{
|
||||
$("#loading_wrapper").hide();
|
||||
swal ( "Oops" , resMsg.toString() , "error" );
|
||||
}
|
||||
}
|
||||
|
||||
//settle for MPU / MPU-UPI
|
||||
function reqCBBankMPUSettlement() {
|
||||
var com_port = $('#sel_com_port').val();
|
||||
var cmd_type = "SETTLEMENT";
|
||||
var payment_type = "MPU";
|
||||
$("#loading_wrapper").show();
|
||||
reqCardSettleTrans(cmd_type,payment_type,com_port);
|
||||
}
|
||||
|
||||
//settle for VMJ (VISA, MASTER)
|
||||
function reqCBBankVMJSettlement() {
|
||||
var com_port = $('#sel_com_port').val();
|
||||
var cmd_type = "SETTLEMENT";
|
||||
var payment_type = "VMJ"; //VISA,Master and JCB
|
||||
$("#loading_wrapper").show();
|
||||
reqCardSettleTrans(cmd_type,payment_type,com_port);
|
||||
}
|
||||
|
||||
//settle for JCB
|
||||
function reqCBBankJCBSettlement() {
|
||||
var com_port = $('#sel_com_port').val();
|
||||
var cmd_type = "SETTLEMENT";
|
||||
var payment_type = "JCB";
|
||||
$("#loading_wrapper").show();
|
||||
reqCardSettleTrans(cmd_type,payment_type,com_port);
|
||||
}
|
||||
|
||||
//settle for International Union Pay (CUP)
|
||||
function reqCBBankCUPSettlement() {
|
||||
var com_port = $('#sel_com_port').val();
|
||||
var cmd_type = "SETTLEMENT";
|
||||
var payment_type = "CUP";
|
||||
$("#loading_wrapper").show();
|
||||
reqCardSettleTrans(cmd_type,payment_type,com_port);
|
||||
}
|
||||
|
||||
//settle for Alipay
|
||||
function reqCBBankAlipaySettlement() {
|
||||
var com_port = $('#sel_com_port').val();
|
||||
var cmd_type = "SETTLEMENT";
|
||||
var payment_type = "Alipay";
|
||||
$("#loading_wrapper").show();
|
||||
reqCardSettleTrans(cmd_type,payment_type,com_port);
|
||||
}
|
||||
|
||||
//settle for insert/direct swipe (now does not using this state - future one)
|
||||
function reqCBBankIPPSettlement() {
|
||||
var com_port = $('#sel_com_port').val();
|
||||
var cmd_type = "SETTLEMENT";
|
||||
var payment_type = "IPP";
|
||||
$("#loading_wrapper").show();
|
||||
reqCardSettleTrans(cmd_type,payment_type,com_port);
|
||||
}
|
||||
/** end CB Card Settle process **/
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user