Remove not working payment_method in root

This commit is contained in:
Alex P 2023-06-28 16:34:14 +03:00
parent 1d75e73b56
commit c9bf899b75
No known key found for this signature in database
GPG key ID: 54487A734A204D71
4 changed files with 7 additions and 139 deletions

View file

@ -18,7 +18,6 @@ use WooCommerce\PayPalCommerce\ApiClient\Entity\Order;
use WooCommerce\PayPalCommerce\ApiClient\Entity\OrderStatus; use WooCommerce\PayPalCommerce\ApiClient\Entity\OrderStatus;
use WooCommerce\PayPalCommerce\ApiClient\Entity\PatchCollection; use WooCommerce\PayPalCommerce\ApiClient\Entity\PatchCollection;
use WooCommerce\PayPalCommerce\ApiClient\Entity\Payer; use WooCommerce\PayPalCommerce\ApiClient\Entity\Payer;
use WooCommerce\PayPalCommerce\ApiClient\Entity\PaymentMethod;
use WooCommerce\PayPalCommerce\ApiClient\Entity\PaymentToken; use WooCommerce\PayPalCommerce\ApiClient\Entity\PaymentToken;
use WooCommerce\PayPalCommerce\ApiClient\Entity\PurchaseUnit; use WooCommerce\PayPalCommerce\ApiClient\Entity\PurchaseUnit;
use WooCommerce\PayPalCommerce\ApiClient\Exception\PayPalApiException; 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\Factory\PatchCollectionFactory;
use WooCommerce\PayPalCommerce\ApiClient\Helper\ErrorResponse; use WooCommerce\PayPalCommerce\ApiClient\Helper\ErrorResponse;
use WooCommerce\PayPalCommerce\ApiClient\Repository\ApplicationContextRepository; use WooCommerce\PayPalCommerce\ApiClient\Repository\ApplicationContextRepository;
use WooCommerce\PayPalCommerce\ApiClient\Repository\PayPalRequestIdRepository;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use WooCommerce\PayPalCommerce\Subscription\Helper\SubscriptionHelper; use WooCommerce\PayPalCommerce\Subscription\Helper\SubscriptionHelper;
use WooCommerce\PayPalCommerce\WcGateway\FraudNet\FraudNet; use WooCommerce\PayPalCommerce\WcGateway\FraudNet\FraudNet;
@ -180,7 +178,6 @@ class OrderEndpoint {
* @param string $shipping_preference One of ApplicationContext::SHIPPING_PREFERENCE_ values. * @param string $shipping_preference One of ApplicationContext::SHIPPING_PREFERENCE_ values.
* @param Payer|null $payer The payer off the order. * @param Payer|null $payer The payer off the order.
* @param PaymentToken|null $payment_token The payment token. * @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 $paypal_request_id The paypal request id.
* @param string $user_action The user action. * @param string $user_action The user action.
* *
@ -192,7 +189,6 @@ class OrderEndpoint {
string $shipping_preference, string $shipping_preference,
Payer $payer = null, Payer $payer = null,
PaymentToken $payment_token = null, PaymentToken $payment_token = null,
PaymentMethod $payment_method = null,
string $paypal_request_id = '', string $paypal_request_id = '',
string $user_action = ApplicationContext::USER_ACTION_CONTINUE string $user_action = ApplicationContext::USER_ACTION_CONTINUE
): Order { ): Order {
@ -221,9 +217,6 @@ class OrderEndpoint {
if ( $payment_token ) { if ( $payment_token ) {
$data['payment_source']['token'] = $payment_token->to_array(); $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. * The filter can be used to modify the order creation request body data.

View file

@ -90,13 +90,6 @@ class ApplicationContext {
*/ */
private $cancel_url; private $cancel_url;
/**
* The payment method.
*
* @var null
*/
private $payment_method;
/** /**
* ApplicationContext constructor. * ApplicationContext constructor.
* *
@ -136,9 +129,6 @@ class ApplicationContext {
$this->landing_page = $landing_page; $this->landing_page = $landing_page;
$this->shipping_preference = $shipping_preference; $this->shipping_preference = $shipping_preference;
$this->user_action = $user_action; $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; return $this->cancel_url;
} }
/**
* Returns the payment method.
*
* @return PaymentMethod|null
*/
public function payment_method() {
return $this->payment_method;
}
/** /**
* Returns the object as array. * Returns the object as array.
* *
@ -223,9 +204,6 @@ class ApplicationContext {
if ( $this->user_action() ) { if ( $this->user_action() ) {
$data['user_action'] = $this->user_action(); $data['user_action'] = $this->user_action();
} }
if ( $this->payment_method() ) {
$data['payment_method'] = $this->payment_method();
}
if ( $this->shipping_preference() ) { if ( $this->shipping_preference() ) {
$data['shipping_preference'] = $this->shipping_preference(); $data['shipping_preference'] = $this->shipping_preference();
} }

View file

@ -1,81 +0,0 @@
<?php
/**
* The PaymentMethod object
*
* @package WooCommerce\PayPalCommerce\ApiClient\Entity
*/
declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\ApiClient\Entity;
/**
* Class PaymentMethod
*/
class PaymentMethod {
const PAYER_SELECTED_DEFAULT = 'PAYPAL';
const PAYEE_PREFERRED_UNRESTRICTED = 'UNRESTRICTED';
const PAYEE_PREFERRED_IMMEDIATE_PAYMENT_REQUIRED = 'IMMEDIATE_PAYMENT_REQUIRED';
/**
* The preferred value.
*
* @var string
*/
private $preferred;
/**
* The selected value.
*
* @var string
*/
private $selected;
/**
* PaymentMethod constructor.
*
* @param string $preferred The preferred value.
* @param string $selected The selected value.
*/
public function __construct(
string $preferred = self::PAYEE_PREFERRED_UNRESTRICTED,
string $selected = self::PAYER_SELECTED_DEFAULT
) {
$this->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(),
);
}
}

View file

@ -19,7 +19,6 @@ use WooCommerce\PayPalCommerce\ApiClient\Entity\ApplicationContext;
use WooCommerce\PayPalCommerce\ApiClient\Entity\Money; use WooCommerce\PayPalCommerce\ApiClient\Entity\Money;
use WooCommerce\PayPalCommerce\ApiClient\Entity\Order; use WooCommerce\PayPalCommerce\ApiClient\Entity\Order;
use WooCommerce\PayPalCommerce\ApiClient\Entity\Payer; use WooCommerce\PayPalCommerce\ApiClient\Entity\Payer;
use WooCommerce\PayPalCommerce\ApiClient\Entity\PaymentMethod;
use WooCommerce\PayPalCommerce\ApiClient\Entity\PurchaseUnit; use WooCommerce\PayPalCommerce\ApiClient\Entity\PurchaseUnit;
use WooCommerce\PayPalCommerce\ApiClient\Exception\PayPalApiException; use WooCommerce\PayPalCommerce\ApiClient\Exception\PayPalApiException;
use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException; use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
@ -32,7 +31,6 @@ use WooCommerce\PayPalCommerce\Button\Helper\EarlyOrderHandler;
use WooCommerce\PayPalCommerce\Session\SessionHandler; use WooCommerce\PayPalCommerce\Session\SessionHandler;
use WooCommerce\PayPalCommerce\Subscription\FreeTrialHandlerTrait; use WooCommerce\PayPalCommerce\Subscription\FreeTrialHandlerTrait;
use WooCommerce\PayPalCommerce\WcGateway\CardBillingMode; use WooCommerce\PayPalCommerce\WcGateway\CardBillingMode;
use WooCommerce\PayPalCommerce\WcGateway\Exception\NotFoundException;
use WooCommerce\PayPalCommerce\WcGateway\Gateway\CardButtonGateway; use WooCommerce\PayPalCommerce\WcGateway\Gateway\CardButtonGateway;
use WooCommerce\PayPalCommerce\WcGateway\Gateway\CreditCardGateway; use WooCommerce\PayPalCommerce\WcGateway\Gateway\CreditCardGateway;
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway; use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
@ -448,7 +446,6 @@ class CreateOrderEndpoint implements EndpointInterface {
$shipping_preference, $shipping_preference,
$payer, $payer,
null, null,
$this->payment_method(),
'', '',
$action $action
); );
@ -471,8 +468,7 @@ class CreateOrderEndpoint implements EndpointInterface {
array( $this->purchase_unit ), array( $this->purchase_unit ),
$shipping_preference, $shipping_preference,
$payer, $payer,
null, null
$this->payment_method()
); );
} }
@ -536,24 +532,6 @@ class CreateOrderEndpoint implements EndpointInterface {
$this->api_endpoint->with_bn_code( $bn_code ); $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. * Checks whether the form fields are valid.
* *