#soko-checkout-testclock
1 messages · Page 1 of 1 (latest)
Hello! What specifically are you having trouble with? I don't think we have an end to end example for this, but if you give me some details I can help
This is the method I'm using right now, but this creates a new price every time someone subscribe
if ($package === 'starter') {
$packageName = 'Starter Package';
$unit_amount = 10 + floor(($cust_count - 10) / 100) * 400;
// echo $unit_amount . '<br/>';
$price_new = $stripe->prices->create([
'unit_amount' => $unit_amount,
'currency' => 'usd',
'recurring' => ['interval' => 'month'],
'product' => 'prod_OEtVg9Xj5cdED0',
]);
// print_r($price_new);
$priceIds['starter'] = $price_new->id;
// print_r($priceIds);
// die;
}
I don't want to create new price every time, I want to charge them based on $cust_count (numbers of customers), using these tiers.
I looked at the docs, coldnt make it work.
Gotcha - so you'll probably want to start with this example (https://stripe.com/docs/products-prices/pricing-models#graduated-pricing) which demonstrates how to create a graduated tiered price
Once you've created that price, you'd just use the same Price ID for every subscription you'd create and include the quantity
// Determine the quantity of units based on the number of customers ($cust_count)
$quantity = $cust_count;
$checkout_session = $stripe->checkout->sessions->create([
'mode' => 'subscription',
'line_items' => [
[
'price' => $priceIds[$package],
'quantity' => $quantity,
],
],
$cust_count is 680, but the price is still $0.10
Can you share that request ID or checkout session ID with me so I can take a look?
Can you log $quantity right before your code that calls $stripe->checkout->sessions->create ?
Right now it looks like your request is still passing in quantity: 1 for some reason, so logging would be the first step
yes... I think I figured it out.
Is there a way to change recurring date for testing?
To see what happens in the after a month that customer has subscribed
The way to change this would be using Test Clocks - https://stripe.com/docs/billing/testing/test-clocks
If you want to test this with Checkout you'd have to first create the customer with a test clock, and then pass that customer ID to the CHeckout Session