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 May 10, 2023
1 parent 3022669 commit 3d7a906
Show file tree
Hide file tree
Showing 41 changed files with 1,132 additions and 555 deletions.
4 changes: 2 additions & 2 deletions ifthenpay/classes/Admin/IfthenpayAdminRefund.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class IfthenpayAdminRefund extends IfthenpayStrategy
public function execute()
{
$this->setDefaultData();
$this->setDefaultEmailData();
return AdminRefundFactory::build($this->order->payment, $this->paymentDefaultData, $this->ifthenpayModule, null, $this->emailDefaultData)->refundPayment();
$this->setAdminEmailData();
return AdminRefundFactory::build($this->order->payment, $this->paymentDefaultData, $this->ifthenpayModule, null, $this->emailAdminData)->refundPayment();
}
}
3 changes: 2 additions & 1 deletion ifthenpay/classes/Admin/Payments/CCardAdminRefund.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@


namespace PrestaShop\Module\Ifthenpay\Admin\Payments;
use PrestaShop\Module\Ifthenpay\Utility\Utility;

if (!defined('_PS_VERSION_')) {
exit;
Expand All @@ -40,7 +41,7 @@ public function refundPayment()
$this->setPaymentModel('ccard');
$this->getFromDatabaseById();
$this->setEmailVariables();
$this->sendEmail('refund', 'Confirmação de Reembolso');
$this->sendEmailToAdmin('refund_token', Utility::getMailTranslationString('ccard', 'refund'));
return $this->securityCode;
}
}
3 changes: 2 additions & 1 deletion ifthenpay/classes/Admin/Payments/MbwayAdminRefund.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@


namespace PrestaShop\Module\Ifthenpay\Admin\Payments;
use PrestaShop\Module\Ifthenpay\Utility\Utility;

if (!defined('_PS_VERSION_')) {
exit;
Expand All @@ -40,7 +41,7 @@ public function refundPayment()
$this->setPaymentModel('mbway');
$this->getFromDatabaseById();
$this->setEmailVariables();
$this->sendEmail('refund', 'Confirmação de Reembolso');
$this->sendEmailToAdmin('refund', Utility::getMailTranslationString('mbway', 'refund'));
return $this->securityCode;
}
}
23 changes: 22 additions & 1 deletion ifthenpay/classes/Base/PaymentBase.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ abstract class PaymentBase
protected $paymentDefaultData;
protected $smartyDefaultData;
protected $emailDefaultData;
protected $emailAdminData;
protected $paymentGatewayResultData;
protected $ifthenpayGateway;
protected $paymentModel;
Expand Down Expand Up @@ -74,7 +75,7 @@ public function getFromDatabaseById()
}

