-
Notifications
You must be signed in to change notification settings - Fork 0
/
Redirector.php
55 lines (51 loc) · 1.79 KB
/
Redirector.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
namespace TFC\Realex;
use Magento\Checkout\Model\Session;
use Magento\Sales\Model\Order as O;
# 2022-12-07
# «If the customer navigates back from the bank card payment page,
# the cart contents should be restored, and the customer should be redirected back to the Magento checkout page»:
# https://github.com/tradefurniturecompany/realex/issues/1
final class Redirector {
/**
* 2023-01-29
* @used-by \TFC\Realex\Observer\Predispatch\Arrival::execute()
*/
static function is():bool {return !!df_checkout_session()->getData(self::$K);}
/**
* 2022-01-29
* I have implemented it by analogy with:
* 1) \Df\Payment\CustomerReturn::execute():
* https://github.com/mage2pro/core/blob/9.2.8/Payment/CustomerReturn.php#L45-L66
* 2) \Df\Payment\W\Strategy\ConfirmPending::_handle():
* https://github.com/mage2pro/core/blob/9.2.8/Payment/W/Strategy/ConfirmPending.php#L124-L156
* @used-by \TFC\Realex\Observer\Predispatch\Arrival::execute()
*/
static function restoreQuote():void {
$s = df_checkout_session(); /** @var Session $s */
if (($o = $s->getLastRealOrder()) && $o->canCancel()) { /** @var O $o */
$o->cancel()->save();
}
$s->restoreQuote();
# 2016-05-06 «How to redirect a customer to the checkout payment step?» https://mage2.pro/t/1523
df_redirect_to_payment();
}
/**
* 2022-12-07
* @used-by \TFC\Realex\Observer\Predispatch\Departure::execute()
*/
static function set():void {df_checkout_session()->setData(self::$K, true);}
/**
* 2023-01-29
* @used-by \TFC\Realex\Observer\Predispatch\Arrival::execute()
*/
static function unset():void {df_checkout_session()->unsetData(self::$K);}
/**
* 2022-12-07 https://3v4l.org/4J9n4
* @used-by self::is()
* @used-by self::set()
* @used-by self::unset()
* @var string
*/
private static $K = __CLASS__;
}