#Wilma-checkout-pricing

1 messages · Page 1 of 1 (latest)

violet forum
#

Hello! I believe this should be possible - have you tried it out yet?

vapid nest
#

Would you be able to use

Stripe::Subscription.create({
  customer: '{{CUSTOMER_ID}}',
  items: [
    {
      price: '{{base_fee_price_id}}',
      quantity: 1,
    },
    {
      price: '{{per_seat_price_id}}',
      quantity: 3,
    },
  ],
})
#

And instead call Stripe::Checkout::Session.create({

violet forum
#

Yeah, to my knowledge that should be fine - but let me confirm something really quick. In this case, is the "per_sear_price_id` the recurring price that is metered?

vapid nest
#

base_fee would be subscription fee. per_seat would be metered billing.

#

I get Received unknown parameter: items

violet forum
#

Sorry I should've been more clear - you'd need to modify the request to match what Checkout is expecting. While Subscription creation expects items, Checkout Session creation would want line_items.

I also want to add - you shouldn't be specifying a quantity with your per_seat price. You'd specify the usage separately after the subscription has been created

vapid nest
#

Okay, so line_items work.

#

I see.

#

It's unclear to me how this works.

#

Step 1: Create a subscription for the user.

    session = Stripe::Checkout::Session.create({
      customer_email: params['email'],
      metadata: {
        customer_id: params['id']
      },

      success_url: 'https://untitledtesting.loca.lt/success',
      cancel_url: 'https://untitledtesting.loca.lt/cancel',
      mode: 'subscription',
      line_items: [{
        price: '{{flat_monthly_fee_price_id}}',
        quantity: 1,
      },
      {
        price: '{{metered_usage_price_id}}',
        quantity: 1,
      }],
    })
#

But how do I update Stripe on what the actual usage of the month was?

#

But the error says otherwise: Quantity should not be specified where usage_type is metered. Remove quantity from line_items[1]``

#

The checkout session looks correct, so I guess the question is how to update Stripe on actual usage.

violet forum
#

That doc is working with Subscription though, not Checkout Sessions so I wouldn't be surprised if Subscriptions allow you to pass in quantity: 1 for a metered price

vapid nest
#

Okay that makes sense.

#

In my case, I'd expect a user to perform a paid action once a week. You recommend this is a background job running every 24 hrs or just as a call immediately after user incurs the usage?

#

Also, thank you for your help. I think Stripe Checkout would benefit from a bit more detailed documentation on 'complex' use cases like this

violet forum
#

It really depends on your integration to decide which option you go for - either will work! As an example, if your users may potentially be doing a lot of paid actions in bursts, it may make more sense to batch all those actions together and report that usage to us in one bundle to minimize the number of API requests you're making. On the other hand, if you're just making a couple of requests here and there, reporting usage after the user has done the action would be fine

vapid nest
#

That's helpful and makes sense.