DiscountGateway.php 744 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. namespace Braintree;
  3. class DiscountGateway
  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() . '/discounts';
  18. $response = $this->_http->get($path);
  19. $discounts = ["discount" => $response['discounts']];
  20. return Util::extractAttributeAsArray(
  21. $discounts,
  22. 'discount'
  23. );
  24. }
  25. }
  26. class_alias('Braintree\DiscountGateway', 'Braintree_DiscountGateway');