UsBankAccountVerification.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <?php
  2. namespace Braintree\Result;
  3. use Braintree\RiskData;
  4. use Braintree\Util;
  5. use Braintree\UsBankAccount;
  6. /**
  7. * Braintree US Bank Account Verification Result
  8. *
  9. * This object is returned as part of an Error Result; it provides
  10. * access to the credit card verification data from the gateway
  11. *
  12. *
  13. * @package Braintree
  14. * @subpackage Result
  15. *
  16. * @property-read string $id
  17. * @property-read string $status
  18. * @property-read string $verificationMethod
  19. * @property-read \DateTime $verificationDeterminedAt
  20. * @property-read Braintree\UsBankAccount $usBankAccount
  21. *
  22. */
  23. class UsBankAccountVerification
  24. {
  25. // Status
  26. const FAILED = 'failed';
  27. const GATEWAY_REJECTED = 'gateway_rejected';
  28. const PROCESSOR_DECLINED = 'processor_declined';
  29. const VERIFIED = 'verified';
  30. const PENDING = 'pending';
  31. const TOKENIZED_CHECK = 'tokenized_check';
  32. const NETWORK_CHECK = 'network_check';
  33. const INDEPENDENT_CHECK = 'independent_check';
  34. const MICRO_TRANSFERS = 'micro_transfers';
  35. private $_attributes;
  36. private $_gatewayRejectionReason;
  37. private $_status;
  38. /**
  39. * @ignore
  40. */
  41. public function __construct($attributes)
  42. {
  43. $this->_initializeFromArray($attributes);
  44. $usBankAccount = isset($attributes['usBankAccount']) ?
  45. UsBankAccount::factory($attributes['usBankAccount']) :
  46. null;
  47. $this->usBankAccount = $usBankAccount;
  48. }
  49. /**
  50. * initializes instance properties from the keys/values of an array
  51. * @ignore
  52. * @access protected
  53. * @param <type> $aAttribs array of properties to set - single level
  54. * @return void
  55. */
  56. private function _initializeFromArray($attributes)
  57. {
  58. $this->_attributes = $attributes;
  59. foreach($attributes AS $name => $value) {
  60. $varName = "_$name";
  61. $this->$varName = $value;
  62. }
  63. }
  64. /**
  65. * @ignore
  66. */
  67. public function __get($name)
  68. {
  69. $varName = "_$name";
  70. return isset($this->$varName) ? $this->$varName : null;
  71. }
  72. /**
  73. * returns a string representation of the customer
  74. * @return string
  75. */
  76. public function __toString()
  77. {
  78. return __CLASS__ . '[' .
  79. Util::attributesToString($this->_attributes) . ']';
  80. }
  81. public static function allStatuses()
  82. {
  83. return [
  84. UsBankAccountVerification::FAILED,
  85. UsBankAccountVerification::GATEWAY_REJECTED,
  86. UsBankAccountVerification::PROCESSOR_DECLINED,
  87. UsBankAccountVerification::VERIFIED,
  88. UsBankAccountVerification::PENDING,
  89. ];
  90. }
  91. public static function allVerificationMethods()
  92. {
  93. return [
  94. UsBankAccountVerification::TOKENIZED_CHECK,
  95. UsBankAccountVerification::NETWORK_CHECK,
  96. UsBankAccountVerification::INDEPENDENT_CHECK,
  97. UsBankAccountVerification::MICRO_TRANSFERS,
  98. ];
  99. }
  100. }
  101. class_alias('Braintree\Result\UsBankAccountVerification', 'Braintree_Result_UsBankAccountVerification');