fix conflict

This commit is contained in:
Marion Muszynski 2016-10-18 12:58:26 +02:00
commit 1f5d683f4b
4 changed files with 70 additions and 62 deletions

View File

@ -43,7 +43,7 @@ if ($id_cart && $id_order && $id_module && $paypal_key)
// PRESTASHOP VERSION
/*
if (version_compare(_PS_VERSION_, '1.5', '<'))
new PayPalExpressCheckoutSubmit();
new PayPalExpressCheckoutSubmit();
return;
*/
// PRESTASHOP VERSION END
@ -51,7 +51,7 @@ if ($id_cart && $id_order && $id_module && $paypal_key)
// @ANTADIS : redirect to bebeboutik specific order-confirmation page
$paypal = new PayPal();
$cart = $paypal->context->cart;
$order = new Order((int)$id_order);
$order = new Order((int)$id_order);
$redirect_after_payment = $paypal->context->link->getPageLink('order-confirmation.php')
.'?id_cart='.$cart->id
@ -133,7 +133,7 @@ if ($request_type && $ppec->type) {
$id_product_attribute = Tools::getValue('id_p_attr');
if (($id_product > 0) && $id_product_attribute !== false && ($product_quantity > 0))
{
{
setContextData($ppec);
if (!$ppec->context->cart->add())
@ -164,9 +164,9 @@ if ($request_type && $ppec->type) {
$login_user = $obj->getRefreshToken();
}
// @ANTADIS send data biling true for return information
$save_billing = Tools::getValue('save_billing', false);
// @ANTADIS send data biling true for return information
$save_billing = Tools::getValue('save_billing', false);
$id_billing_to_use = 0;
if (Tools::getValue('id_billing')) {
$id_billing = Tools::getValue('id_billing');
@ -178,7 +178,7 @@ if ($request_type && $ppec->type) {
// @ANTADIS - if id_billing make transaction
if ($id_billing_to_use != 0) {
$ppec->DoReferenceTransaction($id_billing_to_use);
$ppec->DoReferenceTransaction($id_billing_to_use);
$amount_match = $ppec->rightPaymentProcess();
// PAIEMENT REUSSI
@ -203,17 +203,17 @@ if ($request_type && $ppec->type) {
$transaction = PayPalOrder::getTransactionDetailsForDoReference($ppec, $payment_status, $shipping_cost_wt);
$ppec->context->cookie->id_cart = $cart->id;
$order_total = (float)$cart->getOrderTotal(true, Cart::BOTH);
$ppec->validateOrder((int)$cart->id, $payment_type, $order_total, $ppec->displayName, $message, $transaction,
(int)$cart->id_currency, false, $customer->secure_key, $ppec->context->shop, $id_billing_to_use);
$order = new Order($ppec->currentOrder);
$module_tmp = new Paypal();
$redirect_after_payment = $ppec->context->link->getPageLink('order-confirmation.php').'?id_cart='.$cart->id.'&key='.$order->secure_key.'&id_module='.$module_tmp->id;
Tools::redirectLink($redirect_after_payment);
} else {
return Tools::redirectLink($ppec->context->link->getPageLink('order.php').'?step=3&cgv=1&paypal_error=1');
// $ppec->displayPayPalAPIError($ppec->l('Error during the preparation of the DoReferenceTransaction payment'), $ppec->logs);
// $ppec->displayPayPalAPIError($ppec->l('Error during the preparation of the DoReferenceTransaction payment'), $ppec->logs);
}
} else {
@ -226,8 +226,8 @@ if ($request_type && $ppec->type) {
else
$ppec->displayPayPalAPIError($ppec->l('Error during the preparation of the Express Checkout payment'), $ppec->logs);
}
}
//If a token exist with payer_id, then we are back from the PayPal API
elseif (!empty($ppec->token) && ($ppec->token == $token) && ($ppec->payer_id = $payer_id))
@ -261,50 +261,52 @@ elseif (!empty($ppec->token) && ($ppec->token == $token) && ($ppec->payer_id = $
if (!$customer->id)
$ppec->logs[] = $ppec->l('Cannot create customer');
if (!isset($ppec->result['PAYMENTREQUEST_0_SHIPTOSTREET']) || !isset($ppec->result['PAYMENTREQUEST_0_SHIPTOCITY'])
|| !isset($ppec->result['SHIPTOZIP']) || !isset($ppec->result['COUNTRYCODE']))
$ppec->redirectToCheckout($customer, ($ppec->type != 'payment_cart'));
// if (!isset($ppec->result['PAYMENTREQUEST_0_SHIPTOSTREET']) || !isset($ppec->result['PAYMENTREQUEST_0_SHIPTOCITY'])
// || !isset($ppec->result['SHIPTOZIP']) || !isset($ppec->result['COUNTRYCODE']))
// $ppec->redirectToCheckout($customer, ($ppec->type != 'payment_cart'));
$addresses = $customer->getAddresses($ppec->context->language->id);
foreach ($addresses as $address)
if ($address['alias'] == 'Paypal_Address')
{//If address has already been created
$address = new Address($address['id_address']);
break;
}
// $addresses = $customer->getAddresses($ppec->context->language->id);
// foreach ($addresses as $address)
// if ($address['alias'] == 'Paypal_Address')
// {//If address has already been created
// $address = new Address($address['id_address']);
// break;
// }
/* Create address */
if (is_array($address) && isset($address['id_address']))
$address = new Address($address['id_address']);
// /* Create address */
// if (is_array($address) && isset($address['id_address']))
// $address = new Address($address['id_address']);
if ((!$address || !$address->id) && $customer->id)
{//If address does not exists, we create it
$address = setCustomerAddress($ppec, $customer);
$address->add();
}
else if ($customer->id)
{//If address exists, we update it with new informations
$address = setCustomerAddress($ppec, $customer, $address->id);
$address->save();
}
// if ((!$address || !$address->id) && $customer->id)
// {//If address does not exists, we create it
// $address = setCustomerAddress($ppec, $customer);
// $address->add();
// }
// else if ($customer->id)
// {//If address exists, we update it with new informations
// $address = setCustomerAddress($ppec, $customer, $address->id);
// $address->save();
// }
if ($customer->id && !$address->id)
$ppec->logs[] = $ppec->l('Cannot create Address');
// if ($customer->id && !$address->id)
// $ppec->logs[] = $ppec->l('Cannot create Address');
/* Create Order */
if ($customer->id && $address->id)
{
$ppec->context->cart->id_customer = $customer->id;
$ppec->context->cart->id_guest = $ppec->context->cookie->id_guest;
// /* Create Order */
// if ($customer->id && $address->id)
// {
// $ppec->context->cart->id_customer = $customer->id;
// $ppec->context->cart->id_guest = $ppec->context->cookie->id_guest;
if (!$ppec->context->cart->update())
$ppec->logs[] = $ppec->l('Cannot update existing cart');
else
{
$payment_cart = (bool)($ppec->type != 'payment_cart');
$ppec->redirectToCheckout($customer, $payment_cart);
}
}
// if (!$ppec->context->cart->update())
// $ppec->logs[] = $ppec->l('Cannot update existing cart');
// else
// {
// $payment_cart = (bool)($ppec->type != 'payment_cart');
// $ppec->redirectToCheckout($customer, $payment_cart);
// }
// }
$payment_cart = (bool)($ppec->type != 'payment_cart');
$ppec->redirectToCheckout($customer, $payment_cart);
}
}
/**
@ -379,14 +381,15 @@ if ($ppec->ready && !empty($ppec->token) && (Tools::isSubmit('confirmation') ||
$customer_info = array();
$customer_info['ID_CUSTOMER'] = $cart->id_customer;
$customer_info['EMAIL'] = $ppec->result['EMAIL'];
$customer_info['SHIPTOSTREET'] = $ppec->result['SHIPTOSTREET'];
$customer_info['SHIPTOCITY'] = $ppec->result['SHIPTOCITY'];
$customer_info['SHIPTONAME'] = $ppec->result['SHIPTONAME'];
// When all information are checked before, we can validate the payment to paypal
// and create the prestashop order
$ppec->doExpressCheckout();
$customer_info['SHIPTOSTREET'] = $ppec->result['SHIPTOSTREET'];
$customer_info['SHIPTOCITY'] = $ppec->result['SHIPTOCITY'];
$customer_info['SHIPTONAME'] = $ppec->result['SHIPTONAME'];
// ANTADIS
// si on retourne le biling on le save
if (isset($ppec->result['BILLINGAGREEMENTID'])) {

View File

@ -542,6 +542,7 @@ class PayPal extends PaymentModule
elseif ($method == WPS || $method == ECS)
{
$cart = $this->context->cart;
$orders_with_delivery_address = Db::getInstance()->getValue('
SELECT COUNT(`o.id_order`)
FROM `'._DB_PREFIX_.'orders` o
@ -555,7 +556,11 @@ class PayPal extends PaymentModule
)
)
');
$this->context->smarty->assign('accounts', (($orders_with_delivery_address==0)?array():$this->getBillingAgreement($cart->id_customer)));
//$this->context->smarty->assign('accounts', (($orders_with_delivery_address==0)?array():$this->getBillingAgreement($cart->id_customer)));
// antadis pending account
// $this->getBillingAgreement($cart->id_customer)
$this->context->smarty->assign('accounts', array());
$this->getTranslations();
$this->context->smarty->assign(array(
'custom' => Tools::jsonEncode(array('id_cart' => $cart->id, 'hash' => sha1(serialize($cart->nbProducts())))),

View File

@ -53,10 +53,10 @@
<span class="title_payment">
{$PayPal_content.payment_choice}
</span>
<span class="save_info">
{*<span class="save_info">
<input type="checkbox" id="save_info_paypal" data-change="save_billing_paypal">
<label for="save_info_paypal">{l s='Save my paypal account information for future payments' mod='paypal'} </label><span class="paiement_info_lightbox paypal_info">?</span>
</span>
</span>*}
</div>
</div>

View File

@ -53,18 +53,18 @@
<span class="title_payment">
{$PayPal_content.payment_choice}
</span>
<span class="save_info">
{*<span class="save_info">
<input type="checkbox" id="save_info_paypal" data-change="save_billing_paypal">
<label for="save_info_paypal">{l s='Save my paypal account information for future payments' mod='paypal'} </label>
<span class="paiement_info_lightbox paypal_info">?</span>
</span>
</span>*}
</div>
</div>
{if $accounts}
<div class="account_payment">
<p class="title">{l s='You have registered accounts, you can use them to pay' mod='paypal'}</p>
{foreach from=$accounts item=account}
{foreach from=$accounts item=account}
<div class="box_account">
<div class="hidden">
<form id="paypal_payment_form" action="{$base_dir_ssl}modules/paypal/express_checkout/payment.php" data-ajax="false" title="{l s='Pay with PayPal' mod='paypal'}" method="post">
@ -103,7 +103,7 @@
</div>
</div>
</div>
</div>