suite save paybox info

This commit is contained in:
Marion Muszynski 2016-07-18 11:45:18 +02:00
parent 5ae34ea5ab
commit fb51c877c4
8 changed files with 173 additions and 18 deletions

View File

@ -11,17 +11,16 @@ $controller->preProcess();
if (!$cookie->isLogged())
Tools::redirect('authentication.php');
if (Tools::getValue('id_paybox_card')) {
$paybox_card = Db::getInstance()->getValue('
$id_paybox_card = Tools::getValue('id_paybox_card', false);
if ($id_paybox_card) {
$paybox_card = Db::getInstance()->getRow('
SELECT *
FROM `ps_paybox_customer_agreement`
WHERE `handle` = "'.pSQL($values["u"]).'"
AND `date`='.(int)$values["d"].'
AND `refabonne`='.(int)$value['b'].'
AND `id_customer`='.(int)$id_customer.'
WHERE `id_customer` = '.(int)$cart->id_customer.'
AND `id_paybox_card` = '.(int)$id_paybox_card.'
');
if(empty($paybox_card)) {
Tools::redirect('authentication.php');
Tools::redirect('order.php?step=3&cgv=1&paybox_error=1');
}
}
include(dirname(__FILE__).'/../../header.php');
@ -44,7 +43,10 @@ Configuration::updateValue('NUM_QUESTION_PAYBOX', $num_question);
$montant == (int)sprintf('%010d', number_format(Tools::convertPrice($cart->getOrderTotal(), null, false), 2, '.', '') * 100);
$devise = 978;
$cvv = explode('++', $paybox_card['handle']);
$card_info = explode('++', $paybox_card['handle']);
$numbers = urldecode($card_info[0]);
$dateval = $card_info[1];
$cvv = $card_info[2];
$customer = new Customer((int)$cart->id_customer);
$refabonne = md5($customer->email);
@ -59,9 +61,10 @@ $postfields = array(
'DEVISE' => $devise,
'REFERENCE' => (int)$cart->id,
'REFABONNE' => md5($customer),
'PORTEUR' => $paybox_card['handle'],
'DATEVAL' => $paybox_card['date'],
'CVV' => Configuration::get('PBX_DEMO_MODE') == 0 ?'123':$cvv,
'PORTEUR' => $numbers,
'DATEVAL' => $dateval,
'ACTIVITE' => '027',
/*'CVV' => Configuration::get('PBX_DEMO_MODE') == 0 ?'123':$cvv,*/
'DATEQ' => date('dmYHis')
);
@ -81,7 +84,7 @@ mail('marion@antadis.com', 'Paiement reponse globale', http_build_query($respons
// payment success
if (Configuration::get('PBX_DEMO_MODE') == 0) {
if ($code_reponse[1] == "XXXXXX" || $code_reponse[0] == "XXXXXX") {
if ($code_reponse[1] == "00000" || $code_reponse[0] == "00000") {
return true;
}
} else {

View File

@ -3,6 +3,7 @@
<div class="input_radio">
<div class="hidden">
<form action="{$pbx_link}" method="post" name="paybox_form">
<input type="hidden" name="save_paybox" id="save_paybox" value="0"/>
<input type="hidden" name="PBX_MODE" value="{$PBX_MODE}" />
<input type="hidden" name="PBX_TOTAL" value="{$PBX_TOTAL}" />
{if isset($PBX_PAYBOX)}<input type="hidden" name="PBX_PAYBOX" value="{$PBX_PAYBOX}" />{/if}
@ -17,7 +18,7 @@
<div class="label">
<span class="title_payment">{$pbx_text}</span>
<span class="save_info">
<input type="checkbox" name="save_info_paybox" id="save_info_paybox" data-change="save_info_paybox">
<input type="checkbox" id="save_info_paybox" data-change="save_info_paybox">
<label for="save_info_paybox">{l s='Save my card information for future payments' mod='paybox'}</label><span class="paiement_info_lightbox paybox_info">?</span>
</span>
</div>
@ -33,11 +34,58 @@
<input type="hidden" name="id_paybox_card" value="{$account.id_paybox_card}"/>
</form>
</div>
<input type="radio" value="{$base_dir_ssl}modules/paybox/direct_paiement.php?id_paybox_card={$account.id_paybox_card}" name="paiement-method" id="paybox_{$account.id_paybox_card}">
<input data-module-name="paybox" type="radio" value="{$base_dir_ssl}modules/paybox/direct_paiement.php?id_paybox_card={$account.id_paybox_card}" name="paiement-method" id="paybox_{$account.id_paybox_card}">
<label for="paybox_{$account.id_paybox_card}">{$account.payment_type} {$account.value} - {$account.date_validity}</label>
</div>
{/foreach}
</div>
{/if}
</div>
<div class="overlay_bbb info_paybox"></div>
<div class="box_add_to_cart payment_info_paybox">
<div class="content">
<h3>{l s='Mémorisation de vos données bancaires' mod='paybox'}</h3>
<div id="close_add_to_cart" class="close">
<img alt="{l s='Fermer la fenètre'}" src="{$img_dir}close.jpg">
</div>
<div class="content_box">
<p>
{l s='Lors du passage d\'une commande, vous pouvez choisir de mémoriser vos coordonnées de carte bancaire. Ces dernières seront alors enregistrées sur les serveurs sécurisés de Paybox. Votre compte enregistré vous sera proposé pour vos prochaines commandes sans que vous n\'ayez besoin de saisir de nouveau vos données.' mod='paybox'}
</p>
<p>
{l s='Quelle que soit l\'option choisie, seul paybox a accès à vos informations, et en aucun cas Bébé Boutik.' mod='paybox'}
</p>
<p>
{l s='Vous pouvez à tout moment voir et supprimer vos cartes enregistrées sur la page « Gérer mes moyens de paiement » dans le menu « Mon compte ».' mod='paybox'}
</p>
</div>
</div>
</div>
</div>
{literal}
<script>
$(document).ready(function(){
if ($('#save_info_paybox').is(':checked')) {
$('#save_paybox').val('1');
} else {
$('#save_paybox').val('0');
}
$('.paybox_info').live('click', function(){
$('.info_paybox').fadeIn();
$('.payment_info_paybox').fadeIn();
});
$('#save_info_paybox').change(function(){
if ($(this).is(':checked')) {
$('#save_paybox').val('1');
} else {
$('#save_paybox').val('0');
}
});
});
</script>
{/literal}

View File

@ -22,8 +22,9 @@ $ps_url = 'http://'.$_SERVER['HTTP_HOST'].__PS_BASE_URI__;
$pbx_site = trim(Configuration::get('PBX_SITE'));
$pbx_rang = trim(Configuration::get('PBX_RANG'));
$pbx_id = trim(Configuration::get('PBX_ID'));
$save_paybox = Tools::getValue('save_paybox', false);
if(Tools::getValue('save_info_paybox')) {
if($save_paybox) {
$pbx_retour = 'm:M;r:R;t:T;a:A;b:B;p:P;c:C;s:S;y:Y;e:E;n:N;j:J;d:D;u:U;k:K';
} else {
$pbx_retour = 'm:M;r:R;t:T;a:A;b:B;p:P;c:C;s:S;y:Y;e:E;n:N;j:J;d:D;k:K';

View File

@ -307,7 +307,7 @@ class Paybox extends PaymentModule
**/
public function saveInformationCB($values,$id_customer) {
mail('marion@antadis.com', 'Transaction value', http_build_query($values,'',', ')); // dev
mail('marion@antadis.com', 'Transaction value + Save CB', http_build_query($values,'',', ')); // dev
$exists = Db::getInstance()->getValue('
SELECT `id_paybox_card`

View File

@ -10,7 +10,7 @@ if (!$cookie->isLogged())
include(dirname(__FILE__).'/../../header.php');
// DELTE ACCOUNT PAYPAL
// DELETE ACCOUNT PAYPAL
if (Tools::getValue('delete_agreement')) {
$id_paypal_agreement = Tools::getValue('delete_agreement');
@ -34,6 +34,31 @@ if (Tools::getValue('delete_agreement')) {
'delete' => true,
));
}
// DELETE PAYBOX CARD
if (Tools::getValue('delete_card')) {
$id_paybox_card = Tools::getValue('delete_card');
$id_customer_test = Db::getInstance()->getValue('
SELECT `id_customer`
FROM `'._DB_PREFIX_.'paybox_customer_agreement`
WHERE `id_paybox_card`= '.(int) $id_paybox_card.'
');
if(empty($id_customer_test)) {
return false;
}
if($id_customer_test != $cookie->id_customer) {
return false;
}
// DELETE
Db::getInstance()->execute('
DELETE FROM `'._DB_PREFIX_.'paybox_customer_agreement`
WHERE `id_paybox_card`= '.(int) $id_paybox_card
);
$smarty->assign(array(
'delete' => true,
));
}
// account paypal
$paypal_accounts = Db::getInstance()->executes('
SELECT `id_paypal_agreement`, `email`, `name`, `city`, `date_add`
@ -41,8 +66,16 @@ $paypal_accounts = Db::getInstance()->executes('
WHERE `id_customer`= '.(int) $cookie->id_customer.'
');
// account paybox
$paybox_accounts = Db::getInstance()->executes('
SELECT `id_paybox_card`, `value`, `date`, `payment_type`
FROM `'._DB_PREFIX_.'paybox_customer_agreement`
WHERE `id_customer`= '.(int) $cookie->id_customer.'
');
$smarty->assign(array(
'paypal_accounts' => $paypal_accounts,
'paybox_accounts' => $paybox_accounts,
));

View File

@ -6571,6 +6571,24 @@ table#carrierTable tbody td {
text-align:center;
}
/***** Paybox save CB *****/
.paybox_account {
background: #fff none repeat scroll 0 0;
border: 1px solid #ccc;
margin: 10px 0 5px;
padding: 15px;
overflow: auto;
}
.paybox_account input[type="radio"] {
float: left;
margin-right: 7px;
position: relative;
top: 3px;
}
.paybox_account label {
float: left;
}
@keyframes slideInDown {
0% {
-webkit-transform: translateY(-500px);

View File

@ -37,4 +37,33 @@
<div id="block-history" class="block-center">
<p class="warning">{l s='No account register' mod='paymentinfo'}</p>
</div>
{/if}
<br>
<h3>{l s='My Cards' mod='paymentinfo'}</h3>
{if $paybox_accounts}
<table class="std">
<thead>
<th class="item">{l s='Payment type' mod='paymentinfo'}</th>
<th class="item">{l s='Number' mod='paymentinfo'}</th>
<th class="item">{l s='Date validity' mod='paymentinfo'}</th>
<th class="item">{l s='Action' mod='paymentinfo'}</th>
</thead>
<tbody>
{foreach from=$paybox_accounts item=paybox}
<tr>
<td>{$paybox.payment_type}</td>
<td>{$paybox.value}</td>
<td>{substr_replace($paybox.date,'/',-2,0)}</td>
<td><a onclick="return confirm('{l s='Are you sure?' mod='paymentinfo'}');" href="?delete_card={$paybox.id_paybox_card}">{l s='Delete' mod='paymentinfo'}</a></td>
</tr>
{/foreach}
</tbody>
</table>
{else}
<div id="block-history" class="block-center">
<p class="warning">{l s='No card register' mod='paymentinfo'}</p>
</div>
{/if}

View File

@ -37,6 +37,29 @@
<br />
<h4 class='subtitle'>{l s='My cards' mod='paymentinfo'}</h4>
{if $paybox_accounts}
<table class="std table_skin">
<tbody>
{foreach from=$paybox_accounts item=paybox}
<tr>
<td>
<b>{$paybox.payment_type}</b> - {$paybox.value} {substr_replace($paybox.date,'/',-2,0)}
</td>
<td><a onclick="return confirm('{l s='Are you sure?' mod='paymentinfo'}');" href="?delete_card={$paybox.id_paybox_card}">{l s='Delete' mod='paymentinfo'}</a></td>
</tr>
{/foreach}
</tbody>
</table>
{else}
<div id="block-history" class="block-center">
<p class="warning">{l s='No card register' mod='paymentinfo'}</p>
</div>
{/if}
<br />
<p class="footer_links">
<a class="back_account" href="{$link->getPageLink('my-account.php', true)}" class="button">
<i class="icon-user"></i><span>{l s='Back to my account' mod='paymentinfo'}</span>