Merge branch 'ticket-payboxAgreement' into develop
This commit is contained in:
commit
d1be85cca4
@ -132,185 +132,181 @@ $values = array(
|
||||
'd' => $paybox_card['date'],
|
||||
);
|
||||
|
||||
if ($code_reponse[1] == "00000" || $code_reponse[0] == "00000") {
|
||||
// payment success
|
||||
// payment success
|
||||
|
||||
if ((!isset($autorisation[1]) || empty($autorisation[1])))
|
||||
{
|
||||
Logger::addLog('No autorisation number', 4);
|
||||
die('No autorisation number');
|
||||
}
|
||||
// Wrong authorization number in live mode
|
||||
if ($autorisation[1] == 'XXXXXX' && $test_mode === 1) {
|
||||
$error .= '- error payment - wrong authorization number <br>'."\n";
|
||||
}
|
||||
if ((!isset($autorisation[1]) || empty($autorisation[1])))
|
||||
{
|
||||
Logger::addLog('No autorisation number', 4);
|
||||
die('No autorisation number');
|
||||
}
|
||||
// Wrong authorization number in live mode
|
||||
if ($autorisation[1] == 'XXXXXX' && $test_mode === 1) {
|
||||
$error .= '- error payment - wrong authorization number <br>'."\n";
|
||||
}
|
||||
|
||||
if ($id_order = (int)Order::getOrderByCartId($cart->id))
|
||||
{
|
||||
$paybox->saveInformationPaiement($values);
|
||||
|
||||
if (empty($error))
|
||||
{
|
||||
$order = new Order($id_order);
|
||||
$order->valid = 1;
|
||||
$order->total_paid_real = $values['m'] / 100;
|
||||
$order->update();
|
||||
|
||||
if ($order->getCurrentState() != _PS_OS_PAYMENT_)
|
||||
{
|
||||
$products = $cart->getProducts();
|
||||
foreach ($products as $product)
|
||||
{
|
||||
Product::updateQuantity($product);
|
||||
Hook::updateQuantity($product, $order);
|
||||
}
|
||||
}
|
||||
|
||||
$history = new OrderHistory();
|
||||
$history->id_order = $id_order;
|
||||
$history->changeIdOrderState((int)_PS_OS_PAYMENT_, $id_order);
|
||||
$history->addWithemail(true, array());
|
||||
|
||||
$order_message = '';
|
||||
foreach ($values as $key => $value) {
|
||||
$order_message .= $key.': '.$value.'<br>';
|
||||
}
|
||||
|
||||
if (isset($order_message) && !empty($order_message))
|
||||
{
|
||||
$msg = new Message();
|
||||
$message = $order_message;
|
||||
if (Validate::isCleanHtml($order_message))
|
||||
{
|
||||
$msg->message = $order_message;
|
||||
$msg->id_order = (int)$order->id;
|
||||
$msg->private = 1;
|
||||
$msg->add();
|
||||
}
|
||||
}
|
||||
}
|
||||
die($error);
|
||||
}
|
||||
|
||||
$total_paid = $values['m'] / 100;
|
||||
|
||||
if ($test_mode === 0)
|
||||
{
|
||||
if (empty($error) && $code_reponse[1] == '00000')
|
||||
{
|
||||
$error = '***TEST*** : Validated Payment <br>'."\n";
|
||||
$statut = _PS_OS_PAYMENT_;
|
||||
}
|
||||
else
|
||||
{
|
||||
$error = '***TEST*** : Invalid Payment <br>'."\n".$error;
|
||||
$statut = _PS_OS_ERROR_;
|
||||
}
|
||||
}
|
||||
elseif ($test_mode === 1)
|
||||
{
|
||||
if ($code_reponse[1] == '00000' && empty($error)){
|
||||
$statut = _PS_OS_PAYMENT_;
|
||||
}
|
||||
else
|
||||
{
|
||||
$statut = _PS_OS_ERROR_;
|
||||
}
|
||||
}
|
||||
|
||||
switch ($code_reponse[1])
|
||||
{
|
||||
case '00001':
|
||||
$error .= 'Connection to the authorization center failed or an internal error occurred <br>'."\n";
|
||||
break;
|
||||
case '00003':
|
||||
$error .= 'Paybox error<br>'."\n";
|
||||
break;
|
||||
case '00004':
|
||||
$error .= 'Card number invalid or visual cryptogram invalid <br>'."\n";
|
||||
break;
|
||||
case '00006':
|
||||
$error .= 'Access refused or site/rank/identifier incorrect <br>'."\n";
|
||||
break;
|
||||
case '00008':
|
||||
$error .= 'Incorrect expiry date.<br>'."\n";
|
||||
break;
|
||||
case '00009':
|
||||
$error .= 'Error when during subscriber creation<br>'."\n";
|
||||
break;
|
||||
case '00010':
|
||||
$error .= 'Unknown currency<br>'."\n";
|
||||
break;
|
||||
case '00011':
|
||||
$error .= 'Amount incorrect<br>'."\n";
|
||||
break;
|
||||
case '00015':
|
||||
$error .= 'Payment already done<br>'."\n";
|
||||
break;
|
||||
case '00016':
|
||||
$error .= 'Subscriber already exists<br>'."\n";
|
||||
break;
|
||||
case '00021':
|
||||
$error .= 'Not authorized bin card<br>'."\n";
|
||||
break;
|
||||
case '00029':
|
||||
$error .= 'Not the same card used for the first payment.<br>'."\n";
|
||||
break;
|
||||
case '00030':
|
||||
$error .= 'Time-out > 15 mn before validation by the buyer when the buyer is on the page of payments of PAYBOX<br>'."\n";
|
||||
break;
|
||||
case '00031':
|
||||
case '00032':
|
||||
$error .= 'Reserved<br>'."\n";
|
||||
break;
|
||||
case '00033':
|
||||
$error .= 'Unauthorized country code of the IP address of the cardholder’s browser<br>'."\n";
|
||||
break;
|
||||
case '00040':
|
||||
$error .= 'Operation without 3DSecure authentication, blocked by the fraud filter.<br>'."\n";
|
||||
break;
|
||||
case '99999':
|
||||
$error .= 'Payment waiting confirmation from the issuer<br>'."\n";
|
||||
break;
|
||||
case '00000':
|
||||
default:
|
||||
$error .= '<b>Successful operation</b><br>'."\n\n";
|
||||
break;
|
||||
}
|
||||
|
||||
$error .= 'PayBox version: '.$paybox->version."\n".'<br> POST '.print_r($values, true)."\n".'<br>GET '.print_r($response, true)."\n";
|
||||
$paybox->validateOrder((int)$cart->id, $statut, $total_paid, $paybox->displayName, $error, array(), NULL, false, $customer->secure_key);
|
||||
|
||||
// save info paiement BDD
|
||||
if ($id_order = (int)Order::getOrderByCartId($cart->id))
|
||||
{
|
||||
$paybox->saveInformationPaiement($values);
|
||||
|
||||
if (version_compare(_PS_VERSION_, '1.5.0.0') >= '0')
|
||||
if (empty($error))
|
||||
{
|
||||
$order_id = Order::getOrderByCartId((int)$cart->id);
|
||||
$order = new Order((int)$order_id);
|
||||
if ($order_state == _PS_OS_PAYMENT_)
|
||||
$order = new Order($id_order);
|
||||
$order->valid = 1;
|
||||
$order->total_paid_real = $values['m'] / 100;
|
||||
$order->update();
|
||||
|
||||
if ($order->getCurrentState() != _PS_OS_PAYMENT_)
|
||||
{
|
||||
$order->valid = 1;
|
||||
$order->save();
|
||||
$products = $cart->getProducts();
|
||||
foreach ($products as $product)
|
||||
{
|
||||
Product::updateQuantity($product);
|
||||
Hook::updateQuantity($product, $order);
|
||||
}
|
||||
}
|
||||
|
||||
$id_order_payment = Db::getInstance()->getValue('SELECT id_order_payment
|
||||
FROM `'._DB_PREFIX_.'order_payment`
|
||||
WHERE `order_reference` LIKE \'%'.pSQL($order->reference).'%\'');
|
||||
$history = new OrderHistory();
|
||||
$history->id_order = $id_order;
|
||||
$history->changeIdOrderState((int)_PS_OS_PAYMENT_, $id_order);
|
||||
$history->addWithemail(true, array());
|
||||
|
||||
if ($id_order_payment == false)
|
||||
$order->addOrderPayment($total_paid, null, trim($values['t']));
|
||||
else
|
||||
$order_message = '';
|
||||
foreach ($values as $key => $value) {
|
||||
$order_message .= $key.': '.$value.'<br>';
|
||||
}
|
||||
|
||||
if (isset($order_message) && !empty($order_message))
|
||||
{
|
||||
$order_payment = new OrderPayment((int)$id_order_payment);
|
||||
$order_payment->transaction_id = trim($values['t']);
|
||||
$order_payment->save();
|
||||
$msg = new Message();
|
||||
$message = $order_message;
|
||||
if (Validate::isCleanHtml($order_message))
|
||||
{
|
||||
$msg->message = $order_message;
|
||||
$msg->id_order = (int)$order->id;
|
||||
$msg->private = 1;
|
||||
$msg->add();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
// payment error
|
||||
mail('marion@antadis.com', '[BBB] Soucis paiement direct reponse globale', json_encode($response));
|
||||
return false;
|
||||
die($error);
|
||||
}
|
||||
|
||||
$total_paid = $values['m'] / 100;
|
||||
|
||||
if ($test_mode === 0)
|
||||
{
|
||||
if (empty($error) && $code_reponse[1] == '00000')
|
||||
{
|
||||
$error = '***TEST*** : Validated Payment <br>'."\n";
|
||||
$statut = _PS_OS_PAYMENT_;
|
||||
}
|
||||
else
|
||||
{
|
||||
$error = '***TEST*** : Invalid Payment <br>'."\n".$error;
|
||||
$statut = _PS_OS_ERROR_;
|
||||
}
|
||||
}
|
||||
elseif ($test_mode === 1)
|
||||
{
|
||||
if ($code_reponse[1] == '00000' && empty($error)){
|
||||
$statut = _PS_OS_PAYMENT_;
|
||||
}
|
||||
else
|
||||
{
|
||||
$statut = _PS_OS_ERROR_;
|
||||
}
|
||||
}
|
||||
|
||||
switch ($code_reponse[1])
|
||||
{
|
||||
case '00001':
|
||||
$error .= 'Connection to the authorization center failed or an internal error occurred <br>'."\n";
|
||||
break;
|
||||
case '00003':
|
||||
$error .= 'Paybox error<br>'."\n";
|
||||
break;
|
||||
case '00004':
|
||||
$error .= 'Card number invalid or visual cryptogram invalid <br>'."\n";
|
||||
break;
|
||||
case '00006':
|
||||
$error .= 'Access refused or site/rank/identifier incorrect <br>'."\n";
|
||||
break;
|
||||
case '00008':
|
||||
$error .= 'Incorrect expiry date.<br>'."\n";
|
||||
break;
|
||||
case '00009':
|
||||
$error .= 'Error when during subscriber creation<br>'."\n";
|
||||
break;
|
||||
case '00010':
|
||||
$error .= 'Unknown currency<br>'."\n";
|
||||
break;
|
||||
case '00011':
|
||||
$error .= 'Amount incorrect<br>'."\n";
|
||||
break;
|
||||
case '00015':
|
||||
$error .= 'Payment already done<br>'."\n";
|
||||
break;
|
||||
case '00016':
|
||||
$error .= 'Subscriber already exists<br>'."\n";
|
||||
break;
|
||||
case '00021':
|
||||
$error .= 'Not authorized bin card<br>'."\n";
|
||||
break;
|
||||
case '00029':
|
||||
$error .= 'Not the same card used for the first payment.<br>'."\n";
|
||||
break;
|
||||
case '00030':
|
||||
$error .= 'Time-out > 15 mn before validation by the buyer when the buyer is on the page of payments of PAYBOX<br>'."\n";
|
||||
break;
|
||||
case '00031':
|
||||
case '00032':
|
||||
$error .= 'Reserved<br>'."\n";
|
||||
break;
|
||||
case '00033':
|
||||
$error .= 'Unauthorized country code of the IP address of the cardholder’s browser<br>'."\n";
|
||||
break;
|
||||
case '00040':
|
||||
$error .= 'Operation without 3DSecure authentication, blocked by the fraud filter.<br>'."\n";
|
||||
break;
|
||||
case '99999':
|
||||
$error .= 'Payment waiting confirmation from the issuer<br>'."\n";
|
||||
break;
|
||||
case '00000':
|
||||
default:
|
||||
$error .= '<b>Successful operation</b><br>'."\n\n";
|
||||
break;
|
||||
}
|
||||
|
||||
$error .= 'PayBox version: '.$paybox->version."\n".'<br> POST '.print_r($postfields, true)."\n".'<br>GET '.print_r($data, true)."\n";
|
||||
$paybox->validateOrder((int)$cart->id, $statut, $total_paid, $paybox->displayName, $error, array(), NULL, false, $customer->secure_key);
|
||||
|
||||
// save info paiement BDD
|
||||
$paybox->saveInformationPaiement($values);
|
||||
|
||||
if (version_compare(_PS_VERSION_, '1.5.0.0') >= '0')
|
||||
{
|
||||
$order_id = Order::getOrderByCartId((int)$cart->id);
|
||||
$order = new Order((int)$order_id);
|
||||
if ($order_state == _PS_OS_PAYMENT_)
|
||||
{
|
||||
$order->valid = 1;
|
||||
$order->save();
|
||||
}
|
||||
|
||||
$id_order_payment = Db::getInstance()->getValue('SELECT id_order_payment
|
||||
FROM `'._DB_PREFIX_.'order_payment`
|
||||
WHERE `order_reference` LIKE \'%'.pSQL($order->reference).'%\'');
|
||||
|
||||
if ($id_order_payment == false)
|
||||
$order->addOrderPayment($total_paid, null, trim($values['t']));
|
||||
else
|
||||
{
|
||||
$order_payment = new OrderPayment((int)$id_order_payment);
|
||||
$order_payment->transaction_id = trim($values['t']);
|
||||
$order_payment->save();
|
||||
}
|
||||
}
|
||||
|
||||
Tools::redirect('order-confirmation.php?id_cart='.$cart->id.'&id_module='.$paybox->id.'&key='.$customer->secure_key);
|
||||
|
||||
include(dirname(__FILE__).'/../../footer.php');
|
Loading…
Reference in New Issue
Block a user