payment_tokens.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. include "customer.php";
  7. use Magento\Customer\Model\Customer;
  8. use Magento\Vault\Model\PaymentToken;
  9. $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
  10. $paymentTokens = [
  11. [
  12. 'customer_id' => 1,
  13. 'public_hash' => '1234',
  14. 'payment_method_code' => 'first',
  15. 'type' => 'simple',
  16. 'expires_at' => '2016-09-04 10:18:15',
  17. 'is_active' => 1
  18. ],
  19. [
  20. 'customer_id' => 1,
  21. 'public_hash' => '12345',
  22. 'payment_method_code' => 'second',
  23. 'type' => 'simple',
  24. 'expires_at' => '2016-10-04 10:18:15',
  25. 'is_active' => 1
  26. ],
  27. [
  28. 'customer_id' => 1,
  29. 'public_hash' => '23456',
  30. 'payment_method_code' => 'third',
  31. 'type' => 'notsimple',
  32. 'expires_at' => '2016-11-04 10:18:15',
  33. 'is_active' => 1
  34. ],
  35. [
  36. 'customer_id' => 1,
  37. 'public_hash' => '234567',
  38. 'payment_method_code' => 'fourth',
  39. 'type' => 'simple',
  40. 'expires_at' => '2016-12-04 10:18:15',
  41. 'is_active' => 0
  42. ],
  43. ];
  44. /** @var array $tokenData */
  45. foreach ($paymentTokens as $tokenData) {
  46. /** @var PaymentToken $bookmark */
  47. $paymentToken = $objectManager->create(PaymentToken::class);
  48. $paymentToken
  49. ->setData($tokenData)
  50. ->save();
  51. }