diff --git a/composer.json b/composer.json index c5cfbb6..2195a4a 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "craftcms/commerce-stripe", "description": "Stripe integration for Craft Commerce 2 & 3", - "version": "2.2.3", + "version": "2.3.0", "type": "craft-plugin", "keywords": [ "stripe", diff --git a/src/base/SubscriptionGateway.php b/src/base/SubscriptionGateway.php index 821afe6..b16cd56 100644 --- a/src/base/SubscriptionGateway.php +++ b/src/base/SubscriptionGateway.php @@ -285,11 +285,12 @@ public function getSubscriptionPlans(): array $plans = StripePlan::all([ 'limit' => 100, ]); + $output = []; $planProductMap = []; $planList = []; - + $offset = 100; if (\count($plans->data)) { foreach ($plans->data as $plan) { /** @var StripePlan $plan */ @@ -297,6 +298,20 @@ public function getSubscriptionPlans(): array $planProductMap[$plan['id']] = $plan['product']; $planList[] = $plan; } + while ($plans->has_more) { + + $plans = StripePlan::all([ + 'limit' => 100, + 'offset' => $offset + ]); + $offset = $offset + 100; + foreach ($plans->data as $plan) { + /** @var StripePlan $plan */ + $plan = $plan->jsonSerialize(); + $planProductMap[$plan['id']] = $plan['product']; + $planList[] = $plan; + } + } /** @var Collection $products */ $products = StripeProduct::all([ @@ -305,13 +320,28 @@ public function getSubscriptionPlans(): array ]); $productList = []; - + $offset = 100; if (\count($products->data)) { foreach ($products->data as $product) { /** @var StripeProduct $product */ $product = $product->jsonSerialize(); $productList[$product['id']] = $product; } + + while ($products->has_more) { + + $products = StripeProduct::all([ + 'limit' => 100, + 'ids' => array_values($planProductMap), + 'offset' => $offset + ]); + $offset = $offset + 100; + foreach ($products->data as $product) { + /** @var StripeProduct $product */ + $product = $product->jsonSerialize(); + $productList[$product['id']] = $product; + } + } } foreach ($planList as $plan) { @@ -742,4 +772,4 @@ protected function saveSubscriptionInvoice(array $stripeInvoice, Subscription $s return $invoice; } -} +} \ No newline at end of file