123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?php
- /**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
- namespace Magento\InstantPurchase\Model;
- use Magento\Customer\Model\Address;
- use Magento\Framework\ObjectManagerInterface;
- use Magento\Quote\Api\Data\ShippingMethodInterface;
- use Magento\Vault\Api\Data\PaymentTokenInterface;
- /**
- * Create instances of instant purchase option.
- *
- * @api
- * @since 100.2.0
- */
- class InstantPurchaseOptionFactory
- {
- /**
- * @var ObjectManagerInterface
- */
- private $objectManager;
- /**
- * InstantPurchaseOptionFactory constructor.
- * @param ObjectManagerInterface $objectManager
- */
- public function __construct(ObjectManagerInterface $objectManager)
- {
- $this->objectManager = $objectManager;
- }
- /**
- * Creates new instance.
- *
- * @param PaymentTokenInterface|null $paymentToken
- * @param Address|null $shippingAddress
- * @param Address|null $billingAddress
- * @param ShippingMethodInterface|null $shippingMethod
- * @return InstantPurchaseOption
- * @since 100.2.0
- */
- public function create(
- PaymentTokenInterface $paymentToken = null,
- Address $shippingAddress = null,
- Address $billingAddress = null,
- ShippingMethodInterface $shippingMethod = null
- ): InstantPurchaseOption {
- return $this->objectManager->create(InstantPurchaseOption::class, [
- 'paymentToken' => $paymentToken,
- 'shippingAddress' => $shippingAddress,
- 'billingAddress' => $billingAddress,
- 'shippingMethod' => $shippingMethod,
- ]);
- }
- /**
- * Creates new empty instance (no option available).
- *
- * @return InstantPurchaseOption
- * @since 100.2.0
- */
- public function createDisabledOption(): InstantPurchaseOption
- {
- return $this->create(null, null, null, null);
- }
- }
|