BraintreeResultError

Braintree Error Result.

Defined (1)

The class is defined in the following location(s).

/classes/lib/Braintree/Braintree/Result/Error.php  
  1. class Error extends Base 
  2. /** 
  3. * @var bool always false 
  4. */ 
  5. public $success = false; 
  6.  
  7. /** 
  8. * return original value for a field 
  9. * For example, if a user tried to submit 'invalid-email' in the html field transaction[customer][email],  
  10. * $result->valueForHtmlField("transaction[customer][email]") would yield "invalid-email" 
  11. * @param string $field 
  12. * @return string 
  13. */ 
  14. public function valueForHtmlField($field) 
  15. $pieces = preg_split("/[\[\]]+/", $field, 0, PREG_SPLIT_NO_EMPTY); 
  16. $params = $this->params; 
  17. foreach(array_slice($pieces, 0, -1) as $key) { 
  18. $params = $params[Util::delimiterToCamelCase($key)]; 
  19. if ($key != 'custom_fields') { 
  20. $finalKey = Util::delimiterToCamelCase(end($pieces)); 
  21. } else { 
  22. $finalKey = end($pieces); 
  23. $fieldValue = isset($params[$finalKey]) ? $params[$finalKey] : null; 
  24. return $fieldValue; 
  25.  
  26. /** 
  27. * overrides default constructor 
  28. * @ignore 
  29. * @param array $response gateway response array 
  30. */ 
  31. public function __construct($response) 
  32. $this->_attributes = $response; 
  33. $this->_set('errors', new ErrorCollection($response['errors'])); 
  34.  
  35. if(isset($response['verification'])) { 
  36. $this->_set('creditCardVerification', new CreditCardVerification($response['verification'])); 
  37. } else { 
  38. $this->_set('creditCardVerification', null); 
  39.  
  40. if(isset($response['transaction'])) { 
  41. $this->_set('transaction', Transaction::factory($response['transaction'])); 
  42. } else { 
  43. $this->_set('transaction', null); 
  44.  
  45. if(isset($response['subscription'])) { 
  46. $this->_set('subscription', Subscription::factory($response['subscription'])); 
  47. } else { 
  48. $this->_set('subscription', null); 
  49.  
  50. if(isset($response['merchantAccount'])) { 
  51. $this->_set('merchantAccount', MerchantAccount::factory($response['merchantAccount'])); 
  52. } else { 
  53. $this->_set('merchantAccount', null); 
  54.  
  55. if(isset($response['verification'])) { 
  56. $this->_set('verification', new CreditCardVerification($response['verification'])); 
  57. } else { 
  58. $this->_set('verification', null); 
  59.  
  60. /** 
  61. * create a printable representation of the object as: 
  62. * ClassName[property=value, property=value] 
  63. * @ignore 
  64. * @return string 
  65. */ 
  66. public function __toString() 
  67. $output = Util::attributesToString($this->_attributes); 
  68. if (isset($this->_creditCardVerification)) { 
  69. $output .= sprintf('%s', $this->_creditCardVerification); 
  70. return __CLASS__ .'[' . $output . ']';