Skip to content
Code-Schnipsel Gruppen Projekte
Commit 513be377 erstellt von Patrick Müller's avatar Patrick Müller
Dateien durchsuchen

fix: billing plan pagination

Übergeordneter 7c8b0420
No related branches found
No related tags found
Keine zugehörigen Merge Requests gefunden
......@@ -27,16 +27,19 @@ function ($searchParams) {
$perPage = (int)$searchParams['perPage'];
}
$list = BillingPlans::getBillingPlanList($startId, $perPage);
$Result = BillingPlans::getBillingPlanList($startId, $perPage);
$billingPlans = [];
$count = 0;
if (!empty($list)) {
$billingPlans = $list['data'];
$count = count($billingPlans);
foreach ($Result->autoPagingIterator() as $BillingPlan) {
$billingPlans[] = $BillingPlan->toArray();
}
$count = 0;
if (!empty($billingPlans)) {
$count = \count($billingPlans);
if ($list['has_more']) {
if ($Result->has_more) {
$count++;
}
}
......
......@@ -8,6 +8,7 @@
use QUI\ERP\Payments\Stripe\Provider;
use QUI\ERP\Payments\Stripe\AbstractBasePayment;
use QUI\ERP\Products\Handler\Products as ProductsHandler;
use Stripe\Collection;
use Stripe\Exception\ApiErrorException;
use Stripe\Product as StripeProduct;
use Stripe\Plan as StripePlan;
......@@ -116,7 +117,7 @@ public static function deleteBillingPlan($planId)
*
* @param string $startId (optional) - Stripe plan ID to start from
* @param int $pageSize (optional) - Number of plans per page [range: 1 to 100]
* @return array
* @return Collection
*
* @throws ApiErrorException
*/
......@@ -134,19 +135,11 @@ public static function getBillingPlanList($startId = null, $pageSize = 10)
'limit' => $pageSize
];
// if ($startId) {
// $searchParams['starting_after'] = $startId;
// }
$billingPlans = [];
$results = StripePlan::all($searchParams);
foreach ($results->autoPagingIterator() as $BillingPlan) {
$billingPlans[] = $BillingPlan->toArray();
if ($startId) {
$searchParams['starting_after'] = $startId;
}
return $billingPlans;
return StripePlan::all($searchParams);
}
/**
......
0% oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren