BraintreeMerchantGateway

The PayPal for WooCommerce Braintree MerchantGateway class.

Defined (1)

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

/classes/lib/Braintree/Braintree/MerchantGateway.php  
  1. final class MerchantGateway 
  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->assertHasClientCredentials(); 
  10. $this->_http = new Http($gateway->config); 
  11. $this->_http->useClientCredentials(); 
  12.  
  13. public function create($attribs) 
  14. $response = $this->_http->post('/merchants/create_via_api', ['merchant' => $attribs]); 
  15. return $this->_verifyGatewayResponse($response); 
  16.  
  17. private function _verifyGatewayResponse($response) 
  18. if (isset($response['response']['merchant'])) { 
  19. // return a populated instance of merchant 
  20. return new Result\Successful([ 
  21. Merchant::factory($response['response']['merchant']),  
  22. OAuthCredentials::factory($response['response']['credentials']),  
  23. ]); 
  24. } else if (isset($response['apiErrorResponse'])) { 
  25. return new Result\Error($response['apiErrorResponse']); 
  26. } else { 
  27. throw new Exception\Unexpected( 
  28. "Expected merchant or apiErrorResponse" 
  29. );