@@ -120,18 +120,23 @@ public function getOrderContext(MagentoOrder $order): array
120120
121121 public function getInvoiceContext (MagentoOrder \Invoice $ invoice ): array
122122 {
123- $ stateName = $ invoice ->getStateName ();
123+ try {
124+ $ stateName = $ invoice ->getStateName ();
124125
125- return [
126- 'invoiceId ' => $ invoice ->getEntityId (),
127- 'invoiceIncrementId ' => $ invoice ->getIncrementId (),
128- 'invoiceState ' => $ invoice ->getState (),
129- 'invoiceStateName ' => $ stateName instanceof Phrase ? $ stateName ->getText () : $ stateName ,
130- 'invoiceWasPayCalled ' => $ invoice ->wasPayCalled (),
131- 'invoiceCanCapture ' => $ invoice ->canCapture (),
132- 'invoiceCanCancel ' => $ invoice ->canCancel (),
133- 'invoiceCanVoid ' => $ invoice ->canVoid (),
134- 'invoiceCanRefund ' => $ invoice ->canRefund ()
135- ];
126+ return [
127+ 'invoiceId ' => $ invoice ->getEntityId (),
128+ 'invoiceIncrementId ' => $ invoice ->getIncrementId (),
129+ 'invoiceState ' => $ invoice ->getState (),
130+ 'invoiceStateName ' => $ stateName instanceof Phrase ? $ stateName ->getText () : $ stateName ,
131+ 'invoiceWasPayCalled ' => $ invoice ->wasPayCalled (),
132+ 'invoiceCanCapture ' => $ invoice ->canCapture (),
133+ 'invoiceCanCancel ' => $ invoice ->canCancel (),
134+ 'invoiceCanVoid ' => $ invoice ->canVoid (),
135+ 'invoiceCanRefund ' => $ invoice ->canRefund ()
136+ ];
137+ } catch (\Throwable $ e ) {
138+ $ this ->addAdyenWarning ('Failed to retrieve invoice context: ' . $ e ->getMessage ());
139+ return [];
140+ }
136141 }
137142}
0 commit comments