File: /home/assibfaf/public_html/prox-modules/securetrading/securetrading.php
<?php
use Proxim\Application;
use Proxim\Configuration;
use Proxim\Module\Module;
use Proxim\Module\PaymentModule;
use Proxim\Site\Site;
use Proxim\Util\ArrayUtils;
use Proxim\Validate;
class SecureTrading extends PaymentModule
{
/**
* SecureTrading configuration
*/
const SECURETRADING_ENABLED = 'SECURETRADING_ENABLED';
const SECURETRADING_REFERENCE = 'SECURETRADING_REFERENCE';
public function __construct()
{
$this->name = 'securetrading';
$this->icon = 'fa fa-credit-card';
$this->version = '1.0.0';
$this->prox_versions_compliancy = array('min' => '1.0.0', 'max' => Application::VERSION);
$this->author = 'Davison Pro';
$this->displayName = 'Secure Trading';
$this->description = 'Set up Secure Trading as a payment method and enable users to pay without leaving your website';
$this->bootstrap = true;
parent::__construct();
}
public function isActive() {
return Configuration::get(self::SECURETRADING_ENABLED);
}
/**
* Echoes a template.
*
* @param string $templateName Template name
*/
public function showTemplate($templateName)
{
echo $this->getTemplateContent($templateName);
}
/**
* Return a template.
*
* @param string $templateName Template name
* @param array $additionnalParameters Additionnal parameters to inject on the Twig template
*
* @return string Parsed template
*/
private function getTemplateContent($templateName, $additionnalParameters = array())
{
$this->smarty->assign($additionnalParameters);
return $this->fetch(__DIR__ . '/views/' . $templateName.'.tpl');
}
public function processOrderCheckout($order, $currency) {
$app = $this->application;
$smarty = $this->smarty;
$user = $app->container->user;
$smarty->assign([
'securetrading_reference' => Configuration::get(self::SECURETRADING_REFERENCE),
]);
return $this->getTemplateContent('securetrading.order');
}
public function processAddPaymentCheckout($addPayment, $currency) {
$app = $this->application;
$smarty = $this->smarty;
$user = $app->container->user;
$smarty->assign([
'securetrading_reference' => Configuration::get(self::SECURETRADING_REFERENCE),
]);
return $this->getTemplateContent('securetrading.add-payment');
}
public function processWalletCheckout($amount, $currency) {
$app = $this->application;
$smarty = $this->smarty;
$user = $app->container->user;
$smarty->assign([
'securetrading_reference' => Configuration::get(self::SECURETRADING_REFERENCE),
]);
return $this->getTemplateContent('securetrading.wallet');
}
public function processTipCheckout($amount, $currency) {
$app = $this->application;
$smarty = $this->smarty;
$user = $app->container->user;
$smarty->assign([
'securetrading_reference' => Configuration::get(self::SECURETRADING_REFERENCE),
]);
return $this->getTemplateContent('securetrading.tip');
}
/**
* Hook action verify payment
* @param $params array
* @return void
*/
public function verifyPaymentAfter($params)
{
$handle = ArrayUtils::get($params, 'handle');
$transactionreference = ArrayUtils::get($params, 'transactionreference');
$orderreference = ArrayUtils::get($params, 'orderreference');
$settlestatus = ArrayUtils::get($params, 'settlestatus');
$errorcode = ArrayUtils::get($params, 'errorcode');
if( $orderreference && $settlestatus == "0" ){
PaymentModule::processPayment( $orderreference, $handle, $params );
}
}
}