diff --git a/pos_pax/static/src/css/pos_pax.css b/pos_pax/static/src/css/pos_pax.css index f6a20ec0..6f3bfb7f 100644 --- a/pos_pax/static/src/css/pos_pax.css +++ b/pos_pax/static/src/css/pos_pax.css @@ -10,8 +10,9 @@ cursor: pointer !important; border: 1px solid rgba(255, 255, 255, 0.5); background-color: rgba(255,255,255, 0.2); - display: block; + display: inline-block; text-align: center; - margin: 6px 0 0 0; + margin: 6px 5px 0 0; padding: 2px 5px; + min-width: 100px; } diff --git a/pos_pax/static/src/js/PAXPaymentScreen.js b/pos_pax/static/src/js/PAXPaymentScreen.js index d8ab41df..c7a2c08e 100644 --- a/pos_pax/static/src/js/PAXPaymentScreen.js +++ b/pos_pax/static/src/js/PAXPaymentScreen.js @@ -18,13 +18,18 @@ odoo.define('pos_pax.PAXPaymentScreen', function (require) { // tempting to use 'send-payment-request', // but method implements things that don't seem to exist yet (payment_method.payment_terminal) useListener('pax-send-payment-request', this._sendPAXPaymentRequest); + useListener('pax-send-payment-request-debit', this._sendPAXPaymentRequestDebit); } async _sendPAXPaymentRequest({ detail: line }) { - this.pax_credit_transaction(line); + this.pax_credit_transaction(line, 'credit'); } - pax_credit_transaction(line) { + async _sendPAXPaymentRequestDebit({ detail: line }) { + this.pax_credit_transaction(line, 'debit'); + } + + pax_credit_transaction(line, tender_type) { var order = this.env.pos.get_order(); if(this.env.pos.getPAXOnlinePaymentJournals().length === 0) { @@ -43,7 +48,7 @@ odoo.define('pos_pax.PAXPaymentScreen', function (require) { } transaction = { - command: 'T00', + command: (tender_type == 'debit') ? 'T02' : 'T00', version: '1.28', transactionType: transactionType, amountInformation: { @@ -70,7 +75,7 @@ odoo.define('pos_pax.PAXPaymentScreen', function (require) { }); PAX.mDestinationIP = self.env.pos.config.pax_endpoint; - PAX.DoCredit(transaction, function (response) { + PAX[(tender_type == 'debit') ? 'DoDebit' : 'DoCredit'](transaction, function (response) { console.log(response); var parsed_response = self.env.pos.decodePAXResponse(response); if (parsed_response.fail) { @@ -83,6 +88,7 @@ odoo.define('pos_pax.PAXPaymentScreen', function (require) { line.pax_txn_id = parsed_response.txn_id; line.pax_approval = parsed_response.approval; line.pax_txn_pending = false; + line.pax_tender_type = tender_type; line.set_credit_card_name(); order.trigger('change', order); self.render(); @@ -109,7 +115,7 @@ odoo.define('pos_pax.PAXPaymentScreen', function (require) { }); transaction = { - command: 'T00', + command: (line.pax_tender_type == 'debit') ? 'T02' : 'T00', version: '1.28', transactionType: (line.get_amount() > 0) ? '17' : '18', // V/SALE, V/RETURN cashierInformation: { @@ -124,7 +130,7 @@ odoo.define('pos_pax.PAXPaymentScreen', function (require) { } PAX.mDestinationIP = self.env.pos.config.pax_endpoint; - PAX.DoCredit(transaction, function (response) { + PAX[(line.pax_tender_type == 'debit') ? 'DoDebit' : 'DoCredit'](transaction, function (response) { var parsed_response = self.env.pos.decodePAXResponse(response); if (parsed_response.fail) { def.resolve({message: parsed_response.fail}) diff --git a/pos_pax/static/src/js/pax_device.js b/pos_pax/static/src/js/pax_device.js index 14879313..55bf0b03 100644 --- a/pos_pax/static/src/js/pax_device.js +++ b/pos_pax/static/src/js/pax_device.js @@ -7,6 +7,7 @@ odoo.define('pos_pax.pax_device', function (require) { // Additions and Fixes: // 2020-11-12 Fixed variable i and ii in getLRC // 2020-11-12 Fixed/added 'fail' mechanisms for XHR + // 2020-11-23 Added new DoDebit method //HEX TO BASE64 function hexToBase64(str) { @@ -79,7 +80,8 @@ odoo.define('pos_pax.pax_device', function (require) { "Initialize":120*1000, "GetSignature":120*1000, "DoSignature":120*1000, - "DoCredit":120*1000 + "DoCredit":120*1000, + "DoDebit":120*1000, }, //Set ip and port @@ -150,7 +152,7 @@ odoo.define('pos_pax.pax_device', function (require) { var hex = StringToHex(response).slice(0,len).split(/02|1c/); console.log(hex); - if(commandType == "DoCredit"){ + if(commandType == "DoCredit" || commandType == "DoDebit"){ var subHex=[], subPacketInfo=[]; for(var i=0; i"+customData+""); + // } + + + var url = this.mDestinationIP + '?' + final_b64; + console.log("URL: " + url); + + this.HttpCommunication('DoDebit',url,function(response){ + callback(response); + },PAX.timeout.DoDebit,fail); + }, }; return PAX; diff --git a/pos_pax/static/src/js/pos_pax.js b/pos_pax/static/src/js/pos_pax.js index cebe484b..b56f2b62 100644 --- a/pos_pax/static/src/js/pos_pax.js +++ b/pos_pax/static/src/js/pos_pax.js @@ -17,9 +17,18 @@ pos_model.PosModel = pos_model.PosModel.extend({ return online_payment_methods; }, decodePAXResponse: function (data) { - if (data[5] == 'ABORTED') { + var status = data[5]; + if (status == 'ABORTED') { return {fail: 'Transaction Aborted'}; - } else if (data[5] == 'OK') { + } else if (status == 'DECLINE') { + return {fail: 'Transaction Declined or not Allowed'}; + } else if (status == 'COMM ERROR') { + return {fail: 'Communication Error (e.g. could be your CC processor or internet)'} + } else if (status == 'DEBIT ONLY, TRY ANOTHER TENDER') { + return {fail: 'Card does not support Debit. Use Credit or switch cards.'} + } else if (status == 'RECEIVE ERROR') { + return {fail: 'Error receiving response. Try again?'} + } else if (status == 'OK') { return { success: true, approval: data[6][2], @@ -27,7 +36,11 @@ pos_model.PosModel = pos_model.PosModel.extend({ card_num: '***' + data[9][0], } } - return {fail: 'Unknown Response. ' + data}; + var response = 'Not handled response: ' + status; + if (this.debug) { + response += ' --------- Debug Data: ' + data; + } + return {fail: response}; }, }); @@ -41,6 +54,7 @@ pos_model.Paymentline = pos_model.Paymentline.extend({ this.pax_card_number = json.pax_card_number; this.pax_approval = json.pax_approval; this.pax_txn_id = json.pax_txn_id; + this.pax_tender_type = json.pax_tender_type; this.set_credit_card_name(); }, @@ -51,11 +65,12 @@ pos_model.Paymentline = pos_model.Paymentline.extend({ pax_card_number: this.pax_card_number, pax_approval: this.pax_approval, pax_txn_id: this.pax_txn_id, + pax_tender_type: this.pax_tender_type, }); }, set_credit_card_name: function () { if (this.pax_card_number) { - this.name = this.pax_card_number; + this.name = this.pax_card_number + ((this.pax_tender_type == 'debit') ? ' (Debit)' : ' (Credit)'); } }, }); diff --git a/pos_pax/static/src/xml/PAXPaymentScreenPaymentLines.xml b/pos_pax/static/src/xml/PAXPaymentScreenPaymentLines.xml index 37d291aa..b0704f78 100644 --- a/pos_pax/static/src/xml/PAXPaymentScreenPaymentLines.xml +++ b/pos_pax/static/src/xml/PAXPaymentScreenPaymentLines.xml @@ -5,10 +5,17 @@ WAITING FOR TXN -
- Send +
+
+ Credit +
+
+ Debit +