bebeboutik/modules/paybox/paiement.php

116 lines
4.3 KiB
PHP
Raw Normal View History

2016-01-04 12:49:26 +01:00
<?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())
2016-08-24 17:48:50 +02:00
Tools::redirect('authentication.php');
2016-01-04 12:49:26 +01:00
include(dirname(__FILE__).'/../../header.php');
$customer = new Customer((int)$cart->id_customer);
if (!Validate::isLoadedObject($customer))
2016-08-24 17:48:50 +02:00
die(Tools::displayError());
2016-01-04 12:49:26 +01:00
2017-03-09 15:11:22 +01:00
$ps_url = ((Configuration::get('PS_SSL_ENABLED') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PORT'] == '443')) ? 'https://' : 'http://').$_SERVER['HTTP_HOST'].__PS_BASE_URI__;
2016-01-04 12:49:26 +01:00
2016-08-24 17:48:50 +02:00
$pbx_site = trim(Configuration::get('PBX_SITE'));
$pbx_rang = trim(Configuration::get('PBX_RANG'));
$pbx_id = trim(Configuration::get('PBX_ID'));
$pbx_total = (int)sprintf('%f', number_format(Tools::convertPrice($cart->getOrderTotal(), null, false), 2, '.', '') * 100);
$pbx_devise = 978; // euro
$pbx_ipn = $ps_url.'modules/'.$module->name.'/validation.php';
$pbx_link = $ps_url.'modules/'.$module->name.'/paiement.php';
2017-06-21 16:37:50 +02:00
$pbx_3ds = 'N';
2016-01-04 12:49:26 +01:00
2016-08-24 17:48:50 +02:00
$save_paybox = Tools::getValue('save_paybox', false);
$refabonne = $customer->email;
2016-07-18 11:45:18 +02:00
if($save_paybox) {
$count_cards = Db::getInstance()->getValue('
SELECT COUNT(`id_paybox_card`)
FROM `'._DB_PREFIX_.'paybox_customer_agreement`
WHERE `id_customer` = '.(int)$cart->id_customer.'
');
if ($count_cards) {
$refabonne = $customer->email.((int)$count_cards+1);
}
2017-05-04 11:35:59 +02:00
$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;i:I;k:K';
2016-07-15 17:49:13 +02:00
} else {
2017-05-04 11:35:59 +02:00
$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;i:I;k:K';
2016-07-15 17:49:13 +02:00
}
2016-01-04 12:49:26 +01:00
if (version_compare(_PS_VERSION_, '1.5', '>'))
{
2016-08-24 17:48:50 +02:00
$pbx_confurl = $ps_url.'index.php?controller=order-confirmation&id_cart='.$cart->id.'&id_module='.$module->id.'&key='.$customer->secure_key;
$pbx_cancelurl = $ps_url.'index.php?controller=order&step=3';
2016-01-04 12:49:26 +01:00
}
else
{
2016-08-24 17:48:50 +02:00
$pbx_confurl = $ps_url.'order-confirmation.php?id_cart='.$cart->id.'&id_module='.$module->id.'&key='.$customer->secure_key;
$pbx_cancelurl = $ps_url.'order.php?step=3';
2016-01-04 12:49:26 +01:00
}
$language = new Language((int)$cart->id_lang);
switch ($language->iso_code)
{
2016-08-24 17:48:50 +02:00
case 'fr':
$pbx_langue = 'FRA';
break;
case 'es':
$pbx_langue = 'ESP';
break;
case 'de':
$pbx_langue = 'DEU';
break;
case 'it':
$pbx_langue = 'ITA';
break;
case 'nl':
$pbx_langue = 'NLD';
break;
case 'sv':
$pbx_langue = 'SWE';
break;
case 'en-us':
default:
$pbx_langue = 'GBR';
break;
2016-01-04 12:49:26 +01:00
}
unset($language);
2017-06-21 16:37:50 +02:00
$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=".$refabonne." PBX_3DS=".$pbx_3ds." 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."'";
2016-01-04 12:49:26 +01:00
if( Configuration::get('PBX_DEMO_MODE') == 0 ) {
2016-08-24 17:48:50 +02:00
if (_PS_MOBILE_) {
$params .= " PBX_PAYBOX=https://preprod-tpeweb.paybox.com/cgi/ChoixPaiementMobile.cgi PBX_BACKUP1=https://preprod-tpeweb.paybox.com/cgi/ChoixPaiementMobile.cgi";
} else {
$params .= " PBX_PAYBOX=https://preprod-tpeweb.paybox.com/cgi/MYchoix_pagepaiement.cgi PBX_BACKUP1=https://preprod-tpeweb.paybox.com/cgi/MYchoix_pagepaiement.cgi";
}
2016-01-04 12:49:26 +01:00
} else {
2016-08-24 17:48:50 +02:00
if (_PS_MOBILE_) {
$params .= " PBX_PAYBOX=https://tpeweb.paybox.com/cgi/ChoixPaiementMobile.cgi PBX_BACKUP1=https://tpeweb.paybox.com/cgi/ChoixPaiementMobile.cgi";
}
2016-01-04 12:49:26 +01:00
}
2016-09-28 10:49:22 +02:00
$authorized_ip = array(
'88.163.22.99',
'90.63.178.63',
2017-05-04 11:35:59 +02:00
'217.64.63.215'
2016-09-28 10:49:22 +02:00
);
if (in_array($_SERVER['REMOTE_ADDR'], $authorized_ip)) {
mail('marion@antadis.com', '[BBB] Envoi paybox', $params);
}
2016-01-04 12:49:26 +01:00
$info_useless = array('Content-type: text/html', 'Cache-Control: no-cache, no-store' , 'Pragma: no-cache');
2016-02-23 17:31:51 +01:00
if( Configuration::get('PBX_DEMO_MODE') == 0 ) {
2017-05-04 11:35:59 +02:00
echo str_replace($info_useless,'', shell_exec('/home/www/bb.pp.antadis.net/www/cgi-bin/modulev2.cgi '. $params));
2016-02-23 17:33:01 +01:00
} else {
2016-09-26 17:23:26 +02:00
echo str_replace($info_useless,'', shell_exec('/home/www/bebeboutik.com/cgi/www/modulev2.cgi '. $params));
2016-02-23 17:31:51 +01:00
}
2016-01-04 12:49:26 +01:00
include(dirname(__FILE__).'/../../footer.php');