AuthenticationDataBuilder.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. declare(strict_types=1);
  7. namespace Magento\AuthorizenetAcceptjs\Gateway\Request;
  8. use Magento\AuthorizenetAcceptjs\Gateway\Config;
  9. use Magento\AuthorizenetAcceptjs\Gateway\SubjectReader;
  10. use Magento\Payment\Gateway\Request\BuilderInterface;
  11. /**
  12. * Adds the stored credentials to the request
  13. */
  14. class AuthenticationDataBuilder implements BuilderInterface
  15. {
  16. /**
  17. * @var SubjectReader
  18. */
  19. private $subjectReader;
  20. /**
  21. * @var Config
  22. */
  23. private $config;
  24. /**
  25. * @param SubjectReader $subjectReader
  26. * @param Config $config
  27. */
  28. public function __construct(
  29. SubjectReader $subjectReader,
  30. Config $config
  31. ) {
  32. $this->subjectReader = $subjectReader;
  33. $this->config = $config;
  34. }
  35. /**
  36. * Adds authentication information to the request
  37. *
  38. * @param array $buildSubject
  39. * @return array
  40. */
  41. public function build(array $buildSubject): array
  42. {
  43. $storeId = $this->subjectReader->readStoreId($buildSubject);
  44. return [
  45. 'merchantAuthentication' => [
  46. 'name' => $this->config->getLoginId($storeId),
  47. 'transactionKey' => $this->config->getTransactionKey($storeId)
  48. ]
  49. ];
  50. }
  51. }