|
11 | 11 | */
|
12 | 12 | namespace PostFinanceCheckout\Payment\Gateway\Command;
|
13 | 13 |
|
| 14 | +use Magento\Framework\App\Config\ScopeConfigInterface; |
14 | 15 | use Magento\Framework\Exception\NoSuchEntityException;
|
15 | 16 | use Magento\Payment\Gateway\CommandInterface;
|
16 | 17 | use Magento\Payment\Gateway\Helper\SubjectReader;
|
@@ -58,29 +59,43 @@ class RefundCommand implements CommandInterface
|
58 | 59 | */
|
59 | 60 | private $apiClient;
|
60 | 61 |
|
| 62 | + /** |
| 63 | + * |
| 64 | + * @var ScopeConfigInterface |
| 65 | + */ |
| 66 | + private $scopeConfig; |
| 67 | + |
61 | 68 | /**
|
62 | 69 | *
|
63 | 70 | * @param LoggerInterface $logger
|
64 | 71 | * @param LocaleHelper $localeHelper
|
65 | 72 | * @param RefundJobRepositoryInterface $refundJobRepository
|
66 | 73 | * @param RefundService $refundService
|
67 | 74 | * @param ApiClient $apiClient
|
| 75 | + * @param ScopeConfigInterface $scopeConfig |
68 | 76 | */
|
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 | + ) { |
72 | 85 | $this->logger = $logger;
|
73 | 86 | $this->localeHelper = $localeHelper;
|
74 | 87 | $this->refundJobRepository = $refundJobRepository;
|
75 | 88 | $this->refundService = $refundService;
|
76 | 89 | $this->apiClient = $apiClient;
|
| 90 | + $this->scopeConfig = $scopeConfig; |
77 | 91 | }
|
78 | 92 |
|
79 | 93 | public function execute(array $commandSubject)
|
80 | 94 | {
|
81 | 95 | /** @var \Magento\Sales\Model\Order\Payment $payment */
|
82 | 96 | $payment = SubjectReader::readPayment($commandSubject)->getPayment();
|
83 | 97 | $creditmemo = $payment->getCreditmemo();
|
| 98 | + $isIgnorePendingRefundStatusEnabled = $this->scopeConfig->getValue('postfinancecheckout_payment/pending_refund_status/pending_refund_status_enabled'); |
84 | 99 |
|
85 | 100 | if ($creditmemo->getPostfinancecheckoutExternalId() == null) {
|
86 | 101 | try {
|
@@ -117,7 +132,9 @@ public function execute(array $commandSubject)
|
117 | 132 | throw new \Magento\Framework\Exception\LocalizedException(
|
118 | 133 | \__($this->localeHelper->translate($refund->getFailureReason()
|
119 | 134 | ->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 ) ) { |
121 | 138 | $creditmemo->setPostfinancecheckoutKeepRefundJob(true);
|
122 | 139 | throw new \Magento\Framework\Exception\LocalizedException(
|
123 | 140 | \__('The refund was requested successfully, but is still pending on the gateway.'));
|
|
0 commit comments