File tree Expand file tree Collapse file tree 3 files changed +41
-11
lines changed
app/code/Meta/Sales/Observer/Order Expand file tree Collapse file tree 3 files changed +41
-11
lines changed Original file line number Diff line number Diff line change 17
17
18
18
namespace Meta \Sales \Observer \Order ;
19
19
20
+ use Exception ;
20
21
use GuzzleHttp \Exception \GuzzleException ;
21
22
use Magento \Framework \Event \Observer ;
22
23
use Magento \Framework \Event \ObserverInterface ;
@@ -86,13 +87,22 @@ public function execute(Observer $observer)
86
87
* @param string $fbOrderId
87
88
* @return void
88
89
* @throws GuzzleException
90
+ * @throws Exception
89
91
*/
90
92
private function cancelOrder (int $ storeId , string $ fbOrderId )
91
93
{
92
94
$ this ->graphAPIAdapter
93
95
->setDebugMode ($ this ->systemConfig ->isDebugMode ($ storeId ))
94
96
->setAccessToken ($ this ->systemConfig ->getAccessToken ($ storeId ));
95
-
96
- $ this ->graphAPIAdapter ->cancelOrder ($ fbOrderId );
97
+ try {
98
+ $ this ->graphAPIAdapter ->cancelOrder ($ fbOrderId );
99
+ } catch (GuzzleException $ e ) {
100
+ $ response = $ e ->getResponse ();
101
+ $ body = json_decode ($ response ->getBody ());
102
+ throw new Exception ('Error Code: '
103
+ .(string ) $ body ->error ->code
104
+ .'; '
105
+ . (string ) $ body ->error ->error_user_msg );
106
+ }
97
107
}
98
108
}
Original file line number Diff line number Diff line change 17
17
18
18
namespace Meta \Sales \Observer \Order ;
19
19
20
+ use Exception ;
20
21
use Meta \Sales \Model \Order \Shipper ;
21
22
use Meta \BusinessExtension \Model \System \Config as SystemConfig ;
22
23
use GuzzleHttp \Exception \GuzzleException ;
@@ -64,6 +65,7 @@ public function __construct(
64
65
* @param Observer $observer
65
66
* @throws LocalizedException
66
67
* @throws GuzzleException
68
+ * @throws Exception
67
69
*/
68
70
public function execute (Observer $ observer )
69
71
{
@@ -88,7 +90,15 @@ public function execute(Observer $observer)
88
90
&& $ this ->systemConfig ->isOnsiteCheckoutEnabled ($ storeId ))) {
89
91
return ;
90
92
}
91
-
92
- $ this ->shipper ->markAsShipped ($ shipment );
93
+ try {
94
+ $ this ->shipper ->markAsShipped ($ shipment );
95
+ } catch (GuzzleException $ e ) {
96
+ $ response = $ e ->getResponse ();
97
+ $ body = json_decode ($ response ->getBody ());
98
+ throw new Exception ('Error Code: '
99
+ .(string ) $ body ->error ->code
100
+ .'; '
101
+ . (string ) $ body ->error ->error_user_msg );
102
+ }
93
103
}
94
104
}
Original file line number Diff line number Diff line change @@ -146,6 +146,7 @@ public function execute(Observer $observer)
146
146
* @param string|null $currencyCode
147
147
* @param string|null $reasonText
148
148
* @throws GuzzleException
149
+ * @throws Exception
149
150
*/
150
151
private function refundOrder (
151
152
int $ storeId ,
@@ -159,13 +160,22 @@ private function refundOrder(
159
160
->setDebugMode ($ this ->systemConfig ->isDebugMode ($ storeId ))
160
161
->setAccessToken ($ this ->systemConfig ->getAccessToken ($ storeId ));
161
162
162
- $ this ->graphAPIAdapter ->refundOrder (
163
- $ fbOrderId ,
164
- $ items ,
165
- $ shippingRefundAmount ,
166
- $ currencyCode ,
167
- $ reasonText
168
- );
163
+ try {
164
+ $ this ->graphAPIAdapter ->refundOrder (
165
+ $ fbOrderId ,
166
+ $ items ,
167
+ $ shippingRefundAmount ,
168
+ $ currencyCode ,
169
+ $ reasonText
170
+ );
171
+ } catch (GuzzleException $ e ) {
172
+ $ response = $ e ->getResponse ();
173
+ $ body = json_decode ($ response ->getBody ());
174
+ throw new Exception ('Error Code: '
175
+ .(string ) $ body ->error ->code
176
+ .'; '
177
+ . (string ) $ body ->error ->error_user_msg );
178
+ }
169
179
}
170
180
171
181
/**
You can’t perform that action at this time.
0 commit comments