RefundPaymentDataBuilder.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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\SubjectReader;
  9. use Magento\Payment\Gateway\Request\BuilderInterface;
  10. use Magento\Sales\Model\Order\Payment;
  11. /**
  12. * Adds the basic refund information to the request
  13. */
  14. class RefundPaymentDataBuilder implements BuilderInterface
  15. {
  16. /**
  17. * @var SubjectReader
  18. */
  19. private $subjectReader;
  20. /**
  21. * @param SubjectReader $subjectReader
  22. */
  23. public function __construct(SubjectReader $subjectReader)
  24. {
  25. $this->subjectReader = $subjectReader;
  26. }
  27. /**
  28. * @inheritdoc
  29. * @throws \Exception
  30. */
  31. public function build(array $buildSubject): array
  32. {
  33. $paymentDO = $this->subjectReader->readPayment($buildSubject);
  34. $payment = $paymentDO->getPayment();
  35. $data = [];
  36. if ($payment instanceof Payment) {
  37. $data = [
  38. 'transactionRequest' => [
  39. 'payment' => [
  40. 'creditCard' => [
  41. 'cardNumber' => $payment->getAdditionalInformation('ccLast4'),
  42. 'expirationDate' => 'XXXX'
  43. ]
  44. ]
  45. ]
  46. ];
  47. }
  48. return $data;
  49. }
  50. }