Open Ezyweb-uk opened 3 years ago
The Stripe listPlans function is a GET request to https://api.stripe.com/v1/plans
so the limit parameter needs to be in a query string like https://api.stripe.com/v1/plans?limit=3
I was hoping that Omnipay gateway logic, knowing that ListPlansRequest HttpMethod is 'GET', would add any parameters set to a query string in the CURLOPT_URL. So I tried the following code in my project:
$request = $this->gateway->listPlans(array('limit' => 100))->send();
and
$request = $this->gateway->listPlans()->initialize(array('setLimit' => 100))->send();
But neither applied the limit parameter.
So I added the following class methods to ListPlansRequest:
public function getLimit()
{
return $this->getParameter('limit');
}
public function setLimit($limit)
{
return $this->setParameter('limit', $limit);
}
And extended method get EndPoint:
public function getEndpoint()
{
$query = '';
$limit = (int)$this->getLimit();
if($limit > 0) $query = '?' . http_build_query(array('limit' => $limit));
return $this->endpoint.'/plans' . $query;
}
And the following code in my project at last returned all 21 subscription plans:
$request = $this->gateway->listPlans(array('limit' => 100))->send();
Unless there's another way to pass a parameter to the GET request, it would be good if omnipay-stripe could be extended to accept the limit parameter in the listPlans request either as above or by some other method.
I've tested the listPlans() request and by default a maximum of 10 plans are returned. To return more plans I need to pass the parameter
array('limit' => 100)
but I've not been able to make this work.Even if I add the parameter in Gateway.php as follows the parameter is not logged in Stripe:
But it does work if I use the stripe-php library
UPDATE: I've tried adding the following function to omnipay\stripe\src\Message\ListPlansRequest.php
And changed my code to:
But still only 10 plans returned and the limit parameter is not logged as received in the Stripe request GET logs.