4
4
namespace Rvvup \Payments \Model \Queue \Handler ;
5
5
6
6
use Magento \Framework \Api \SearchCriteriaBuilder ;
7
+ use Magento \Framework \App \Area ;
7
8
use Magento \Framework \Exception \AlreadyExistsException ;
8
9
use Magento \Framework \Exception \LocalizedException ;
9
10
use Magento \Framework \Serialize \SerializerInterface ;
10
11
use Magento \Sales \Api \Data \OrderInterface ;
11
12
use Magento \Sales \Model \ResourceModel \Order \Payment ;
13
+ use Magento \Store \Model \App \Emulation ;
12
14
use Psr \Log \LoggerInterface ;
13
15
use Rvvup \Payments \Api \WebhookRepositoryInterface ;
14
16
use Rvvup \Payments \Gateway \Method ;
@@ -52,6 +54,9 @@ class Handler
52
54
/** @var Json */
53
55
private $ json ;
54
56
57
+ /** @var Emulation */
58
+ private $ emulation ;
59
+
55
60
/**
56
61
* @param WebhookRepositoryInterface $webhookRepository
57
62
* @param SerializerInterface $serializer
@@ -62,6 +67,7 @@ class Handler
62
67
* @param Payment $paymentResource
63
68
* @param Cache $cacheService
64
69
* @param Capture $captureService
70
+ * @param Emulation $emulation
65
71
* @param Json $json
66
72
*/
67
73
public function __construct (
@@ -74,6 +80,7 @@ public function __construct(
74
80
Payment $ paymentResource ,
75
81
Cache $ cacheService ,
76
82
Capture $ captureService ,
83
+ Emulation $ emulation ,
77
84
Json $ json
78
85
) {
79
86
$ this ->webhookRepository = $ webhookRepository ;
@@ -85,6 +92,7 @@ public function __construct(
85
92
$ this ->paymentResource = $ paymentResource ;
86
93
$ this ->cacheService = $ cacheService ;
87
94
$ this ->logger = $ logger ;
95
+ $ this ->emulation = $ emulation ;
88
96
$ this ->json = $ json ;
89
97
}
90
98
@@ -102,7 +110,13 @@ public function execute(string $data)
102
110
103
111
$ rvvupOrderId = $ payload ['order_id ' ];
104
112
$ rvvupPaymentId = $ payload ['payment_id ' ];
105
- $ storeId = $ payload ['store_id ' ];
113
+ $ storeId = $ payload ['store_id ' ] ?? false ;
114
+
115
+ if (!$ storeId ) {
116
+ return ;
117
+ }
118
+
119
+ $ this ->emulation ->startEnvironmentEmulation ((int ) $ storeId );
106
120
107
121
if ($ paymentLinkId = $ payload ['payment_link_id ' ]) {
108
122
$ order = $ this ->captureService ->getOrderByRvvupPaymentLinkId ($ paymentLinkId , $ storeId );
0 commit comments