Search code examples
phplaravelstripe-paymentslaravel-cashier

How to retrieves plans of product in stripe?


My stripe account has a Product with plans and I created a new product with two plans. I m using Laravel cashier and I want to retrieve selected product's plans.

    $stripe = new StripeClient(config('services.stripe.secret'));
    $product = $stripe->products->retrieve(config('services.stripe.product'),[]);
    //$plans = $product->plans();//something like that

But I m unable to find a way to achieve this. the following method retrieves all plans from all products.

        $stripe = new \Stripe\StripeClient(\config('services.stripe.secret'));
        $plans = $stripe->plans->all();

Can you please help me to achieve this? Thanks


Solution

  • I have found the answer of my Question.Just pass the product id in array like this,

     $stripe = new \Stripe\StripeClient(\config('services.stripe.secret'));
     $plans = $stripe->plans->all(['product'=>config('services.stripe.product') ]);