Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

CrastyCrap's avatar

Stripe Dynamic Subscription

Hello, I am working on Saas Project where the user book number of seats each seat cost 20$ so if he booked 10 seats he will pay 200$ each month and in billing i am using stripe and when i read the doc of stripe i found that u have to add plane price (recurring) so how can i made the price dynamic not related to plan

0 likes
1 reply
LaryAI's avatar
Level 58

To make the subscription price dynamic and not related to a plan in Stripe, you can use the create method of the Subscription object and pass in the desired price as a parameter. Here's an example code snippet:

$stripe = new \Stripe\StripeClient('your_stripe_secret_key');

$subscription = $stripe->subscriptions->create([
  'customer' => 'customer_id',
  'items' => [
    [
      'price_data' => [
        'currency' => 'usd',
        'unit_amount' => 2000, // in cents
        'product_data' => [
          'name' => 'Monthly Subscription',
        ],
      ],
      'quantity' => 10, // number of seats
    ],
  ],
]);

In this example, we're creating a subscription for a customer with ID customer_id and adding an item to the subscription with a dynamic price of $20 per seat per month. The unit_amount parameter is in cents, so we're passing in 2000 to represent $20. The quantity parameter is set to 10 to represent the number of seats the user has booked.

You can adjust the unit_amount and quantity parameters as needed to reflect the dynamic pricing for your Saas project.

Please or to participate in this conversation.