#Drewbie - Pricing
1 messages ยท Page 1 of 1 (latest)
so let me explain my business quickly
I have a laundry service company
its a flat monthly fee of 200$
but that only includes up to 300lbs of laundry per month
once a customer goes over that amount I charge $1 per pound of laundry
I have pricing setup for the 200
but idk how to charge past the threshold
I was reviewing your past thread and I think my colleague had a great example of how you could achieve this
So you've set up the metered billing? with a $0 price up to 300lbs ?
when a customer goes to register it only shows the metered pricing and not the up front 200$
yes i did that
first i setup the monthly fee then as one price
then created another price for usage
When the customer goes to register, what are you using to provide that interface?
checkout
basically im trying to get checkout to tell the customer its 200 per month and charge them right away but also let them know if they go over 300lb it is 1 dollar per pound
Okay. Can you send me a screenshot of the Checkout screen and let me know what you expect to see?
This looks like perhaps the Checkout session is only getting configured with the metered billing price.
yes thats correct
i do believe its a problem with my code
can i show you what i have there?
You basically can create the Checkout session with multiple line_items objects, each corresponding to the pricing models you want to apply
Please feel free to share you code, that's always helpful
so for every price i have i need a new object?
const session = await stripe.checkout.sessions.create({
billing_address_collection: 'auto',
payment_method_types: ['card'],
line_items: [
{
price: prices.data[0].id,
// price: 'price_1JoWxZFloSBcKpu8Se672913',
// For metered billing, do not pass quantity
// quantity: 1,
},
],
mode: 'subscription',
allow_promotion_codes: true,
success_url: ${YOUR_DOMAIN}?success=true&session_id={CHECKOUT_SESSION_ID},
cancel_url: ${YOUR_DOMAIN}?canceled=true,
});
If you want to apply multiple prices you will want to have multiple objets in the line_items with each of the pricing models you wish to apply.
ok let me try that
looks good
thanks for the help
when i want to add usage. Do i do that in my dashboard?
Hey, I have to run but @sand geode is here to answer any further questions about this. I hope you can get it worked out without any trouble!
Happy to help ๐
when i want to add usage. Do i do that in my dashboard?
Oh, btw here's a doc on usage: https://stripe.com/docs/billing/prices-guide#reporting-usage
ok great
I haven't seen it in the dashboard but the API should get you there.
perfect
๐ Hey there, just reading through the messages here, have you got the suggested changes working like you want them now @earnest aurora
ya everything looks good
need to read through the reporting docs i was sent
just questions
does stripe accept in person payments
OK great, yea I looked at your recent requests to create checkout session and they appear to include both the license + metered prices ๐ looks great ๐
ok let me know if you have questions about reporting usage and i'll do my best to help
Yes, Stripe has a "Terminal" product to support in person payments with physical cards!
You can read about this here: https://stripe.com/terminal
ok will do...thanks for sending terminal docs
NP! As with usage let me know if you have any questions ๐
working with it now. I will let you know
alright so im reading the docs
i dont understand when im used to create this usage report
can you describe what youre trying to accomplish? you mean to track usage of your service (in pounds) to bill for use over 300?
yes
i pick weekly
so theres no usage typically for the first two weeks
because it takes time to reach the threshold
how do i report the usage in week 3 or week 4 of the month
ah, so, you can two choices
1/ as you've done, set the price for up to 300 to be zero, then charge after 300. but for this you need to report all usage in order to get to 300 and start charging
2/ alternatively, if you track the "free" usage internally, you can skipp that, and set the metered plan to charge starting at 1 unit, and only report the overage
in that case the usage would be "pounds over 300" instead of "pounds"
sticking with your current setup, 1/, you'd report all usage with the timestamp of that usage, however granular you want to make that
const stripe = require('stripe')('');
stripe.subscriptionItems.createUsageRecord(
'{{SUBSCRIPTION_ITEM_ID}}',
{
quantity: 100,
timestamp: 1638911316,
action: 'increment',
}
);
i pulled this from the docs
where am I inserting this block of code into my application
before i help with that, can you remove your secret key from that please
use sk_test_123 or another placeholder
you'll want to roll your key to prevent anybody from impersonating you: https://stripe.com/docs/keys#rolling-keys
ok ill do that
This would go in your code that tracks and updates usages on whatever schedule you choose -- up to you
can you send me an application that uses metered billing as a reference
what do you mean? I'm not sure I've got something like that handy but let me take a look at our samples
If you tracking usage in a database, perhaps you watn to push a copy of each record to Stripe when you log that, or after some weekly report etc
it really depends on what youre doing in your own code to track customer usage
im not tracking usage at all right now...im trying to add it in
Hey, we do have a sample with that ๐
So you can see the usage record creation here: https://github.com/stripe-samples/subscription-use-cases/blob/master/usage-based-subscriptions/server/node/reportUsage.js#L24-L40
this is just a sketch -- you might set this up as an internal API endpoint you call, for example, after each customer interaction where you measure usage
ie, maybe after each drop off or pickup, whenever you weigh
ok so i need to actually track the usage in a database
i cant just count the pounds over and bill the customer
i actually need to input that usage data
well you need to tell stripe what the usage is -- its probably a good idea to record this yourself too to double check, but not strictly required
if you sent us every usage, you wouldnt need to record it (even if a good idea)
ya i see i can use an interval that reports every 24 hours
so to do that i would need to input the usage manually into the database
the interval doesnt really matter if you use increment type usage (the default)
this will just be added up for the billing period when the invoice is generated
ok I am going to give it a shot with the example you sent me
ok cool! yes, you should consider when the right time to record usage is. whenever your staff weight and accept or weight and return items to a customer is likely a good time, but this is really up to you and your business needs.
if you have more question my colleague @fierce niche is online