Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion pos_payment_method_cashdro/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
from . import pos_payment_method
from . import pos_session
13 changes: 13 additions & 0 deletions pos_payment_method_cashdro/models/pos_payment_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ def _get_payment_terminal_selection(self):
)
cashdro_user = fields.Char()
cashdro_password = fields.Char()
cashdro_http = fields.Boolean(
string="Use HTTP connection",
help="Check this to enable HTTP (not secure) connection. You should enable it"
" also in Cashdro configuration interface.",
)

def _onchange_journal_id(self):
"""Cash payment method force the `use_payment_terminal` to `False` as
Expand All @@ -33,3 +38,11 @@ def _compute_hide_use_payment_terminal(self):
return super(
PosPaymentMethod, self - cash_payment_types
)._compute_hide_use_payment_terminal()

def _load_pos_data_fields(self, config_id):
return super()._load_pos_data_fields(config_id) + [
"cashdro_host",
"cashdro_user",
"cashdro_password",
"cashdro_http",
]
14 changes: 0 additions & 14 deletions pos_payment_method_cashdro/models/pos_session.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,15 @@ export class PaymentCashdro extends PaymentInterface {
_cashdro_url() {
// Cashdro machines don't support safe POST calls, so we're sending
// all the data quite unsafely constantly...
const method = this.pos.get_order().selected_paymentline.payment_method;
const method = this.pos
.get_order()
.get_selected_paymentline().payment_method_id;
const host = method && method.cashdro_host;
if (!host) {
return false;
}
let url = `${host}/Cashdro3WS/index.php`;
const connection = method.cashdro_http ? `http://` : `https://`;
let url = `${connection}${host}/Cashdro3WS/index.php`;
url += `?name=${method.cashdro_user}`;
url += `&password=${method.cashdro_password}`;
return url;
Expand All @@ -125,7 +128,7 @@ export class PaymentCashdro extends PaymentInterface {
const operationType = parameters.amount > 0 ? 4 : 3;
parameters = {...parameters, amount: Math.abs(parameters.amount)};
let url = `${this._cashdro_url()}&operation=startOperation&type=${operationType}`;
url += `&posid=pos-${this.pos.pos_session.name}`;
url += `&posid=pos-${this.pos.session.name}`;
url += `&posuser=${user}`;
url += `&parameters=${encodeURIComponent(JSON.stringify(parameters))}`;
return url;
Expand Down
4 changes: 4 additions & 0 deletions pos_payment_method_cashdro/views/pos_payment_method_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
invisible="use_payment_terminal != 'cashdro'"
required="use_payment_terminal == 'cashdro'"
/>
<field
name="cashdro_http"
invisible="use_payment_terminal != 'cashdro'"
/>
<field
name="cashdro_user"
invisible="use_payment_terminal != 'cashdro'"
Expand Down
Loading