private function _processWebhook() { $webhook = new \beGateway\Webhook(); if ($webhook->isAuthorized() && ($webhook->isSuccess() || $webhook->isFailed())) { $Status = $webhook->getStatus(); $Currency = $webhook->getResponse()->transaction->currency; $Amount = new \beGateway\Money(); $Amount->setCurrency($Currency); $Amount->setCents($webhook->getResponse()->transaction->amount); $TransId = $webhook->getUid(); $orderno = $webhook->getTrackingId(); $cart = new Cart((int) $orderno); if (!Validate::isLoadedObject($cart)) { Logger::addLog($this->l('Webhook: error to load cart'), 4); die($this->l('Critical error to load order cart')); } $customer = new Customer((int) $cart->id_customer); if (!Validate::isLoadedObject($customer)) { Logger::addLog($this->l('Webhook: error to load customer details'), 4); die($this->l('Critical error to load customer')); } $shop_ptype = trim(Configuration::get('BEGATEWAY_SHOP_PAYTYPE')); $payment_status = $webhook->isSuccess() ? Configuration::get('PS_OS_PAYMENT') : Configuration::get('PS_OS_ERROR'); $this->be_gateway->validateOrder((int) $orderno, $payment_status, $Amount->getAmount(), $this->be_gateway->displayName, $webhook->getMessage(), array('transaction_id' => $TransId), NULL, false, $customer->secure_key); $order_new = empty($this->be_gateway->currentOrder) ? $orderno : $this->be_gateway->currentOrder; Db::getInstance()->Execute(' INSERT INTO ' . _DB_PREFIX_ . 'begateway_transaction (type, id_begateway_customer, id_cart, id_order, uid, amount, status, currency, date_add) VALUES ("' . $shop_ptype . '", ' . $cart->id_customer . ', ' . $orderno . ', ' . $order_new . ', "' . $TransId . '", ' . $Amount->getAmount() . ', "' . $Status . '", "' . $Currency . '", NOW())'); die('OK'); } }