Remove payee from purchase units

This commit is contained in:
Emili Castells Guasch 2023-10-24 11:49:43 +02:00
parent df283218bd
commit f47d7cec18
4 changed files with 0 additions and 81 deletions

View file

@ -309,8 +309,6 @@ return array(
'api.factory.purchase-unit' => static function ( ContainerInterface $container ): PurchaseUnitFactory { 'api.factory.purchase-unit' => static function ( ContainerInterface $container ): PurchaseUnitFactory {
$amount_factory = $container->get( 'api.factory.amount' ); $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' ); $item_factory = $container->get( 'api.factory.item' );
$shipping_factory = $container->get( 'api.factory.shipping' ); $shipping_factory = $container->get( 'api.factory.shipping' );
$payments_factory = $container->get( 'api.factory.payments' ); $payments_factory = $container->get( 'api.factory.payments' );
@ -320,8 +318,6 @@ return array(
return new PurchaseUnitFactory( return new PurchaseUnitFactory(
$amount_factory, $amount_factory,
$payee_repository,
$payee_factory,
$item_factory, $item_factory,
$shipping_factory, $shipping_factory,
$payments_factory, $payments_factory,

View file

@ -51,13 +51,6 @@ class PurchaseUnit {
*/ */
private $description; private $description;
/**
* The Payee.
*
* @var Payee|null
*/
private $payee;
/** /**
* The custom id. * The custom id.
* *
@ -108,7 +101,6 @@ class PurchaseUnit {
* @param Shipping|null $shipping The Shipping. * @param Shipping|null $shipping The Shipping.
* @param string $reference_id The reference ID. * @param string $reference_id The reference ID.
* @param string $description The description. * @param string $description The description.
* @param Payee|null $payee The Payee.
* @param string $custom_id The custom ID. * @param string $custom_id The custom ID.
* @param string $invoice_id The invoice ID. * @param string $invoice_id The invoice ID.
* @param string $soft_descriptor The soft descriptor. * @param string $soft_descriptor The soft descriptor.
@ -120,7 +112,6 @@ class PurchaseUnit {
Shipping $shipping = null, Shipping $shipping = null,
string $reference_id = 'default', string $reference_id = 'default',
string $description = '', string $description = '',
Payee $payee = null,
string $custom_id = '', string $custom_id = '',
string $invoice_id = '', string $invoice_id = '',
string $soft_descriptor = '', string $soft_descriptor = '',
@ -150,7 +141,6 @@ class PurchaseUnit {
} }
) )
); );
$this->payee = $payee;
$this->custom_id = $custom_id; $this->custom_id = $custom_id;
$this->invoice_id = $invoice_id; $this->invoice_id = $invoice_id;
$this->soft_descriptor = $soft_descriptor; $this->soft_descriptor = $soft_descriptor;
@ -257,15 +247,6 @@ class PurchaseUnit {
return $this->soft_descriptor; return $this->soft_descriptor;
} }
/**
* Returns the Payee.
*
* @return Payee|null
*/
public function payee() {
return $this->payee;
}
/** /**
* Returns the Payments. * Returns the Payments.
* *
@ -314,10 +295,6 @@ class PurchaseUnit {
), ),
); );
if ( $this->payee() ) {
$purchase_unit['payee'] = $this->payee()->to_array();
}
if ( $this->payments() ) { if ( $this->payments() ) {
$purchase_unit['payments'] = $this->payments()->to_array(); $purchase_unit['payments'] = $this->payments()->to_array();
} }

View file

@ -14,7 +14,6 @@ use WooCommerce\PayPalCommerce\ApiClient\Entity\Item;
use WooCommerce\PayPalCommerce\ApiClient\Entity\PurchaseUnit; use WooCommerce\PayPalCommerce\ApiClient\Entity\PurchaseUnit;
use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException; use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
use WooCommerce\PayPalCommerce\ApiClient\Helper\PurchaseUnitSanitizer; use WooCommerce\PayPalCommerce\ApiClient\Helper\PurchaseUnitSanitizer;
use WooCommerce\PayPalCommerce\ApiClient\Repository\PayeeRepository;
use WooCommerce\PayPalCommerce\Webhooks\CustomIds; use WooCommerce\PayPalCommerce\Webhooks\CustomIds;
/** /**
@ -29,20 +28,6 @@ class PurchaseUnitFactory {
*/ */
private $amount_factory; private $amount_factory;
/**
* The payee repository.
*
* @var PayeeRepository
*/
private $payee_repository;
/**
* The payee factory.
*
* @var PayeeFactory
*/
private $payee_factory;
/** /**
* The item factory. * The item factory.
* *
@ -89,8 +74,6 @@ class PurchaseUnitFactory {
* PurchaseUnitFactory constructor. * PurchaseUnitFactory constructor.
* *
* @param AmountFactory $amount_factory The amount factory. * @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 ItemFactory $item_factory The item factory.
* @param ShippingFactory $shipping_factory The shipping factory. * @param ShippingFactory $shipping_factory The shipping factory.
* @param PaymentsFactory $payments_factory The payments factory. * @param PaymentsFactory $payments_factory The payments factory.
@ -100,8 +83,6 @@ class PurchaseUnitFactory {
*/ */
public function __construct( public function __construct(
AmountFactory $amount_factory, AmountFactory $amount_factory,
PayeeRepository $payee_repository,
PayeeFactory $payee_factory,
ItemFactory $item_factory, ItemFactory $item_factory,
ShippingFactory $shipping_factory, ShippingFactory $shipping_factory,
PaymentsFactory $payments_factory, PaymentsFactory $payments_factory,
@ -111,8 +92,6 @@ class PurchaseUnitFactory {
) { ) {
$this->amount_factory = $amount_factory; $this->amount_factory = $amount_factory;
$this->payee_repository = $payee_repository;
$this->payee_factory = $payee_factory;
$this->item_factory = $item_factory; $this->item_factory = $item_factory;
$this->shipping_factory = $shipping_factory; $this->shipping_factory = $shipping_factory;
$this->payments_factory = $payments_factory; $this->payments_factory = $payments_factory;
@ -146,7 +125,6 @@ class PurchaseUnitFactory {
} }
$reference_id = 'default'; $reference_id = 'default';
$description = ''; $description = '';
$payee = $this->payee_repository->payee();
$custom_id = (string) $order->get_id(); $custom_id = (string) $order->get_id();
$invoice_id = $this->prefix . $order->get_order_number(); $invoice_id = $this->prefix . $order->get_order_number();
$soft_descriptor = $this->soft_descriptor; $soft_descriptor = $this->soft_descriptor;
@ -157,7 +135,6 @@ class PurchaseUnitFactory {
$shipping, $shipping,
$reference_id, $reference_id,
$description, $description,
$payee,
$custom_id, $custom_id,
$invoice_id, $invoice_id,
$soft_descriptor $soft_descriptor
@ -211,8 +188,6 @@ class PurchaseUnitFactory {
$reference_id = 'default'; $reference_id = 'default';
$description = ''; $description = '';
$payee = $this->payee_repository->payee();
$custom_id = ''; $custom_id = '';
$session = WC()->session; $session = WC()->session;
if ( $session instanceof WC_Session_Handler ) { if ( $session instanceof WC_Session_Handler ) {
@ -229,7 +204,6 @@ class PurchaseUnitFactory {
$shipping, $shipping,
$reference_id, $reference_id,
$description, $description,
$payee,
$custom_id, $custom_id,
$invoice_id, $invoice_id,
$soft_descriptor $soft_descriptor
@ -269,7 +243,6 @@ class PurchaseUnitFactory {
$data->items $data->items
); );
} }
$payee = isset( $data->payee ) ? $this->payee_factory->from_paypal_response( $data->payee ) : null;
$shipping = null; $shipping = null;
try { try {
if ( isset( $data->shipping ) ) { if ( isset( $data->shipping ) ) {
@ -293,7 +266,6 @@ class PurchaseUnitFactory {
$shipping, $shipping,
$data->reference_id, $data->reference_id,
$description, $description,
$payee,
$custom_id, $custom_id,
$invoice_id, $invoice_id,
$soft_descriptor, $soft_descriptor,

View file

@ -75,8 +75,6 @@ class PurchaseUnitFactoryTest extends TestCase
$paymentsFacory = Mockery::mock(PaymentsFactory::class); $paymentsFacory = Mockery::mock(PaymentsFactory::class);
$testee = new PurchaseUnitFactory( $testee = new PurchaseUnitFactory(
$amountFactory, $amountFactory,
$payeeRepository,
$payeeFactory,
$itemFactory, $itemFactory,
$shippingFactory, $shippingFactory,
$paymentsFacory $paymentsFacory
@ -139,8 +137,6 @@ class PurchaseUnitFactoryTest extends TestCase
$paymentsFacory = Mockery::mock(PaymentsFactory::class); $paymentsFacory = Mockery::mock(PaymentsFactory::class);
$testee = new PurchaseUnitFactory( $testee = new PurchaseUnitFactory(
$amountFactory, $amountFactory,
$payeeRepository,
$payeeFactory,
$itemFactory, $itemFactory,
$shippingFactory, $shippingFactory,
$paymentsFacory $paymentsFacory
@ -194,8 +190,6 @@ class PurchaseUnitFactoryTest extends TestCase
$paymentsFacory = Mockery::mock(PaymentsFactory::class); $paymentsFacory = Mockery::mock(PaymentsFactory::class);
$testee = new PurchaseUnitFactory( $testee = new PurchaseUnitFactory(
$amountFactory, $amountFactory,
$payeeRepository,
$payeeFactory,
$itemFactory, $itemFactory,
$shippingFactory, $shippingFactory,
$paymentsFacory $paymentsFacory
@ -243,8 +237,6 @@ class PurchaseUnitFactoryTest extends TestCase
$paymentsFacory = Mockery::mock(PaymentsFactory::class); $paymentsFacory = Mockery::mock(PaymentsFactory::class);
$testee = new PurchaseUnitFactory( $testee = new PurchaseUnitFactory(
$amountFactory, $amountFactory,
$payeeRepository,
$payeeFactory,
$itemFactory, $itemFactory,
$shippingFactory, $shippingFactory,
$paymentsFacory $paymentsFacory
@ -299,8 +291,6 @@ class PurchaseUnitFactoryTest extends TestCase
$paymentsFacory = Mockery::mock(PaymentsFactory::class); $paymentsFacory = Mockery::mock(PaymentsFactory::class);
$testee = new PurchaseUnitFactory( $testee = new PurchaseUnitFactory(
$amountFactory, $amountFactory,
$payeeRepository,
$payeeFactory,
$itemFactory, $itemFactory,
$shippingFactory, $shippingFactory,
$paymentsFacory $paymentsFacory
@ -346,8 +336,6 @@ class PurchaseUnitFactoryTest extends TestCase
$paymentsFacory = Mockery::mock(PaymentsFactory::class); $paymentsFacory = Mockery::mock(PaymentsFactory::class);
$testee = new PurchaseUnitFactory( $testee = new PurchaseUnitFactory(
$amountFactory, $amountFactory,
$payeeRepository,
$payeeFactory,
$itemFactory, $itemFactory,
$shippingFactory, $shippingFactory,
$paymentsFacory $paymentsFacory
@ -395,8 +383,6 @@ class PurchaseUnitFactoryTest extends TestCase
$paymentsFacory = Mockery::mock(PaymentsFactory::class); $paymentsFacory = Mockery::mock(PaymentsFactory::class);
$testee = new PurchaseUnitFactory( $testee = new PurchaseUnitFactory(
$amountFactory, $amountFactory,
$payeeRepository,
$payeeFactory,
$itemFactory, $itemFactory,
$shippingFactory, $shippingFactory,
$paymentsFacory $paymentsFacory
@ -427,8 +413,6 @@ class PurchaseUnitFactoryTest extends TestCase
$paymentsFacory = Mockery::mock(PaymentsFactory::class); $paymentsFacory = Mockery::mock(PaymentsFactory::class);
$testee = new PurchaseUnitFactory( $testee = new PurchaseUnitFactory(
$amountFactory, $amountFactory,
$payeeRepository,
$payeeFactory,
$itemFactory, $itemFactory,
$shippingFactory, $shippingFactory,
$paymentsFacory $paymentsFacory
@ -478,8 +462,6 @@ class PurchaseUnitFactoryTest extends TestCase
$paymentsFacory = Mockery::mock(PaymentsFactory::class); $paymentsFacory = Mockery::mock(PaymentsFactory::class);
$testee = new PurchaseUnitFactory( $testee = new PurchaseUnitFactory(
$amountFactory, $amountFactory,
$payeeRepository,
$payeeFactory,
$itemFactory, $itemFactory,
$shippingFactory, $shippingFactory,
$paymentsFacory $paymentsFacory
@ -518,8 +500,6 @@ class PurchaseUnitFactoryTest extends TestCase
$paymentsFacory = Mockery::mock(PaymentsFactory::class); $paymentsFacory = Mockery::mock(PaymentsFactory::class);
$testee = new PurchaseUnitFactory( $testee = new PurchaseUnitFactory(
$amountFactory, $amountFactory,
$payeeRepository,
$payeeFactory,
$itemFactory, $itemFactory,
$shippingFactory, $shippingFactory,
$paymentsFacory $paymentsFacory
@ -550,8 +530,6 @@ class PurchaseUnitFactoryTest extends TestCase
$paymentsFacory = Mockery::mock(PaymentsFactory::class); $paymentsFacory = Mockery::mock(PaymentsFactory::class);
$testee = new PurchaseUnitFactory( $testee = new PurchaseUnitFactory(
$amountFactory, $amountFactory,
$payeeRepository,
$payeeFactory,
$itemFactory, $itemFactory,
$shippingFactory, $shippingFactory,
$paymentsFacory $paymentsFacory
@ -600,8 +578,6 @@ class PurchaseUnitFactoryTest extends TestCase
$testee = new PurchaseUnitFactory( $testee = new PurchaseUnitFactory(
$amountFactory, $amountFactory,
$payeeRepository,
$payeeFactory,
$itemFactory, $itemFactory,
$shippingFactory, $shippingFactory,
$paymentsFactory $paymentsFactory
@ -650,8 +626,6 @@ class PurchaseUnitFactoryTest extends TestCase
$testee = new PurchaseUnitFactory( $testee = new PurchaseUnitFactory(
$amountFactory, $amountFactory,
$payeeRepository,
$payeeFactory,
$itemFactory, $itemFactory,
$shippingFactory, $shippingFactory,
$paymentsFactory $paymentsFactory