#Drewbie - Pricing

1 messages ยท Page 1 of 1 (latest)

amber lion
#

Hi! Okay, what seems to be the issue?

earnest aurora
#

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

amber lion
#

I was reviewing your past thread and I think my colleague had a great example of how you could achieve this

earnest aurora
#

so i did that

#

i think my problem is with my code then

amber lion
#

So you've set up the metered billing? with a $0 price up to 300lbs ?

earnest aurora
#

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

amber lion
#

When the customer goes to register, what are you using to provide that interface?

earnest aurora
#

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

amber lion
#

Okay. Can you send me a screenshot of the Checkout screen and let me know what you expect to see?

earnest aurora
#

where it says price varies i need it to say 200 per month

amber lion
#

This looks like perhaps the Checkout session is only getting configured with the metered billing price.

earnest aurora
#

yes thats correct

#

i do believe its a problem with my code

#

can i show you what i have there?

amber lion
#

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

earnest aurora
#

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,
});

amber lion
#

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.

earnest aurora
#

ok let me try that

#

looks good

#

thanks for the help

#

when i want to add usage. Do i do that in my dashboard?

amber lion
#

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!

earnest aurora
#

ok its looking good so far

#

thanks again

amber lion
#

Happy to help ๐Ÿ‘‹

earnest aurora
#

when i want to add usage. Do i do that in my dashboard?

amber lion
earnest aurora
#

ok great

amber lion
#

I haven't seen it in the dashboard but the API should get you there.

earnest aurora
#

perfect

sand geode
#

๐Ÿ‘‹ Hey there, just reading through the messages here, have you got the suggested changes working like you want them now @earnest aurora

earnest aurora
#

ya everything looks good

#

need to read through the reporting docs i was sent

#

just questions

#

does stripe accept in person payments

sand geode
#

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

earnest aurora
#

ok will do...thanks for sending terminal docs

sand geode
#

NP! As with usage let me know if you have any questions ๐Ÿ™‚

earnest aurora
#

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

sand geode
#

can you describe what youre trying to accomplish? you mean to track usage of your service (in pounds) to bill for use over 300?

earnest aurora
#

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

sand geode
#

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

earnest aurora
#

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

sand geode
#

before i help with that, can you remove your secret key from that please

#

use sk_test_123 or another placeholder

earnest aurora
#

ok ill do that

sand geode
earnest aurora
#

can you send me an application that uses metered billing as a reference

sand geode
#

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

earnest aurora
#

im not tracking usage at all right now...im trying to add it in

sand geode
#

Hey, we do have a sample with that ๐Ÿ˜„

#

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

earnest aurora
#

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

sand geode
#

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)

earnest aurora
#

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

sand geode
#

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

earnest aurora
#

ok I am going to give it a shot with the example you sent me

sand geode
#

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