Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
paypal_vault_token.php
Go to the documentation of this file.
1 <?php
13 
14 require __DIR__ . '/../../../Magento/Customer/_files/customer.php';
15 
17 $config = $objectManager->get(Config::class);
18 $config->setDataByPath('payment/' . ConfigProvider::PAYPAL_CODE . '/active', 1);
19 $config->save();
20 $config->setDataByPath('payment/' . ConfigProvider::PAYPAL_VAULT_CODE . '/active', 1);
21 $config->save();
22 
24 $encryptor = $objectManager->get(EncryptorInterface::class);
25 
27 $paymentToken = $objectManager->create(PaymentToken::class);
29  ->setCustomerId($customer->getId())
30  ->setPaymentMethodCode(ConfigProvider::PAYPAL_CODE)
31  ->setType(AccountPaymentTokenFactory::TOKEN_TYPE_ACCOUNT)
32  ->setGatewayToken('mx29vk')
33  ->setPublicHash($encryptor->hash($customer->getId()))
34  ->setTokenDetails(json_encode(['payerEmail' => '[email protected]']))
35  ->setIsActive(true)
36  ->setIsVisible(true)
37  ->setExpiresAt(date('Y-m-d H:i:s', strtotime('+1 year')));
38 
40 $tokenRepository = $objectManager->create(PaymentTokenRepository::class);
$objectManager
Definition: bootstrap.php:17
$customer
Definition: customers.php:11
defined('TESTS_BP')||define('TESTS_BP' __DIR__
Definition: _bootstrap.php:60
$tokenRepository