From b825e4be7642eacf1b924943246976b2af3064f9 Mon Sep 17 00:00:00 2001 From: Kirill Braslavsky Date: Mon, 15 Mar 2021 11:05:47 +0200 Subject: [PATCH 01/19] remove redundant ternary --- modules/ppcp-button/src/Endpoint/class-createorderendpoint.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ppcp-button/src/Endpoint/class-createorderendpoint.php b/modules/ppcp-button/src/Endpoint/class-createorderendpoint.php index 6068b2703..5941cf435 100644 --- a/modules/ppcp-button/src/Endpoint/class-createorderendpoint.php +++ b/modules/ppcp-button/src/Endpoint/class-createorderendpoint.php @@ -163,7 +163,7 @@ class CreateOrderEndpoint implements EndpointInterface { $this->set_bn_code( $data ); $needs_shipping = WC()->cart && WC()->cart->needs_shipping(); - $shipping_address_is_fix = $needs_shipping && 'checkout' === $data['context'] ? true : false; + $shipping_address_is_fix = $needs_shipping && 'checkout' === $data['context']; $order = $this->api_endpoint->create( $purchase_units, $this->payer( $data, $wc_order ), From 9bdd2631ddad3a020c46cfebe452621cff9219d4 Mon Sep 17 00:00:00 2001 From: Kirill Braslavsky Date: Mon, 15 Mar 2021 13:38:04 +0200 Subject: [PATCH 02/19] rename function --- .../ppcp-button/src/Endpoint/class-createorderendpoint.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/ppcp-button/src/Endpoint/class-createorderendpoint.php b/modules/ppcp-button/src/Endpoint/class-createorderendpoint.php index 5941cf435..53d5465dd 100644 --- a/modules/ppcp-button/src/Endpoint/class-createorderendpoint.php +++ b/modules/ppcp-button/src/Endpoint/class-createorderendpoint.php @@ -173,7 +173,7 @@ class CreateOrderEndpoint implements EndpointInterface { $shipping_address_is_fix ); if ( 'checkout' === $data['context'] ) { - $this->validate_checkout_form( $data['form'], $order ); + $this->process_checkout_form( $data['form'], $order ); } if ( 'pay-now' === $data['context'] && get_option( 'woocommerce_terms_page_id', '' ) !== '' ) { $this->validate_paynow_form( $data['form'] ); @@ -263,7 +263,7 @@ class CreateOrderEndpoint implements EndpointInterface { * * @throws \Exception On Error. */ - private function validate_checkout_form( string $form_values, Order $order ) { + private function process_checkout_form(string $form_values, Order $order ) { $this->order = $order; $form_values = explode( '&', $form_values ); From edb0c9551c73d21981b5804d61ac7bc30ab32fea Mon Sep 17 00:00:00 2001 From: Kirill Braslavsky Date: Mon, 15 Mar 2021 16:43:39 +0200 Subject: [PATCH 03/19] always return array from the process_payment() --- .../src/Gateway/class-processpaymenttrait.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/modules/ppcp-wc-gateway/src/Gateway/class-processpaymenttrait.php b/modules/ppcp-wc-gateway/src/Gateway/class-processpaymenttrait.php index 4c1260470..8d587a570 100644 --- a/modules/ppcp-wc-gateway/src/Gateway/class-processpaymenttrait.php +++ b/modules/ppcp-wc-gateway/src/Gateway/class-processpaymenttrait.php @@ -21,13 +21,19 @@ trait ProcessPaymentTrait { * * @param int $order_id The WooCommerce order id. * - * @return array|null + * @return array */ public function process_payment( $order_id ) { global $woocommerce; + + $failure_data = array( + 'result' => 'failure', + 'redirect' => wc_get_checkout_url(), + ); + $wc_order = wc_get_order( $order_id ); if ( ! is_a( $wc_order, \WC_Order::class ) ) { - return null; + return $failure_data; } /** @@ -63,7 +69,7 @@ trait ProcessPaymentTrait { __( 'Please use a different payment method.', 'woocommerce-paypal-payments' ), 'error' ); - return null; + return $failure_data; } return array( 'result' => 'success', @@ -75,7 +81,7 @@ trait ProcessPaymentTrait { } catch ( RuntimeException $error ) { $this->session_handler->destroy_session_data(); wc_add_notice( $error->getMessage(), 'error' ); - return null; + return $failure_data; } wc_add_notice( @@ -83,6 +89,6 @@ trait ProcessPaymentTrait { 'error' ); - return null; + return $failure_data; } } From 824e3a97c85602fd528e85c71a556548ee30c6ad Mon Sep 17 00:00:00 2001 From: Kirill Braslavsky Date: Mon, 15 Mar 2021 17:33:20 +0200 Subject: [PATCH 04/19] add wc notice --- .../src/Gateway/class-processpaymenttrait.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/ppcp-wc-gateway/src/Gateway/class-processpaymenttrait.php b/modules/ppcp-wc-gateway/src/Gateway/class-processpaymenttrait.php index 8d587a570..4bf9b1954 100644 --- a/modules/ppcp-wc-gateway/src/Gateway/class-processpaymenttrait.php +++ b/modules/ppcp-wc-gateway/src/Gateway/class-processpaymenttrait.php @@ -33,6 +33,11 @@ trait ProcessPaymentTrait { $wc_order = wc_get_order( $order_id ); if ( ! is_a( $wc_order, \WC_Order::class ) ) { + wc_add_notice( + __('Couldn\'t find order to process', 'woocommerce-paypal-payments' ), + 'error' + ); + return $failure_data; } From da23be6d4cf29fba4ca0c4c398fceada6dc6897d Mon Sep 17 00:00:00 2001 From: Kirill Braslavsky Date: Mon, 15 Mar 2021 17:57:55 +0200 Subject: [PATCH 05/19] remove redundant parameter --- .../src/Gateway/class-processpaymenttrait.php | 3 +-- .../ppcp-wc-gateway/src/Processor/class-orderprocessor.php | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/modules/ppcp-wc-gateway/src/Gateway/class-processpaymenttrait.php b/modules/ppcp-wc-gateway/src/Gateway/class-processpaymenttrait.php index 4bf9b1954..8bf5d4480 100644 --- a/modules/ppcp-wc-gateway/src/Gateway/class-processpaymenttrait.php +++ b/modules/ppcp-wc-gateway/src/Gateway/class-processpaymenttrait.php @@ -24,7 +24,6 @@ trait ProcessPaymentTrait { * @return array */ public function process_payment( $order_id ) { - global $woocommerce; $failure_data = array( 'result' => 'failure', @@ -55,7 +54,7 @@ trait ProcessPaymentTrait { //phpcs:enable WordPress.Security.NonceVerification.Recommended try { - if ( $this->order_processor->process( $wc_order, $woocommerce ) ) { + if ( $this->order_processor->process( $wc_order ) ) { $this->session_handler->destroy_session_data(); return array( 'result' => 'success', diff --git a/modules/ppcp-wc-gateway/src/Processor/class-orderprocessor.php b/modules/ppcp-wc-gateway/src/Processor/class-orderprocessor.php index 875951c24..4b9ea0577 100644 --- a/modules/ppcp-wc-gateway/src/Processor/class-orderprocessor.php +++ b/modules/ppcp-wc-gateway/src/Processor/class-orderprocessor.php @@ -146,11 +146,10 @@ class OrderProcessor { * Processes a given WooCommerce order and captured/authorizes the connected PayPal orders. * * @param \WC_Order $wc_order The WooCommerce order. - * @param \WooCommerce $woocommerce The WooCommerce object. * * @return bool */ - public function process( \WC_Order $wc_order, \WooCommerce $woocommerce ): bool { + public function process( \WC_Order $wc_order): bool { $order = $this->session_handler->order(); if ( ! $order ) { return false; @@ -212,7 +211,7 @@ class OrderProcessor { $wc_order->update_meta_data( PayPalGateway::CAPTURED_META_KEY, 'true' ); $wc_order->update_status( 'processing' ); } - $woocommerce->cart->empty_cart(); + wc()->cart->empty_cart(); $this->session_handler->destroy_session_data(); $this->last_error = ''; return true; From 76cdce20422a0b1c4b021847ced90d87ead7417a Mon Sep 17 00:00:00 2001 From: Kirill Braslavsky Date: Mon, 15 Mar 2021 19:04:09 +0200 Subject: [PATCH 06/19] remove not used class dependencies --- modules/ppcp-wc-gateway/services.php | 4 ---- .../src/Processor/class-orderprocessor.php | 22 ------------------- 2 files changed, 26 deletions(-) diff --git a/modules/ppcp-wc-gateway/services.php b/modules/ppcp-wc-gateway/services.php index effb4554c..680ba13a9 100644 --- a/modules/ppcp-wc-gateway/services.php +++ b/modules/ppcp-wc-gateway/services.php @@ -130,9 +130,7 @@ return array( 'wcgateway.order-processor' => static function ( $container ): OrderProcessor { $session_handler = $container->get( 'session.handler' ); - $cart_repository = $container->get( 'api.repository.cart' ); $order_endpoint = $container->get( 'api.endpoint.order' ); - $payments_endpoint = $container->get( 'api.endpoint.payments' ); $order_factory = $container->get( 'api.factory.order' ); $threed_secure = $container->get( 'button.helper.three-d-secure' ); $authorized_payments_processor = $container->get( 'wcgateway.processor.authorized-payments' ); @@ -142,9 +140,7 @@ return array( return new OrderProcessor( $session_handler, - $cart_repository, $order_endpoint, - $payments_endpoint, $order_factory, $threed_secure, $authorized_payments_processor, diff --git a/modules/ppcp-wc-gateway/src/Processor/class-orderprocessor.php b/modules/ppcp-wc-gateway/src/Processor/class-orderprocessor.php index 4b9ea0577..2c36588b6 100644 --- a/modules/ppcp-wc-gateway/src/Processor/class-orderprocessor.php +++ b/modules/ppcp-wc-gateway/src/Processor/class-orderprocessor.php @@ -11,11 +11,9 @@ namespace WooCommerce\PayPalCommerce\WcGateway\Processor; use Psr\Log\LoggerInterface; use WooCommerce\PayPalCommerce\ApiClient\Endpoint\OrderEndpoint; -use WooCommerce\PayPalCommerce\ApiClient\Endpoint\PaymentsEndpoint; use WooCommerce\PayPalCommerce\ApiClient\Entity\Order; use WooCommerce\PayPalCommerce\ApiClient\Entity\OrderStatus; use WooCommerce\PayPalCommerce\ApiClient\Factory\OrderFactory; -use WooCommerce\PayPalCommerce\ApiClient\Repository\CartRepository; use WooCommerce\PayPalCommerce\Button\Helper\ThreeDSecure; use WooCommerce\PayPalCommerce\Session\SessionHandler; use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway; @@ -40,13 +38,6 @@ class OrderProcessor { */ private $session_handler; - /** - * The Cart Repository. - * - * @var CartRepository - */ - private $cart_repository; - /** * The Order Endpoint. * @@ -54,13 +45,6 @@ class OrderProcessor { */ private $order_endpoint; - /** - * The Payments Endpoint. - * - * @var PaymentsEndpoint - */ - private $payments_endpoint; - /** * The Order Factory. * @@ -107,9 +91,7 @@ class OrderProcessor { * OrderProcessor constructor. * * @param SessionHandler $session_handler The Session Handler. - * @param CartRepository $cart_repository The Cart Repository. * @param OrderEndpoint $order_endpoint The Order Endpoint. - * @param PaymentsEndpoint $payments_endpoint The Payments Endpoint. * @param OrderFactory $order_factory The Order Factory. * @param ThreeDSecure $three_d_secure The ThreeDSecure Helper. * @param AuthorizedPaymentsProcessor $authorized_payments_processor The Authorized Payments Processor. @@ -119,9 +101,7 @@ class OrderProcessor { */ public function __construct( SessionHandler $session_handler, - CartRepository $cart_repository, OrderEndpoint $order_endpoint, - PaymentsEndpoint $payments_endpoint, OrderFactory $order_factory, ThreeDSecure $three_d_secure, AuthorizedPaymentsProcessor $authorized_payments_processor, @@ -131,9 +111,7 @@ class OrderProcessor { ) { $this->session_handler = $session_handler; - $this->cart_repository = $cart_repository; $this->order_endpoint = $order_endpoint; - $this->payments_endpoint = $payments_endpoint; $this->order_factory = $order_factory; $this->threed_secure = $three_d_secure; $this->authorized_payments_processor = $authorized_payments_processor; From 1076c58002134099f754f07957165ddcbd242466 Mon Sep 17 00:00:00 2001 From: Kirill Braslavsky Date: Mon, 15 Mar 2021 19:07:23 +0200 Subject: [PATCH 07/19] remove not used import --- modules/ppcp-api-client/src/Repository/class-cartrepository.php | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/ppcp-api-client/src/Repository/class-cartrepository.php b/modules/ppcp-api-client/src/Repository/class-cartrepository.php index 489124923..226f50d91 100644 --- a/modules/ppcp-api-client/src/Repository/class-cartrepository.php +++ b/modules/ppcp-api-client/src/Repository/class-cartrepository.php @@ -9,7 +9,6 @@ declare(strict_types=1); namespace WooCommerce\PayPalCommerce\ApiClient\Repository; -use WooCommerce\PayPalCommerce\ApiClient\Entity\Item; use WooCommerce\PayPalCommerce\ApiClient\Entity\PurchaseUnit; use WooCommerce\PayPalCommerce\ApiClient\Factory\PurchaseUnitFactory; From a83af94b88e8a82efa5d1c1a7efe87690f6f91e3 Mon Sep 17 00:00:00 2001 From: Kirill Braslavsky Date: Mon, 15 Mar 2021 19:49:10 +0200 Subject: [PATCH 08/19] avoid redundant exception throwing --- .../src/Endpoint/class-createorderendpoint.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/modules/ppcp-button/src/Endpoint/class-createorderendpoint.php b/modules/ppcp-button/src/Endpoint/class-createorderendpoint.php index 53d5465dd..9dd79512a 100644 --- a/modules/ppcp-button/src/Endpoint/class-createorderendpoint.php +++ b/modules/ppcp-button/src/Endpoint/class-createorderendpoint.php @@ -245,12 +245,16 @@ class CreateOrderEndpoint implements EndpointInterface { * Returns the PaymentMethod object for the order. * * @return PaymentMethod - * @throws \WooCommerce\PayPalCommerce\WcGateway\Exception\NotFoundException In case a setting would not be found. */ private function payment_method() : PaymentMethod { - $payee_preferred = $this->settings->has( 'payee_preferred' ) && $this->settings->get( 'payee_preferred' ) ? - PaymentMethod::PAYEE_PREFERRED_IMMEDIATE_PAYMENT_REQUIRED - : PaymentMethod::PAYEE_PREFERRED_UNRESTRICTED; + try { + $payee_preferred = $this->settings->has( 'payee_preferred' ) && $this->settings->get( 'payee_preferred' ) ? + PaymentMethod::PAYEE_PREFERRED_IMMEDIATE_PAYMENT_REQUIRED + : PaymentMethod::PAYEE_PREFERRED_UNRESTRICTED; + } catch (NotFoundException $exception){ + $payee_preferred = PaymentMethod::PAYEE_PREFERRED_UNRESTRICTED; + } + $payment_method = new PaymentMethod( $payee_preferred ); return $payment_method; } From c631b64ca91894c75dc10c945859dcde72891052 Mon Sep 17 00:00:00 2001 From: Kirill Braslavsky Date: Mon, 15 Mar 2021 19:53:35 +0200 Subject: [PATCH 09/19] move creating PayPal order into separate function --- .../Endpoint/class-createorderendpoint.php | 39 ++++++++++++++----- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/modules/ppcp-button/src/Endpoint/class-createorderendpoint.php b/modules/ppcp-button/src/Endpoint/class-createorderendpoint.php index 9dd79512a..10cf98ba3 100644 --- a/modules/ppcp-button/src/Endpoint/class-createorderendpoint.php +++ b/modules/ppcp-button/src/Endpoint/class-createorderendpoint.php @@ -13,12 +13,15 @@ use WooCommerce\PayPalCommerce\ApiClient\Endpoint\OrderEndpoint; use WooCommerce\PayPalCommerce\ApiClient\Entity\Order; use WooCommerce\PayPalCommerce\ApiClient\Entity\Payer; use WooCommerce\PayPalCommerce\ApiClient\Entity\PaymentMethod; +use WooCommerce\PayPalCommerce\ApiClient\Entity\PurchaseUnit; use WooCommerce\PayPalCommerce\ApiClient\Exception\PayPalApiException; +use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException; use WooCommerce\PayPalCommerce\ApiClient\Factory\PayerFactory; use WooCommerce\PayPalCommerce\ApiClient\Factory\PurchaseUnitFactory; use WooCommerce\PayPalCommerce\ApiClient\Repository\CartRepository; use WooCommerce\PayPalCommerce\Button\Helper\EarlyOrderHandler; use WooCommerce\PayPalCommerce\Session\SessionHandler; +use WooCommerce\PayPalCommerce\WcGateway\Exception\NotFoundException; use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings; /** @@ -162,16 +165,9 @@ class CreateOrderEndpoint implements EndpointInterface { } $this->set_bn_code( $data ); - $needs_shipping = WC()->cart && WC()->cart->needs_shipping(); - $shipping_address_is_fix = $needs_shipping && 'checkout' === $data['context']; - $order = $this->api_endpoint->create( - $purchase_units, - $this->payer( $data, $wc_order ), - null, - $this->payment_method(), - '', - $shipping_address_is_fix - ); + + $order = $this->create_paypal_order($data, $purchase_units, $wc_order); + if ( 'checkout' === $data['context'] ) { $this->process_checkout_form( $data['form'], $order ); } @@ -193,6 +189,29 @@ class CreateOrderEndpoint implements EndpointInterface { } } + /** + * @param array $request_data Parsed data of the checkout or pay now form. + * @param PurchaseUnit[] $purchase_units The list of order items. + * @param \WC_Order $wc_order The respective WC order to get data from. + * + * @return Order Created PayPal order. + * + * @throws RuntimeException If create order request fails. + */ + private function create_paypal_order(array $request_data, array $purchase_units, \WC_Order $wc_order): Order { + $needs_shipping = WC()->cart && WC()->cart->needs_shipping(); + $shipping_address_is_fix = $needs_shipping && 'checkout' === $request_data['context']; + + return $this->api_endpoint->create( + $purchase_units, + $this->payer( $request_data, $wc_order ), + null, + $this->payment_method(), + '', + $shipping_address_is_fix + ); + } + /** * Returns the Payer entity based on the request data. * From 8f008940800d0c500a39ecf178a75a8696dde478 Mon Sep 17 00:00:00 2001 From: Kirill Braslavsky Date: Tue, 16 Mar 2021 12:02:02 +0200 Subject: [PATCH 10/19] don't throw exceptions from handle_request() --- .../ppcp-button/src/Endpoint/class-createorderendpoint.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/ppcp-button/src/Endpoint/class-createorderendpoint.php b/modules/ppcp-button/src/Endpoint/class-createorderendpoint.php index 10cf98ba3..e9c68b1e7 100644 --- a/modules/ppcp-button/src/Endpoint/class-createorderendpoint.php +++ b/modules/ppcp-button/src/Endpoint/class-createorderendpoint.php @@ -141,7 +141,6 @@ class CreateOrderEndpoint implements EndpointInterface { * Handles the request. * * @return bool - * @throws \WooCommerce\PayPalCommerce\WcGateway\Exception\NotFoundException In case a setting was not found. */ public function handle_request(): bool { try { @@ -185,8 +184,11 @@ class CreateOrderEndpoint implements EndpointInterface { 'details' => is_a( $error, PayPalApiException::class ) ? $error->details() : array(), ) ); - return false; + } catch (\Exception $exception){ + wc_add_notice($exception->getMessage(), 'error'); } + + return false; } /** From 91adee26e4df1112d8c5edcc22addd0ffc25cbb8 Mon Sep 17 00:00:00 2001 From: Kirill Braslavsky Date: Tue, 16 Mar 2021 15:32:52 +0200 Subject: [PATCH 11/19] store data to create PP order in class properties --- .../Endpoint/class-createorderendpoint.php | 33 +++++++++++++------ 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/modules/ppcp-button/src/Endpoint/class-createorderendpoint.php b/modules/ppcp-button/src/Endpoint/class-createorderendpoint.php index e9c68b1e7..0fc55e0e1 100644 --- a/modules/ppcp-button/src/Endpoint/class-createorderendpoint.php +++ b/modules/ppcp-button/src/Endpoint/class-createorderendpoint.php @@ -95,6 +95,20 @@ class CreateOrderEndpoint implements EndpointInterface { */ private $order; + /** + * Data from the request. + * + * @var array + */ + private $parsed_request_data; + + /** + * The array of purchase units for order. + * + * @var PurchaseUnit[] + */ + private $purchase_units; + /** * CreateOrderEndpoint constructor. * @@ -145,6 +159,7 @@ class CreateOrderEndpoint implements EndpointInterface { public function handle_request(): bool { try { $data = $this->request_data->read_request( $this->nonce() ); + $this->parsed_request_data = $data; $wc_order = null; if ( 'pay-now' === $data['context'] ) { $wc_order = wc_get_order( (int) $data['order_id'] ); @@ -158,14 +173,14 @@ class CreateOrderEndpoint implements EndpointInterface { ) ); } - $purchase_units = array( $this->purchase_unit_factory->from_wc_order( $wc_order ) ); + $this->purchase_units = array( $this->purchase_unit_factory->from_wc_order( $wc_order ) ); } else { - $purchase_units = $this->cart_repository->all(); + $this->purchase_units = $this->cart_repository->all(); } $this->set_bn_code( $data ); - $order = $this->create_paypal_order($data, $purchase_units, $wc_order); + $order = $this->create_paypal_order($wc_order); if ( 'checkout' === $data['context'] ) { $this->process_checkout_form( $data['form'], $order ); @@ -192,21 +207,19 @@ class CreateOrderEndpoint implements EndpointInterface { } /** - * @param array $request_data Parsed data of the checkout or pay now form. - * @param PurchaseUnit[] $purchase_units The list of order items. - * @param \WC_Order $wc_order The respective WC order to get data from. + * @param \WC_Order|null $wc_order WC order to get data from. * * @return Order Created PayPal order. * * @throws RuntimeException If create order request fails. */ - private function create_paypal_order(array $request_data, array $purchase_units, \WC_Order $wc_order): Order { + private function create_paypal_order(\WC_Order $wc_order = null): Order { $needs_shipping = WC()->cart && WC()->cart->needs_shipping(); - $shipping_address_is_fix = $needs_shipping && 'checkout' === $request_data['context']; + $shipping_address_is_fix = $needs_shipping && 'checkout' === $this->parsed_request_data['context']; return $this->api_endpoint->create( - $purchase_units, - $this->payer( $request_data, $wc_order ), + $this->purchase_units, + $this->payer( $this->parsed_request_data, $wc_order ), null, $this->payment_method(), '', From e0d59ce2a023b044eb13698893baad04c343bc92 Mon Sep 17 00:00:00 2001 From: Kirill Braslavsky Date: Tue, 16 Mar 2021 15:45:36 +0200 Subject: [PATCH 12/19] don't store PP order in class properties --- .../src/Endpoint/class-createorderendpoint.php | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/modules/ppcp-button/src/Endpoint/class-createorderendpoint.php b/modules/ppcp-button/src/Endpoint/class-createorderendpoint.php index 0fc55e0e1..fd6bf7fdf 100644 --- a/modules/ppcp-button/src/Endpoint/class-createorderendpoint.php +++ b/modules/ppcp-button/src/Endpoint/class-createorderendpoint.php @@ -88,13 +88,6 @@ class CreateOrderEndpoint implements EndpointInterface { */ private $early_order_handler; - /** - * The current PayPal order in a process. - * - * @var Order|null - */ - private $order; - /** * Data from the request. * @@ -183,7 +176,7 @@ class CreateOrderEndpoint implements EndpointInterface { $order = $this->create_paypal_order($wc_order); if ( 'checkout' === $data['context'] ) { - $this->process_checkout_form( $data['form'], $order ); + $this->process_checkout_form( $data['form'] ); } if ( 'pay-now' === $data['context'] && get_option( 'woocommerce_terms_page_id', '' ) !== '' ) { $this->validate_paynow_form( $data['form'] ); @@ -297,12 +290,10 @@ class CreateOrderEndpoint implements EndpointInterface { * Prepare the Request parameter and process the checkout form and validate it. * * @param string $form_values The values of the form. - * @param Order $order The Order. * * @throws \Exception On Error. */ - private function process_checkout_form(string $form_values, Order $order ) { - $this->order = $order; + private function process_checkout_form(string $form_values ) { $form_values = explode( '&', $form_values ); $parsed_values = array(); @@ -354,8 +345,6 @@ class CreateOrderEndpoint implements EndpointInterface { * @return array */ public function after_checkout_validation( array $data, \WP_Error $errors ): array { - - $order = $this->order; if ( ! $errors->errors ) { /** From 9d4ce86c37ad7335c29a7aa906e2ca649af4f0e9 Mon Sep 17 00:00:00 2001 From: Kirill Braslavsky Date: Tue, 16 Mar 2021 15:46:08 +0200 Subject: [PATCH 13/19] create PP order after checkout validation --- modules/ppcp-button/src/Endpoint/class-createorderendpoint.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/ppcp-button/src/Endpoint/class-createorderendpoint.php b/modules/ppcp-button/src/Endpoint/class-createorderendpoint.php index fd6bf7fdf..0998a5d65 100644 --- a/modules/ppcp-button/src/Endpoint/class-createorderendpoint.php +++ b/modules/ppcp-button/src/Endpoint/class-createorderendpoint.php @@ -347,6 +347,8 @@ class CreateOrderEndpoint implements EndpointInterface { public function after_checkout_validation( array $data, \WP_Error $errors ): array { if ( ! $errors->errors ) { + $order = $this->create_paypal_order(); + /** * In case we are onboarded and everything is fine with the \WC_Order * we want this order to be created. We will intercept it and leave it From 6c3e627752d472287a0f07f469b979e299d36b8a Mon Sep 17 00:00:00 2001 From: Kirill Braslavsky Date: Tue, 16 Mar 2021 16:08:42 +0200 Subject: [PATCH 14/19] create PayPal order after checkout validation --- .../src/Endpoint/class-createorderendpoint.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/ppcp-button/src/Endpoint/class-createorderendpoint.php b/modules/ppcp-button/src/Endpoint/class-createorderendpoint.php index 0998a5d65..d522be69c 100644 --- a/modules/ppcp-button/src/Endpoint/class-createorderendpoint.php +++ b/modules/ppcp-button/src/Endpoint/class-createorderendpoint.php @@ -173,14 +173,16 @@ class CreateOrderEndpoint implements EndpointInterface { $this->set_bn_code( $data ); - $order = $this->create_paypal_order($wc_order); - if ( 'checkout' === $data['context'] ) { $this->process_checkout_form( $data['form'] ); } if ( 'pay-now' === $data['context'] && get_option( 'woocommerce_terms_page_id', '' ) !== '' ) { $this->validate_paynow_form( $data['form'] ); } + + //if we are here so the context is not 'checkout' as it exits before. Therefore, a PayPal order is not created yet. + //It would be a good idea to refactor the checkout process in the future. + $order = $this->create_paypal_order($wc_order); wp_send_json_success( $order->to_array() ); return true; } catch ( \RuntimeException $error ) { @@ -224,7 +226,7 @@ class CreateOrderEndpoint implements EndpointInterface { * Returns the Payer entity based on the request data. * * @param array $data The request data. - * @param \WC_Order $wc_order The order. + * @param \WC_Order|null $wc_order The order. * * @return Payer|null */ From f599d3b0b7b2ca0dea82759baf93e172658bf415 Mon Sep 17 00:00:00 2001 From: Kirill Braslavsky Date: Wed, 17 Mar 2021 09:47:12 +0200 Subject: [PATCH 15/19] fix function name --- modules/ppcp-wc-gateway/src/Processor/class-orderprocessor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ppcp-wc-gateway/src/Processor/class-orderprocessor.php b/modules/ppcp-wc-gateway/src/Processor/class-orderprocessor.php index 2c36588b6..7c9e91649 100644 --- a/modules/ppcp-wc-gateway/src/Processor/class-orderprocessor.php +++ b/modules/ppcp-wc-gateway/src/Processor/class-orderprocessor.php @@ -189,7 +189,7 @@ class OrderProcessor { $wc_order->update_meta_data( PayPalGateway::CAPTURED_META_KEY, 'true' ); $wc_order->update_status( 'processing' ); } - wc()->cart->empty_cart(); + WC()->cart->empty_cart(); $this->session_handler->destroy_session_data(); $this->last_error = ''; return true; From a50a0cd5cb7b6912e5d3fa03f876215c3c0c3590 Mon Sep 17 00:00:00 2001 From: Kirill Braslavsky Date: Wed, 17 Mar 2021 10:30:02 +0200 Subject: [PATCH 16/19] update tests --- .../WcGateway/Gateway/WcGatewayTest.php | 48 ++++++++++++++----- .../Processor/OrderProcessorTest.php | 48 ++++++++++--------- .../ApplicationContextRepositoryTest.php | 5 +- .../Repository/CartRepositoryTest.php | 2 +- 4 files changed, 63 insertions(+), 40 deletions(-) diff --git a/tests/PHPUnit/WcGateway/Gateway/WcGatewayTest.php b/tests/PHPUnit/WcGateway/Gateway/WcGatewayTest.php index df70e8071..d0418d41e 100644 --- a/tests/PHPUnit/WcGateway/Gateway/WcGatewayTest.php +++ b/tests/PHPUnit/WcGateway/Gateway/WcGatewayTest.php @@ -12,10 +12,10 @@ use WooCommerce\PayPalCommerce\WcGateway\Processor\AuthorizedPaymentsProcessor; use WooCommerce\PayPalCommerce\WcGateway\Processor\OrderProcessor; use WooCommerce\PayPalCommerce\WcGateway\Processor\RefundProcessor; use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings; -use WooCommerce\PayPalCommerce\WcGateway\Settings\SettingsFields; use WooCommerce\PayPalCommerce\WcGateway\Settings\SettingsRenderer; use Mockery; use function Brain\Monkey\Functions\expect; +use function Brain\Monkey\Functions\when; class WcGatewayTest extends TestCase { @@ -31,7 +31,7 @@ class WcGatewayTest extends TestCase $orderProcessor ->expects('process') ->andReturnUsing( - function(\WC_Order $order, $woocommerce) use ($wcOrder) : bool { + function(\WC_Order $order) use ($wcOrder) : bool { return $order === $wcOrder; } ); @@ -64,11 +64,14 @@ class WcGatewayTest extends TestCase ->with($orderId) ->andReturn($wcOrder); - global $woocommerce; - $woocommerce = Mockery::mock(\WooCommerce::class); + + when('wc_get_checkout_url') + ->justReturn('test'); + $result = $testee->process_payment($orderId); - unset($woocommerce); + $this->assertIsArray($result); + $this->assertEquals('success', $result['result']); $this->assertEquals($result['redirect'], $wcOrder); } @@ -106,10 +109,21 @@ class WcGatewayTest extends TestCase ->with($orderId) ->andReturn(false); - global $woocommerce; - $woocommerce = Mockery::mock(\WooCommerce::class); - $this->assertNull($testee->process_payment($orderId)); - unset($woocommerce); + $redirectUrl = 'http://example.com/checkout'; + + when('wc_get_checkout_url') + ->justReturn($redirectUrl); + + expect('wc_add_notice') + ->with('Couldn\'t find order to process','error'); + + $this->assertEquals( + [ + 'result' => 'failure', + 'redirect' => $redirectUrl + ], + $testee->process_payment($orderId) + ); } @@ -156,11 +170,19 @@ class WcGatewayTest extends TestCase expect('wc_add_notice') ->with($lastError, 'error'); - global $woocommerce; - $woocommerce = Mockery::mock(\WooCommerce::class); + $redirectUrl = 'http://example.com/checkout'; + + when('wc_get_checkout_url') + ->justReturn($redirectUrl); + $result = $testee->process_payment($orderId); - unset($woocommerce); - $this->assertNull($result); + $this->assertEquals( + [ + 'result' => 'failure', + 'redirect' => $redirectUrl + ], + $result + ); } public function testCaptureAuthorizedPayment() { diff --git a/tests/PHPUnit/WcGateway/Processor/OrderProcessorTest.php b/tests/PHPUnit/WcGateway/Processor/OrderProcessorTest.php index 125e87b47..03121934a 100644 --- a/tests/PHPUnit/WcGateway/Processor/OrderProcessorTest.php +++ b/tests/PHPUnit/WcGateway/Processor/OrderProcessorTest.php @@ -6,20 +6,19 @@ namespace WooCommerce\PayPalCommerce\WcGateway\Processor; use Psr\Log\LoggerInterface; use WooCommerce\PayPalCommerce\ApiClient\Endpoint\OrderEndpoint; -use WooCommerce\PayPalCommerce\ApiClient\Endpoint\PaymentsEndpoint; use Woocommerce\PayPalCommerce\ApiClient\Entity\Capture; use WooCommerce\PayPalCommerce\ApiClient\Entity\Order; use WooCommerce\PayPalCommerce\ApiClient\Entity\OrderStatus; use WooCommerce\PayPalCommerce\ApiClient\Entity\Payments; use WooCommerce\PayPalCommerce\ApiClient\Entity\PurchaseUnit; use WooCommerce\PayPalCommerce\ApiClient\Factory\OrderFactory; -use WooCommerce\PayPalCommerce\ApiClient\Repository\CartRepository; use WooCommerce\PayPalCommerce\Button\Helper\ThreeDSecure; use WooCommerce\PayPalCommerce\Session\SessionHandler; use WooCommerce\PayPalCommerce\TestCase; use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway; use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings; use Mockery; +use function Brain\Monkey\Functions\when; class OrderProcessorTest extends TestCase { @@ -78,8 +77,6 @@ class OrderProcessorTest extends TestCase $sessionHandler ->expects('destroy_session_data'); - $cartRepository = Mockery::mock(CartRepository::class); - $orderEndpoint = Mockery::mock(OrderEndpoint::class); $orderEndpoint ->expects('patch_order_with') @@ -90,8 +87,6 @@ class OrderProcessorTest extends TestCase ->with($currentOrder) ->andReturn($currentOrder); - $paymentsEndpoint = Mockery::mock(PaymentsEndpoint::class); - $orderFactory = Mockery::mock(OrderFactory::class); $orderFactory ->expects('from_wc_order') @@ -111,9 +106,7 @@ class OrderProcessorTest extends TestCase $testee = new OrderProcessor( $sessionHandler, - $cartRepository, $orderEndpoint, - $paymentsEndpoint, $orderFactory, $threeDSecure, $authorizedPaymentProcessor, @@ -126,6 +119,9 @@ class OrderProcessorTest extends TestCase $cart ->expects('empty_cart'); $woocommerce = Mockery::mock(\WooCommerce::class); + when('WC') + ->justReturn($woocommerce); + $woocommerce->cart = $cart; $wcOrder @@ -149,7 +145,9 @@ class OrderProcessorTest extends TestCase $wcOrder ->expects('update_status') ->with('on-hold', 'Awaiting payment.'); - $this->assertTrue($testee->process($wcOrder, $woocommerce)); + + + $this->assertTrue($testee->process($wcOrder)); } public function testCapture() { @@ -198,7 +196,6 @@ class OrderProcessorTest extends TestCase ->andReturn($currentOrder); $sessionHandler ->expects('destroy_session_data'); - $cartRepository = Mockery::mock(CartRepository::class); $orderEndpoint = Mockery::mock(OrderEndpoint::class); $orderEndpoint ->expects('patch_order_with') @@ -208,7 +205,6 @@ class OrderProcessorTest extends TestCase ->expects('capture') ->with($currentOrder) ->andReturn($currentOrder); - $paymentsEndpoint = Mockery::mock(PaymentsEndpoint::class); $orderFactory = Mockery::mock(OrderFactory::class); $orderFactory ->expects('from_wc_order') @@ -221,14 +217,24 @@ class OrderProcessorTest extends TestCase ->shouldReceive('has') ->andReturnFalse(); + $cart = Mockery::mock(\WC_Cart::class); + $cart + ->shouldReceive('empty_cart'); + + $woocommerce = Mockery::Mock(\Woocommerce::class); + $woocommerce + ->shouldReceive('__get') + ->with('cart') + ->set('cart', $cart); + when('WC') + ->justReturn($woocommerce); + $logger = Mockery::mock(LoggerInterface::class); $testee = new OrderProcessor( $sessionHandler, - $cartRepository, $orderEndpoint, - $paymentsEndpoint, $orderFactory, $threeDSecure, $authorizedPaymentProcessor, @@ -243,6 +249,9 @@ class OrderProcessorTest extends TestCase $woocommerce = Mockery::mock(\WooCommerce::class); $woocommerce->cart = $cart; + when('WC') + ->justReturn($woocommerce); + $wcOrder ->expects('update_meta_data') ->with( @@ -265,7 +274,7 @@ class OrderProcessorTest extends TestCase $wcOrder ->expects('update_status') ->with('processing', 'Payment received.'); - $this->assertTrue($testee->process($wcOrder, $woocommerce)); + $this->assertTrue($testee->process($wcOrder)); } public function testError() { @@ -316,9 +325,7 @@ class OrderProcessorTest extends TestCase $sessionHandler ->expects('order') ->andReturn($currentOrder); - $cartRepository = Mockery::mock(CartRepository::class); $orderEndpoint = Mockery::mock(OrderEndpoint::class); - $paymentsEndpoint = Mockery::mock(PaymentsEndpoint::class); $orderFactory = Mockery::mock(OrderFactory::class); $threeDSecure = Mockery::mock(ThreeDSecure::class); $authorizedPaymentProcessor = Mockery::mock(AuthorizedPaymentsProcessor::class); @@ -328,9 +335,7 @@ class OrderProcessorTest extends TestCase $testee = new OrderProcessor( $sessionHandler, - $cartRepository, $orderEndpoint, - $paymentsEndpoint, $orderFactory, $threeDSecure, $authorizedPaymentProcessor, @@ -339,10 +344,6 @@ class OrderProcessorTest extends TestCase false ); - $cart = Mockery::mock(\WC_Cart::class); - $woocommerce = Mockery::mock(\WooCommerce::class); - $woocommerce->cart = $cart; - $wcOrder ->expects('update_meta_data') ->with( @@ -355,7 +356,8 @@ class OrderProcessorTest extends TestCase PayPalGateway::INTENT_META_KEY, $orderIntent ); - $this->assertFalse($testee->process($wcOrder, $woocommerce)); + + $this->assertFalse($testee->process($wcOrder)); $this->assertNotEmpty($testee->last_error()); } diff --git a/tests/PHPUnit/WcGateway/Repository/ApplicationContextRepositoryTest.php b/tests/PHPUnit/WcGateway/Repository/ApplicationContextRepositoryTest.php index 8c346d13e..7b8d1800e 100644 --- a/tests/PHPUnit/WcGateway/Repository/ApplicationContextRepositoryTest.php +++ b/tests/PHPUnit/WcGateway/Repository/ApplicationContextRepositoryTest.php @@ -2,10 +2,11 @@ declare(strict_types=1); -namespace WooCommerce\PayPalCommerce\ApiClient\Repository; +namespace WooCommerce\PayPalCommerce\WcGateway\Repository; use Hamcrest\Matchers; use WooCommerce\PayPalCommerce\ApiClient\Entity\ApplicationContext; +use WooCommerce\PayPalCommerce\ApiClient\Repository\ApplicationContextRepository; use WooCommerce\PayPalCommerce\TestCase; use Mockery\MockInterface; use Psr\Container\ContainerInterface; @@ -25,8 +26,6 @@ class ApplicationContextRepositoryTest extends TestCase array $expected ): void { - $brandName = 'Acme Corp.'; - // Config foreach ($container as $key => $value) { $this->buildTestee()[0]->shouldReceive('has') diff --git a/tests/PHPUnit/WcGateway/Repository/CartRepositoryTest.php b/tests/PHPUnit/WcGateway/Repository/CartRepositoryTest.php index 4a359b466..db8cc6322 100644 --- a/tests/PHPUnit/WcGateway/Repository/CartRepositoryTest.php +++ b/tests/PHPUnit/WcGateway/Repository/CartRepositoryTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace WooCommerce\PayPalCommerce\ApiClient\Repository; +namespace WooCommerce\PayPalCommerce\WcGateway\Repository; use Mockery\Adapter\Phpunit\MockeryTestCase; From d04cd56cd95566b706e3833ba3451b2f86034e42 Mon Sep 17 00:00:00 2001 From: Kirill Braslavsky Date: Wed, 17 Mar 2021 13:59:18 +0200 Subject: [PATCH 17/19] auto fix phpcs errors --- .../Endpoint/class-createorderendpoint.php | 26 +++++++++---------- .../src/Gateway/class-processpaymenttrait.php | 2 +- .../src/Processor/class-orderprocessor.php | 4 +-- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/modules/ppcp-button/src/Endpoint/class-createorderendpoint.php b/modules/ppcp-button/src/Endpoint/class-createorderendpoint.php index d522be69c..f9723846f 100644 --- a/modules/ppcp-button/src/Endpoint/class-createorderendpoint.php +++ b/modules/ppcp-button/src/Endpoint/class-createorderendpoint.php @@ -151,9 +151,9 @@ class CreateOrderEndpoint implements EndpointInterface { */ public function handle_request(): bool { try { - $data = $this->request_data->read_request( $this->nonce() ); + $data = $this->request_data->read_request( $this->nonce() ); $this->parsed_request_data = $data; - $wc_order = null; + $wc_order = null; if ( 'pay-now' === $data['context'] ) { $wc_order = wc_get_order( (int) $data['order_id'] ); if ( ! is_a( $wc_order, \WC_Order::class ) ) { @@ -180,9 +180,9 @@ class CreateOrderEndpoint implements EndpointInterface { $this->validate_paynow_form( $data['form'] ); } - //if we are here so the context is not 'checkout' as it exits before. Therefore, a PayPal order is not created yet. - //It would be a good idea to refactor the checkout process in the future. - $order = $this->create_paypal_order($wc_order); + // if we are here so the context is not 'checkout' as it exits before. Therefore, a PayPal order is not created yet. + // It would be a good idea to refactor the checkout process in the future. + $order = $this->create_paypal_order( $wc_order ); wp_send_json_success( $order->to_array() ); return true; } catch ( \RuntimeException $error ) { @@ -194,8 +194,8 @@ class CreateOrderEndpoint implements EndpointInterface { 'details' => is_a( $error, PayPalApiException::class ) ? $error->details() : array(), ) ); - } catch (\Exception $exception){ - wc_add_notice($exception->getMessage(), 'error'); + } catch ( \Exception $exception ) { + wc_add_notice( $exception->getMessage(), 'error' ); } return false; @@ -208,7 +208,7 @@ class CreateOrderEndpoint implements EndpointInterface { * * @throws RuntimeException If create order request fails. */ - private function create_paypal_order(\WC_Order $wc_order = null): Order { + private function create_paypal_order( \WC_Order $wc_order = null ): Order { $needs_shipping = WC()->cart && WC()->cart->needs_shipping(); $shipping_address_is_fix = $needs_shipping && 'checkout' === $this->parsed_request_data['context']; @@ -225,7 +225,7 @@ class CreateOrderEndpoint implements EndpointInterface { /** * Returns the Payer entity based on the request data. * - * @param array $data The request data. + * @param array $data The request data. * @param \WC_Order|null $wc_order The order. * * @return Payer|null @@ -280,11 +280,11 @@ class CreateOrderEndpoint implements EndpointInterface { $payee_preferred = $this->settings->has( 'payee_preferred' ) && $this->settings->get( 'payee_preferred' ) ? PaymentMethod::PAYEE_PREFERRED_IMMEDIATE_PAYMENT_REQUIRED : PaymentMethod::PAYEE_PREFERRED_UNRESTRICTED; - } catch (NotFoundException $exception){ + } catch ( NotFoundException $exception ) { $payee_preferred = PaymentMethod::PAYEE_PREFERRED_UNRESTRICTED; } - - $payment_method = new PaymentMethod( $payee_preferred ); + + $payment_method = new PaymentMethod( $payee_preferred ); return $payment_method; } @@ -295,7 +295,7 @@ class CreateOrderEndpoint implements EndpointInterface { * * @throws \Exception On Error. */ - private function process_checkout_form(string $form_values ) { + private function process_checkout_form( string $form_values ) { $form_values = explode( '&', $form_values ); $parsed_values = array(); diff --git a/modules/ppcp-wc-gateway/src/Gateway/class-processpaymenttrait.php b/modules/ppcp-wc-gateway/src/Gateway/class-processpaymenttrait.php index 8bf5d4480..fdc31674e 100644 --- a/modules/ppcp-wc-gateway/src/Gateway/class-processpaymenttrait.php +++ b/modules/ppcp-wc-gateway/src/Gateway/class-processpaymenttrait.php @@ -33,7 +33,7 @@ trait ProcessPaymentTrait { $wc_order = wc_get_order( $order_id ); if ( ! is_a( $wc_order, \WC_Order::class ) ) { wc_add_notice( - __('Couldn\'t find order to process', 'woocommerce-paypal-payments' ), + __( 'Couldn\'t find order to process', 'woocommerce-paypal-payments' ), 'error' ); diff --git a/modules/ppcp-wc-gateway/src/Processor/class-orderprocessor.php b/modules/ppcp-wc-gateway/src/Processor/class-orderprocessor.php index 7c9e91649..bdbbe533f 100644 --- a/modules/ppcp-wc-gateway/src/Processor/class-orderprocessor.php +++ b/modules/ppcp-wc-gateway/src/Processor/class-orderprocessor.php @@ -123,11 +123,11 @@ class OrderProcessor { /** * Processes a given WooCommerce order and captured/authorizes the connected PayPal orders. * - * @param \WC_Order $wc_order The WooCommerce order. + * @param \WC_Order $wc_order The WooCommerce order. * * @return bool */ - public function process( \WC_Order $wc_order): bool { + public function process( \WC_Order $wc_order ): bool { $order = $this->session_handler->order(); if ( ! $order ) { return false; From 267c2c071e409fbc9fbea5fa852d0311acd94782 Mon Sep 17 00:00:00 2001 From: Kirill Braslavsky Date: Wed, 17 Mar 2021 14:01:13 +0200 Subject: [PATCH 18/19] add missed comment --- modules/ppcp-button/src/Endpoint/class-createorderendpoint.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/ppcp-button/src/Endpoint/class-createorderendpoint.php b/modules/ppcp-button/src/Endpoint/class-createorderendpoint.php index f9723846f..d3825c5e9 100644 --- a/modules/ppcp-button/src/Endpoint/class-createorderendpoint.php +++ b/modules/ppcp-button/src/Endpoint/class-createorderendpoint.php @@ -202,6 +202,8 @@ class CreateOrderEndpoint implements EndpointInterface { } /** + * Creates the order in the PayPal, uses data from WC order if provided. + * * @param \WC_Order|null $wc_order WC order to get data from. * * @return Order Created PayPal order. From 468008db9dd7d8b9c8228f727a55a803c9e7fb4b Mon Sep 17 00:00:00 2001 From: Kirill Braslavsky Date: Wed, 17 Mar 2021 14:02:00 +0200 Subject: [PATCH 19/19] remove extra whitespace --- modules/ppcp-button/src/Endpoint/class-createorderendpoint.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ppcp-button/src/Endpoint/class-createorderendpoint.php b/modules/ppcp-button/src/Endpoint/class-createorderendpoint.php index d3825c5e9..79e9a4185 100644 --- a/modules/ppcp-button/src/Endpoint/class-createorderendpoint.php +++ b/modules/ppcp-button/src/Endpoint/class-createorderendpoint.php @@ -203,7 +203,7 @@ class CreateOrderEndpoint implements EndpointInterface { /** * Creates the order in the PayPal, uses data from WC order if provided. - * + * * @param \WC_Order|null $wc_order WC order to get data from. * * @return Order Created PayPal order.