Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Attributes
GuestPaymentInformationManagement Class Reference
Inheritance diagram for GuestPaymentInformationManagement:
GuestPaymentInformationManagementInterface

Public Member Functions

 __construct (\Magento\Quote\Api\GuestBillingAddressManagementInterface $billingAddressManagement, \Magento\Quote\Api\GuestPaymentMethodManagementInterface $paymentMethodManagement, \Magento\Quote\Api\GuestCartManagementInterface $cartManagement, \Magento\Checkout\Api\PaymentInformationManagementInterface $paymentInformationManagement, \Magento\Quote\Model\QuoteIdMaskFactory $quoteIdMaskFactory, CartRepositoryInterface $cartRepository, ResourceConnection $connectionPool=null)
 
 savePaymentInformationAndPlaceOrder ( $cartId, $email, \Magento\Quote\Api\Data\PaymentInterface $paymentMethod, \Magento\Quote\Api\Data\AddressInterface $billingAddress=null)
 
 getPaymentInformation ($cartId)
 
- Public Member Functions inherited from GuestPaymentInformationManagementInterface
 savePaymentInformationAndPlaceOrder ( $cartId, $email, \Magento\Quote\Api\Data\PaymentInterface $paymentMethod, \Magento\Quote\Api\Data\AddressInterface $billingAddress=null)
 
 savePaymentInformation ( $cartId, $email, \Magento\Quote\Api\Data\PaymentInterface $paymentMethod, \Magento\Quote\Api\Data\AddressInterface $billingAddress=null)
 

Protected Attributes

 $billingAddressManagement
 
 $paymentMethodManagement
 
 $cartManagement
 
 $paymentInformationManagement
 
 $quoteIdMaskFactory
 
 $cartRepository
 

Detailed Description

@SuppressWarnings(PHPMD.CouplingBetweenObjects)

Definition at line 19 of file GuestPaymentInformationManagement.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( \Magento\Quote\Api\GuestBillingAddressManagementInterface  $billingAddressManagement,
\Magento\Quote\Api\GuestPaymentMethodManagementInterface  $paymentMethodManagement,
\Magento\Quote\Api\GuestCartManagementInterface  $cartManagement,
\Magento\Checkout\Api\PaymentInformationManagementInterface  $paymentInformationManagement,
\Magento\Quote\Model\QuoteIdMaskFactory  $quoteIdMaskFactory,
CartRepositoryInterface  $cartRepository,
ResourceConnection  $connectionPool = null 
)
Parameters
\Magento\Quote\Api\GuestBillingAddressManagementInterface$billingAddressManagement
\Magento\Quote\Api\GuestPaymentMethodManagementInterface$paymentMethodManagement
\Magento\Quote\Api\GuestCartManagementInterface$cartManagement
\Magento\Checkout\Api\PaymentInformationManagementInterface$paymentInformationManagement
\Magento\Quote\Model\QuoteIdMaskFactory$quoteIdMaskFactory
CartRepositoryInterface$cartRepository
ResourceConnection|null@codeCoverageIgnore

Definition at line 72 of file GuestPaymentInformationManagement.php.

Member Function Documentation

◆ getPaymentInformation()

getPaymentInformation (   $cartId)

Get payment information

Parameters
string$cartId
Returns
\Magento\Checkout\Api\Data\PaymentDetailsInterface

Implements GuestPaymentInformationManagementInterface.

Definition at line 161 of file GuestPaymentInformationManagement.php.

162  {
163  $quoteIdMask = $this->quoteIdMaskFactory->create()->load($cartId, 'masked_id');
164  return $this->paymentInformationManagement->getPaymentInformation($quoteIdMask->getQuoteId());
165  }
$cartId
Definition: quote.php:22

◆ savePaymentInformationAndPlaceOrder()

savePaymentInformationAndPlaceOrder (   $cartId,
  $email,
\Magento\Quote\Api\Data\PaymentInterface  $paymentMethod,
\Magento\Quote\Api\Data\AddressInterface  $billingAddress = null 
)

Definition at line 93 of file GuestPaymentInformationManagement.php.

98  {
99  $salesConnection = $this->connectionPool->getConnection('sales');
100  $checkoutConnection = $this->connectionPool->getConnection('checkout');
101  $salesConnection->beginTransaction();
102  $checkoutConnection->beginTransaction();
103 
104  try {
105  $this->savePaymentInformation($cartId, $email, $paymentMethod, $billingAddress);
106  try {
107  $orderId = $this->cartManagement->placeOrder($cartId);
108  } catch (\Magento\Framework\Exception\LocalizedException $e) {
109  throw new CouldNotSaveException(
110  __($e->getMessage()),
111  $e
112  );
113  } catch (\Exception $e) {
114  $this->getLogger()->critical($e);
115  throw new CouldNotSaveException(
116  __('An error occurred on the server. Please try to place the order again.'),
117  $e
118  );
119  }
120  $salesConnection->commit();
121  $checkoutConnection->commit();
122  } catch (\Exception $e) {
123  $salesConnection->rollBack();
124  $checkoutConnection->rollBack();
125  throw $e;
126  }
127 
128  return $orderId;
129  }
$billingAddress
Definition: order.php:25
$email
Definition: details.phtml:13
__()
Definition: __.php:13
$cartId
Definition: quote.php:22
savePaymentInformation( $cartId, $email, \Magento\Quote\Api\Data\PaymentInterface $paymentMethod, \Magento\Quote\Api\Data\AddressInterface $billingAddress=null)

Field Documentation

◆ $billingAddressManagement

$billingAddressManagement
protected

Definition at line 25 of file GuestPaymentInformationManagement.php.

◆ $cartManagement

$cartManagement
protected

Definition at line 35 of file GuestPaymentInformationManagement.php.

◆ $cartRepository

$cartRepository
protected

Definition at line 50 of file GuestPaymentInformationManagement.php.

◆ $paymentInformationManagement

$paymentInformationManagement
protected

Definition at line 40 of file GuestPaymentInformationManagement.php.

◆ $paymentMethodManagement

$paymentMethodManagement
protected

Definition at line 30 of file GuestPaymentInformationManagement.php.

◆ $quoteIdMaskFactory

$quoteIdMaskFactory
protected

Definition at line 45 of file GuestPaymentInformationManagement.php.


The documentation for this class was generated from the following file: