Catalog text overlap fixed, tpv return url fixed
This commit is contained in:
parent
27ec20369e
commit
0a5aa8e6cd
|
@ -11,4 +11,5 @@ rules:
|
||||||
no-unexpected-multiline: 0
|
no-unexpected-multiline: 0
|
||||||
brace-style: [error, 1tbs]
|
brace-style: [error, 1tbs]
|
||||||
space-before-function-paren: [error, never]
|
space-before-function-paren: [error, never]
|
||||||
padded-blocks: [error, never]
|
padded-blocks: [error, never]
|
||||||
|
func-call-spacing: [error, never]
|
|
@ -1,4 +1,4 @@
|
||||||
hedera-web (1.406.32) stable; urgency=low
|
hedera-web (1.406.33) stable; urgency=low
|
||||||
|
|
||||||
* Initial Release.
|
* Initial Release.
|
||||||
|
|
||||||
|
|
|
@ -162,6 +162,7 @@
|
||||||
font-size: 1.1em;
|
font-size: 1.1em;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
max-height: 2.4em;
|
||||||
}
|
}
|
||||||
.item-info > p
|
.item-info > p
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,66 +1,57 @@
|
||||||
|
|
||||||
Hedera.Orders = new Class
|
Hedera.Orders = new Class({
|
||||||
({
|
Extends: Hedera.Form,
|
||||||
Extends: Hedera.Form
|
|
||||||
|
|
||||||
,activate: function ()
|
activate: function() {
|
||||||
{
|
this.tpv = new Hedera.Tpv({conn: this.conn});
|
||||||
this.tpv = new Hedera.Tpv ({conn: this.conn});
|
this.tpv.check(this._onTpvCheck.bind(this));
|
||||||
this.tpv.check (this._onTpvCheck.bind (this));
|
},
|
||||||
}
|
|
||||||
|
|
||||||
,_onTpvCheck: function (tpv, tpvOrder, tpvStatus)
|
_onTpvCheck: function(tpv, tpvOrder, tpvStatus) {
|
||||||
{
|
|
||||||
if (tpvStatus === 'ko')
|
if (tpvStatus === 'ko')
|
||||||
this.$('error-dialog').show ();
|
this.$('error-dialog').show();
|
||||||
}
|
},
|
||||||
|
|
||||||
,onBasketClick: function ()
|
onBasketClick: function() {
|
||||||
{
|
this.hash.set({form: 'ecomerce/basket'});
|
||||||
this.hash.set ({form: 'ecomerce/basket'});
|
},
|
||||||
}
|
|
||||||
|
|
||||||
,repeaterFunc: function (res, form)
|
repeaterFunc: function(res, form) {
|
||||||
{
|
res.$('link').href = this.hash.make({
|
||||||
res.$('link').href = this.hash.make ({
|
|
||||||
form: 'ecomerce/ticket',
|
form: 'ecomerce/ticket',
|
||||||
ticket: form.get ('id')
|
ticket: form.get('id')
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
|
|
||||||
// TPV
|
// TPV
|
||||||
|
|
||||||
,balanceConditionalFunc: function (field, value)
|
balanceConditionalFunc: function(field, value) {
|
||||||
{
|
|
||||||
if (value >= 0)
|
if (value >= 0)
|
||||||
Vn.Node.removeClass (this.$('balance'), 'negative');
|
Vn.Node.removeClass(this.$('balance'), 'negative');
|
||||||
else
|
else
|
||||||
Vn.Node.addClass (this.$('balance'), 'negative');
|
Vn.Node.addClass(this.$('balance'), 'negative');
|
||||||
}
|
},
|
||||||
|
|
||||||
,onPayButtonClick: function ()
|
onPayButtonClick: function() {
|
||||||
{
|
|
||||||
var amount = -this.$('debt').value;
|
var amount = -this.$('debt').value;
|
||||||
amount = amount <= 0 ? null : amount;
|
amount = amount <= 0 ? null : amount;
|
||||||
|
|
||||||
var defaultAmountStr = '';
|
var defaultAmountStr = '';
|
||||||
|
|
||||||
if (amount !== null)
|
if (amount !== null)
|
||||||
defaultAmountStr = Vn.Value.format (amount, '%.2d');
|
defaultAmountStr = Vn.Value.format(amount, '%.2d');
|
||||||
|
|
||||||
amount = prompt (_('AmountToPay:'), defaultAmountStr);
|
amount = prompt(_('AmountToPay:'), defaultAmountStr);
|
||||||
|
|
||||||
if (amount != null)
|
if (amount != null) {
|
||||||
{
|
amount = parseFloat(amount.replace(',', '.'));
|
||||||
amount = parseFloat (amount.replace (',', '.'));
|
this.tpv.pay(amount, null);
|
||||||
this.tpv.pay (amount, null);
|
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
|
||||||
,onDialogResponse: function (dialog, response)
|
onDialogResponse: function(dialog, response) {
|
||||||
{
|
|
||||||
if (response == Htk.Dialog.Button.RETRY)
|
if (response == Htk.Dialog.Button.RETRY)
|
||||||
this.tpv.retryPay ();
|
this.tpv.retryPay();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
104
js/hedera/tpv.js
104
js/hedera/tpv.js
|
@ -6,116 +6,102 @@ module.exports = new Class
|
||||||
,tpvOrder: null
|
,tpvOrder: null
|
||||||
,tpvStatus: null
|
,tpvStatus: null
|
||||||
|
|
||||||
,check: function (callback)
|
,check: function(callback) {
|
||||||
{
|
this.tpvOrder = Vn.Hash.get('tpvOrder');
|
||||||
this.tpvOrder = Vn.Hash.get ('tpvOrder');
|
this.tpvStatus = Vn.Hash.get('tpvStatus');
|
||||||
this.tpvStatus = Vn.Hash.get ('tpvStatus');
|
|
||||||
|
|
||||||
if (this.tpvStatus)
|
if (this.tpvStatus) {
|
||||||
{
|
var batch = new Sql.Batch();
|
||||||
var batch = new Sql.Batch ();
|
batch.addValue('transaction', this.tpvOrder);
|
||||||
batch.addValue ('transaction', this.tpvOrder);
|
batch.addValue('status', this.tpvStatus);
|
||||||
batch.addValue ('status', this.tpvStatus);
|
|
||||||
|
|
||||||
var query = 'CALL tpvTransactionEnd (#transaction, #status)';
|
var query = 'CALL tpvTransactionEnd (#transaction, #status)';
|
||||||
this.conn.execQuery (query, null, batch);
|
this.conn.execQuery(query, null, batch);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (callback)
|
if (callback)
|
||||||
callback (this, this.tpvOrder, this.tpvStatus);
|
callback(this, this.tpvOrder, this.tpvStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
,pay: function (amount, company)
|
,pay: function(amount, company) {
|
||||||
{
|
this._realPay(amount * 100, company);
|
||||||
this._realPay (amount * 100, company);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
,_realPay: function (amount, company)
|
,_realPay: function(amount, company) {
|
||||||
{
|
if (isNumeric(amount) && amount > 0) {
|
||||||
if (isNumeric (amount) && amount > 0)
|
|
||||||
{
|
|
||||||
var params = {
|
var params = {
|
||||||
amount: parseInt (amount)
|
amount: parseInt(amount)
|
||||||
,urlOk: this._makeUrl ('ok')
|
,urlOk: this._makeUrl('ok')
|
||||||
,urlKo: this._makeUrl ('ko')
|
,urlKo: this._makeUrl('ko')
|
||||||
,company: company
|
,company: company
|
||||||
};
|
};
|
||||||
|
|
||||||
this.conn.send ('tpv/transaction', params,
|
this.conn.send('tpv/transaction', params,
|
||||||
this._onTransactionStart.bind (this));
|
this._onTransactionStart.bind(this));
|
||||||
}
|
} else
|
||||||
else
|
Htk.Toast.showError(_('AmountError'));
|
||||||
Htk.Toast.showError (_('AmountError'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
,_onTransactionStart: function (json)
|
,_onTransactionStart: function(json) {
|
||||||
{
|
if (json) {
|
||||||
if (json)
|
|
||||||
{
|
|
||||||
var postValues = json.postValues;
|
var postValues = json.postValues;
|
||||||
|
|
||||||
var form = document.createElement ('form');
|
var form = document.createElement('form');
|
||||||
form.method = 'POST';
|
form.method = 'POST';
|
||||||
form.action = json.url;
|
form.action = json.url;
|
||||||
document.body.appendChild (form);
|
document.body.appendChild(form);
|
||||||
|
|
||||||
for (var field in postValues)
|
for (var field in postValues) {
|
||||||
{
|
var input = document.createElement('input');
|
||||||
var input = document.createElement ('input');
|
|
||||||
input.type = 'hidden';
|
input.type = 'hidden';
|
||||||
input.name = field;
|
input.name = field;
|
||||||
form.appendChild (input);
|
form.appendChild(input);
|
||||||
|
|
||||||
if (postValues[field])
|
if (postValues[field])
|
||||||
input.value = postValues[field];
|
input.value = postValues[field];
|
||||||
}
|
}
|
||||||
|
|
||||||
form.submit ();
|
form.submit();
|
||||||
}
|
} else
|
||||||
else
|
Htk.Toast.showWarning(_('PayError'));
|
||||||
Htk.Toast.showWarning (_('PayError'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
,retryPay: function ()
|
,retryPay: function() {
|
||||||
{
|
var batch = new Sql.Batch();
|
||||||
var batch = new Sql.Batch ();
|
batch.addValue('transaction', parseInt(this.tpvOrder));
|
||||||
batch.addValue ('transaction', parseInt (this.tpvOrder));
|
|
||||||
|
|
||||||
var query = 'SELECT t.amount, m.companyFk '
|
var query = 'SELECT t.amount, m.companyFk '
|
||||||
+'FROM myTpvTransaction t '
|
+'FROM myTpvTransaction t '
|
||||||
+'JOIN tpvMerchant m ON m.id = t.merchantFk '
|
+'JOIN tpvMerchant m ON m.id = t.merchantFk '
|
||||||
+'WHERE t.id = #transaction';
|
+'WHERE t.id = #transaction';
|
||||||
this.conn.execQuery (query,
|
this.conn.execQuery(query,
|
||||||
this._onRetryPayDone.bind (this), batch);
|
this._onRetryPayDone.bind(this), batch);
|
||||||
}
|
}
|
||||||
|
|
||||||
,_onRetryPayDone: function (resultSet)
|
,_onRetryPayDone: function(resultSet) {
|
||||||
{
|
var res = resultSet.fetchResult();
|
||||||
var res = resultSet.fetchResult ();
|
|
||||||
|
|
||||||
if (res.next ())
|
if (res.next())
|
||||||
this._realPay (res.get ('amount'), res.get ('companyFk'));
|
this._realPay(res.get('amount'), res.get('companyFk'));
|
||||||
else
|
else
|
||||||
Htk.Toast.showError (_('AmountError'));
|
Htk.Toast.showError(_('AmountError'));
|
||||||
}
|
}
|
||||||
|
|
||||||
,_makeUrl: function (status)
|
,_makeUrl: function(status) {
|
||||||
{
|
|
||||||
var path = location.protocol +'//'+ location.host;
|
var path = location.protocol +'//'+ location.host;
|
||||||
path += location.port ? ':'+ location.port : '';
|
path += location.port ? ':'+ location.port : '';
|
||||||
path += location.pathname;
|
path += location.pathname;
|
||||||
path += location.search ? location.search : '';
|
path += location.search ? location.search : '';
|
||||||
path += Vn.Hash.make ({
|
path += Vn.Hash.make({
|
||||||
form: 'ecomerce/orders',
|
form: 'ecomerce/orders',
|
||||||
tpvStatus: status,
|
tpvStatus: status,
|
||||||
tpvOrder: '%s'
|
tpvOrder: '_transactionId_'
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function isNumeric (n)
|
function isNumeric(n) {
|
||||||
{
|
return !isNaN(parseFloat(n)) && isFinite(n);
|
||||||
return !isNaN (parseFloat(n)) && isFinite (n);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
var HashListener = require ('./hash-listener');
|
var HashListener = require('./hash-listener');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class to handle the URL.
|
* Class to handle the URL.
|
||||||
|
@ -11,15 +11,15 @@ module.exports =
|
||||||
,_listener: null
|
,_listener: null
|
||||||
|
|
||||||
,initialize: function() {
|
,initialize: function() {
|
||||||
this._listener = new HashListener ();
|
this._listener = new HashListener();
|
||||||
|
|
||||||
this._hashChangedHandler = this._hashChanged.bind (this);
|
this._hashChangedHandler = this._hashChanged.bind(this);
|
||||||
window.addEventListener ('hashchange', this._hashChangedHandler);
|
window.addEventListener('hashchange', this._hashChangedHandler);
|
||||||
this._hashChanged ();
|
this._hashChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
,destroy: function() {
|
,destroy: function() {
|
||||||
window.removeEventListener ('hashchange', this._hashChangedHandler);
|
window.removeEventListener('hashchange', this._hashChangedHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
,getListener: function() {
|
,getListener: function() {
|
||||||
|
@ -46,7 +46,7 @@ module.exports =
|
||||||
for (var key in map)
|
for (var key in map)
|
||||||
newMap[key] = map[key];
|
newMap[key] = map[key];
|
||||||
|
|
||||||
this.set (newMap);
|
this.set(newMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -60,7 +60,7 @@ module.exports =
|
||||||
if (map[key] === null || map[key] === undefined)
|
if (map[key] === null || map[key] === undefined)
|
||||||
delete map[key];
|
delete map[key];
|
||||||
|
|
||||||
var newHash = this.make (map);
|
var newHash = this.make(map);
|
||||||
|
|
||||||
if (!map)
|
if (!map)
|
||||||
map = {};
|
map = {};
|
||||||
|
@ -73,7 +73,7 @@ module.exports =
|
||||||
location.hash = newHash;
|
location.hash = newHash;
|
||||||
this._blockChanged = false;
|
this._blockChanged = false;
|
||||||
|
|
||||||
this._listener.changed ();
|
this._listener.changed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,10 +109,10 @@ module.exports =
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var newMap = hashMap = {};
|
var newMap = hashMap = {};
|
||||||
var kvPairs = newHash.substr(2).split ('&');
|
var kvPairs = newHash.substr(2).split('&');
|
||||||
|
|
||||||
for (var i = 0; i < kvPairs.length; i++) {
|
for (var i = 0; i < kvPairs.length; i++) {
|
||||||
var kvPair = kvPairs[i].split ('=', 2);
|
var kvPair = kvPairs[i].split('=', 2);
|
||||||
|
|
||||||
if (kvPair[0])
|
if (kvPair[0])
|
||||||
newMap[decodeURIComponent(kvPair[0])] = decodeURIComponent(kvPair[1]);
|
newMap[decodeURIComponent(kvPair[0])] = decodeURIComponent(kvPair[1]);
|
||||||
|
@ -120,6 +120,6 @@ module.exports =
|
||||||
|
|
||||||
this._hashMap = newMap;
|
this._hashMap = newMap;
|
||||||
this._hash = newHash;
|
this._hash = newHash;
|
||||||
this._listener.changed ();
|
this._listener.changed();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
39
js/vn/url.js
39
js/vn/url.js
|
@ -8,10 +8,9 @@ module.exports =
|
||||||
*
|
*
|
||||||
* @param {string} key The variable name
|
* @param {string} key The variable name
|
||||||
**/
|
**/
|
||||||
getQuery: function (key)
|
getQuery: function(key) {
|
||||||
{
|
var regExp = new RegExp('[\?\&]'+ key +'=([^\&]*)(\&?)', 'i');
|
||||||
var regExp = new RegExp ('[\?\&]'+ key +'=([^\&]*)(\&?)', 'i');
|
var value = location.search.match(regExp);
|
||||||
var value = location.search.match (regExp);
|
|
||||||
|
|
||||||
return value ? value[1] : value;
|
return value ? value[1] : value;
|
||||||
}
|
}
|
||||||
|
@ -22,21 +21,18 @@ module.exports =
|
||||||
* @param {string} key The variable name
|
* @param {string} key The variable name
|
||||||
* @param {string} value The new value
|
* @param {string} value The new value
|
||||||
**/
|
**/
|
||||||
,setQuery: function (key, value)
|
,setQuery: function(key, value) {
|
||||||
{
|
|
||||||
var changed = true;
|
var changed = true;
|
||||||
var found = false;
|
var found = false;
|
||||||
var newPair = key +'='+ value;
|
var newPair = key +'='+ value;
|
||||||
var kvPairs = location.search.substr(1).split ('?');
|
var kvPairs = location.search.substr(1).split('?');
|
||||||
|
|
||||||
for (var i = 0; i < kvPairs.length; i++)
|
for (var i = 0; i < kvPairs.length; i++) {
|
||||||
{
|
var kvPair = kvPairs[i].split('=', 1);
|
||||||
var kvPair = kvPairs[i].split ('=', 1);
|
|
||||||
|
|
||||||
if (kvPair[0] == key)
|
if (kvPair[0] == key) {
|
||||||
{
|
|
||||||
if (kvPair[1] != value)
|
if (kvPair[1] != value)
|
||||||
kvPairs.splice (i, 1, newPair);
|
kvPairs.splice(i, 1, newPair);
|
||||||
else
|
else
|
||||||
changed = false;
|
changed = false;
|
||||||
|
|
||||||
|
@ -46,29 +42,26 @@ module.exports =
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found)
|
if (!found)
|
||||||
kvPairs.push (newPair);
|
kvPairs.push(newPair);
|
||||||
|
|
||||||
if (changed)
|
if (changed)
|
||||||
document.location.hash = '?'+ kvPairs.join ('&');
|
document.location.hash = '?'+ kvPairs.join('&');
|
||||||
}
|
}
|
||||||
|
|
||||||
,makeUri: function (map)
|
,makeUri: function(map) {
|
||||||
{
|
|
||||||
var post = '';
|
var post = '';
|
||||||
|
|
||||||
for (var key in map)
|
for (var key in map) {
|
||||||
{
|
|
||||||
var value = map[key];
|
var value = map[key];
|
||||||
|
|
||||||
if (post.length > 2)
|
|
||||||
post += '&';
|
|
||||||
|
|
||||||
if (value === null || value === undefined)
|
if (value === null || value === undefined)
|
||||||
continue;
|
continue;
|
||||||
if (typeof value == 'boolean')
|
if (typeof value == 'boolean')
|
||||||
value = value ? '1' : '0';
|
value = value ? '1' : '0';
|
||||||
|
if (post.length > 2)
|
||||||
|
post += '&';
|
||||||
|
|
||||||
post += key +'='+ encodeURIComponent (value);
|
post += encodeURIComponent(key) +'='+ encodeURIComponent(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return post;
|
return post;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "hedera-web",
|
"name": "hedera-web",
|
||||||
"version": "1.406.32",
|
"version": "1.406.33",
|
||||||
"description": "Verdnatura web page",
|
"description": "Verdnatura web page",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
|
@ -17,9 +17,11 @@ class Transaction extends Vn\Web\JsonRequest {
|
||||||
throw new Exception('Transaction error');
|
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 : '';
|
||||||
|
$urlOk = empty($_REQUEST['urlOk']) ? '' :
|
||||||
|
str_replace('_transactionId_', $transactionId, $_REQUEST['urlOk']);
|
||||||
|
$urlKo = empty($_REQUEST['urlKo']) ? '' :
|
||||||
|
str_replace('_transactionId_', $transactionId, $_REQUEST['urlKo']);
|
||||||
|
|
||||||
$params = [
|
$params = [
|
||||||
'Ds_Merchant_Amount' => $amount
|
'Ds_Merchant_Amount' => $amount
|
||||||
|
@ -39,9 +41,16 @@ class Transaction extends Vn\Web\JsonRequest {
|
||||||
|
|
||||||
$bytes = [0, 0, 0, 0, 0, 0, 0, 0];
|
$bytes = [0, 0, 0, 0, 0, 0, 0, 0];
|
||||||
$iv = implode(array_map('chr', $bytes));
|
$iv = implode(array_map('chr', $bytes));
|
||||||
$key = mcrypt_encrypt(MCRYPT_3DES, $key, $transactionId, MCRYPT_MODE_CBC, $iv);
|
|
||||||
|
$paddedData = $transactionId;
|
||||||
$signature = base64_encode(hash_hmac('sha256', $encodedParams, $key, TRUE));
|
if (strlen($paddedData) % 8) {
|
||||||
|
$paddedData = str_pad($paddedData,
|
||||||
|
strlen($paddedData) + 8 - strlen($paddedData) % 8, "\0");
|
||||||
|
}
|
||||||
|
|
||||||
|
$encryptedData = openssl_encrypt($paddedData,
|
||||||
|
'des-ede3-cbc', $key, OPENSSL_RAW_DATA | OPENSSL_NO_PADDING , $iv);
|
||||||
|
$signature = base64_encode(hash_hmac('sha256', $encodedParams, $encryptedData, TRUE));
|
||||||
|
|
||||||
$url = $row->url;
|
$url = $row->url;
|
||||||
$postValues = [
|
$postValues = [
|
||||||
|
|
Loading…
Reference in New Issue