payment.php 1.0 KB

1234567891011121314151617181920212223242526272829
  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\ConfigProvider;
  8. use Magento\Sales\Api\Data\OrderPaymentExtensionInterfaceFactory;
  9. use Magento\Sales\Model\Order\Payment;
  10. use Magento\TestFramework\Helper\Bootstrap;
  11. use Magento\TestFramework\ObjectManager;
  12. /** @var ObjectManager $objectManager */
  13. $objectManager = Bootstrap::getObjectManager();
  14. require __DIR__ . '/../../Vault/_files/token.php';
  15. $token->setPaymentMethodCode(ConfigProvider::CODE);
  16. /** @var OrderPaymentExtensionInterfaceFactory $paymentExtensionFactory */
  17. $paymentExtensionFactory = $objectManager->get(OrderPaymentExtensionInterfaceFactory::class);
  18. $extensionAttributes = $paymentExtensionFactory->create();
  19. $extensionAttributes->setVaultPaymentToken($token);
  20. /** @var Payment $payment */
  21. $payment = $objectManager->create(Payment::class);
  22. $payment->setMethod(ConfigProvider::CODE);
  23. $payment->setExtensionAttributes($extensionAttributes);
  24. $payment->setAuthorizationTransaction(true);