forked from verdnatura/hedera-web
Catalog text overlap fixed, tpv return url fixed
This commit is contained in:
parent
27ec20369e
commit
0a5aa8e6cd
|
@ -12,3 +12,4 @@ rules:
|
||||||
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,45 +1,38 @@
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
|
@ -50,15 +43,13 @@ Hedera.Orders = new Class
|
||||||
|
|
||||||
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();
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,13 +6,11 @@ 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);
|
||||||
|
@ -25,15 +23,12 @@ module.exports = new Class
|
||||||
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')
|
||||||
|
@ -43,15 +38,12 @@ module.exports = new Class
|
||||||
|
|
||||||
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');
|
||||||
|
@ -59,8 +51,7 @@ module.exports = new Class
|
||||||
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;
|
||||||
|
@ -71,13 +62,11 @@ module.exports = new Class
|
||||||
}
|
}
|
||||||
|
|
||||||
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));
|
||||||
|
|
||||||
|
@ -89,8 +78,7 @@ module.exports = new Class
|
||||||
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())
|
||||||
|
@ -99,8 +87,7 @@ module.exports = new Class
|
||||||
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;
|
||||||
|
@ -108,14 +95,13 @@ module.exports = new Class
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
25
js/vn/url.js
25
js/vn/url.js
|
@ -8,8 +8,7 @@ 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);
|
||||||
|
|
||||||
|
@ -22,19 +21,16 @@ 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
|
||||||
|
@ -52,23 +48,20 @@ module.exports =
|
||||||
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);
|
|
||||||
|
|
||||||
$signature = base64_encode(hash_hmac('sha256', $encodedParams, $key, TRUE));
|
$paddedData = $transactionId;
|
||||||
|
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