protected function sendEmail($emailTemplate, $emailSubject)
{
{
\Mail::Send(
(int)$this->paymentDefaultData->order->id_lang,
$emailTemplate,
Expand All @@ -92,6 +93,26 @@ protected function sendEmail($emailTemplate, $emailSubject)
);
}

protected function sendEmailToAdmin($emailTemplate, $emailSubject)
{
$context = \Context::getContext();
\Mail::Send(
(int)$context->employee->id_lang,
$emailTemplate,
$emailSubject,
$this->emailDefaultData,
$context->employee->email,
$context->employee->firstname . ' ' . $context->employee->lastname,
null,
null,
null,
null,
_PS_MODULE_DIR_ . 'ifthenpay/mails/',
false,
(int)$this->paymentDefaultData->order->id_shop
);
}

public function getSmartyVariables()
{
return $this->smartyDefaultData;
Expand Down
4 changes: 2 additions & 2 deletions ifthenpay/classes/Config/IfthenpayConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ private function uninstallByPaymentMethod()
\Configuration::deleteByName('IFTHENPAY_MULTIBANCO_URL_CALLBACK');
\Configuration::deleteByName('IFTHENPAY_MULTIBANCO_CHAVE_ANTI_PHISHING');
\Configuration::deleteByName('IFTHENPAY_MULTIBANCO_CANCEL_ORDER_AFTER_TIMEOUT');

break;
case 'mbway':
\Configuration::deleteByName('IFTHENPAY_MBWAY_KEY');
Expand All @@ -94,7 +93,7 @@ private function uninstallByPaymentMethod()
\Configuration::deleteByName('IFTHENPAY_MBWAY_CANCEL_ORDER_AFTER_TIMEOUT');
\Configuration::deleteByName('IFTHENPAY_MBWAY_SHOW_COUNTDOWN');
\Configuration::deleteByName('IFTHENPAY_MBWAY_CANCEL_ORDER_AFTER_TIMEOUT');

\Configuration::deleteByName('IFTHENPAY_MBWAY_REFUND');
break;
case 'payshop':
\Configuration::deleteByName('IFTHENPAY_PAYSHOP_KEY');
Expand All @@ -106,6 +105,7 @@ private function uninstallByPaymentMethod()
case 'ccard':
\Configuration::deleteByName('IFTHENPAY_CCARD_KEY');
\Configuration::deleteByName('IFTHENPAY_CCARD_CANCEL_ORDER_AFTER_TIMEOUT');
\Configuration::deleteByName('IFTHENPAY_CCARD_REFUND');
break;
default:
}
Expand Down
6 changes: 3 additions & 3 deletions ifthenpay/classes/Factory/Admin/AdminRefundFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ public static function build(
$paymentDefaultData,
$ifthenpayModule,
$smartyDefaultData = null,
$emailDefaultData = null
$emailAdminData = null
) {
switch ($type) {
case 'mbway':
return new MbwayAdminRefund($ifthenpayModule, $paymentDefaultData, $smartyDefaultData, $emailDefaultData);
return new MbwayAdminRefund($ifthenpayModule, $paymentDefaultData, $smartyDefaultData, $emailAdminData);
case 'ccard':
return new CCardAdminRefund($ifthenpayModule, $paymentDefaultData, $smartyDefaultData, $emailDefaultData);
return new CCardAdminRefund($ifthenpayModule, $paymentDefaultData, $smartyDefaultData, $emailAdminData);
default:
throw new \Exception('Unknown Admin Refund class');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,9 @@ public static function buildCustomer($id = null)
{
return new \Customer($id);
}

public static function buildEmployee($id = null)
{
return new \Employee($id);
}
}
38 changes: 30 additions & 8 deletions ifthenpay/classes/Forms/CCardConfigForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@
class CCardConfigForm extends ConfigForm
{
protected $paymentMethod = 'ccard';

protected $options = []; // array of entity options for GUI select


/**
* "gets" the form into object... it sets the form that will display in the payment method configuration
*
Expand All @@ -49,8 +47,9 @@ public function getForm()
{
// assign template variables
$this->setSmartyVariables();

$this->setFormParent();

// sets the $this->options
$this->setEntityOptions();

$this->form['form']['input'][] = [
Expand All @@ -71,18 +70,39 @@ public function getForm()
'type' => 'switch',
'label' => $this->ifthenpayModule->l('Cancel CCard Order', pathinfo(__FILE__)['filename']),
'name' => 'IFTHENPAY_CCARD_CANCEL_ORDER_AFTER_TIMEOUT',
'desc' => $this->ifthenpayModule->l('Cancel order if not payed within 30 minutes after confirmation. This is triggered when admin visits the order list page.'),
'desc' => $this->ifthenpayModule->l('Cancel order if not payed within 30 minutes after confirmation. This is triggered when admin visits the order list page.', pathinfo(__FILE__)['filename']),
'is_bool' => true,
'values' => [
[
'id' => 'active_on',
'value' => true,
'label' => $this->ifthenpayModule->l('ON', pathinfo(__FILE__)['filename'])
],
[
'id' => 'active_off',
'value' => false,
'label' => $this->ifthenpayModule->l('OFF', pathinfo(__FILE__)['filename'])
]
]
];

// activate partial refund method
$this->form['form']['input'][] = [
'type' => 'switch',
'label' => $this->ifthenpayModule->l('Partial Refund', pathinfo(__FILE__)['filename']),
'name' => 'IFTHENPAY_CCARD_REFUND',
'desc' => $this->ifthenpayModule->l('Allows the admin to make partial refunds directly to the Ifthenpay Payment Gateway.', pathinfo(__FILE__)['filename']),
'is_bool' => true,
'values' => [
[
'id' => 'active_on',
'value' => true,
'label' => $this->ifthenpayModule->l('Activate', pathinfo(__FILE__)['filename'])
'label' => $this->ifthenpayModule->l('ON', pathinfo(__FILE__)['filename'])
],
[
'id' => 'active_off',
'value' => false,
'label' => $this->ifthenpayModule->l('Disabled', pathinfo(__FILE__)['filename'])
'label' => $this->ifthenpayModule->l('OFF', pathinfo(__FILE__)['filename'])
]
]
];
Expand All @@ -101,6 +121,7 @@ protected function getConfigFormValues()
return array_merge(parent::getCommonConfigFormValues(), [
'IFTHENPAY_CCARD_KEY' => \Configuration::get('IFTHENPAY_CCARD_KEY'),
'IFTHENPAY_CCARD_CANCEL_ORDER_AFTER_TIMEOUT' => \Configuration::get('IFTHENPAY_CCARD_CANCEL_ORDER_AFTER_TIMEOUT'),
'IFTHENPAY_CCARD_REFUND' => \Configuration::get('IFTHENPAY_CCARD_REFUND')
]);
}

Expand Down Expand Up @@ -133,7 +154,7 @@ public function processForm()
// save specific values
\Configuration::updateValue('IFTHENPAY_CCARD_KEY', $this->gatewayDataBuilder->getData()->subEntidade);
\Configuration::updateValue('IFTHENPAY_CCARD_CANCEL_ORDER_AFTER_TIMEOUT', \Tools::getValue('IFTHENPAY_CCARD_CANCEL_ORDER_AFTER_TIMEOUT'));

\Configuration::updateValue('IFTHENPAY_CCARD_REFUND', \Tools::getValue('IFTHENPAY_CCARD_REFUND'));
$this->updatePayMethodCommonValues();

// response msg after submiting form
Expand All @@ -142,7 +163,7 @@ public function processForm()
return true;

} else {

return false;
}
}
Expand Down Expand Up @@ -176,5 +197,6 @@ public function deleteConfigValues()
$this->deleteCommonConfigValues();
\Configuration::deleteByName('IFTHENPAY_CCARD_KEY');
\Configuration::deleteByName('IFTHENPAY_CCARD_CANCEL_ORDER_AFTER_TIMEOUT');
\Configuration::deleteByName('IFTHENPAY_CCARD_REFUND');
}
}
4 changes: 2 additions & 2 deletions ifthenpay/classes/Forms/ConfigForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,12 @@ protected function addActivateCallbackToForm()
[
'id' => 'active_on',
'value' => true,
'label' => $this->ifthenpayModule->l('Activate', pathinfo(__FILE__)['filename'])
'label' => $this->ifthenpayModule->l('ON', pathinfo(__FILE__)['filename'])
],
[
'id' => 'active_off',
'value' => false,
'label' => $this->ifthenpayModule->l('Disabled', pathinfo(__FILE__)['filename'])
'label' => $this->ifthenpayModule->l('OFF', pathinfo(__FILE__)['filename'])
]
]
];
Expand Down
Loading

0 comments on commit 3d7a906

Please sign in to comment.