ResponseValidator.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Braintree\Gateway\Validator;
  7. use Braintree\Result\Error;
  8. use Braintree\Result\Successful;
  9. use Braintree\Transaction;
  10. use Magento\Payment\Gateway\Validator\ResultInterfaceFactory;
  11. /**
  12. * Class ResponseValidator
  13. */
  14. class ResponseValidator extends GeneralResponseValidator
  15. {
  16. /**
  17. * @return array
  18. */
  19. protected function getResponseValidators()
  20. {
  21. return array_merge(
  22. parent::getResponseValidators(),
  23. [
  24. function ($response) {
  25. return [
  26. $response instanceof Successful
  27. && isset($response->transaction)
  28. && in_array(
  29. $response->transaction->status,
  30. [Transaction::AUTHORIZED, Transaction::SUBMITTED_FOR_SETTLEMENT, Transaction::SETTLING]
  31. ),
  32. [__('Wrong transaction status')]
  33. ];
  34. }
  35. ]
  36. );
  37. }
  38. }