#skoshkarli - present discounted price

1 messages · Page 1 of 1 (latest)

misty light
#

Hello, I think you can have us automatically calculate it. Are you creating your subscriptions here directly or through Checkout?

final hearth
#

i am not using checkout

#

we have a custom payment page where we will be collecting payment info using Stripe Elements and creating a subscription right away

#

How would i have you guys automatically calculate it?

misty light
#

Apologies, was a bit busy in other threads and accidentally dropped this one. Looking now

final hearth
#

i dont think this works

#

this is BEFORE the subscription is created or a customer is created

#

i am fetching products from Stripe and want to show the prices of those products to a customer and this customer is using a coupon code

#

so i would like to show the price with the coupon code applied

misty light
final hearth
#

customer is required for upcoming invoice, which i wouldn't have still

misty light
#

In this case it would probably be worth it to create a dummy customer and use that. I will test this quickly and get back to you

final hearth
#

seems a bit hacky, i'd have thousands of users going through this one customer id to fetch their prices? There has got to be a better way

misty light
#

You can do it with just one Customer object. Like create a Customer named "preview prices", make sure they are never subscribed to anything, and make preview invoices with that customer's ID to show what a new subscription would be like

#

Just tested it and it properly calculates the price + discount for you

#

So there we go, preview discount and non-hacky

final hearth
#

interesting, what would i put into customer_details ?

#

i don't really know anything about the customer at that point

misty light
#

Actually after testing it more fully, that won't work. It looks like you need either an existing customer or subscription to make the call with. Re-using the same customer ID would probably be the best way to go here. I can put in a feature request to remove that requirement but for now that would be the best way to preview a subscription's price without any pre-existing Customer for the actual user you are creating the subscription for.

final hearth
#

ok thank you!

#

so just to clarify, i'd be using upcoming invoice and passing in this dummy customer id as well as coupon id to coupon param and priceId to invoice_items.price param?

sharp forge
#

just catching up here. you'll want to pass in a subscription, customer, and coupon. the price should already be associated with the subscription.

final hearth
#

there is no subscription created in this case

#

we are trying to preview a price with coupon applied before subscription is created using a dummy customer

#

I can't be the first person to want to preview a price for a user