/** * Constructor. * * @param \Cartalyst\Stripe\ConfigInterface $config * @return void */ public function __construct(ConfigInterface $config) { parent::__construct(['base_url' => $config->base_url]); // Set the Config repository instance $this->config = $config; // Prepare the request headers $this->prepareRequestHeaders(); // Register some before events $this->getEmitter()->on('before', function (BeforeEvent $event) { // Get the event request $request = $event->getRequest(); // Set the Stripe API key $request->setHeader('Authorization', "Basic " . base64_encode($this->config->api_key)); // Set the query aggregator $request->getQuery()->setAggregator(Query::phpAggregator(false)); }); }
/** * Get the aggregator used to join multi-valued field parameters * * @return callable */ final protected function getAggregator() { if (!$this->aggregator) { $this->aggregator = Query::phpAggregator(); } return $this->aggregator; }
public function testPhpEncodesNoNumericIndices() { $agg = Query::phpAggregator(false); $result = $agg($this->encodeData); $this->assertEquals(array('t[v1][]' => ['a', '1'], 't[v2]' => ['b'], 't[v3][v4]' => ['c'], 't[v3][v5]' => ['d']), $result); }