CreditCardVerification.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. namespace Braintree\Result;
  3. use Braintree\RiskData;
  4. use Braintree\Util;
  5. /**
  6. * Braintree Credit Card Verification Result
  7. *
  8. * This object is returned as part of an Error Result; it provides
  9. * access to the credit card verification data from the gateway
  10. *
  11. *
  12. * @package Braintree
  13. * @subpackage Result
  14. *
  15. * @property-read string $avsErrorResponseCode
  16. * @property-read string $avsPostalCodeResponseCode
  17. * @property-read string $avsStreetAddressResponseCode
  18. * @property-read string $cvvResponseCode
  19. * @property-read string $status
  20. *
  21. */
  22. class CreditCardVerification
  23. {
  24. // Status
  25. const FAILED = 'failed';
  26. const GATEWAY_REJECTED = 'gateway_rejected';
  27. const PROCESSOR_DECLINED = 'processor_declined';
  28. const VERIFIED = 'verified';
  29. private $_attributes;
  30. private $_amount;
  31. private $_avsErrorResponseCode;
  32. private $_avsPostalCodeResponseCode;
  33. private $_avsStreetAddressResponseCode;
  34. private $_currencyIsoCode;
  35. private $_cvvResponseCode;
  36. private $_gatewayRejectionReason;
  37. private $_status;
  38. /**
  39. * @ignore
  40. */
  41. public function __construct($attributes)
  42. {
  43. $this->_initializeFromArray($attributes);
  44. }
  45. /**
  46. * initializes instance properties from the keys/values of an array
  47. * @ignore
  48. * @access protected
  49. * @param <type> $aAttribs array of properties to set - single level
  50. * @return void
  51. */
  52. private function _initializeFromArray($attributes)
  53. {
  54. if(isset($attributes['riskData']))
  55. {
  56. $attributes['riskData'] = RiskData::factory($attributes['riskData']);
  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. CreditCardVerification::FAILED,
  85. CreditCardVerification::GATEWAY_REJECTED,
  86. CreditCardVerification::PROCESSOR_DECLINED,
  87. CreditCardVerification::VERIFIED
  88. ];
  89. }
  90. }
  91. class_alias('Braintree\Result\CreditCardVerification', 'Braintree_Result_CreditCardVerification');