Skip to content

Commit

Permalink
Remove Controller Quote Restoration Logic and harden the guard in web…
Browse files Browse the repository at this point in the history
…hook handling when validation fails (#196)
  • Loading branch information
aashwin-rvvup authored Oct 10, 2024
1 parent 48babfd commit 342debc
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 96 deletions.
4 changes: 4 additions & 0 deletions Controller/Redirect/In.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ public function execute()
true
);
}
return $this->resultFactory->create(ResultFactory::TYPE_REDIRECT)->setPath(
In::FAILURE,
['_secure' => true, '_fragment' => 'payment']
);
}

$payment = $quote->getPayment();
Expand Down
9 changes: 2 additions & 7 deletions Model/Queue/Handler/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
use Rvvup\Payments\Gateway\Method;
use Rvvup\Payments\Model\Payment\PaymentDataGetInterface;
use Rvvup\Payments\Model\ProcessOrder\ProcessorPool;
use Rvvup\Payments\Model\Queue\QueueContextCleaner;
use Rvvup\Payments\Model\RvvupConfigProvider;
use Rvvup\Payments\Model\Webhook\WebhookEventType;
use Rvvup\Payments\Service\Cache;
use Rvvup\Payments\Service\Capture;
use Rvvup\Payments\Model\Queue\QueueContextCleaner;

class Handler
{
Expand Down Expand Up @@ -187,12 +187,7 @@ public function execute(string $data)
$lastTransactionId = (string)$payment->getAdditionalInformation(Method::TRANSACTION_ID);
$validate = $this->captureService->validate($quote, $rvvupOrderId, null, $origin);
if (!$validate->getIsValid()) {
if ($validate->getRedirectToCart()) {
return;
}
if ($validate->getAlreadyExists()) {
return;
}
return;
}
$this->captureService->setCheckoutMethod($quote);
$validation = $this->captureService->createOrder($rvvupOrderId, $quote, $origin);
Expand Down
76 changes: 0 additions & 76 deletions Observer/Restore.php

This file was deleted.

10 changes: 0 additions & 10 deletions etc/frontend/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,6 @@
<argument name="logger" xsi:type="object">Rvvup\Payments\Model\Logger</argument>
</arguments>
</type>
<type name="Rvvup\Payments\Observer\Restore">
<arguments>
<argument name="restrictedPaths" xsi:type="array">
<item name="captcha" xsi:type="string">captcha/refresh</item>
<item name="customer_section" xsi:type="string">customer/section/load</item>
<item name="rvvup" xsi:type="string">rvvup/redirect/in</item>
</argument>
<argument name="session" xsi:type="object">Magento\Checkout\Model\Session\Proxy</argument>
</arguments>
</type>
<!-- View Models -->
<type name="Rvvup\Payments\ViewModel\Clearpay">
<arguments>
Expand Down
3 changes: 0 additions & 3 deletions etc/frontend/events.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
<observer name="rvvup_payments_checkout_cart_restrictions_warning"
instance="Rvvup\Payments\Observer\CartRestrictionsWarning" />
</event>
<event name="controller_action_predispatch">
<observer name="rvvup_payments_reload_cart_data" instance="Rvvup\Payments\Observer\Restore" />
</event>
<!-- Remove express payment data when a quote is restored (payment cancelled/rejected etc) -->
<event name="restore_quote">
<observer name="Rvvup_Payments::Observer\Session\RemoveExpressPaymentDataObserver"
Expand Down

0 comments on commit 342debc

Please sign in to comment.