Skip to content

Commit

Permalink
release: module update from ifthenpay/dev_prestashop_8 (ifthenpay/dev…
Browse files Browse the repository at this point in the history
  • Loading branch information
joaocouto-ifthenpay committed Oct 4, 2024
1 parent 201c7ca commit 953809a
Show file tree
Hide file tree
Showing 95 changed files with 9,037 additions and 1,468 deletions.
75 changes: 75 additions & 0 deletions ifthenpay/classes/Admin/Payments/IfthenpaygatewayAdminOrder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?php

/**
* 2007-2022 Ifthenpay Lda
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @copyright 2007-2022 Ifthenpay Lda
* @author Ifthenpay Lda <[email protected]>
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

namespace PrestaShop\Module\Ifthenpay\Admin\Payments;

if (!defined('_PS_VERSION_')) {
exit;
}


use PrestaShop\Module\Ifthenpay\Base\Payments\IfthenpaygatewayBase;
use PrestaShop\Module\Ifthenpay\Contracts\Admin\AdminOrderInterface;

class IfthenpaygatewayAdminOrder extends IfthenpaygatewayBase implements AdminOrderInterface
{

public function setSmartyVariables($paymentInDatabase)
{
if ($paymentInDatabase) {
$this->smartyDefaultData->setPaymentUrl($this->paymentDataFromDb['payment_url']);
$this->smartyDefaultData->setDeadline(
(isset($this->paymentDataFromDb['deadline']) && $this->paymentDataFromDb['deadline'] != '') ?
(new \DateTime($this->paymentDataFromDb['deadline']))->format('d-m-Y') : ''
);
} else {
$this->smartyDefaultData->setPaymentUrl($this->paymentGatewayResultData->paymentUrl);
$this->smartyDefaultData->setDeadline((new \DateTime($this->paymentGatewayResultData->deadline))->format('d-m-Y'));
}
}



public function getAdminOrder()
{
$this->setPaymentModel('ifthenpaygateway');
$this->getFromDatabaseById();
if (!empty($this->paymentDataFromDb)) {
$this->setSmartyVariables(true);
} else {
$this->setGatewayBuilderData();
$this->paymentGatewayResultData = $this->ifthenpayGateway->execute(
$this->paymentDefaultData->paymentMethod,
$this->gatewayBuilder,
strval($this->paymentDefaultData->order->id),
strval($this->paymentDefaultData->order->getOrdersTotalPaid())
)->getData();
$this->saveToDatabase();
$this->setSmartyVariables(false);
}
return $this;
}
}
4 changes: 2 additions & 2 deletions ifthenpay/classes/Admin/Payments/MbwayAdminRefund.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ public function refundPayment()
{
$this->setPaymentModel('mbway');
$this->getFromDatabaseById();
$this->setEmailVariables();
$this->sendEmailToAdmin('refund', Utility::getMailTranslationString('mbway', 'refund'));
$this->setEmailVariables();
$this->sendEmailToAdmin('refund_token', Utility::getMailTranslationString('mbway', 'refund'));
return $this->securityCode;
}
}
16 changes: 8 additions & 8 deletions ifthenpay/classes/Base/Payments/CCardBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

class CCardBase extends PaymentBase
{

private function getUrlCallback()
{
return \Context::getContext()->link->getModuleLink('ifthenpay', 'callback', array(), true);
Expand All @@ -45,18 +45,18 @@ private function getUrlCallback()
protected function setGatewayBuilderData()
{
$this->gatewayBuilder->setCCardKey(\Configuration::get('IFTHENPAY_CCARD_KEY'));
$this->gatewayBuilder->setSuccessUrl($this->getUrlCallback() . '?type=online&payment=ccard&cartId=' . \Tools::getValue('id_cart') . '&qn=' .
Token::encrypt(Status::getStatusSuccess())
$this->gatewayBuilder->setSuccessUrl($this->getUrlCallback() . '?type=online&p=ccard&cartId=' . \Tools::getValue('id_cart') . '&qn=' .
Token::encrypt(Status::getStatusSuccess())
);
$this->gatewayBuilder->setErrorUrl($this->getUrlCallback() . '?type=online&payment=ccard&cartId=' . \Tools::getValue('id_cart') . '&qn=' .

$this->gatewayBuilder->setErrorUrl($this->getUrlCallback() . '?type=online&p=ccard&cartId=' . \Tools::getValue('id_cart') . '&qn=' .
Token::encrypt(Status::getStatusError())
);
$this->gatewayBuilder->setCancelUrl($this->getUrlCallback() . '?type=online&payment=ccard&cartId=' . \Tools::getValue('id_cart') . '&qn=' .

$this->gatewayBuilder->setCancelUrl($this->getUrlCallback() . '?type=online&p=ccard&cartId=' . \Tools::getValue('id_cart') . '&qn=' .
Token::encrypt(Status::getStatusCancel())
);

}

protected function saveToDatabase()
Expand Down
11 changes: 6 additions & 5 deletions ifthenpay/classes/Base/Payments/CofidispayBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

class CofidispayBase extends PaymentBase
{

private function getUrlCallback()
{
return \Context::getContext()->link->getModuleLink('ifthenpay', 'callback', array(), true);
Expand All @@ -45,10 +45,11 @@ private function getUrlCallback()
protected function setGatewayBuilderData()
{
$this->gatewayBuilder->setCofidisKey(\Configuration::get('IFTHENPAY_COFIDIS_KEY'));

$this->gatewayBuilder->setSuccessUrl($this->getUrlCallback() . '?type=online&payment=cofidispay&cartId=' . \Tools::getValue('id_cart') . '&qn=' .
Token::encrypt(Status::getStatusSuccess())
);

$this->gatewayBuilder->setSuccessUrl(
$this->getUrlCallback() . '?type=online&p=cofidispay&cartId=' . \Tools::getValue('id_cart') . '&qn=' .
Token::encrypt(Status::getStatusSuccess())
);
}

protected function saveToDatabase()
Expand Down
88 changes: 88 additions & 0 deletions ifthenpay/classes/Base/Payments/IfthenpaygatewayBase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?php

/**
* 2007-2022 Ifthenpay Lda
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @copyright 2007-2022 Ifthenpay Lda
* @author Ifthenpay Lda <[email protected]>
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/


namespace PrestaShop\Module\Ifthenpay\Base\Payments;

if (!defined('_PS_VERSION_')) {
exit;
}

use PrestaShop\Module\Ifthenpay\Base\PaymentBase;


class IfthenpaygatewayBase extends PaymentBase
{
protected function setGatewayBuilderData()
{
$this->gatewayBuilder->setKey(\Configuration::get('IFTHENPAY_IFTHENPAYGATEWAY_KEY'));
$this->gatewayBuilder->setSelectableMethods(\Configuration::get('IFTHENPAY_IFTHENPAYGATEWAY_METHODS'));
$this->gatewayBuilder->setDefaultMethod(\Configuration::get('IFTHENPAY_IFTHENPAYGATEWAY_DEFAULT_METHOD'));
$this->gatewayBuilder->setDeadline(\Configuration::get('IFTHENPAY_IFTHENPAYGATEWAY_DEADLINE'));
}



protected function saveToDatabase()
{
$this->paymentModel->payment_url = $this->paymentGatewayResultData->paymentUrl;
$this->paymentModel->deadline = $this->paymentGatewayResultData->deadline;
$this->paymentModel->order_id = $this->paymentDefaultData->order->id;
$this->paymentModel->status = 'pending';
$this->paymentModel->save();
}



protected function updateDatabase()
{
$this->setPaymentModel('ifthenpaygateway', $this->paymentDataFromDb['id_ifthenpay_ifthenpaygateway']);
$this->paymentModel->payment_url = $this->paymentGatewayResultData->payment_url;
$this->paymentModel->deadline = isset($this->paymentGatewayResultData->deadline) ? $this->paymentGatewayResultData->deadline : null;
$this->paymentModel->update();
}



protected function setEmailVariables()
{
$this->emailDefaultData['{mb_logo}'] = _PS_BASE_URL_ . _MODULE_DIR_ . 'ifthenpay/views/img/ifthenpaygateway.png';
$this->emailDefaultData['{payment_url}'] = $this->paymentGatewayResultData ? $this->paymentGatewayResultData->paymentUrl : $this->paymentDataFromDb['payment_url'];

$this->smartyDefaultData->setDeadline(isset($this->paymentGatewayResultData->deadline) ? (new \DateTime($this->paymentGatewayResultData->deadline))->format('d-m-Y') : '');

$deadline = isset($this->paymentGatewayResultData->deadline) ? $this->paymentGatewayResultData->deadline : $this->paymentDataFromDb['deadline'];
$deadline = $deadline != '' ? (new \DateTime($deadline))->format('d-m-Y') : '';

$deadlineHtml = <<<HTML
<tr>
<td colspan="2" style="padding-left: 4px;">Deadline: <b>{$deadline}</b></td>
</tr>
HTML;

$this->emailDefaultData['{deadline}'] = $deadline != '' ? $deadlineHtml : '';
}
}
Loading

0 comments on commit 953809a

Please sign in to comment.