From 8a1ff8a2215a93ba5db357edf6e7db260b676944 Mon Sep 17 00:00:00 2001 From: Christophe LATOUR Date: Mon, 22 Jan 2018 16:06:29 +0100 Subject: [PATCH] =?UTF-8?q?error-paybox=20:=20V=C3=A9rification=20du=20pan?= =?UTF-8?q?ier=20avant=20paiement=20"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Payments/PayboxController.php | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/app/Web/Controllers/Payments/PayboxController.php b/app/Web/Controllers/Payments/PayboxController.php index be9361f..b85f1ff 100644 --- a/app/Web/Controllers/Payments/PayboxController.php +++ b/app/Web/Controllers/Payments/PayboxController.php @@ -57,6 +57,31 @@ class PayboxController extends ApiBaseController { * Returns num question for paybox */ public function getQuestion(Request $request) { + + + $cart = $this->getCart(); + if ($cart->getNbProducts($cart->id) <= 0) { + $date_add = \Db::getInstance()->executeS(' + SELECT `date_add` + FROM `'._DB_PREFIX_.'orders` + WHERE `id_customer` = '.(int)$request->user()->id.' + AND `valid` = 1 + ORDER BY date_add DESC LIMIT 1 + '); + + /* CHECK LAST ORDER DATE */ + if ($date_add && isset($date_add[0]['date_add'])) { + $date_add = $date_add[0]['date_add']; + if (strtotime('now') - strtotime($date_add) <= 60 * 3) { + throw new HttpBadRequestException('Votre panier est vide. Il semblerai que vous ayez passer une commande il y a ' . (strtotime('now') - strtotime($date_add)) . ' secondes. Merci de vérifier vos commandes.'); + } else { + throw new HttpBadRequestException('Veuillez vérifier votre panier. Il semblerai qu\'il soit vide'); + } + } + throw new HttpBadRequestException('Veuillez vérifier votre panier. Il semblerai qu\'il soit vide'); + } + + $numquestion = (int)ApiConfiguration::get('NUM_QUESTION_PAYBOX') + 1; (int)ApiConfiguration::updateValue('NUM_QUESTION_PAYBOX', $numquestion); @@ -101,7 +126,7 @@ class PayboxController extends ApiBaseController { $fp = fopen(__DIR__. '/../../../../log_payment'.date('Y-m-d').'.txt', 'a+'); $str = var_export($_SERVER['REMOTE_ADDR'], true) . " " . - var_export($user->email, true) . " " . + var_export($user->email, true) . " " . var_export($response, true) . " " . var_export($input_data, true) . " " . var_export($create_order, true) . " " . @@ -274,4 +299,4 @@ class PayboxController extends ApiBaseController { } return $data; } -} +} \ No newline at end of file