AddOnGateway.php 952 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace Braintree;
  3. class AddOnGateway
  4. {
  5. /**
  6. *
  7. * @var Gateway
  8. */
  9. private $_gateway;
  10. /**
  11. *
  12. * @var Configuration
  13. */
  14. private $_config;
  15. /**
  16. *
  17. * @var Http
  18. */
  19. private $_http;
  20. /**
  21. *
  22. * @param Gateway $gateway
  23. */
  24. public function __construct($gateway)
  25. {
  26. $this->_gateway = $gateway;
  27. $this->_config = $gateway->config;
  28. $this->_config->assertHasAccessTokenOrKeys();
  29. $this->_http = new Http($gateway->config);
  30. }
  31. /**
  32. *
  33. * @return AddOn[]
  34. */
  35. public function all()
  36. {
  37. $path = $this->_config->merchantPath() . '/add_ons';
  38. $response = $this->_http->get($path);
  39. $addOns = ["addOn" => $response['addOns']];
  40. return Util::extractAttributeAsArray(
  41. $addOns,
  42. 'addOn'
  43. );
  44. }
  45. }
  46. class_alias('Braintree\AddOnGateway', 'Braintree_AddOnGateway');