public function install() { if (!parent::install() || !$this->registerHook('payment') || !$this->registerHook('displayPaymentEU') || !$this->registerHook('paymentReturn') || !$this->registerHook('shoppingCartExtra') || !$this->registerHook('backBeforePayment') || !$this->registerHook('rightColumn') || !$this->registerHook('cancelProduct') || !$this->registerHook('productFooter') || !$this->registerHook('header') || !$this->registerHook('adminOrder') || !$this->registerHook('backOfficeHeader') || !$this->registerHook('actionPSCleanerGetModulesTables')) { return false; } if (_PS_VERSION_ >= '1.5' && (!$this->registerHook('displayMobileHeader') || !$this->registerHook('displayMobileShoppingCartTop') || !$this->registerHook('displayMobileAddToCartTop'))) { return false; } include_once _PS_MODULE_DIR_ . $this->name . '/paypal_install.php'; $paypal_install = new PayPalInstall(); $paypal_install->createTables(); $paypal_install->updateConfiguration($this->version); $paypal_install->createOrderState(); $paypal_tools = new PayPalTools($this->name); $paypal_tools->moveTopPayments(1); $paypal_tools->moveRightColumn(3); $this->runUpgrades(true); return true; }
private function _updatePaymentStatusOfOrder($id_order) { include_once _PS_MODULE_DIR_ . 'paypal/api/paypal_lib.php'; if (!$id_order || !$this->isPayPalAPIAvailable()) { return false; } $paypal_order = PayPalOrder::getOrderById((int) $id_order); if (!$paypal_order) { return false; } $paypal_lib = new PaypalLib(); $response = $paypal_lib->makeCall($this->getAPIURL(), $this->getAPIScript(), 'GetTransactionDetails', '&' . http_build_query(array('TRANSACTIONID' => $paypal_order->id_transaction), '', '&')); if (array_key_exists('ACK', $response)) { if ($response['ACK'] == 'Success' && isset($response['PAYMENTSTATUS'])) { $history = new OrderHistory(); $history->id_order = (int) $id_order; if ($response['PAYMENTSTATUS'] == 'Completed') { $history->changeIdOrderState(Configuration::get('PS_OS_PAYMENT'), (int) $id_order); } elseif ($response['PAYMENTSTATUS'] == 'Pending' && $response['PENDINGREASON'] == 'authorization') { $history->changeIdOrderState((int) Configuration::get('PAYPAL_OS_AUTHORIZATION'), (int) $id_order); } elseif ($response['PAYMENTSTATUS'] == 'Reversed') { $history->changeIdOrderState(Configuration::get('PS_OS_ERROR'), (int) $id_order); } $history->addWithemail(); if (!Db::getInstance()->Execute(' UPDATE `' . _DB_PREFIX_ . 'paypal_order` SET `payment_status` = \'' . pSQL($response['PAYMENTSTATUS']) . ($response['PENDINGREASON'] == 'authorization' ? '_authorization' : '') . '\' WHERE `id_order` = ' . (int) $id_order)) { die(Tools::displayError('Error when updating PayPal database')); } } $message = $this->l('Verification status :') . '<br>'; PayPalTools::formatMessage($response, $message); $this->_addNewPrivateMessage((int) $id_order, $message); return $response; } return false; }