This commit is contained in:
ToutPratique 2017-04-28 17:39:44 +02:00
parent 43d3c5f567
commit 3afc1c78d5
2 changed files with 94 additions and 69 deletions

View File

@ -24,7 +24,7 @@ function payzenCheckFields() {
});
var cardNumber = $('#payzen_card_number').val();
if(cardNumber.length <= 0 || !(/^\d{13,19}$/.test(cardNumber))){
if(cardNumber.length <= 0 || !(/^[0-9 ]+$/.test(cardNumber))){
$('#payzen_card_number').addClass('invalid');
}

View File

@ -14,74 +14,99 @@
</div>
<div class="cbForm clearfix">
<form action="{$link->getModuleLink('payzen', 'redirect', array(), true)|escape:'html':'UTF-8'}" method="post" id="payzen_standard" {if $payzen_std_card_data_mode == 3}onsubmit="javascript: return payzenCheckFields();"{/if}>
<input type="hidden" name="payzen_payment_type" value="standard" />
{if ($payzen_std_card_data_mode == 2) OR ($payzen_std_card_data_mode == 3)}
<br />
{assign var=first value=true}
<div class="row">
{foreach from=$payzen_avail_cards key="key" item="label"}
<div style="display: inline-block;" class="inputCb col-xs-4 col-xxs-12">
{if $payzen_avail_cards|@count == 1}
<input type="hidden" id="payzen_card_type_{$key|escape:'html':'UTF-8'}" name="payzen_card_type" value="{$key|escape:'html':'UTF-8'}" >
{else}
<input class="custom-input inline" type="radio" id="payzen_card_type_{$key|escape:'html':'UTF-8'}" name="payzen_card_type" value="{$key|escape:'html':'UTF-8'}" style="vertical-align: middle;"{if $first == true} checked="checked"{/if} >
{/if}
<label for="payzen_card_type_{$key|escape:'html':'UTF-8'}">
{assign var=img_file value=$smarty.const._PS_MODULE_DIR_|cat:'payzen/views/img/':{$key|lower|escape:'html':'UTF-8'}:'.png'}
{if file_exists($img_file)}
<img src="{$base_dir_ssl|escape:'html':'UTF-8'}modules/payzen/views/img/{$key|lower}.png" alt="{$label|escape:'html':'UTF-8'}" title="{$label|escape:'html':'UTF-8'}" class="card" >
{else}
<span class="card">{$label|escape:'html':'UTF-8'}</span>
{/if}
</label>
{assign var=first value=false}
</div>
{/foreach}
</div>
<div style="margin-bottom: 12px;"></div>
{if $payzen_std_card_data_mode == 3}
<div class="row rowPayzen">
<div class="col-lg-4 col-md-6 col-xs-4 col-xxs-12">
<label for="payzen_card_number"> {l s='Card number' mod='payzen'}</label><br />
<input type="text" name="payzen_card_number" value="" autocomplete="off" maxlength="19" id="payzen_card_number" style="max-width: 220px;" class="data" >
</div>
<div class="col-lg-2 col-md-2 col-sm-2 col-xs-4 col-xxs-12 cvv">
<label for="payzen_cvv"> {l s='CVV' mod='payzen'}</label><br />
<input type="text" name="payzen_cvv" value="" autocomplete="off" maxlength="4" id="payzen_cvv" style="max-width: 55px;" class="data" >
</div>
<div class="col-lg-6 col-md-8 col-sm-6 col-xs-8 col-xxs-12">
<label for="payzen_expiry_month">{l s='Expiration date' mod='payzen'}</label>
<div class="row">
<div class="col-sm-6 col-xs-6 col-xxs-12">
<select name="payzen_expiry_month" id="payzen_expiry_month" style="width: 90px;" class="data custom-input">
<option value="">{l s='Month' mod='payzen'}</option>
{section name=expiry start=1 loop=13 step=1}
<option value="{$smarty.section.expiry.index|intval}">{$smarty.section.expiry.index|str_pad:2:"0":$smarty.const.STR_PAD_LEFT}</option>
{/section}
</select>
</div>
<div class="col-sm-6 col-xs-6 col-xxs-12">
<select name="payzen_expiry_year" id="payzen_expiry_year" style="width: 90px;" class="data custom-input">
<option value="">{l s='Year' mod='payzen'}</option>
{assign var=year value=$smarty.now|date_format:"%Y"}
{section name=expiry start=$year loop=$year+9 step=1}
<option value="{$smarty.section.expiry.index|intval}">{$smarty.section.expiry.index|intval}</option>
{/section}
</select>
</div>
</div>
</div>
</div>
{/if}
{*{if version_compare($smarty.const._PS_VERSION_, '1.6', '<')}
<input type="submit" name="submit" value="{l s='Pay now' mod='payzen'}" class="button pull-right" />
<input type="hidden" name="payzen_payment_type" value="standard" />
{if ($payzen_std_card_data_mode == 2) OR ($payzen_std_card_data_mode == 3)}
<br />
{assign var=first value=true}
<div class="row">
{foreach from=$payzen_avail_cards key="key" item="label"}
<div style="display: inline-block;" class="inputCb col-xs-4 col-xxs-12">
{if $payzen_avail_cards|@count == 1}
<input type="hidden" id="payzen_card_type_{$key|escape:'html':'UTF-8'}" name="payzen_card_type" value="{$key|escape:'html':'UTF-8'}" >
{else}
<button type="submit" name="submit" class="button btn btn-default standard-checkout button-medium pull-right" >
<span>{l s='Pay now' mod='payzen'}</span>
</button>
{/if}*}
{/if}
</form>
<input class="custom-input inline" type="radio" id="payzen_card_type_{$key|escape:'html':'UTF-8'}" name="payzen_card_type" value="{$key|escape:'html':'UTF-8'}" style="vertical-align: middle;"{if $first == true} checked="checked"{/if} >
{/if}
<label for="payzen_card_type_{$key|escape:'html':'UTF-8'}">
{assign var=img_file value=$smarty.const._PS_MODULE_DIR_|cat:'payzen/views/img/':{$key|lower|escape:'html':'UTF-8'}:'.png'}
{if file_exists($img_file)}
<img src="{$base_dir_ssl|escape:'html':'UTF-8'}modules/payzen/views/img/{$key|lower}.png" alt="{$label|escape:'html':'UTF-8'}" title="{$label|escape:'html':'UTF-8'}" class="card" >
{else}
<span class="card">{$label|escape:'html':'UTF-8'}</span>
{/if}
</label>
{assign var=first value=false}
</div>
{/foreach}
</div>
<div style="margin-bottom: 12px;"></div>
{if $payzen_std_card_data_mode == 3}
<div class="row rowPayzen">
<div class="col-lg-4 col-md-6 col-xs-4 col-xxs-12">
<label for="payzen_card_number"> {l s='Card number' mod='payzen'}</label><br />
<input type="text" name="payzen_card_number" value="" autocomplete="off" maxlength="19" id="payzen_card_number" style="max-width: 220px;" class="data" >
</div>
<div class="col-lg-2 col-md-2 col-sm-2 col-xs-4 col-xxs-12 cvv">
<label for="payzen_cvv"> {l s='CVV' mod='payzen'}</label><br />
<input type="text" name="payzen_cvv" value="" autocomplete="off" maxlength="4" id="payzen_cvv" style="max-width: 55px;" class="data" >
</div>
<div class="col-lg-6 col-md-8 col-sm-6 col-xs-8 col-xxs-12">
<label for="payzen_expiry_month">{l s='Expiration date' mod='payzen'}</label>
<div class="row">
<div class="col-sm-6 col-xs-6 col-xxs-12">
<select name="payzen_expiry_month" id="payzen_expiry_month" style="width: 90px;" class="data custom-input">
<option value="">{l s='Month' mod='payzen'}</option>
{section name=expiry start=1 loop=13 step=1}
<option value="{$smarty.section.expiry.index|intval}">{$smarty.section.expiry.index|str_pad:2:"0":$smarty.const.STR_PAD_LEFT}</option>
{/section}
</select>
</div>
<div class="col-sm-6 col-xs-6 col-xxs-12">
<select name="payzen_expiry_year" id="payzen_expiry_year" style="width: 90px;" class="data custom-input">
<option value="">{l s='Year' mod='payzen'}</option>
{assign var=year value=$smarty.now|date_format:"%Y"}
{section name=expiry start=$year loop=$year+9 step=1}
<option value="{$smarty.section.expiry.index|intval}">{$smarty.section.expiry.index|intval}</option>
{/section}
</select>
</div>
</div>
</div>
</div>
{/if}
{*{if version_compare($smarty.const._PS_VERSION_, '1.6', '<')}
<input type="submit" name="submit" value="{l s='Pay now' mod='payzen'}" class="button pull-right" />
{else}
<button type="submit" name="submit" class="button btn btn-default standard-checkout button-medium pull-right" >
<span>{l s='Pay now' mod='payzen'}</span>
</button>
{/if}*}
{/if}
</form>
<script>
{literal}
cardNumber = $('#payzen_card_number');
cardNumber.on('keyup', function() {
cardNumber.val(formatCardNumber(cardNumber.val()));
});
function formatCardNumber(value) {
var v = value.replace(/\s+/g, '').replace(/[^0-9]/gi, '')
var matches = v.match(/\d{4,19}/g);
var match = matches && matches[0] || ''
var parts = []
for (i=0, len=match.length; i<len; i+=4) {
parts.push(match.substring(i, i+4))
}
if (parts.length) {
return parts.join(' ')
} else {
return value
}
}
{/literal}
</script>
</div>
</div>