From c9bf899b75cdd14ecdcc26ea6a10c00d82d345ab Mon Sep 17 00:00:00 2001 From: Alex P Date: Wed, 28 Jun 2023 16:34:14 +0300 Subject: [PATCH] Remove not working payment_method in root --- .../src/Endpoint/OrderEndpoint.php | 19 ++--- .../src/Entity/ApplicationContext.php | 22 ----- .../src/Entity/PaymentMethod.php | 81 ------------------- .../src/Endpoint/CreateOrderEndpoint.php | 24 +----- 4 files changed, 7 insertions(+), 139 deletions(-) delete mode 100644 modules/ppcp-api-client/src/Entity/PaymentMethod.php diff --git a/modules/ppcp-api-client/src/Endpoint/OrderEndpoint.php b/modules/ppcp-api-client/src/Endpoint/OrderEndpoint.php index cf22e8106..3b0954fae 100644 --- a/modules/ppcp-api-client/src/Endpoint/OrderEndpoint.php +++ b/modules/ppcp-api-client/src/Endpoint/OrderEndpoint.php @@ -18,7 +18,6 @@ use WooCommerce\PayPalCommerce\ApiClient\Entity\Order; use WooCommerce\PayPalCommerce\ApiClient\Entity\OrderStatus; use WooCommerce\PayPalCommerce\ApiClient\Entity\PatchCollection; use WooCommerce\PayPalCommerce\ApiClient\Entity\Payer; -use WooCommerce\PayPalCommerce\ApiClient\Entity\PaymentMethod; use WooCommerce\PayPalCommerce\ApiClient\Entity\PaymentToken; use WooCommerce\PayPalCommerce\ApiClient\Entity\PurchaseUnit; use WooCommerce\PayPalCommerce\ApiClient\Exception\PayPalApiException; @@ -27,7 +26,6 @@ use WooCommerce\PayPalCommerce\ApiClient\Factory\OrderFactory; use WooCommerce\PayPalCommerce\ApiClient\Factory\PatchCollectionFactory; use WooCommerce\PayPalCommerce\ApiClient\Helper\ErrorResponse; use WooCommerce\PayPalCommerce\ApiClient\Repository\ApplicationContextRepository; -use WooCommerce\PayPalCommerce\ApiClient\Repository\PayPalRequestIdRepository; use Psr\Log\LoggerInterface; use WooCommerce\PayPalCommerce\Subscription\Helper\SubscriptionHelper; use WooCommerce\PayPalCommerce\WcGateway\FraudNet\FraudNet; @@ -176,13 +174,12 @@ class OrderEndpoint { /** * Creates an order. * - * @param PurchaseUnit[] $items The purchase unit items for the order. - * @param string $shipping_preference One of ApplicationContext::SHIPPING_PREFERENCE_ values. - * @param Payer|null $payer The payer off the order. - * @param PaymentToken|null $payment_token The payment token. - * @param PaymentMethod|null $payment_method The payment method. - * @param string $paypal_request_id The paypal request id. - * @param string $user_action The user action. + * @param PurchaseUnit[] $items The purchase unit items for the order. + * @param string $shipping_preference One of ApplicationContext::SHIPPING_PREFERENCE_ values. + * @param Payer|null $payer The payer off the order. + * @param PaymentToken|null $payment_token The payment token. + * @param string $paypal_request_id The paypal request id. + * @param string $user_action The user action. * * @return Order * @throws RuntimeException If the request fails. @@ -192,7 +189,6 @@ class OrderEndpoint { string $shipping_preference, Payer $payer = null, PaymentToken $payment_token = null, - PaymentMethod $payment_method = null, string $paypal_request_id = '', string $user_action = ApplicationContext::USER_ACTION_CONTINUE ): Order { @@ -221,9 +217,6 @@ class OrderEndpoint { if ( $payment_token ) { $data['payment_source']['token'] = $payment_token->to_array(); } - if ( $payment_method ) { - $data['payment_method'] = $payment_method->to_array(); - } /** * The filter can be used to modify the order creation request body data. diff --git a/modules/ppcp-api-client/src/Entity/ApplicationContext.php b/modules/ppcp-api-client/src/Entity/ApplicationContext.php index 51a3ad005..2efe5b888 100644 --- a/modules/ppcp-api-client/src/Entity/ApplicationContext.php +++ b/modules/ppcp-api-client/src/Entity/ApplicationContext.php @@ -90,13 +90,6 @@ class ApplicationContext { */ private $cancel_url; - /** - * The payment method. - * - * @var null - */ - private $payment_method; - /** * ApplicationContext constructor. * @@ -136,9 +129,6 @@ class ApplicationContext { $this->landing_page = $landing_page; $this->shipping_preference = $shipping_preference; $this->user_action = $user_action; - - // Currently we have not implemented the payment method. - $this->payment_method = null; } /** @@ -204,15 +194,6 @@ class ApplicationContext { return $this->cancel_url; } - /** - * Returns the payment method. - * - * @return PaymentMethod|null - */ - public function payment_method() { - return $this->payment_method; - } - /** * Returns the object as array. * @@ -223,9 +204,6 @@ class ApplicationContext { if ( $this->user_action() ) { $data['user_action'] = $this->user_action(); } - if ( $this->payment_method() ) { - $data['payment_method'] = $this->payment_method(); - } if ( $this->shipping_preference() ) { $data['shipping_preference'] = $this->shipping_preference(); } diff --git a/modules/ppcp-api-client/src/Entity/PaymentMethod.php b/modules/ppcp-api-client/src/Entity/PaymentMethod.php deleted file mode 100644 index 0362e0093..000000000 --- a/modules/ppcp-api-client/src/Entity/PaymentMethod.php +++ /dev/null @@ -1,81 +0,0 @@ -preferred = $preferred; - $this->selected = $selected; - } - - /** - * Returns the payer preferred value. - * - * @return string - */ - public function payee_preferred(): string { - return $this->preferred; - } - - /** - * Returns the payer selected value. - * - * @return string - */ - public function payer_selected(): string { - return $this->selected; - } - - /** - * Returns the object as array. - * - * @return array - */ - public function to_array(): array { - return array( - 'payee_preferred' => $this->payee_preferred(), - 'payer_selected' => $this->payer_selected(), - ); - } -} diff --git a/modules/ppcp-button/src/Endpoint/CreateOrderEndpoint.php b/modules/ppcp-button/src/Endpoint/CreateOrderEndpoint.php index 686b87dd8..76e9e7f1a 100644 --- a/modules/ppcp-button/src/Endpoint/CreateOrderEndpoint.php +++ b/modules/ppcp-button/src/Endpoint/CreateOrderEndpoint.php @@ -19,7 +19,6 @@ use WooCommerce\PayPalCommerce\ApiClient\Entity\ApplicationContext; use WooCommerce\PayPalCommerce\ApiClient\Entity\Money; 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; @@ -32,7 +31,6 @@ use WooCommerce\PayPalCommerce\Button\Helper\EarlyOrderHandler; use WooCommerce\PayPalCommerce\Session\SessionHandler; use WooCommerce\PayPalCommerce\Subscription\FreeTrialHandlerTrait; use WooCommerce\PayPalCommerce\WcGateway\CardBillingMode; -use WooCommerce\PayPalCommerce\WcGateway\Exception\NotFoundException; use WooCommerce\PayPalCommerce\WcGateway\Gateway\CardButtonGateway; use WooCommerce\PayPalCommerce\WcGateway\Gateway\CreditCardGateway; use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway; @@ -448,7 +446,6 @@ class CreateOrderEndpoint implements EndpointInterface { $shipping_preference, $payer, null, - $this->payment_method(), '', $action ); @@ -471,8 +468,7 @@ class CreateOrderEndpoint implements EndpointInterface { array( $this->purchase_unit ), $shipping_preference, $payer, - null, - $this->payment_method() + null ); } @@ -536,24 +532,6 @@ class CreateOrderEndpoint implements EndpointInterface { $this->api_endpoint->with_bn_code( $bn_code ); } - /** - * Returns the PaymentMethod object for the order. - * - * @return PaymentMethod - */ - private function payment_method() : PaymentMethod { - 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; - } - /** * Checks whether the form fields are valid. *