@@ -113,7 +113,7 @@ public function doCreatePayPalOrder(
113113 string $ returnUrl = null ,
114114 string $ cancelUrl = null ,
115115 bool $ setProvidedAddress = true
116- ): Order {
116+ ): ? Order {
117117 //TODO return value
118118 $ this ->setPaymentExecutionError (self ::PAYMENT_ERROR_NONE );
119119
@@ -133,7 +133,7 @@ public function doCreatePayPalOrder(
133133 $ setProvidedAddress
134134 );
135135
136- $ response = [] ;
136+ $ response = null ;
137137
138138 try {
139139 $ response = $ orderService ->createOrder (
@@ -172,8 +172,13 @@ public function doCreatePatchedOrder(
172172 false
173173 );
174174
175- $ paypalOrderId = $ response ->id ?: '' ;
176- $ status = $ response ->status ?: '' ;
175+ $ paypalOrderId = '' ;
176+ $ status = '' ;
177+
178+ if ($ response ) {
179+ $ paypalOrderId = $ response ->id ?: '' ;
180+ $ status = $ response ->status ?: '' ;
181+ }
177182
178183 // patch the order only if paypalOrderId exists
179184 if ($ paypalOrderId ) {
@@ -583,7 +588,10 @@ public function doExecuteStandardPayment(
583588 false
584589 );
585590
586- $ orderId = $ response ->id ?: '' ;
591+ $ orderId = '' ;
592+ if ($ response ) {
593+ $ orderId = $ response ->id ?: '' ;
594+ }
587595
588596 if (!$ orderId ) {
589597 $ this ->setPaymentExecutionError (self ::PAYMENT_ERROR_GENERIC );
@@ -632,7 +640,11 @@ public function doCreateUAPMOrder(EshopModelBasket $basket): string
632640 false
633641 );
634642
635- return $ response ->id ?: '' ;
643+ $ result = '' ;
644+ if ($ response ) {
645+ $ result = $ response ->id ?: '' ;
646+ }
647+ return $ result ;
636648 }
637649
638650 public function doExecutePuiPayment (
@@ -642,6 +654,7 @@ public function doExecutePuiPayment(
642654 ): bool {
643655 $ this ->setPaymentExecutionError (self ::PAYMENT_ERROR_NONE );
644656
657+ $ payPalOrderId = '' ;
645658 try {
646659 $ result = $ this ->doCreatePayPalOrder (
647660 $ basket ,
@@ -652,7 +665,9 @@ public function doExecutePuiPayment(
652665 $ payPalClientMetadataId ,
653666 Constants::PAYPAL_PARTNER_ATTRIBUTION_ID_PPCP
654667 );
655- $ payPalOrderId = $ result ->id ;
668+ if ($ result ) {
669+ $ payPalOrderId = $ result ->id ;
670+ }
656671 } catch (Exception $ exception ) {
657672 $ this ->setPaymentExecutionError (self ::PAYMENT_ERROR_PUI_GENERIC );
658673 $ this ->logger ->log ('error ' , 'Error on pui order creation call. ' , [$ exception ]);
0 commit comments