#brian_portal-coupon
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question. Thank you for your patience!
โฑ๏ธ We automatically close idle threads, which makes them read-only. Make sure you stick around to chat in realtime! If this thread is closed and you have another question you'll need to start a new thread.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1214619263713943622
๐ Have more to share? You can add more detail below, including code, screenshots, videos, etc.
brian_portal-coupon
@rose drift Let me see if I can reproduce, give me a few minutes
kk, i think if a user has slower internet it'll show up with the coupon ๐
Do you have some example full code for the Session creation?
I am using elixir's stripity stripe library, most of the billing portal logic is here, the functions and stuff just retrieve strings
item_id = get_subscription_item_id(sub)
upgrade_price_id = Application.get_env(:core, :stripe_plans)[String.to_atom(plan)]
subscription_update_confirm = %{
subscription: sub.id,
items: [
%{
id: item_id,
price: upgrade_price_id
}
],
discounts: [coupon_to_apply]
}
flow_data = %{
type: :subscription_update_confirm,
subscription_update_confirm: subscription_update_confirm
}
create_billing_portal_session_req(user, %{
customer: customer_id,
return_url: @billing_portal_return_url,
configuration: get_billing_portal_configuration_id(user),
flow_data: flow_data
})
then create_billing_portal_session_req is basically just this
Stripe.BillingPortal.Session.create(params)
where we return the result
{:ok, %Stripe.BillingPortal.Session{url: url}} -> {:ok, url}
hard to read your magic/meta code
then in the front end with react we do
await Api.createStripeSession(payloadToUse)
.then((r) => {
const { url, code } = r.data;
// A session got created!
if (url) {
setTimeout(() => {
window.open(url, "_self");
}, 1000);
} else if (code === "unprocessable_entity") {
throw { response: r };
} else {
router.push("/settings?upgraded=true");
}
})
it doesn't work for me locally without the setTimeout()
like what's [coupon_to_apply]?
its just the coupon, so %{coupon: coupon_id}
but basically, without the timeout here the coupon doesn't show up, the url is the same
so the session creation should be fine
I mean sure but I need to reproduce end to end so I have to fully understand your code and what could be different betwen yours and mine.
I struggle to parse what you copy-pasted or what is router.push("/settings?upgraded=true"); and such
I just tried end to end and the flow works fine for me with either promotion_code or coupon passed in discounts
that part of the code doesnt really matter, if we call window.open(url, "_self"); without the timeout then i don't see the coupon, if i add a timeout there is a coupon
Okay, can you give me a way to reproduce your exact flow?
Just to confirm: I tried 10 times in a row on my end and it has the coupon every time without adding any delay so I'd need to see it live to unerstand what's going on
@rose drift Any update?
yeah figuring out a way to screen cap
I don't really want a screen cap, that won't give me anything
I would like a public URL where I can go through the flow end to end
Or maybe share an exact request id or some URL I can load where the coupon is missing?
the problem is, if i give you the url to load, it will have the coupon, if i load it myself it wont have the coupon, i am now quite confused since i can no longer even get the copon to show up but manually entering the url i receive works 100% of the time
๐
await Api.createStripeSession(payloadToUse)
.then((r) => {
const { url } = r.data;
// A session got created!
if (url) {
console.log(url);
window.open(url, "_blank");
}
return;
});
if i click the console.log url
i get the coupon
How are you doing a window.open on a server-side call?
Neither do I right now
like even if we somehow transformed the url on open, it'd give an error ๐
Can you try to do this
- Create the Session,
lotslog its idbps_123 - Immediately load the URL and share that URL with me
- Do nothing else with anything
I will then look at logs on our end to try and figure out what's up
kk
ah when you share the URL put it between ` if possible so that it's not loaded by Discord
bps_1Or2F3FqArqfkwbMA4lN4kX7 and https://billing.stripe.com/p/session/live_YWNjdF8xR29kZ1VGcUFycWZrd2JNLF9QZ1AzdDIyNUxhdU5tMXRZalB0MThPV3Q2QjJUUDVl0100aK9ZYZAs/flow
no coupons applied, it should be 15% off something around 448
(will take a while to debug)
no problem, but im not crazy right? ๐ coupon should be there?
yep that's exactly what I needed, looking
Can you try and reproduce this end to end in Test mode?
you're in Live mode, also forcing a BillingPortal Configuration id, so it's tough to end up in the exact same state as you are
sure
Hello! Any luck reproducing in test mode?
sorry, still woprking on it, we don't really have a good stripe test mode setup so having to set everything up
i can't reproduce in test :/
bps_1Or3nyFqArqfkwbMJYg26t1h
and
https://billing.stripe.com/p/session/test_YWNjdF8xR29kZ1VGcUFycWZrd2JNLF9QZ1FmRXFyU1pNYkwxUWphYjV4a0pRZVUwWnJvZkMz0100QvmN4b3n/flow
but the discount is properly applied
Interesting. We couldn't reproduce in test mode either, so it might be an issue specific to live mode.
Okay so I think it might be an issue with your configuration. I'd recommend reaching out to our support team for 1:1 help here: https://support.stripe.com/contact and they can investigate further with the product team!
like stripe configuration or just the billing configuration?
sadly no idea which one could impact this since we have not been able to reproduce in any way. Reaching out to our support team is best
okay will do, thanks for your help