#mattc

1 messages · Page 1 of 1 (latest)

molten wharfBOT
cursive bear
#

No, you can add as many prices as you want to a product

unreal harness
#

perfect - there are many its an apartment with many prices for different nights

cursive bear
#

If you are changing it per night, you might find it easier to only create the Product and then use the price_data hash to define a one time price each time you charge

unreal harness
#

a product for each night

#

or one product being the apartment

cursive bear
#

One product for the apartment and a price for each night

unreal harness
#

so 365 prices on one product?

cursive bear
#

But the price doesn't need to be its own Price object, you can just define it per Checkout Session or Invoice

unreal harness
#

ah k so i dont need to create a price each time or lookup a price

cursive bear
#

Can you tell me more about how you want to charge for this apartment? Will every single night cost a different amount?

unreal harness
#

i can simple add a price each checkout without an item existing

#

not every night but it may get updated closer to dates if still available

#

so it will fluctuate

cursive bear
unreal harness
cursive bear
#

Correct

unreal harness
#

these properties dont look to exist

#

Name = "T-shirt",
Description = "Comfortable cotton t-shirt",
Amount = 2000,
Currency = "usd",

#

in namespace Stripe.Checkout

cursive bear
#

What section of that doc are you looking at?

#

Description is on the Product

#

Amount is now UnitAmount

unreal harness
#

under Server-side code for inline items

cursive bear
#

Currency should still exist on the PriceData

unreal harness
#

.net example

cursive bear
#

The red sections meant that that is deprecated

unreal harness
#

ok maybe just example out of date

#

ok

cursive bear
#

Use the code from the green section

unreal harness
#

does this mean no product will be create when its price data in effect

#

in the portal

#

and its dynamic

cursive bear
#

Correct, if you provide a pre-defined product we won't create a new product

#

You can also create one-time products with the product_data hash, but here it will probably make more sense to use a pre-made Product object if this is always the same thing

unreal harness
#

so for example i have an apartment and one price for one night and another price for another night

#

should i always use price data

cursive bear
#

Yes. Unless you are in a situation where the room will always be one of three pre-defined prices it will probably make sense to just use one-time prices

unreal harness
#

one time prices means price_data?

cursive bear
#

It sounds like here you are calculating the price each night right? In that case one time prices will be the easiest to work with

#

Correct. One time prices means price_data

unreal harness
#

yes i am calculating

#

then there is a cleaning cost

#

should cleaning cost be a product with a price

#

and night prices be price data in effect then

#

in my list or SessionLineItemOptions

cursive bear
#

You can do it either way. Having it be a separate Product might make the cost breakdown clearer

unreal harness
#

as in a separate product for every booking?

#

something like this

#

think i need to go with something like this

#

can you apply a discount for checkout too?

#

i.e over 30 days 20% discount applied

cursive bear
#

You can do a separate product each time if you want. Either would work

#

Yes Checkout supports discounts. Are you trying to add the discount to the session via the API or to allow your users to add the code themselves?

unreal harness
#

i think maybe too many products

#

i would apply it

#

say for a month booking 20%

#

of nightly rate

cursive bear
unreal harness
#

i can apply this to of the items right

#

as in the nightly price

cursive bear
#

Right

unreal harness
#

so 20% of the nightly price for 30 days and cleaning fee is standard and no discount

#

this is possible?

cursive bear
#

So that would be easy to do for a pre-defined product, but you cannot create a discount ahead of time that will only work for a product_data product

unreal harness
#

product_data cant apply a discount?

cursive bear
#

You can

#

But you can't restrict a coupon to only work for a product_data product

unreal harness
#

so i could effectively end up with 365 products?

cursive bear
#

So if you want the coupon to apply to the room rate but not cleaning then you will need to use pre-defined Product object

unreal harness
#

one for each day?

cursive bear
#

More than that, we will create a new object each session

unreal harness
#

wont this be unmanagable

cursive bear
#

So if you rent it more than 365 times then Checkout will keep creating products

#

Yes, so you should not use the product_data hash and should instead create one Product object per apartment

unreal harness
#

one product for each booking

#

or one product with multiple prices?

#

as in product 1 - apartment 1 for 5th July - 10th July/ product 2 - apartment 1 for 11th July - 20th July

#

or product 1 - apartment 1

#

price 1 - 5th July to 10 July - £300

#

price 2 - 11 July - 20th july - £500

cursive bear
#

The way that I would do it is product 1 -> apartment 1 and then a new price per booking

unreal harness
#

ok and i can apply the discount this way also right?

#

to the nightly price

#

i.e 30 days booking 20% discount to nighly rate and then standard cleaning fee £50

molten wharfBOT
cursive bear
#

Yes, you could create a 20% off coupon with a one month duration that only applies to the apartment product

unreal harness
#

ok

#

so one product multiple prices

#

apply discount to price

#

rather than product right?

#

i.e. product 1 is apartment 1

#

user books thirty days - add a price - 01/07/2023-30/07/2023 and apply a discount to this price?

cursive bear
unreal harness
#

so i need a new product for every booking that has a discount

#

?

cursive bear
#

No

unreal harness
#

i thought i passed in the price id to the sessionlineitemsoption

cursive bear
#

You can but that is irrelevant to how the discount works

#

I thought you wanted to charge an apartment fee and a cleaning fee but only have the 20% discount apply to the apartment fee

#

For that you will want the apartment fee and cleaning fee to be separate products

unreal harness
#

thats correct

cursive bear
#

You can create a 20% coupon that applies specifically to the apartment fee product

#

That will work regardless of whether you use the price_data hash or whether you create prices and pass in their IDs

unreal harness
#

do i can use a coupon with price_data

cursive bear
#

You don't

unreal harness
#

cant?

cursive bear
#

You can, just not how you are describing

