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]
|
||||
space-before-function-paren: [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.
|
||||
|
||||
|
|
|
@ -162,6 +162,7 @@
|
|||
font-size: 1.1em;
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
max-height: 2.4em;
|
||||
}
|
||||
.item-info > p
|
||||
{
|
||||
|
|
|
@ -1,45 +1,38 @@
|
|||
|
||||
Hedera.Orders = new Class
|
||||
({
|
||||
Extends: Hedera.Form
|
||||
Hedera.Orders = new Class({
|
||||
Extends: Hedera.Form,
|
||||
|
||||
,activate: function ()
|
||||
{
|
||||
activate: function() {
|
||||
this.tpv = new Hedera.Tpv({conn: this.conn});
|
||||
this.tpv.check(this._onTpvCheck.bind(this));
|
||||
}
|
||||
},
|
||||
|
||||
,_onTpvCheck: function (tpv, tpvOrder, tpvStatus)
|
||||
{
|
||||
_onTpvCheck: function(tpv, tpvOrder, tpvStatus) {
|
||||
if (tpvStatus === 'ko')
|
||||
this.$('error-dialog').show();
|
||||
}
|
||||
},
|
||||
|
||||
,onBasketClick: function ()
|
||||
{
|
||||
onBasketClick: function() {
|
||||
this.hash.set({form: 'ecomerce/basket'});
|
||||
}
|
||||
},
|
||||
|
||||
,repeaterFunc: function (res, form)
|
||||
{
|
||||
repeaterFunc: function(res, form) {
|
||||
res.$('link').href = this.hash.make({
|
||||
form: 'ecomerce/ticket',
|
||||
ticket: form.get('id')
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// TPV
|
||||
|
||||
,balanceConditionalFunc: function (field, value)
|
||||
{
|
||||
balanceConditionalFunc: function(field, value) {
|
||||
if (value >= 0)
|
||||
Vn.Node.removeClass(this.$('balance'), 'negative');
|
||||
else
|
||||
Vn.Node.addClass(this.$('balance'), 'negative');
|
||||
}
|
||||
},
|
||||
|
||||
,onPayButtonClick: function ()
|
||||
{
|
||||
onPayButtonClick: function() {
|
||||
var amount = -this.$('debt').value;
|
||||
amount = amount <= 0 ? null : amount;
|
||||
|
||||
|
@ -50,15 +43,13 @@ Hedera.Orders = new Class
|
|||
|
||||
amount = prompt(_('AmountToPay:'), defaultAmountStr);
|
||||
|
||||
if (amount != null)
|
||||
{
|
||||
if (amount != null) {
|
||||
amount = parseFloat(amount.replace(',', '.'));
|
||||
this.tpv.pay(amount, null);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
,onDialogResponse: function (dialog, response)
|
||||
{
|
||||
onDialogResponse: function(dialog, response) {
|
||||
if (response == Htk.Dialog.Button.RETRY)
|
||||
this.tpv.retryPay();
|
||||
}
|
||||
|
|
|
@ -6,13 +6,11 @@ module.exports = new Class
|
|||
,tpvOrder: null
|
||||
,tpvStatus: null
|
||||
|
||||
,check: function (callback)
|
||||
{
|
||||
,check: function(callback) {
|
||||
this.tpvOrder = Vn.Hash.get('tpvOrder');
|
||||
this.tpvStatus = Vn.Hash.get('tpvStatus');
|
||||
|
||||
if (this.tpvStatus)
|
||||
{
|
||||
if (this.tpvStatus) {
|
||||
var batch = new Sql.Batch();
|
||||
batch.addValue('transaction', this.tpvOrder);
|
||||
batch.addValue('status', this.tpvStatus);
|
||||
|
@ -25,15 +23,12 @@ module.exports = new Class
|
|||
callback(this, this.tpvOrder, this.tpvStatus);
|
||||
}
|
||||
|
||||
,pay: function (amount, company)
|
||||
{
|
||||
,pay: function(amount, company) {
|
||||
this._realPay(amount * 100, company);
|
||||
}
|
||||
|
||||
,_realPay: function (amount, company)
|
||||
{
|
||||
if (isNumeric (amount) && amount > 0)
|
||||
{
|
||||
,_realPay: function(amount, company) {
|
||||
if (isNumeric(amount) && amount > 0) {
|
||||
var params = {
|
||||
amount: parseInt(amount)
|
||||
,urlOk: this._makeUrl('ok')
|
||||
|
@ -43,15 +38,12 @@ module.exports = new Class
|
|||
|
||||
this.conn.send('tpv/transaction', params,
|
||||
this._onTransactionStart.bind(this));
|
||||
}
|
||||
else
|
||||
} else
|
||||
Htk.Toast.showError(_('AmountError'));
|
||||
}
|
||||
|
||||
,_onTransactionStart: function (json)
|
||||
{
|
||||
if (json)
|
||||
{
|
||||
,_onTransactionStart: function(json) {
|
||||
if (json) {
|
||||
var postValues = json.postValues;
|
||||
|
||||
var form = document.createElement('form');
|
||||
|
@ -59,8 +51,7 @@ module.exports = new Class
|
|||
form.action = json.url;
|
||||
document.body.appendChild(form);
|
||||
|
||||
for (var field in postValues)
|
||||
{
|
||||
for (var field in postValues) {
|
||||
var input = document.createElement('input');
|
||||
input.type = 'hidden';
|
||||
input.name = field;
|
||||
|
@ -71,13 +62,11 @@ module.exports = new Class
|
|||
}
|
||||
|
||||
form.submit();
|
||||
}
|
||||
else
|
||||
} else
|
||||
Htk.Toast.showWarning(_('PayError'));
|
||||
}
|
||||
|
||||
,retryPay: function ()
|
||||
{
|
||||
,retryPay: function() {
|
||||
var batch = new Sql.Batch();
|
||||
batch.addValue('transaction', parseInt(this.tpvOrder));
|
||||
|
||||
|
@ -89,8 +78,7 @@ module.exports = new Class
|
|||
this._onRetryPayDone.bind(this), batch);
|
||||
}
|
||||
|
||||
,_onRetryPayDone: function (resultSet)
|
||||
{
|
||||
,_onRetryPayDone: function(resultSet) {
|
||||
var res = resultSet.fetchResult();
|
||||
|
||||
if (res.next())
|
||||
|
@ -99,8 +87,7 @@ module.exports = new Class
|
|||
Htk.Toast.showError(_('AmountError'));
|
||||
}
|
||||
|
||||
,_makeUrl: function (status)
|
||||
{
|
||||
,_makeUrl: function(status) {
|
||||
var path = location.protocol +'//'+ location.host;
|
||||
path += location.port ? ':'+ location.port : '';
|
||||
path += location.pathname;
|
||||
|
@ -108,14 +95,13 @@ module.exports = new Class
|
|||
path += Vn.Hash.make({
|
||||
form: 'ecomerce/orders',
|
||||
tpvStatus: status,
|
||||
tpvOrder: '%s'
|
||||
tpvOrder: '_transactionId_'
|
||||
}, true);
|
||||
|
||||
return path;
|
||||
}
|
||||
});
|
||||
|
||||
function isNumeric (n)
|
||||
{
|
||||
function isNumeric(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
|
||||
**/
|
||||
getQuery: function (key)
|
||||
{
|
||||
getQuery: function(key) {
|
||||
var regExp = new RegExp('[\?\&]'+ key +'=([^\&]*)(\&?)', 'i');
|
||||
var value = location.search.match(regExp);
|
||||
|
||||
|
@ -22,19 +21,16 @@ module.exports =
|
|||
* @param {string} key The variable name
|
||||
* @param {string} value The new value
|
||||
**/
|
||||
,setQuery: function (key, value)
|
||||
{
|
||||
,setQuery: function(key, value) {
|
||||
var changed = true;
|
||||
var found = false;
|
||||
var newPair = key +'='+ value;
|
||||
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);
|
||||
|
||||
if (kvPair[0] == key)
|
||||
{
|
||||
if (kvPair[0] == key) {
|
||||
if (kvPair[1] != value)
|
||||
kvPairs.splice(i, 1, newPair);
|
||||
else
|
||||
|
@ -52,23 +48,20 @@ module.exports =
|
|||
document.location.hash = '?'+ kvPairs.join('&');
|
||||
}
|
||||
|
||||
,makeUri: function (map)
|
||||
{
|
||||
,makeUri: function(map) {
|
||||
var post = '';
|
||||
|
||||
for (var key in map)
|
||||
{
|
||||
for (var key in map) {
|
||||
var value = map[key];
|
||||
|
||||
if (post.length > 2)
|
||||
post += '&';
|
||||
|
||||
if (value === null || value === undefined)
|
||||
continue;
|
||||
if (typeof value == 'boolean')
|
||||
value = value ? '1' : '0';
|
||||
if (post.length > 2)
|
||||
post += '&';
|
||||
|
||||
post += key +'='+ encodeURIComponent (value);
|
||||
post += encodeURIComponent(key) +'='+ encodeURIComponent(value);
|
||||
}
|
||||
|
||||
return post;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "hedera-web",
|
||||
"version": "1.406.32",
|
||||
"version": "1.406.33",
|
||||
"description": "Verdnatura web page",
|
||||
"license": "GPL-3.0",
|
||||
"repository": {
|
||||
|
|
|
@ -17,9 +17,11 @@ class Transaction extends Vn\Web\JsonRequest {
|
|||
throw new Exception('Transaction error');
|
||||
|
||||
$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 : '';
|
||||
$urlOk = empty($_REQUEST['urlOk']) ? '' :
|
||||
str_replace('_transactionId_', $transactionId, $_REQUEST['urlOk']);
|
||||
$urlKo = empty($_REQUEST['urlKo']) ? '' :
|
||||
str_replace('_transactionId_', $transactionId, $_REQUEST['urlKo']);
|
||||
|
||||
$params = [
|
||||
'Ds_Merchant_Amount' => $amount
|
||||
|
@ -39,9 +41,16 @@ class Transaction extends Vn\Web\JsonRequest {
|
|||
|
||||
$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));
|
||||
$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;
|
||||
$postValues = [
|
||||
|
|
Loading…
Reference in New Issue