Compare commits

...

2 Commits

Author SHA1 Message Date
Marion Muszynski
1e7243c023 checking orders addition 2016-09-09 17:19:12 +02:00
Marion Muszynski
e9ea05d32b addition of delivery address checking 2016-09-08 18:08:21 +02:00

View File

@ -108,7 +108,7 @@ class PayPal extends PaymentModule
if (self::isInstalled($this->name))
{
$this->loadDefaults();
$this->loadDefaults();
if ($mobile_enabled && $this->active)
$this->checkMobileCredentials();
elseif ($mobile_enabled && !$this->active)
@ -542,8 +542,20 @@ class PayPal extends PaymentModule
elseif ($method == WPS || $method == ECS)
{
$cart = $this->context->cart;
$this->context->smarty->assign('accounts', $this->getBillingAgreement($cart->id_customer));
$orders_with_delivery_address = Db::getInstance()->getValue('
SELECT COUNT(`o.id_order`)
FROM `'._DB_PREFIX_.'orders` o
WHERE o.`id_address_delivery` = '.(int)$cart->id_address_delivery.'
AND o.`id_customer` = '.(int)$cart->id_customer.'
AND (
o.valid = 1
OR (
o.valid = 0
AND (SELECT h.id_order_state FROM `'._DB_PREFIX_.'order_history` h WHERE h.id_order = o.id_order ORDER BY h.date_add DESC LIMIT 1) NOT IN (6,8,15,16,18)
)
)
');
$this->context->smarty->assign('accounts', (($orders_with_delivery_address==0)?array():$this->getBillingAgreement($cart->id_customer)));
$this->getTranslations();
$this->context->smarty->assign(array(
'custom' => Tools::jsonEncode(array('id_cart' => $cart->id, 'hash' => sha1(serialize($cart->nbProducts())))),
@ -632,13 +644,13 @@ class PayPal extends PaymentModule
if ($this->_canRefund((int)$params['id_order']))
$admin_templates[] = 'refund';
}
if (count($admin_templates) > 0)
{
$sql = "SELECT `id_transaction`FROM `"._DB_PREFIX_."paypal_order` WHERE id_order = " .$params['id_order'];
$id_transaction = Db::getInstance()->getValue($sql);
if(empty($id_transaction)){
$id_transaction = "";
$id_transaction = "";
}
$order = new Order((int)$params['id_order']);
@ -675,7 +687,7 @@ class PayPal extends PaymentModule
{
// if (Tools::isSubmit('generateDiscount') || !$this->isPayPalAPIAvailable())
// return false;
// // delete test sur la génération d'avoir
// // delete test sur la génération d'avoir
if (!$this->isPayPalAPIAvailable())
return false;
elseif ($params['order']->module != $this->name || !($order = $params['order']) || !Validate::isLoadedObject($order))
@ -1359,8 +1371,8 @@ class PayPal extends PaymentModule
}
}
public function getBillingAgreement($id_customer)
public function getBillingAgreement($id_customer)
{
return Db::getInstance()->executeS('
SELECT `id_paypal_agreement`, `email`, `name`, `city`, `address`
@ -1390,7 +1402,7 @@ class PayPal extends PaymentModule
if (isset($this->pcc))
$this->pcc->transaction_id = (isset($transaction['transaction_id']) ? $transaction['transaction_id'] : '');
if (version_compare(_PS_VERSION_, '1.5', '<'))
if (version_compare(_PS_VERSION_, '1.5', '<'))
parent::validateOrder((int)$id_cart, (int)$id_order_state, (float)$amount_paid, $payment_method, $message, $transaction, $currency_special, $dont_touch_amount, $secure_key);
else
parent::validateOrder((int)$id_cart, (int)$id_order_state, (float)$amount_paid, $payment_method, $message, $transaction, $currency_special, $dont_touch_amount, $secure_key, $shop);