#

Notice that the discounts property is at the top level of that call. It applies to the entire Checkout Session

#

And remember that coupons only apply to specific products

unreal harness
#

would this work

#

how would it apply the coupon to the price data

cursive bear
#

I was just explaining how that wouldn't work

#

I think you need to read the docs that I sent you

unreal harness
#

ok so forget pricedata

#

like this?

cursive bear
#

Yes

#

I would reccommend testing your code to check how it works though

#

We can't verify too much just by looking at it

unreal harness
#

ok hows the coupon link to the product id?

cursive bear
unreal harness
#

ok will do thanks for your help

#

would you recommend doing lookups on prices and updates in case another user did not complete checkout

#

and an update if the price has changed

#

or just double up and add the price again

cursive bear
#

Unfortunately the prices on Checkout Sessions can't be updated. You would need to delete the old one and create a new one. How often will your prices change like this?

#

I am unclear on this new scenario, can you give me an example of how the price might change and what you would want to do there?

unreal harness
#

ok so user a goes to checkout 01/06/2023-10/06/2023 for £400

#

doesnt complete

#

user b comes back and 01/06/2023-10/06/2023 prices have changed as its 3 weeks later

cursive bear
#

Checkout Sessions only last for 24 hours, so you will have to create a new Session if they come back more than a day later

unreal harness
#

and a new price object right?

#

as the existing price object that i created will not longer be valid

#

or update the existing price item?

cursive bear
#

Yes it will need to be a new Price object. If you created it with price_data then the old one will already be invalid

unreal harness
#

i cant use price_data right

#

as i may need to apply a discount

#

discounts dont work with price_data right

#

or you saying bets to use price_data if there is no discount

#

i.e. user 1 comes along wants to book apartment 1 for 30 days - i want to apply a 20% discount

#

they dont complete

#

user 2 comes along 30 days for the same dates and the prices have changed

#

i basically need to store the details locally right for the dates and see if i already have a product then validate the price and if updated update right?

cursive bear
#

Discounts work with price_data prices as long as the price_data uses a product that the discount applies to

unreal harness
#

ok you have any exampl eof this

cursive bear
#

No, just use your code but with price_data instead of price

unreal harness
#

how does the discount get applied to price data

#

i can see that the coupon is applied to the product

cursive bear
#

So in our system Products have a one to many relationship with prices

#

You create one or more Price for each Product

#

A Price must have a product

#

If the price is for a product that the discount applies to, then the discount applies to that price

#

It does not matter whether you made the price directly or via price_data

#

The discount will apply either way

#

If you test this code out I think it will all become much clearer

unreal harness
#

like this?

#

i get this error - Stripe.StripeException: 'You may only specify one of these parameters: product, product_data.'

carmine cloud
#

👋 taking over
What does the error tell you? 🙂

unreal harness
#

i cant have a product and price data

#

i thought A Price must have a product

carmine cloud
#

Does the error say price data or product data?

unreal harness
#

product_data

#

i thought - A Price must have a product

#

how do i specify a product when using productdata

carmine cloud
#

Yup, but you're setting a "product" and "product_data" in your price_data parameter
You must choose one

unreal harness
#

if i choose product data how do i apply a discount

#

this is part i am little unsure on

#

If the price is for a product that the discount applies to, then the discount applies to that price
It does not matter whether you made the price directly or via price_data
The discount will apply either way

#

if i use price_data how do i apply the discount to the price_data

carmine cloud
#

It does not matter whether you made the price directly or via price_data
The discount will apply either way
it doesn't matter, correct.

If you use price_data then you associate it to a product by passing in a product id to the product parameter (instead of using product_data)

unreal harness
#

ok

#

if i use

#

can i change the description dynamically or not

#

i.e. from 15/06/2023 to 20/06/2023

carmine cloud
#

No, you can't change the description dynamically in that case

unreal harness
#

If you use price_data then you associate it to a product by passing in a product id to the product parameter (instead of using product_data)

#

i thought i couild not have product and product_data

carmine cloud
#

you can't have both

#

you can only have one

unreal harness
#

ok i am unclear what this means -

#

If you use price_data then you associate it to a product by passing in a product id to the product parameter (instead of using product_data)

carmine cloud
#

did you test the code you shared in the last screenshot?

unreal harness
#

yes i wanted description to read like on product_data

#

but then cant seem to associate a discount

#

i get this -

carmine cloud
#

Okay so applying the discount works at this point right?
I feel like you're going in circles trying to solve unrelated issues

unreal harness
#

yes but like description to read like this

#

with the discount

#

its clear then the property name, dates and discount applied

carmine cloud
#

Yeah you won't be able to have the discount apply and create a product using product_data at the same time.

#

Ignore the custom field suggestion, that won't work

unreal harness
#

k

#

i have to go with one or the other then basically?

carmine cloud
#

Yup

unreal harness
#

ok

carmine cloud
unreal harness
#

ok

#

thanks for your help

#

be a nice addition in future

#

to be able to customise description using a product id

#

you can see my point with no dates -

#

at checkout

carmine cloud
#

Totally understand. You can file a feature request by writing in to our support via
https://support.stripe.com/?contact=true

That way you should also be able to check back if there were any updates on that

unreal harness
#

ok perfect will do

carmine cloud
#

Appreciate your patience! 🙂 Good luck

unreal harness
#

i just drop an email for a feature request?

carmine cloud
#

yup

#

would recommend providing context on your usecase so its easier for the team to understand

unreal harness
#

ok support chat or sales?

carmine cloud
#

support

unreal harness
#

api integration?

carmine cloud
#

yup

unreal harness
#

ok

#

anyway i can copy this chat?

carmine cloud
#

Hmm I don't think discord supports that unfortunately.
You'd likely want to summarize in your own words