PlanGateway.php 820 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace Braintree;
  3. class PlanGateway
  4. {
  5. private $_gateway;
  6. private $_config;
  7. private $_http;
  8. public function __construct($gateway)
  9. {
  10. $this->_gateway = $gateway;
  11. $this->_config = $gateway->config;
  12. $this->_config->assertHasAccessTokenOrKeys();
  13. $this->_http = new Http($gateway->config);
  14. }
  15. public function all()
  16. {
  17. $path = $this->_config->merchantPath() . '/plans';
  18. $response = $this->_http->get($path);
  19. if (key_exists('plans', $response)){
  20. $plans = ["plan" => $response['plans']];
  21. } else {
  22. $plans = ["plan" => []];
  23. }
  24. return Util::extractAttributeAsArray(
  25. $plans,
  26. 'plan'
  27. );
  28. }
  29. }
  30. class_alias('Braintree\PlanGateway', 'Braintree_PlanGateway');