-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
release: module update from ifthenpay/dev_prestashop_8 (ifthenpay/dev…
- Loading branch information
1 parent
201c7ca
commit 953809a
Showing
95 changed files
with
9,037 additions
and
1,468 deletions.
There are no files selected for viewing
75 changes: 75 additions & 0 deletions
75
ifthenpay/classes/Admin/Payments/IfthenpaygatewayAdminOrder.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 : ''; | ||
} | ||
} |
Oops, something went wrong.