fix conflict

This commit is contained in:
Marion Muszynski 2016-07-15 17:50:32 +02:00
commit 354e020c68
5 changed files with 176 additions and 5 deletions

View File

@ -0,0 +1,94 @@
<?php
require_once(dirname(__FILE__).'/../../config/config.inc.php');
require_once(dirname(__FILE__).'/../../init.php');
require_once(dirname(__FILE__).'/paybox.php');
global $cart, $smarty;
$module = new Paybox();
$controller->preProcess();
if (!$cookie->isLogged())
Tools::redirect('authentication.php');
if (Tools::getValue('id_paybox_card')) {
$paybox_card = Db::getInstance()->getValue('
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.'
');
if(empty($paybox_card)) {
Tools::redirect('authentication.php');
}
}
include(dirname(__FILE__).'/../../header.php');
if(Configuration::get('PBX_DEMO_MODE') == 0) {
$curl = curl_init('https://preprod-ppps.paybox.com/PPPS.php');
} else {
//$curl = curl_init('https://ppps.paybox.com/PPPS.php');
}
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_COOKIESESSION, true);
$pbx_site = trim(Configuration::get('PBX_SITE'));
$pbx_rang = trim(Configuration::get('PBX_RANG'));
$pbx_id = trim(Configuration::get('PBX_ID'));
$num_question = Configuration::get('NUM_QUESTION_PAYBOX') + 1;
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']);
$customer = new Customer((int)$cart->id_customer);
$refabonne = md5($customer->email);
$postfields = array(
'VERSION' => '00104',
'TYPE' => '00053',
'SITE' => $pbx_site,
'RANG' => $pbx_rang,
'CLE' => 'EFNLJKFB',
'NUMQUESTION' => $num_question,
'MONTANT' => $montant,
'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,
'DATEQ' => date('dmYHis')
);
$trame = http_build_query($postfields, '', '&');
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
curl_setopt($curl, CURLOPT_POSTFIELDS, $trame);
$response = curl_exec($curl);
curl_close($curl);
$data = explode('&', $response);
$code_reponse = explode('CODEREPONSE=', $data[6]);
mail('marion@antadis.com', 'Paiement reponse globale', http_build_query($response,'',', '));
// payment success
if (Configuration::get('PBX_DEMO_MODE') == 0) {
if ($code_reponse[1] == "XXXXXX" || $code_reponse[0] == "XXXXXX") {
return true;
}
} else {
if ($code_reponse[1] == "00000" || $code_reponse[0] == "00000") {
return true;
} else {
mail('marion@antadis.com', 'Soucis paiement reponse globale', json_encode($response));
return false;
}
}

View File

@ -16,6 +16,28 @@
</div>
<div class="label">
<span class="title_payment">{$pbx_text}</span>
<span class="save_info">
<input type="checkbox" id="save_info_paypal" 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>
</div>
{if $paybox_cards}
<div class="account_payment">
<p class="title">{l s='You have registered cards, you can use them to pay' mod='paypal'}</p>
{foreach from=$paybox_cards item=account}
<div class="box_account">
<div class="hidden">
<form id="paybox_payment_form" action="{$pbx_link_plus}" data-ajax="false" title="{l s='Pay with Paybox' mod='paybox'}" method="post">
<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}">
<label for="paybox_{$account.id_paybox_card}">{$account.payment_type} {$account.value} - {$account.date_validity}</label>
</div>
{/foreach}
</div>
{/if}
</div>

View File

