Skip to content

Commit f8da071

Browse files
Release 2.1.20
1 parent ec55406 commit f8da071

File tree

17 files changed

+78
-29
lines changed

17 files changed

+78
-29
lines changed

Controller/Adminhtml/Order/Refund.php

+19-5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace PostFinanceCheckout\Payment\Controller\Adminhtml\Order;
1313

1414
use Magento\Backend\App\Action\Context;
15+
use Magento\Framework\App\Config\ScopeConfigInterface;
1516
use Magento\Framework\Controller\Result\ForwardFactory;
1617
use Magento\Framework\Exception\NoSuchEntityException;
1718
use PostFinanceCheckout\Payment\Api\RefundJobRepositoryInterface;
@@ -57,27 +58,39 @@ class Refund extends \PostFinanceCheckout\Payment\Controller\Adminhtml\Order
5758
*/
5859
private $apiClient;
5960

61+
/**
62+
*
63+
* @var ScopeConfigInterface
64+
*/
65+
private $scopeConfig;
66+
6067
/**
6168
*
6269
* @param Context $context
6370
* @param ForwardFactory $resultForwardFactory
6471
* @param LocaleHelper $localeHelper
6572
* @param RefundJobRepositoryInterface $refundJobRepository
6673
* @param ApiClient $apiClient
74+
* @param ScopeConfigInterface $scopeConfig
6775
*/
68-
public function __construct(Context $context, ForwardFactory $resultForwardFactory, LocaleHelper $localeHelper,
69-
RefundJobRepositoryInterface $refundJobRepository, ApiClient $apiClient)
70-
{
76+
public function __construct(Context $context, ForwardFactory $resultForwardFactory,
77+
LocaleHelper $localeHelper,
78+
RefundJobRepositoryInterface $refundJobRepository,
79+
ApiClient $apiClient,
80+
ScopeConfigInterface $scopeConfig
81+
) {
7182
parent::__construct($context);
7283
$this->resultForwardFactory = $resultForwardFactory;
7384
$this->localeHelper = $localeHelper;
7485
$this->refundJobRepository = $refundJobRepository;
7586
$this->apiClient = $apiClient;
87+
$this->scopeConfig = $scopeConfig;
7688
}
7789

7890
public function execute()
7991
{
8092
$orderId = $this->getRequest()->getParam('order_id');
93+
$isIgnorePendingRefundStatusEnabled = $this->scopeConfig->getValue('postfinancecheckout_payment/pending_refund_status/pending_refund_status_enabled');
8194
if ($orderId) {
8295
try {
8396
$refundJob = $this->refundJobRepository->getByOrderId($orderId);
@@ -90,8 +103,9 @@ public function execute()
90103
$this->messageManager->addErrorMessage(
91104
$this->localeHelper->translate($refund->getFailureReason()
92105
->getDescription()));
93-
} elseif ($refund->getState() == RefundState::PENDING ||
94-
$refund->getState() == RefundState::MANUAL_CHECK) {
106+
} elseif ( ! $isIgnorePendingRefundStatusEnabled &&
107+
( $refund->getState() == RefundState::PENDING ||
108+
$refund->getState() == RefundState::MANUAL_CHECK ) ) {
95109
$this->messageManager->addErrorMessage(
96110
\__('The refund was requested successfully, but is still pending on the gateway.'));
97111
} else {

Gateway/Command/RefundCommand.php

+21-4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
*/
1212
namespace PostFinanceCheckout\Payment\Gateway\Command;
1313

14+
use Magento\Framework\App\Config\ScopeConfigInterface;
1415
use Magento\Framework\Exception\NoSuchEntityException;
1516
use Magento\Payment\Gateway\CommandInterface;
1617
use Magento\Payment\Gateway\Helper\SubjectReader;
@@ -58,29 +59,43 @@ class RefundCommand implements CommandInterface
5859
*/
5960
private $apiClient;
6061

62+
/**
63+
*
64+
* @var ScopeConfigInterface
65+
*/
66+
private $scopeConfig;
67+
6168
/**
6269
*
6370
* @param LoggerInterface $logger
6471
* @param LocaleHelper $localeHelper
6572
* @param RefundJobRepositoryInterface $refundJobRepository
6673
* @param RefundService $refundService
6774
* @param ApiClient $apiClient
75+
* @param ScopeConfigInterface $scopeConfig
6876
*/
69-
public function __construct(LoggerInterface $logger, LocaleHelper $localeHelper,
70-
RefundJobRepositoryInterface $refundJobRepository, RefundService $refundService, ApiClient $apiClient)
71-
{
77+
public function __construct(
78+
LoggerInterface $logger,
79+
LocaleHelper $localeHelper,
80+
RefundJobRepositoryInterface $refundJobRepository,
81+
RefundService $refundService,
82+
ApiClient $apiClient,
83+
ScopeConfigInterface $scopeConfig
84+
) {
7285
$this->logger = $logger;
7386
$this->localeHelper = $localeHelper;
7487
$this->refundJobRepository = $refundJobRepository;
7588
$this->refundService = $refundService;
7689
$this->apiClient = $apiClient;
90+
$this->scopeConfig = $scopeConfig;
7791
}
7892

7993
public function execute(array $commandSubject)
8094
{
8195
/** @var \Magento\Sales\Model\Order\Payment $payment */
8296
$payment = SubjectReader::readPayment($commandSubject)->getPayment();
8397
$creditmemo = $payment->getCreditmemo();
98+
$isIgnorePendingRefundStatusEnabled = $this->scopeConfig->getValue('postfinancecheckout_payment/pending_refund_status/pending_refund_status_enabled');
8499

85100
if ($creditmemo->getPostfinancecheckoutExternalId() == null) {
86101
try {
@@ -117,7 +132,9 @@ public function execute(array $commandSubject)
117132
throw new \Magento\Framework\Exception\LocalizedException(
118133
\__($this->localeHelper->translate($refund->getFailureReason()
119134
->getDescription())));
120-
} elseif ($refund->getState() == RefundState::PENDING || $refund->getState() == RefundState::MANUAL_CHECK) {
135+
} elseif ( ! $isIgnorePendingRefundStatusEnabled &&
136+
( $refund->getState() == RefundState::PENDING ||
137+
$refund->getState() == RefundState::MANUAL_CHECK ) ) {
121138
$creditmemo->setPostfinancecheckoutKeepRefundJob(true);
122139
throw new \Magento\Framework\Exception\LocalizedException(
123140
\__('The refund was requested successfully, but is still pending on the gateway.'));

Model/Webhook/Listener/Transaction/AuthorizedCommand.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ public function execute($entity, Order $order)
7676
} else {
7777
$payment->registerAuthorizationNotification($payment->getAmountAuthorized());
7878
if ($entity->getState() != TransactionState::FULFILL) {
79-
80-
$order->setState(Order::STATE_PAYMENT_REVIEW);
79+
// Order's state cannot be Payment Review, but pending or processing.
80+
$order->setState(Order::STATE_PROCESSING);
8181
$order->addStatusToHistory('pending',
8282
\__('The order should not be fulfilled yet, as the payment is not guaranteed.')
8383
);

Model/Webhook/Listener/Transaction/FulfillCommand.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ public function execute($entity, Order $order)
5757
$payment = $order->getPayment();
5858
$payment->setIsTransactionApproved(true);
5959
$payment->update(false);
60-
} elseif ($order->getStatus() == 'processing') {
61-
$order->setState(Order::STATE_PROCESSING);
60+
} elseif ($order->getStatus() == Order::STATE_PROCESSING) {
61+
// $order->setState(Order::STATE_PROCESSING);
6262
$order->addStatusToHistory(true, \__('The order can be fulfilled now.'));
6363
}
6464
$this->orderRepository->save($order);
6565
}
66-
}
66+
}

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This repository contains the Magento 2 extension that enables to process payment
1212

1313
## Documentation
1414

15-
* [Documentation](https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.1.19/docs/en/documentation.html)
15+
* [Documentation](https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.1.20/docs/en/documentation.html)
1616

1717

1818
## Support
@@ -39,4 +39,4 @@ We do provide special integrations for the following one step checkouts:
3939

4040
## License
4141

42-
Please see the [license file](https://github.com/pfpayments/magento-2/blob/2.1.19/LICENSE) for more information.
42+
Please see the [license file](https://github.com/pfpayments/magento-2/blob/2.1.20/LICENSE) for more information.

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
}
1717
],
1818
"type" : "magento2-module",
19-
"version" : "2.1.19",
19+
"version" : "2.1.20",
2020
"require" : {
2121
"php" : "~7.1.3||~7.2.0||~7.3.0||~7.4.0||~8.0||~8.1||~8.2",
2222
"magento/framework" : "^102.0.0||^103.0.0",

docs/en/documentation.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ <h2>Documentation</h2> </div>
2323
</a>
2424
</li>
2525
<li>
26-
<a href="https://github.com/pfpayments/magento-2/releases/tag/2.1.19/">
26+
<a href="https://github.com/pfpayments/magento-2/releases/tag/2.1.20/">
2727
Source
2828
</a>
2929
</li>

etc/adminhtml/system.xml

+9-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<resource>PostFinanceCheckout_Payment::config</resource>
2020
<group id="information" translate="label comment" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
2121
<label>Information</label>
22-
<comment><![CDATA[If you need help setting up the PostFinance Checkout extension, check out the <a href="https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.1.19/docs/en/documentation.html" target="_blank">documentation</a>.]]></comment>
22+
<comment><![CDATA[If you need help setting up the PostFinance Checkout extension, check out the <a href="https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.1.20/docs/en/documentation.html" target="_blank">documentation</a>.]]></comment>
2323
<field id="version" translate="label" type="label" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
2424
<label>Module Version</label>
2525
</field>
@@ -74,7 +74,14 @@
7474
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
7575
</field>
7676
</group>
77-
77+
<group id="pending_refund_status" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
78+
<label>Pending refund status</label>
79+
<field id="pending_refund_status_enabled" translate="label comment" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
80+
<label>When a refund request is in a pending state, update its status to successful</label>
81+
<comment>Ignore the pending refund status and mark refund as successful</comment>
82+
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
83+
</field>
84+
</group>
7885
<group id="gdpr" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
7986
<label>GDPR Settings</label>
8087
<field id="gdpr_enabled" translate="label comment" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">

etc/config.xml

+4-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<default>
1616
<postfinancecheckout_payment>
1717
<information>
18-
<version>2.1.19</version>
18+
<version>2.1.20</version>
1919
<sdk_version>4.6.0</sdk_version>
2020
</information>
2121
<general>
@@ -30,6 +30,9 @@
3030
<email>
3131
<order>1</order>
3232
</email>
33+
<pending_refund_status>
34+
<pending_refund_status_enabled>0</pending_refund_status_enabled>
35+
</pending_refund_status>
3336
<gdpr>
3437
<gdpr_enabled>disabled</gdpr_enabled>
3538
</gdpr>

etc/module.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*/
1313
-->
1414
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
15-
<module name="PostFinanceCheckout_Payment" setup_version="2.1.19">
15+
<module name="PostFinanceCheckout_Payment" setup_version="2.1.20">
1616
<sequence>
1717
<module name="Magento_Sales"/>
1818
<module name="Magento_Payment"/>

i18n/de_CH.csv

+2-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@
5050
"Gift Wrap","Geschenkverpackung"
5151
"Hold Delivery","Lieferung halten"
5252
"ID required","ID erforderlich"
53-
"If you need help setting up the PostFinance Checkout extension, check out the <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.1.19/docs/en/documentation.html"" target=""_blank"">documentation</a>.","Falls Sie Hilfe benötigen beim Einrichten der PostFinance Checkout-Erweiterung, sehen Sie sich die <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.1.19/docs/en/documentation.html"" target=""_blank"">Dokumentation</a> an."
53+
"When a refund request is in a pending state, update its status to successful", "Wenn die Rückerstattung aussteht, markieren Sie sie als erfolgreich"
54+
"If you need help setting up the PostFinance Checkout extension, check out the <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.1.20/docs/en/documentation.html"" target=""_blank"">documentation</a>.","Falls Sie Hilfe benötigen beim Einrichten der PostFinance Checkout-Erweiterung, sehen Sie sich die <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.1.20/docs/en/documentation.html"" target=""_blank"">Dokumentation</a> an."
5455
"Inactive","Inaktiv"
5556
"Information","Informationen"
5657
"Invoice","Rechnung"

i18n/de_DE.csv

+2-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@
5050
"Gift Wrap","Geschenkverpackung"
5151
"Hold Delivery","Lieferung halten"
5252
"ID required","ID erforderlich"
53-
"If you need help setting up the PostFinance Checkout extension, check out the <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.1.19/docs/en/documentation.html"" target=""_blank"">documentation</a>.","Falls Sie Hilfe benötigen beim Einrichten der PostFinance Checkout-Erweiterung, sehen Sie sich die <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.1.19/docs/en/documentation.html"" target=""_blank"">Dokumentation</a> an."
53+
"When a refund request is in a pending state, update its status to successful", "Wenn die Rückerstattung aussteht, markieren Sie sie als erfolgreich"
54+
"If you need help setting up the PostFinance Checkout extension, check out the <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.1.20/docs/en/documentation.html"" target=""_blank"">documentation</a>.","Falls Sie Hilfe benötigen beim Einrichten der PostFinance Checkout-Erweiterung, sehen Sie sich die <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.1.20/docs/en/documentation.html"" target=""_blank"">Dokumentation</a> an."
5455
"Inactive","Inaktiv"
5556
"Information","Informationen"
5657
"Invoice","Rechnung"

i18n/en_US.csv

+3-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@
5050
"Gift Wrap","Gift Wrap"
5151
"Hold Delivery","Hold Delivery"
5252
"ID required","ID required"
53-
"If you need help setting up the PostFinance Checkout extension, check out the <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.1.19/docs/en/documentation.html"" target=""_blank"">documentation</a>.","If you need help setting up the PostFinance Checkout extension, check out the <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.1.19/docs/en/documentation.html"" target=""_blank"">documentation</a>."
53+
"When a refund request is in a pending state, update its status to successful", "When a refund request is in a pending state, update its status to successful"
54+
"If you need help setting up the PostFinance Checkout extension, check out the <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.1.20/docs/en/documentation.html"" target=""_blank"">documentation</a>.","If you need help setting up the PostFinance Checkout extension, check out the <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.1.20/docs/en/documentation.html"" target=""_blank"">documentation</a>."
5455
"Inactive","Inactive"
5556
"Information","Information"
5657
"Invoice","Invoice"
@@ -64,6 +65,7 @@
6465
"Packing Slip","Packing Slip"
6566
"Payment Method","Payment Method"
6667
"Pending","Pending"
68+
"Pending refund status", "Pending refund status"
6769
"Place Order","Place Order"
6870
"Processing","Processing"
6971
"Product Attributes","Product Attributes"

i18n/fr_CH.csv

+2-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"Gift Wrap","Papier cadeau"
5151
"Hold Delivery","Suspendre la livraison"
5252
"ID required","Pièce d'identité requise"
53-
"If you need help setting up the postfinancecheckout extension, check out the <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.1.19/docs/en/documentation.html"" target=""_blank"">documentation</a>.","Si vous avez besoin d'aide pour configurer l'extension postfinancecheckout, consultez la <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.1.19/docs/en/documentation.html"" target=""_blank"">documentation</a> an."
53+
"If you need help setting up the postfinancecheckout extension, check out the <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.1.20/docs/en/documentation.html"" target=""_blank"">documentation</a>.","Si vous avez besoin d'aide pour configurer l'extension postfinancecheckout, consultez la <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.1.20/docs/en/documentation.html"" target=""_blank"">documentation</a> an."
5454
"Inactive","Inactif"
5555
"Information","Information"
5656
"Invoice","Facture"
@@ -129,6 +129,7 @@
129129
"User Id","Identifiant de l'utilisateur"
130130
"View in postfinancecheckout","Vue en postfinancecheckout"
131131
"Voided","Annulé"
132+
"When a refund request is in a pending state, update its status to successful", "Lorsqu'une demande de remboursement est en état d'attente, mettre à jour son statut pour le marquer comme réussi"
132133
"postfinancecheckout Payment Methods","postfinancecheckout Payment Methods"
133134
"postfinancecheckout Payment Tokens","jetons de paiement postfinancecheckout"
134135
"postfinancecheckout Payment","paiement postfinancecheckout"

i18n/fr_FR.csv

+2-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@
5050
"Gift Wrap","Papier cadeau"
5151
"Hold Delivery","Suspendre la livraison"
5252
"ID required","Pièce d'identité requise"
53-
"If you need help setting up the postfinancecheckout extension, check out the <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.1.19/docs/en/documentation.html"" target=""_blank"">documentation</a>.","Si vous avez besoin d'aide pour configurer l'extension postfinancecheckout, consultez la <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.1.19/docs/en/documentation.html"" target=""_blank"">documentation</a> an."
53+
"When a refund request is in a pending state, update its status to successful", "Lorsqu'une demande de remboursement est en état d'attente, mettre à jour son statut pour le marquer comme réussi"
54+
"If you need help setting up the postfinancecheckout extension, check out the <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.1.20/docs/en/documentation.html"" target=""_blank"">documentation</a>.","Si vous avez besoin d'aide pour configurer l'extension postfinancecheckout, consultez la <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.1.20/docs/en/documentation.html"" target=""_blank"">documentation</a> an."
5455
"Inactive","Inactif"
5556
"Information","Information"
5657
"Invoice","Facture"

i18n/it_CH.csv

+2-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@
5050
"Gift Wrap","Confezione regalo"
5151
"Hold Delivery","Sospendi la consegna"
5252
"ID required","ID richiesto"
53-
"If you need help setting up the postfinancecheckout extension, check out the <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.1.19/docs/en/documentation.html"" target=""_blank"">documentation</a>.","Se hai bisogno di aiuto per configurare l'estensione postfinancecheckout, consulta la <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.1.19/docs/en/documentation.html"" target=""_blank"">documentazione</a> an."
53+
"When a refund request is in a pending state, update its status to successful", "Quando una richiesta di rimborso è in stato di attesa, contrassegnalo come eseguito con successo."
54+
"If you need help setting up the postfinancecheckout extension, check out the <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.1.20/docs/en/documentation.html"" target=""_blank"">documentation</a>.","Se hai bisogno di aiuto per configurare l'estensione postfinancecheckout, consulta la <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/2.1.20/docs/en/documentation.html"" target=""_blank"">documentazione</a> an."
5455
"Inactive","Inattivo"
5556
"Information","Informazione"
5657
"Invoice","Fattura"

0 commit comments

Comments
 (0)