#soko-checkout-testclock

1 messages · Page 1 of 1 (latest)

leaden geyserBOT
clever summit
#

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

upbeat dust
#

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.

clever summit
#

Once you've created that price, you'd just use the same Price ID for every subscription you'd create and include the quantity

upbeat dust
#

// 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

clever summit
#

Can you share that request ID or checkout session ID with me so I can take a look?

clever summit
#

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

clever summit
#

What did you get from that log?

#

Did you get quantity 1?

upbeat dust
#

yes... I think I figured it out.

upbeat dust
#

Is there a way to change recurring date for testing?
To see what happens in the after a month that customer has subscribed

clever summit
#

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

leaden geyserBOT