From f47d7cec18bb87d0ff7ec9f5de2c9174f4136be2 Mon Sep 17 00:00:00 2001 From: Emili Castells Guasch Date: Tue, 24 Oct 2023 11:49:43 +0200 Subject: [PATCH] Remove payee from purchase units --- modules/ppcp-api-client/services.php | 4 --- .../src/Entity/PurchaseUnit.php | 23 --------------- .../src/Factory/PurchaseUnitFactory.php | 28 ------------------- .../Factory/PurchaseUnitFactoryTest.php | 26 ----------------- 4 files changed, 81 deletions(-) diff --git a/modules/ppcp-api-client/services.php b/modules/ppcp-api-client/services.php index a222f0782..bad667b78 100644 --- a/modules/ppcp-api-client/services.php +++ b/modules/ppcp-api-client/services.php @@ -309,8 +309,6 @@ return array( 'api.factory.purchase-unit' => static function ( ContainerInterface $container ): PurchaseUnitFactory { $amount_factory = $container->get( 'api.factory.amount' ); - $payee_repository = $container->get( 'api.repository.payee' ); - $payee_factory = $container->get( 'api.factory.payee' ); $item_factory = $container->get( 'api.factory.item' ); $shipping_factory = $container->get( 'api.factory.shipping' ); $payments_factory = $container->get( 'api.factory.payments' ); @@ -320,8 +318,6 @@ return array( return new PurchaseUnitFactory( $amount_factory, - $payee_repository, - $payee_factory, $item_factory, $shipping_factory, $payments_factory, diff --git a/modules/ppcp-api-client/src/Entity/PurchaseUnit.php b/modules/ppcp-api-client/src/Entity/PurchaseUnit.php index 820df82af..1f0c5572d 100644 --- a/modules/ppcp-api-client/src/Entity/PurchaseUnit.php +++ b/modules/ppcp-api-client/src/Entity/PurchaseUnit.php @@ -51,13 +51,6 @@ class PurchaseUnit { */ private $description; - /** - * The Payee. - * - * @var Payee|null - */ - private $payee; - /** * The custom id. * @@ -108,7 +101,6 @@ class PurchaseUnit { * @param Shipping|null $shipping The Shipping. * @param string $reference_id The reference ID. * @param string $description The description. - * @param Payee|null $payee The Payee. * @param string $custom_id The custom ID. * @param string $invoice_id The invoice ID. * @param string $soft_descriptor The soft descriptor. @@ -120,7 +112,6 @@ class PurchaseUnit { Shipping $shipping = null, string $reference_id = 'default', string $description = '', - Payee $payee = null, string $custom_id = '', string $invoice_id = '', string $soft_descriptor = '', @@ -150,7 +141,6 @@ class PurchaseUnit { } ) ); - $this->payee = $payee; $this->custom_id = $custom_id; $this->invoice_id = $invoice_id; $this->soft_descriptor = $soft_descriptor; @@ -257,15 +247,6 @@ class PurchaseUnit { return $this->soft_descriptor; } - /** - * Returns the Payee. - * - * @return Payee|null - */ - public function payee() { - return $this->payee; - } - /** * Returns the Payments. * @@ -314,10 +295,6 @@ class PurchaseUnit { ), ); - if ( $this->payee() ) { - $purchase_unit['payee'] = $this->payee()->to_array(); - } - if ( $this->payments() ) { $purchase_unit['payments'] = $this->payments()->to_array(); } diff --git a/modules/ppcp-api-client/src/Factory/PurchaseUnitFactory.php b/modules/ppcp-api-client/src/Factory/PurchaseUnitFactory.php index ecb35592b..7642401b1 100644 --- a/modules/ppcp-api-client/src/Factory/PurchaseUnitFactory.php +++ b/modules/ppcp-api-client/src/Factory/PurchaseUnitFactory.php @@ -14,7 +14,6 @@ use WooCommerce\PayPalCommerce\ApiClient\Entity\Item; use WooCommerce\PayPalCommerce\ApiClient\Entity\PurchaseUnit; use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException; use WooCommerce\PayPalCommerce\ApiClient\Helper\PurchaseUnitSanitizer; -use WooCommerce\PayPalCommerce\ApiClient\Repository\PayeeRepository; use WooCommerce\PayPalCommerce\Webhooks\CustomIds; /** @@ -29,20 +28,6 @@ class PurchaseUnitFactory { */ private $amount_factory; - /** - * The payee repository. - * - * @var PayeeRepository - */ - private $payee_repository; - - /** - * The payee factory. - * - * @var PayeeFactory - */ - private $payee_factory; - /** * The item factory. * @@ -89,8 +74,6 @@ class PurchaseUnitFactory { * PurchaseUnitFactory constructor. * * @param AmountFactory $amount_factory The amount factory. - * @param PayeeRepository $payee_repository The Payee repository. - * @param PayeeFactory $payee_factory The Payee factory. * @param ItemFactory $item_factory The item factory. * @param ShippingFactory $shipping_factory The shipping factory. * @param PaymentsFactory $payments_factory The payments factory. @@ -100,8 +83,6 @@ class PurchaseUnitFactory { */ public function __construct( AmountFactory $amount_factory, - PayeeRepository $payee_repository, - PayeeFactory $payee_factory, ItemFactory $item_factory, ShippingFactory $shipping_factory, PaymentsFactory $payments_factory, @@ -111,8 +92,6 @@ class PurchaseUnitFactory { ) { $this->amount_factory = $amount_factory; - $this->payee_repository = $payee_repository; - $this->payee_factory = $payee_factory; $this->item_factory = $item_factory; $this->shipping_factory = $shipping_factory; $this->payments_factory = $payments_factory; @@ -146,7 +125,6 @@ class PurchaseUnitFactory { } $reference_id = 'default'; $description = ''; - $payee = $this->payee_repository->payee(); $custom_id = (string) $order->get_id(); $invoice_id = $this->prefix . $order->get_order_number(); $soft_descriptor = $this->soft_descriptor; @@ -157,7 +135,6 @@ class PurchaseUnitFactory { $shipping, $reference_id, $description, - $payee, $custom_id, $invoice_id, $soft_descriptor @@ -211,8 +188,6 @@ class PurchaseUnitFactory { $reference_id = 'default'; $description = ''; - $payee = $this->payee_repository->payee(); - $custom_id = ''; $session = WC()->session; if ( $session instanceof WC_Session_Handler ) { @@ -229,7 +204,6 @@ class PurchaseUnitFactory { $shipping, $reference_id, $description, - $payee, $custom_id, $invoice_id, $soft_descriptor @@ -269,7 +243,6 @@ class PurchaseUnitFactory { $data->items ); } - $payee = isset( $data->payee ) ? $this->payee_factory->from_paypal_response( $data->payee ) : null; $shipping = null; try { if ( isset( $data->shipping ) ) { @@ -293,7 +266,6 @@ class PurchaseUnitFactory { $shipping, $data->reference_id, $description, - $payee, $custom_id, $invoice_id, $soft_descriptor, diff --git a/tests/PHPUnit/ApiClient/Factory/PurchaseUnitFactoryTest.php b/tests/PHPUnit/ApiClient/Factory/PurchaseUnitFactoryTest.php index a693bbb7b..0c3ba52b9 100644 --- a/tests/PHPUnit/ApiClient/Factory/PurchaseUnitFactoryTest.php +++ b/tests/PHPUnit/ApiClient/Factory/PurchaseUnitFactoryTest.php @@ -75,8 +75,6 @@ class PurchaseUnitFactoryTest extends TestCase $paymentsFacory = Mockery::mock(PaymentsFactory::class); $testee = new PurchaseUnitFactory( $amountFactory, - $payeeRepository, - $payeeFactory, $itemFactory, $shippingFactory, $paymentsFacory @@ -139,8 +137,6 @@ class PurchaseUnitFactoryTest extends TestCase $paymentsFacory = Mockery::mock(PaymentsFactory::class); $testee = new PurchaseUnitFactory( $amountFactory, - $payeeRepository, - $payeeFactory, $itemFactory, $shippingFactory, $paymentsFacory @@ -194,8 +190,6 @@ class PurchaseUnitFactoryTest extends TestCase $paymentsFacory = Mockery::mock(PaymentsFactory::class); $testee = new PurchaseUnitFactory( $amountFactory, - $payeeRepository, - $payeeFactory, $itemFactory, $shippingFactory, $paymentsFacory @@ -243,8 +237,6 @@ class PurchaseUnitFactoryTest extends TestCase $paymentsFacory = Mockery::mock(PaymentsFactory::class); $testee = new PurchaseUnitFactory( $amountFactory, - $payeeRepository, - $payeeFactory, $itemFactory, $shippingFactory, $paymentsFacory @@ -299,8 +291,6 @@ class PurchaseUnitFactoryTest extends TestCase $paymentsFacory = Mockery::mock(PaymentsFactory::class); $testee = new PurchaseUnitFactory( $amountFactory, - $payeeRepository, - $payeeFactory, $itemFactory, $shippingFactory, $paymentsFacory @@ -346,8 +336,6 @@ class PurchaseUnitFactoryTest extends TestCase $paymentsFacory = Mockery::mock(PaymentsFactory::class); $testee = new PurchaseUnitFactory( $amountFactory, - $payeeRepository, - $payeeFactory, $itemFactory, $shippingFactory, $paymentsFacory @@ -395,8 +383,6 @@ class PurchaseUnitFactoryTest extends TestCase $paymentsFacory = Mockery::mock(PaymentsFactory::class); $testee = new PurchaseUnitFactory( $amountFactory, - $payeeRepository, - $payeeFactory, $itemFactory, $shippingFactory, $paymentsFacory @@ -427,8 +413,6 @@ class PurchaseUnitFactoryTest extends TestCase $paymentsFacory = Mockery::mock(PaymentsFactory::class); $testee = new PurchaseUnitFactory( $amountFactory, - $payeeRepository, - $payeeFactory, $itemFactory, $shippingFactory, $paymentsFacory @@ -478,8 +462,6 @@ class PurchaseUnitFactoryTest extends TestCase $paymentsFacory = Mockery::mock(PaymentsFactory::class); $testee = new PurchaseUnitFactory( $amountFactory, - $payeeRepository, - $payeeFactory, $itemFactory, $shippingFactory, $paymentsFacory @@ -518,8 +500,6 @@ class PurchaseUnitFactoryTest extends TestCase $paymentsFacory = Mockery::mock(PaymentsFactory::class); $testee = new PurchaseUnitFactory( $amountFactory, - $payeeRepository, - $payeeFactory, $itemFactory, $shippingFactory, $paymentsFacory @@ -550,8 +530,6 @@ class PurchaseUnitFactoryTest extends TestCase $paymentsFacory = Mockery::mock(PaymentsFactory::class); $testee = new PurchaseUnitFactory( $amountFactory, - $payeeRepository, - $payeeFactory, $itemFactory, $shippingFactory, $paymentsFacory @@ -600,8 +578,6 @@ class PurchaseUnitFactoryTest extends TestCase $testee = new PurchaseUnitFactory( $amountFactory, - $payeeRepository, - $payeeFactory, $itemFactory, $shippingFactory, $paymentsFactory @@ -650,8 +626,6 @@ class PurchaseUnitFactoryTest extends TestCase $testee = new PurchaseUnitFactory( $amountFactory, - $payeeRepository, - $payeeFactory, $itemFactory, $shippingFactory, $paymentsFactory