@ -23,7 +23,11 @@ $pbx_site = trim(Configuration::get('PBX_SITE'));
$pbx_rang = trim(Configuration::get('PBX_RANG'));
$pbx_id = trim(Configuration::get('PBX_ID'));
$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';
if(Tools::getValue('save_info_paypal')) {
$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';
}
$pbx_total = (int)sprintf('%f', number_format(Tools::convertPrice($cart->getOrderTotal(), null, false), 2, '.', '') * 100);
if (version_compare(_PS_VERSION_, '1.5', '>'))
@ -70,7 +74,7 @@ unset($language);
$pbx_devise = 978; // euro
$params = "PBX_MODE=4 PBX_SITE=".$pbx_site." PBX_RANG=".$pbx_rang." PBX_TOTAL=".$pbx_total." PBX_DEVISE=".$pbx_devise." PBX_CMD=".(int)$cart->id." PBX_PORTEUR=".$customer->email." PBX_RETOUR='".$pbx_retour."' PBX_IDENTIFIANT=".$pbx_id." PBX_EFFECTUE='".$pbx_confurl."' PBX_ANNULE='".$pbx_cancelurl."' PBX_LANGUE='".$pbx_langue."' PBX_REFUSE='".$pbx_confurl."' PBX_REPONDRE_A='".$pbx_ipn."'";
$params = "PBX_MODE=4 PBX_SITE=".$pbx_site." PBX_RANG=".$pbx_rang." PBX_TOTAL=".$pbx_total." PBX_DEVISE=".$pbx_devise." PBX_CMD=".(int)$cart->id." PBX_PORTEUR=".$customer->email." PBX_REFABONNE=".md5($customer->email)." PBX_RETOUR='".$pbx_retour."' PBX_IDENTIFIANT=".$pbx_id." PBX_EFFECTUE='".$pbx_confurl."' PBX_ANNULE='".$pbx_cancelurl."' PBX_LANGUE='".$pbx_langue."' PBX_REFUSE='".$pbx_confurl."' PBX_REPONDRE_A='".$pbx_ipn."'";
if( Configuration::get('PBX_DEMO_MODE') == 0 ) {
if (_PS_MOBILE_) {

View File

@ -240,13 +240,25 @@ class Paybox extends PaymentModule
$pbx_total = (int)sprintf('%f', number_format(Tools::convertPrice($cart->getOrderTotal(), null, false), 2, '.', '') * 100);
$pbx_link = $ps_url.'modules/'.$this->name.'/paiement.php';
$pbx_link_plus = $ps_url.'modules/'.$this->name.'/direct_paiement.php';
$paybox_cards = Db::getInstance()->executeS('
SELECT `id_paybox_card`, `value`, `date`, `payment_type`
FROM `'._DB_PREFIX_.'paybox_customer_agreement`
WHERE `id_customer` = '.(int)$cart->id_customer.'
');
foreach ($paybox_cards as $key => $card) {
$paybox_cards[$key]['date_validity'] = substr_replace($card['date'],'/',-2,0);
}
$smarty->assign(array(
'PBX_MODE' => 1,
'pbx_link' => $pbx_link,
'PBX_TOTAL' => $pbx_total,
'pbx_picture' => 'paybox',
'pbx_text' => $this->l('Pay by credit card with Paybox')
'pbx_text' => $this->l('Pay by credit card with Paybox'),
'paybox_cards' => $paybox_cards,
'pbx_link_plus' => $pbx_link_plus,
));
return ($this->display(__FILE__, 'hookpayment.tpl'));
@ -289,6 +301,42 @@ class Paybox extends PaymentModule
}
}
/**
* Save Information de carte Paiement Paybox (retour de la banque + handle de la cart)
* @param array $values Tableau de retour Paybox
**/
public function saveInformationCB($values,$id_customer) {
mail('marion@antadis.com', 'Transaction value', http_build_query($values,'',', ')); // dev
$exists = Db::getInstance()->getValue('
SELECT `id_paybox_card`
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.'
');
if (empty($exists)) {
$num_value = (int)$values["n"].'XXXXX'.(int)$values["j"];
$save = Db::getInstance()->execute('
INSERT INTO `ps_paybox_customer_agreement`
(`id_customer`, `handle`, `refabonne`,`value`,`date`,`payment_type`)
VALUES (
'. (int)$id_customer .',
'. (int)$values["b"] .',
"'. pSQL($values["u"]) .'",
"'. pSQL($num_value) .'",
'. (int)$values["d"] .',
"'. pSQL($values["c"]) .'"
)');
if(!$save) {
mail('marion@antadis.com', 'Erreur save card', http_build_query($values,'',', '));
}
}
}
public function hookcancelShipping($params) {
global $cookie;

View File

@ -90,6 +90,9 @@ if (!$cart->id)
if ($id_order = (int)Order::getOrderByCartId($cart->id))
{
$paybox->saveInformationPaiement($values);
if (isset($values['u'])) {
$paybox->saveInformationCB($values,$cart->id_customer);
}
if (empty($error))
{