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

MoeSaid's avatar

flexible subscription plan with stripe

Hi mates,

so what's the best practise of having a custom build plan price, let's say that I have different plans with different rates $ 100, $ 200, $ 300, $400 and then I do have add-ons that can add on the price with no limitation how that can be done?

is there any way that the price plan can be handled as a variable?

0 likes
4 replies
bugsysha's avatar

Something like this? I know this was possible before. Not sure if they've changed their API.

\Stripe\Charge::create([
    'amount'   => $amount,
    'card'     => $card,
    'currency' => 'usd',
    'customer' => $customer,
    'metadata' => $meta,
]);
MoeSaid's avatar

that how you make a one-time charge, am talking about using casher normally but instead of using a fixed plans i wanna see if can somehow have fixability with the plan price

bugsysha's avatar

Never tried that. Post a solution when you find it :)

depsimon's avatar

You should use metered billing.

There are multiple strategies for this. The simplest solution might be to have a plan that reflects the smaller common divider.

$plan = \Stripe\Plan::create([
    'currency' => 'usd',
    'interval' => 'month',
    'product' => 'prod_CHxGUqw1dyKsDM',
    'nickname' => 'Unit Plan',
    'amount' => 100, // = 
    'usage_type' => 'metered',
]);

Then you record the usages.

// Monthly Plan
\Stripe\SubscriptionItem::createUsageRecord(
  '{{SUBSCRIPTION_ITEM_ID}}',
  [
    'quantity' => 100, // = 100x
    'timestamp' => 1522893428,
    'action' => "increment",
  ]
);
//  Add-on
\Stripe\SubscriptionItem::createUsageRecord(
  '{{SUBSCRIPTION_ITEM_ID}}',
  [
    'quantity' => 25, // = 25
    'timestamp' => 1522893428,
    'action' => "increment",
  ]
);

Please or to participate in this conversation.