diff --git a/debian/changelog b/debian/changelog index 966e2605..e8be1eef 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -hedera-web (1.405.24) stable; urgency=low +hedera-web (1.405.25) stable; urgency=low * Initial Release. diff --git a/forms/ecomerce/confirm/confirm.js b/forms/ecomerce/confirm/confirm.js index 261c4cb9..1f510b0e 100644 --- a/forms/ecomerce/confirm/confirm.js +++ b/forms/ecomerce/confirm/confirm.js @@ -34,7 +34,7 @@ Hedera.Confirm = new Class Vn.Node.setText (this.$('method'), _('Warehouse')); } - var total = form.get ('tax_base') + form.get ('vat'); + var total = form.get ('taxBase') + form.get ('tax'); if (total === null) total = 0; @@ -149,10 +149,7 @@ Hedera.Confirm = new Class this.disableButtons (false); if (resultSet.fetchResult ()) - { - Vn.Cookie.unset ('order'); this.$('success-dialog').show (); - } } ,onDialogResponse: function () diff --git a/forms/ecomerce/confirm/ui.xml b/forms/ecomerce/confirm/ui.xml index a5026c86..54cc0894 100755 --- a/forms/ecomerce/confirm/ui.xml +++ b/forms/ecomerce/confirm/ui.xml @@ -3,7 +3,7 @@ - CALL basket_get_vat (); + CALL basketGetTax; SELECT o.id, o.date_send, o.note, o.company_id, ag.description agency, v.code method, ad.consignee, ad.zip_code, ad.city, ad.name address, @@ -15,11 +15,11 @@ JOIN customer_view c JOIN ( SELECT - IFNULL(SUM(tax_base), 0) tax_base, - IFNULL(SUM(vat + surcharge), 0) vat - FROM t_order_vat + IFNULL(SUM(taxBase), 0) taxBase, + IFNULL(SUM(tax + equalizationTax), 0) tax + FROM tmp.orderTax ) t; - DROP TEMPORARY TABLE t_order_vat; + DROP TEMPORARY TABLE tmp.orderTax; @@ -76,7 +76,7 @@ Order total - + @@ -84,7 +84,7 @@ Order VAT - + diff --git a/forms/ecomerce/orders/orders.js b/forms/ecomerce/orders/orders.js index 1e4a6727..a4214ccd 100644 --- a/forms/ecomerce/orders/orders.js +++ b/forms/ecomerce/orders/orders.js @@ -41,17 +41,20 @@ Hedera.Orders = new Class ,onPayButtonClick: function () { var amount = -this.$('debt').value; - amount = amount <= 0 ? null : amount; var defaultAmountStr = ''; if (amount !== null) defaultAmountStr = Vn.Value.format (amount, '%.2d'); + + amount = prompt (_('AmountToPay:'), defaultAmountStr); - var amount = parseFloat (prompt (_('AmountToPay:'), defaultAmountStr)); - - this.tpv.pay (amount, null); + if (amount != null) + { + amount = parseFloat (amount.replace (',', '.')); + this.tpv.pay (amount, null); + } } ,onDialogResponse: function (dialog, response) diff --git a/js/hedera/tpv.js b/js/hedera/tpv.js index ec276777..07c03365 100644 --- a/js/hedera/tpv.js +++ b/js/hedera/tpv.js @@ -27,24 +27,24 @@ module.exports = new Class ,pay: function (amount, company) { - this._realPpay (amount * 100, company); + this._realPay (amount * 100, company); } - ,_realPpay: function (amount, company) - { - if (amount > 0) + ,_realPay: function (amount, company) + { + if (isNumeric (amount) && amount > 0) { var params = { - 'amount': parseInt (amount) - ,'urlOk': this._makeUrl ('ok') - ,'urlKo': this._makeUrl ('ko') - ,'company': company + amount: parseInt (amount) + ,urlOk: this._makeUrl ('ok') + ,urlKo: this._makeUrl ('ko') + ,company: company }; this.conn.send ('tpv/transaction', params, this._onTransactionStart.bind (this)); } - else if (!isNaN (amount)) + else Htk.Toast.showError (_('AmountError')); } @@ -52,27 +52,22 @@ module.exports = new Class { if (json) { + var postValues = json.postValues; + var form = document.createElement ('form'); form.method = 'post'; form.action = json.url; document.body.appendChild (form); - var fieldsMap = - { - 'Ds_SignatureVersion': 'HMAC_SHA256_V1' - ,'Ds_MerchantParameters': json.params - ,'Ds_Signature': json.signature - }; - - for (var field in fieldsMap) + for (var field in postValues) { var input = document.createElement ('input'); input.type = 'hidden'; input.name = field; form.appendChild (input); - if (fieldsMap[field]) - input.value = fieldsMap[field]; + if (postValues[field]) + input.value = postValues[field]; } form.submit (); @@ -99,7 +94,7 @@ module.exports = new Class var res = resultSet.fetchResult (); if (res.next ()) - this._realPpay (res.get ('amount'), res.get ('company_id')); + this._realPay (res.get ('amount'), res.get ('company_id')); else Htk.Toast.showError (_('AmountError')); } @@ -111,12 +106,16 @@ module.exports = new Class path += location.pathname; path += location.search ? location.search : ''; path += Vn.Hash.make ({ - 'form': 'ecomerce/orders', - 'tpvStatus': status, - 'tpvOrder': '%s' + form: 'ecomerce/orders', + tpvStatus: status, + tpvOrder: '%s' }, true); return path; } }); +function isNumeric (n) +{ + return !isNaN (parseFloat(n)) && isFinite (n); +} diff --git a/package.json b/package.json index 29a62535..c009cd4b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hedera-web", - "version": "1.405.24", + "version": "1.405.25", "description": "Verdnatura web page", "license": "GPL-3.0", "repository": { diff --git a/pages/production/ui.php b/pages/production/ui.php new file mode 100644 index 00000000..e69de29b diff --git a/rest/tpv/transaction.php b/rest/tpv/transaction.php index c024869e..5a158898 100755 --- a/rest/tpv/transaction.php +++ b/rest/tpv/transaction.php @@ -2,7 +2,7 @@ /** * Starts a new TPV transaction and returns the params. - **/ + */ class Transaction extends Vn\Web\JsonRequest { const PARAMS = ['amount']; @@ -12,24 +12,24 @@ class Transaction extends Vn\Web\JsonRequest $amount = (int) $_REQUEST['amount']; $companyId = empty ($_REQUEST['company']) ? NULL : $_REQUEST['company']; - $row = $db->getRow ('CALL transactionStart (#, #)', + $row = $db->getObject ('CALL transactionStart (#, #)', [$amount, $companyId]); if (!isset ($row)) throw new Exception ('Transaction error'); - $transactionId = str_pad ($row['transactionId'], 12, '0', STR_PAD_LEFT); + $transactionId = str_pad ($row->transactionId, 12, '0', STR_PAD_LEFT); $urlOk = empty ($_REQUEST['urlOk']) ? '' : sprintf ($_REQUEST['urlOk'], $transactionId); $urlKo = empty ($_REQUEST['urlKo']) ? '' : sprintf ($_REQUEST['urlKo'], $transactionId); - $merchantUrl = $row['merchantUrl'] ? $row['merchantUrl'] : ''; + $merchantUrl = $row->merchantUrl ? $row->merchantUrl : ''; $params = [ 'Ds_Merchant_Amount' => $amount ,'Ds_Merchant_Order' => $transactionId - ,'Ds_Merchant_MerchantCode' => $row['merchant'] - ,'Ds_Merchant_Currency' => $row['currency'] - ,'Ds_Merchant_TransactionType' => $row['transactionType'] - ,'Ds_Merchant_Terminal' => $row['terminal'] + ,'Ds_Merchant_MerchantCode' => $row->merchant + ,'Ds_Merchant_Currency' => $row->currency + ,'Ds_Merchant_TransactionType' => $row->transactionType + ,'Ds_Merchant_Terminal' => $row->terminal ,'Ds_Merchant_MerchantURL' => $merchantUrl ,'Ds_Merchant_UrlOK' => $urlOk ,'Ds_Merchant_UrlKO' => $urlKo @@ -37,20 +37,24 @@ class Transaction extends Vn\Web\JsonRequest $encodedParams = base64_encode (json_encode ($params)); - $key = base64_decode ($row['secretKey']); + $key = base64_decode ($row->secretKey); $bytes = [0, 0, 0, 0, 0, 0, 0, 0]; $iv = implode (array_map ('chr', $bytes)); $key = mcrypt_encrypt (MCRYPT_3DES, $key, $transactionId, MCRYPT_MODE_CBC, $iv); $signature = base64_encode (hash_hmac ('sha256', $encodedParams, $key, TRUE)); - $url = $row['url']; + + $url = $row->url; + $postValues = [ + 'Ds_SignatureVersion' => 'HMAC_SHA256_V1' + ,'Ds_MerchantParameters' => $encodedParams + ,'Ds_Signature' => $signature + ]; return [ - 'url' => $url - ,'params' => $encodedParams - ,'signature' => $signature + 'url' => $url + ,'postValues' => $postValues ]; } } -