BraintreeCreditCardVerificationGateway

The Paid Memberships Pro Braintree CreditCardVerificationGateway class.

Defined (1)

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

/includes/lib/Braintree/lib/Braintree/CreditCardVerificationGateway.php  
  1. class CreditCardVerificationGateway 
  2. private $_gateway; 
  3. private $_config; 
  4. private $_http; 
  5.  
  6. public function __construct($gateway) 
  7. $this->_gateway = $gateway; 
  8. $this->_config = $gateway->config; 
  9. $this->_config->assertHasAccessTokenOrKeys(); 
  10. $this->_http = new Http($gateway->config); 
  11.  
  12. public function create($attributes) 
  13. $response = $this->_http->post($this->_config->merchantPath() . "/verifications", ['verification' => $attributes]); 
  14. return $this->_verifyGatewayResponse($response); 
  15.  
  16. private function _verifyGatewayResponse($response) 
  17.  
  18. if(isset($response['verification'])) { 
  19. return new Result\Successful( 
  20. CreditCardVerification::factory($response['verification']) 
  21. ); 
  22. } else if (isset($response['apiErrorResponse'])) { 
  23. return new Result\Error($response['apiErrorResponse']); 
  24. } else { 
  25. throw new Exception\Unexpected( 
  26. "Expected transaction or apiErrorResponse" 
  27. ); 
  28.  
  29. public function fetch($query, $ids) 
  30. $criteria = []; 
  31. foreach ($query as $term) { 
  32. $criteria[$term->name] = $term->toparam(); 
  33. $criteria["ids"] = CreditCardVerificationSearch::ids()->in($ids)->toparam(); 
  34. $path = $this->_config->merchantPath() . '/verifications/advanced_search'; 
  35. $response = $this->_http->post($path, ['search' => $criteria]); 
  36.  
  37. return Util::extractattributeasarray( 
  38. $response['creditCardVerifications'],  
  39. 'verification' 
  40. ); 
  41.  
  42. public function search($query) 
  43. $criteria = []; 
  44. foreach ($query as $term) { 
  45. $criteria[$term->name] = $term->toparam(); 
  46.  
  47. $path = $this->_config->merchantPath() . '/verifications/advanced_search_ids'; 
  48. $response = $this->_http->post($path, ['search' => $criteria]); 
  49. $pager = [ 
  50. 'object' => $this,  
  51. 'method' => 'fetch',  
  52. 'methodArgs' => [$query] 
  53. ]; 
  54.  
  55. return new ResourceCollection($response, $pager);