diff --git a/modules/ppcp-api-client/src/Endpoint/Orders.php b/modules/ppcp-api-client/src/Endpoint/Orders.php index b6cb562ad..e8386ec86 100644 --- a/modules/ppcp-api-client/src/Endpoint/Orders.php +++ b/modules/ppcp-api-client/src/Endpoint/Orders.php @@ -145,8 +145,15 @@ class Orders { $status_code = (int) wp_remote_retrieve_response_code( $response ); if ( $status_code !== 200 ) { + $body = json_decode( $response['body'] ); + + $message = $body->details[0]->description ?? ''; + if ( $message ) { + throw new RuntimeException( $message ); + } + throw new PayPalApiException( - json_decode( $response['body'] ), + $body, $status_code ); } diff --git a/modules/ppcp-local-alternative-payment-methods/src/BancontactGateway.php b/modules/ppcp-local-alternative-payment-methods/src/BancontactGateway.php index c37be41ec..8b89ba8fd 100644 --- a/modules/ppcp-local-alternative-payment-methods/src/BancontactGateway.php +++ b/modules/ppcp-local-alternative-payment-methods/src/BancontactGateway.php @@ -13,6 +13,7 @@ use WC_Payment_Gateway; use WooCommerce\PayPalCommerce\ApiClient\Endpoint\Orders; use WooCommerce\PayPalCommerce\ApiClient\Factory\PurchaseUnitFactory; use WooCommerce\PayPalCommerce\Button\Exception\RuntimeException; +use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway; use WooCommerce\PayPalCommerce\WcGateway\Gateway\TransactionUrlProvider; use WooCommerce\PayPalCommerce\WcGateway\Processor\RefundProcessor; @@ -177,6 +178,9 @@ class BancontactGateway extends WC_Payment_Gateway { $body = json_decode( $response['body'] ); + $wc_order->update_meta_data( PayPalGateway::ORDER_ID_META_KEY, $body->id ); + $wc_order->save_meta_data(); + $payer_action = ''; foreach ( $body->links as $link ) { if ( $link->rel === 'payer-action' ) { diff --git a/modules/ppcp-local-alternative-payment-methods/src/BlikGateway.php b/modules/ppcp-local-alternative-payment-methods/src/BlikGateway.php index ec49df338..c8cba7ca5 100644 --- a/modules/ppcp-local-alternative-payment-methods/src/BlikGateway.php +++ b/modules/ppcp-local-alternative-payment-methods/src/BlikGateway.php @@ -13,6 +13,7 @@ use WC_Payment_Gateway; use WooCommerce\PayPalCommerce\ApiClient\Endpoint\Orders; use WooCommerce\PayPalCommerce\ApiClient\Factory\PurchaseUnitFactory; use WooCommerce\PayPalCommerce\Button\Exception\RuntimeException; +use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway; use WooCommerce\PayPalCommerce\WcGateway\Gateway\TransactionUrlProvider; use WooCommerce\PayPalCommerce\WcGateway\Processor\RefundProcessor; @@ -178,6 +179,9 @@ class BlikGateway extends WC_Payment_Gateway { $body = json_decode( $response['body'] ); + $wc_order->update_meta_data( PayPalGateway::ORDER_ID_META_KEY, $body->id ); + $wc_order->save_meta_data(); + $payer_action = ''; foreach ( $body->links as $link ) { if ( $link->rel === 'payer-action' ) { diff --git a/modules/ppcp-local-alternative-payment-methods/src/EPSGateway.php b/modules/ppcp-local-alternative-payment-methods/src/EPSGateway.php index 4bc74985f..220e3bef7 100644 --- a/modules/ppcp-local-alternative-payment-methods/src/EPSGateway.php +++ b/modules/ppcp-local-alternative-payment-methods/src/EPSGateway.php @@ -13,6 +13,7 @@ use WC_Payment_Gateway; use WooCommerce\PayPalCommerce\ApiClient\Endpoint\Orders; use WooCommerce\PayPalCommerce\ApiClient\Factory\PurchaseUnitFactory; use WooCommerce\PayPalCommerce\Button\Exception\RuntimeException; +use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway; use WooCommerce\PayPalCommerce\WcGateway\Gateway\TransactionUrlProvider; use WooCommerce\PayPalCommerce\WcGateway\Processor\RefundProcessor; @@ -177,6 +178,9 @@ class EPSGateway extends WC_Payment_Gateway { $body = json_decode( $response['body'] ); + $wc_order->update_meta_data( PayPalGateway::ORDER_ID_META_KEY, $body->id ); + $wc_order->save_meta_data(); + $payer_action = ''; foreach ( $body->links as $link ) { if ( $link->rel === 'payer-action' ) { diff --git a/modules/ppcp-local-alternative-payment-methods/src/IDealGateway.php b/modules/ppcp-local-alternative-payment-methods/src/IDealGateway.php index 7c1d65436..d7d671e1a 100644 --- a/modules/ppcp-local-alternative-payment-methods/src/IDealGateway.php +++ b/modules/ppcp-local-alternative-payment-methods/src/IDealGateway.php @@ -13,6 +13,7 @@ use WC_Payment_Gateway; use WooCommerce\PayPalCommerce\ApiClient\Endpoint\Orders; use WooCommerce\PayPalCommerce\ApiClient\Factory\PurchaseUnitFactory; use WooCommerce\PayPalCommerce\Button\Exception\RuntimeException; +use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway; use WooCommerce\PayPalCommerce\WcGateway\Gateway\TransactionUrlProvider; use WooCommerce\PayPalCommerce\WcGateway\Processor\RefundProcessor; @@ -179,6 +180,9 @@ class IDealGateway extends WC_Payment_Gateway { $body = json_decode( $response['body'] ); + $wc_order->update_meta_data( PayPalGateway::ORDER_ID_META_KEY, $body->id ); + $wc_order->save_meta_data(); + $payer_action = ''; foreach ( $body->links as $link ) { if ( $link->rel === 'payer-action' ) { diff --git a/modules/ppcp-local-alternative-payment-methods/src/MultibancoGateway.php b/modules/ppcp-local-alternative-payment-methods/src/MultibancoGateway.php index 15941a2ef..a1c11dfe2 100644 --- a/modules/ppcp-local-alternative-payment-methods/src/MultibancoGateway.php +++ b/modules/ppcp-local-alternative-payment-methods/src/MultibancoGateway.php @@ -13,6 +13,7 @@ use WC_Payment_Gateway; use WooCommerce\PayPalCommerce\ApiClient\Endpoint\Orders; use WooCommerce\PayPalCommerce\ApiClient\Factory\PurchaseUnitFactory; use WooCommerce\PayPalCommerce\Button\Exception\RuntimeException; +use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway; use WooCommerce\PayPalCommerce\WcGateway\Gateway\TransactionUrlProvider; use WooCommerce\PayPalCommerce\WcGateway\Processor\RefundProcessor; @@ -180,6 +181,9 @@ class MultibancoGateway extends WC_Payment_Gateway { WC()->cart->empty_cart(); + $wc_order->update_meta_data( PayPalGateway::ORDER_ID_META_KEY, $body->id ); + $wc_order->save_meta_data(); + return array( 'result' => 'success', 'redirect' => esc_url( $payer_action ), diff --git a/modules/ppcp-local-alternative-payment-methods/src/MyBankGateway.php b/modules/ppcp-local-alternative-payment-methods/src/MyBankGateway.php index ec33430b8..d7296e5ce 100644 --- a/modules/ppcp-local-alternative-payment-methods/src/MyBankGateway.php +++ b/modules/ppcp-local-alternative-payment-methods/src/MyBankGateway.php @@ -13,6 +13,7 @@ use WC_Payment_Gateway; use WooCommerce\PayPalCommerce\ApiClient\Endpoint\Orders; use WooCommerce\PayPalCommerce\ApiClient\Factory\PurchaseUnitFactory; use WooCommerce\PayPalCommerce\Button\Exception\RuntimeException; +use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway; use WooCommerce\PayPalCommerce\WcGateway\Gateway\TransactionUrlProvider; use WooCommerce\PayPalCommerce\WcGateway\Processor\RefundProcessor; @@ -177,6 +178,9 @@ class MyBankGateway extends WC_Payment_Gateway { $body = json_decode( $response['body'] ); + $wc_order->update_meta_data( PayPalGateway::ORDER_ID_META_KEY, $body->id ); + $wc_order->save_meta_data(); + $payer_action = ''; foreach ( $body->links as $link ) { if ( $link->rel === 'payer-action' ) { diff --git a/modules/ppcp-local-alternative-payment-methods/src/P24Gateway.php b/modules/ppcp-local-alternative-payment-methods/src/P24Gateway.php index 97e23f7c0..0d79dd862 100644 --- a/modules/ppcp-local-alternative-payment-methods/src/P24Gateway.php +++ b/modules/ppcp-local-alternative-payment-methods/src/P24Gateway.php @@ -13,6 +13,7 @@ use WC_Payment_Gateway; use WooCommerce\PayPalCommerce\ApiClient\Endpoint\Orders; use WooCommerce\PayPalCommerce\ApiClient\Factory\PurchaseUnitFactory; use WooCommerce\PayPalCommerce\Button\Exception\RuntimeException; +use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway; use WooCommerce\PayPalCommerce\WcGateway\Gateway\TransactionUrlProvider; use WooCommerce\PayPalCommerce\WcGateway\Processor\RefundProcessor; @@ -178,6 +179,9 @@ class P24Gateway extends WC_Payment_Gateway { $body = json_decode( $response['body'] ); + $wc_order->update_meta_data( PayPalGateway::ORDER_ID_META_KEY, $body->id ); + $wc_order->save_meta_data(); + $payer_action = ''; foreach ( $body->links as $link ) { if ( $link->rel === 'payer-action' ) { diff --git a/modules/ppcp-local-alternative-payment-methods/src/TrustlyGateway.php b/modules/ppcp-local-alternative-payment-methods/src/TrustlyGateway.php index 7d34e02d7..96a018166 100644 --- a/modules/ppcp-local-alternative-payment-methods/src/TrustlyGateway.php +++ b/modules/ppcp-local-alternative-payment-methods/src/TrustlyGateway.php @@ -13,6 +13,7 @@ use WC_Payment_Gateway; use WooCommerce\PayPalCommerce\ApiClient\Endpoint\Orders; use WooCommerce\PayPalCommerce\ApiClient\Factory\PurchaseUnitFactory; use WooCommerce\PayPalCommerce\Button\Exception\RuntimeException; +use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway; use WooCommerce\PayPalCommerce\WcGateway\Gateway\TransactionUrlProvider; use WooCommerce\PayPalCommerce\WcGateway\Processor\RefundProcessor; @@ -177,6 +178,9 @@ class TrustlyGateway extends WC_Payment_Gateway { $body = json_decode( $response['body'] ); + $wc_order->update_meta_data( PayPalGateway::ORDER_ID_META_KEY, $body->id ); + $wc_order->save_meta_data(); + $payer_action = ''; foreach ( $body->links as $link ) { if ( $link->rel === 'payer-action' ) {