// Merge -> revision 8800
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
@@ -36,7 +36,7 @@ class GCheckout extends PaymentModule
|
||||
$this->tab = 'payments_gateways';
|
||||
$this->version = '1.2';
|
||||
$this->author = 'PrestaShop';
|
||||
|
||||
|
||||
$this->currencies = true;
|
||||
$this->currencies_mode = 'radio';
|
||||
|
||||
@@ -44,7 +44,7 @@ class GCheckout extends PaymentModule
|
||||
|
||||
$this->displayName = $this->l('Google Checkout');
|
||||
$this->description = $this->l('Google Checkout API implementation');
|
||||
|
||||
|
||||
if (!sizeof(Currency::checkPaymentCurrencies($this->id)))
|
||||
$this->warning = $this->l('No currency set for this module');
|
||||
|
||||
@@ -57,13 +57,13 @@ class GCheckout extends PaymentModule
|
||||
}
|
||||
|
||||
public function install()
|
||||
{
|
||||
if (!parent::install() OR !$this->registerHook('payment') OR
|
||||
!$this->registerHook('paymentReturn') OR
|
||||
!Configuration::updateValue('GCHECKOUT_MERCHANT_ID', '822305931131113') OR
|
||||
!Configuration::updateValue('GCHECKOUT_MERCHANT_KEY', '2Lv_osMomVIocnLK0aif3A') OR
|
||||
!Configuration::updateValue('GCHECKOUT_LOGS', '1') OR
|
||||
!Configuration::updateValue('GCHECKOUT_MODE', 'real') OR
|
||||
{
|
||||
if (!parent::install() OR !$this->registerHook('payment') OR
|
||||
!$this->registerHook('paymentReturn') OR
|
||||
!Configuration::updateValue('GCHECKOUT_MERCHANT_ID', '822305931131113') OR
|
||||
!Configuration::updateValue('GCHECKOUT_MERCHANT_KEY', '2Lv_osMomVIocnLK0aif3A') OR
|
||||
!Configuration::updateValue('GCHECKOUT_LOGS', '1') OR
|
||||
!Configuration::updateValue('GCHECKOUT_MODE', 'real') OR
|
||||
!Configuration::updateValue('GCHECKOUT_NO_SHIPPING', '0'))
|
||||
return false;
|
||||
return true;
|
||||
@@ -71,14 +71,14 @@ class GCheckout extends PaymentModule
|
||||
|
||||
public function uninstall()
|
||||
{
|
||||
return (parent::uninstall() AND
|
||||
Configuration::deleteByName('GCHECKOUT_MERCHANT_ID') AND
|
||||
return (parent::uninstall() AND
|
||||
Configuration::deleteByName('GCHECKOUT_MERCHANT_ID') AND
|
||||
Configuration::deleteByName('GCHECKOUT_MERCHANT_KEY') AND
|
||||
Configuration::deleteByName('GCHECKOUT_MODE') AND
|
||||
Configuration::deleteByName('GCHECKOUT_LOGS') AND
|
||||
Configuration::deleteByName('GCHECKOUT_MODE') AND
|
||||
Configuration::deleteByName('GCHECKOUT_LOGS') AND
|
||||
Configuration::deleteByName('GCHECKOUT_NO_SHIPPING'));
|
||||
}
|
||||
|
||||
|
||||
public function getContent()
|
||||
{
|
||||
if (Tools::isSubmit('submitGoogleCheckout'))
|
||||
@@ -98,20 +98,20 @@ class GCheckout extends PaymentModule
|
||||
Configuration::updateValue('GCHECKOUT_LOGS', 1);
|
||||
else
|
||||
Configuration::updateValue('GCHECKOUT_LOGS', 0);
|
||||
|
||||
|
||||
if (Tools::getValue('gcheckout_no_shipping'))
|
||||
Configuration::updateValue('GCHECKOUT_NO_SHIPPING', 1);
|
||||
else
|
||||
Configuration::updateValue('GCHECKOUT_NO_SHIPPING', 0);
|
||||
|
||||
if (!sizeof($errors))
|
||||
Tools::redirectAdmin(AdminTab::$currentIndex.'&configure=gcheckout&token='.Tools::getValue('token').'&conf=4');
|
||||
if (!$errors)
|
||||
Tools::redirectAdmin(AdminTab::$currentIndex.'&configure=gcheckout&token='.Tools::safeOutput(Tools::getValue('token')).'&conf=4');
|
||||
foreach ($errors as $error)
|
||||
echo $error;
|
||||
}
|
||||
|
||||
|
||||
$html = '<h2>'.$this->displayName.'</h2>
|
||||
<form action="'.$_SERVER['REQUEST_URI'].'" method="post">
|
||||
<form action="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'" method="post">
|
||||
<fieldset>
|
||||
<legend><img src="'.__PS_BASE_URI__.'modules/gcheckout/logo.gif" />'.$this->l('Settings').'</legend>
|
||||
<p>
|
||||
@@ -139,13 +139,13 @@ class GCheckout extends PaymentModule
|
||||
'.$this->l('Merchant ID').'
|
||||
</label>
|
||||
<div class="margin-form">
|
||||
<input type="text" name="gcheckout_merchant_id" value="'.Tools::getValue('gcheckout_merchant_id', Configuration::get('GCHECKOUT_MERCHANT_ID')).'" />
|
||||
<input type="text" name="gcheckout_merchant_id" value="'.Tools::safeOutput(Tools::getValue('gcheckout_merchant_id', Configuration::get('GCHECKOUT_MERCHANT_ID'))).'" />
|
||||
</div>
|
||||
<label>
|
||||
'.$this->l('Merchant Key').'
|
||||
</label>
|
||||
<div class="margin-form">
|
||||
<input type="text" name="gcheckout_merchant_key" value="'.Tools::getValue('gcheckout_merchant_key', Configuration::get('GCHECKOUT_MERCHANT_KEY')).'" />
|
||||
<input type="text" name="gcheckout_merchant_key" value="'.Tools::safeOutput(Tools::getValue('gcheckout_merchant_key', Configuration::get('GCHECKOUT_MERCHANT_KEY'))).'" />
|
||||
</div>
|
||||
<p>'.$this->l('If you click this box, buyers will be able to see the shipping fees you have setup in Google Checkout on the purchase page.').'</p>
|
||||
<label>
|
||||
@@ -154,7 +154,7 @@ class GCheckout extends PaymentModule
|
||||
<div class="margin-form" style="margin-top:5px">
|
||||
<input type="checkbox" name="gcheckout_no_shipping"'.(Tools::getValue('gcheckout_no_shipping', Configuration::get('GCHECKOUT_NO_SHIPPING')) ? ' checked="checked"' : '').' />
|
||||
</div>
|
||||
<p>'.$this->l('You can log the server-to-server communication. The log files are').' '.__PS_BASE_URI__.'modules/gcheckout/googleerror.log '.$this->l('and').' '.__PS_BASE_URI__.'modules/gcheckout/googlemessage.log. '.$this->l('If activated, be sure to protect them by putting a .htaccess file in the same directory. If not, they will be readable by everyone.').'</p>
|
||||
<p>'.$this->l('You can log the server-to-server communication. The log files are').' '.__PS_BASE_URI__.'modules/gcheckout/googleerror.log '.$this->l('and').' '.__PS_BASE_URI__.'modules/gcheckout/googlemessage.log. '.$this->l('If activated, be sure to protect them by putting a .htaccess file in the same directory. If not, they will be readable by everyone.').'</p>
|
||||
<label>
|
||||
'.$this->l('Logs').'
|
||||
</label>
|
||||
@@ -173,7 +173,7 @@ class GCheckout extends PaymentModule
|
||||
<p>- '.$this->l('The callback method must be set to').' <b>XML</b>.</p>
|
||||
<p>- '.$this->l('Orders must be placed with the same currency as your seller account. Carts in other currencies will be converted if the customer chooses to pay with this module.').'<p>
|
||||
</fieldset>';
|
||||
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
@@ -185,22 +185,22 @@ class GCheckout extends PaymentModule
|
||||
$this->context->smarty->assign('buttonText', $this->l('Pay with GoogleCheckout'));
|
||||
return $this->display(__FILE__, 'payment.tpl');
|
||||
}
|
||||
|
||||
|
||||
public function hookPaymentReturn($params)
|
||||
{
|
||||
if (!$this->active)
|
||||
return;
|
||||
return $this->display(__FILE__, 'payment_return.tpl');
|
||||
}
|
||||
|
||||
|
||||
public function preparePayment()
|
||||
{
|
||||
require_once(dirname(__FILE__).'/library/googlecart.php');
|
||||
require_once(dirname(__FILE__).'/library/googleitem.php');
|
||||
require_once(dirname(__FILE__).'/library/googleshipping.php');
|
||||
|
||||
|
||||
$currency = $this->getCurrency($this->context->cart->id_currency);
|
||||
|
||||
|
||||
if ($this->context->cart->id_currency != $currency->id)
|
||||
{
|
||||
$this->context->cart->id_currency = (int)$currency->id;
|
||||
@@ -208,29 +208,29 @@ class GCheckout extends PaymentModule
|
||||
$this->context->cart->update();
|
||||
Tools::redirect('modules/'.$this->name.'/payment.php');
|
||||
}
|
||||
|
||||
|
||||
$googleCart = new GoogleCart(
|
||||
Configuration::get('GCHECKOUT_MERCHANT_ID'),
|
||||
Configuration::get('GCHECKOUT_MERCHANT_KEY'),
|
||||
Configuration::get('GCHECKOUT_MERCHANT_ID'),
|
||||
Configuration::get('GCHECKOUT_MERCHANT_KEY'),
|
||||
Configuration::get('GCHECKOUT_MODE'), $currency->iso_code);
|
||||
|
||||
|
||||
foreach ($this->context->cart->getProducts() AS $product)
|
||||
$googleCart->AddItem(new GoogleItem(utf8_decode($product['name'].
|
||||
((isset($product['attributes']) AND !empty($product['attributes'])) ?
|
||||
' - '.$product['attributes'] : '')), utf8_decode($product['description_short']),
|
||||
(int)$product['cart_quantity'], $product['price_wt'],
|
||||
((isset($product['attributes']) AND !empty($product['attributes'])) ?
|
||||
' - '.$product['attributes'] : '')), utf8_decode($product['description_short']),
|
||||
(int)$product['cart_quantity'], $product['price_wt'],
|
||||
strtoupper(Configuration::get('PS_WEIGHT_UNIT')), (float)$product['weight']));
|
||||
|
||||
|
||||
if ($wrapping = $this->context->cart->getOrderTotal(true, Cart::ONLY_WRAPPING))
|
||||
$googleCart->AddItem(new GoogleItem(utf8_decode($this->l('Wrapping')), '', 1, $wrapping));
|
||||
foreach ($this->context->cart->getDiscounts() AS $voucher)
|
||||
$googleCart->AddItem(new GoogleItem(utf8_decode($voucher['name']),
|
||||
$googleCart->AddItem(new GoogleItem(utf8_decode($voucher['name']),
|
||||
utf8_decode($voucher['description']), 1, '-'.$voucher['value_real']));
|
||||
|
||||
|
||||
if (!Configuration::get('GCHECKOUT_NO_SHIPPING'))
|
||||
{
|
||||
$carrier = new Carrier((int)($this->context->cart->id_carrier), $this->context->language->id);
|
||||
$googleCart->AddShipping(new GoogleFlatRateShipping(utf8_decode($carrier->name),
|
||||
$googleCart->AddShipping(new GoogleFlatRateShipping(utf8_decode($carrier->name),
|
||||
$this->context->cart->getOrderShippingCost($this->context->cart->id_carrier)));
|
||||
}
|
||||
|
||||
@@ -238,9 +238,9 @@ class GCheckout extends PaymentModule
|
||||
$googleCart->SetContinueShoppingUrl(Tools::getShopDomainSsl(true, true).__PS_BASE_URI__.'order-confirmation.php');
|
||||
$googleCart->SetRequestBuyerPhone(false);
|
||||
$googleCart->SetMerchantPrivateData($this->context->cart->id.'|'.$this->context->cart->secure_key);
|
||||
|
||||
|
||||
$total = $this->context->cart->getOrderTotal();
|
||||
|
||||
|
||||
$this->context->smarty->assign(array(
|
||||
'googleCheckoutExtraForm' => $googleCart->CheckoutButtonCode($this->l('Pay with GoogleCheckout'), 'LARGE'),
|
||||
'total' => $total,
|
||||
|
||||
Reference in New Issue
Block a user