paypal_quote.php 895 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. declare(strict_types=1);
  7. use Magento\Braintree\Model\Ui\PayPal\ConfigProvider;
  8. use Magento\Quote\Api\CartRepositoryInterface;
  9. require __DIR__ . '/../_files/paypal_vault_token.php';
  10. require __DIR__ . '/../../Sales/_files/quote_with_customer.php';
  11. $quote->getShippingAddress()
  12. ->setShippingMethod('flatrate_flatrate')
  13. ->setCollectShippingRates(true);
  14. $quote->getPayment()
  15. ->setMethod(ConfigProvider::PAYPAL_VAULT_CODE)
  16. ->setAdditionalInformation(
  17. [
  18. 'customer_id' => $quote->getCustomerId(),
  19. 'public_hash' => $paymentToken->getPublicHash()
  20. ]
  21. );
  22. $quote->collectTotals();
  23. /** @var CartRepositoryInterface $quoteRepository */
  24. $quoteRepository = $objectManager->get(CartRepositoryInterface::class);
  25. $quoteRepository->save($quote);