Модуль оплаты Prestashop

В настоящее время я пишу модуль Prestashop Payment, в котором используется SDK Paypal Adaptive Payments.
Когда я пытаюсь установить свой модуль, я получаю следующую ошибку:

[PrestaShop] Fatal error in module Configuration:
Cannot redeclare class Configuration

вот мой код
PayPal SDK установлен правильно и работает.

config.xml

<?xml version="1.0" encoding="UTF-8" ?>
<module>
<name>MyPayments</name>
<displayName><![CDATA[My module]]></displayName>
<version><![CDATA[1.0]]></version>
<description><![CDATA[Description of my module.]]></description>
<author></author>
<tab><![CDATA[payments_gateways]]></tab>
<confirmUninstall>Are you sure you want to uninstall? You will lose all your settings!</confirmUninstall>
<is_configurable>0</is_configurable>
<need_instance>0</need_instance>
<limited_countries></limited_countries>
</module>

mypayments.php

<?php
if (!defined('_PS_VERSION_'))
exit;

//include paypal adaptive payments sdk lib
require(_PS_MODULE_DIR_.'/mypayments/samples/PPBootStrap.php');

class MyPayments extends PaymentModule {

public function __construct() {

$this->name = 'mypayments';
$this->tab = 'payments_gateways';
$this->version = '0.1';
$this->need_instance = 0;
$this->ps_versions_compliancy = array('min' => '1.5', 'max' => '1.6');
$this->bootstrap = true;

parent::__construct();

#$this->page = basename(__FILE__, '.php');
$this->displayName = $this->l('Adaptive Payments');
$this->description = $this->l('Paypal Adaptive Payments');

$this->confirmUninstall = $this->l('Are you sure you want to uninstall?');

if (!Configuration::get('MYMODULE_NAME'))
$this->warning = $this->l('No name provided');
}

public function install() {
if (!parent::install()
OR !$this->registerHook('payment')
OR !Configuration::updateValue('MYMODULE_NAME', 'My Payments')
)
return false;
return true;
}

public function uninstall() {
if (!parent::uninstall() ||
!Configuration::deleteByName('MYMODULE_NAME')
)
return false;
return true;
}

//output the current payment method to the choice list of available methods on the checkout pages
function hookPayment($params){

if(!$this->active) return;

global $smarty;

//checks if all products in cart are valid
foreach ($params['cart']->getProducts() AS $product)
if (Validate::isUnsignedInt(ProductDownload::getIdFromIdProduct(intval($product['id_product']))))
return false;

//assign smarty paths
$smarty->assign(array(
'this_path' => $this->_path,
'this_path_ssl' => (Configuration::get('PS_SSL_ENABLED') ? 'https://' :'http://').htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8').__PS_BASE_URI__.'modules/'.$this->name.'/'
));

//return the template file to render the payment option
return $this->display(__FILE__, 'payment.tpl');
}

public function paypalPayCall($Email1, $Email2, $totalAmount){

$Email3;

$Payment1 = $totalAmount/2;
$Payment2 = $totalAmount/4;
$Payment3 = $totalAmount/4;$payRequest = new PayRequest();

$receiver = array();
$receiver[0] = new Receiver();
$receiver[0]->amount = $Payment1;
$receiver[0]->email = $Email1;
$receiver[0]->primary = "true";

$receiver[1] = new Receiver();
$receiver[1]->amount = $Payment2;
$receiver[1]->email = $Email2;

$receiver[2] = new Receiver();
$receiver[2]->amount = $Payment3;
$receiver[2]->email = $Email3;

$receiverList = new ReceiverList($receiver);
$payRequest->receiverList = $receiverList;

$requestEnvelope = new RequestEnvelope("en_US");
$payRequest->requestEnvelope = $requestEnvelope;
$payRequest->actionType = "PAY";
$payRequest->cancelUrl = "http://www.google.at/";
$payRequest->returnUrl = dirname(__FILE__)."validation.php";
$payRequest->currencyCode = "EUR";//CONFIGURATION - now sandbox
$sdkConfig = array(
"mode" => "sandbox",
"acct1.UserName" => "xxx",
"acct1.Password" => "xxx",
"acct1.Signature" => "xxx",
"acct1.AppId" => "xxx");

/* the payment call */
$adaptivePaymentsService = new AdaptivePaymentsService($sdkConfig);
$payResponse = $adaptivePaymentsService->Pay($payRequest);

//read response
$response = json_decode($payResponse);
$payKey = $response->payKey;

//check if acknowledged
if (strtoupper($response->responseEnvelope->ack) == 'SUCCESS')
{
$payUrl = "https://www.sandbox.paypal.com/webscr?cmd=_ap-payment&paykey=" . $payKey;
return $payUrl;
}
else
{
return false;
}
}}
?>

payment.php

<?php

include(dirname(__FILE__).'/../../config/config.inc.php');
include(dirname(__FILE__).'/../../header.php');
include(dirname(__FILE__).'/mypayments.php');

if (!$cookie->isLogged())
Tools::redirect('authentication.php?back=order.php');

$paypalImgUrl = dirname(__FILE__).'/img/default_logos/default_logo.gif';

//create new instance of my payment class
$myPayments = new MyPayments();

//get cart total
$total = floatval(number_format($cart->getOrderTotal(true, 3), 2, '.', ''));

$Email1;
$Email2;

//call method from my payment class
$payUrl = $myPayments->paypalPayCall($Email1, $Email2, $total);

if ($payUrl == false)
{
echo "<center>Error generating payment link</center>";
}
else
{
//show link to buy with paypal
echo '<center><a href="'.$payUrl.'"><img src="'.$paypalImgUrl.'" alt="Pay with Paypal"/></a></center>';
}

include_once(dirname(__FILE__).'/../../footer.php');

?>

validation.php

<?php
//PAYPALS RETURN URL REDIRECTS HERE TO VALIDATE AND PLACE THE ORDER

include(dirname(__FILE__).'/../../config/config.inc.php');
include(dirname(__FILE__).'/../../header.php');
include(dirname(__FILE__).'/mypayments.php');$total = floatval(number_format($cart->getOrderTotal(true, 3), 2, '.', ''));
$myPayments->validateOrder(intval($cart->id), _PS_OS_PREPARATION_, $total, $myPayments->displayName);
$order = new Order(intval($myPayments->currentOrder));

echo "<center> Thank you! Your order is being processed </center>";

include(dirname(__FILE__).'/../../footer.php');

?>

payment.tpl

<p class="payment_module">

<a href="{$this_path}payment.php" title="{l s='Pay with Paypal' mod='mypayments'}">

<img src="{$this_path}paypal.png" alt="{l s='Pay with Paypal' mod='mypayments'}" />

{l s='Pay with Paypal' mod='mypayments'}

</a>
</p>

Любая помощь высоко ценится!

0

Решение

…Paypal SDK имеет свой собственный класс конфигурации

В конце концов, очень тривиальная ошибка

0

Другие решения

Других решений пока нет …

По вопросам рекламы [email protected]