#brian_portal-coupon

1 messages ยท Page 1 of 1 (latest)

sacred bridgeBOT
#

๐Ÿ‘‹ 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.

silver cryptBOT
severe roost
#

brian_portal-coupon

#

@rose drift Let me see if I can reproduce, give me a few minutes

rose drift
severe roost
#

Do you have some example full code for the Session creation?

rose drift
#

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}
severe roost
#

hard to read your magic/meta code

rose drift
#

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()

severe roost
#

like what's [coupon_to_apply]?

rose drift
#

its just the coupon, so %{coupon: coupon_id}

rose drift
#

so the session creation should be fine

severe roost
#

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

rose drift
#

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

severe roost
#

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

severe roost
#

@rose drift Any update?

rose drift
#

yeah figuring out a way to screen cap

severe roost
#

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?

rose drift
#

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

severe roost
#

๐Ÿ˜…

rose drift
#
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

severe roost
#

How are you doing a window.open on a server-side call?

rose drift
#

the server is in elixir

#

i dont understand why the results change though

severe roost
#

Neither do I right now

rose drift
#

like even if we somehow transformed the url on open, it'd give an error ๐Ÿ˜…

severe roost
#

Can you try to do this

  1. Create the Session, lots log its id bps_123
  2. Immediately load the URL and share that URL with me
  3. Do nothing else with anything
#

I will then look at logs on our end to try and figure out what's up

rose drift
#

kk

severe roost
#

ah when you share the URL put it between ` if possible so that it's not loaded by Discord

rose drift
#

bps_1Or2F3FqArqfkwbMA4lN4kX7 and https://billing.stripe.com/p/session/live_YWNjdF8xR29kZ1VGcUFycWZrd2JNLF9QZ1AzdDIyNUxhdU5tMXRZalB0MThPV3Q2QjJUUDVl0100aK9ZYZAs/flow

#

no coupons applied, it should be 15% off something around 448

silver cryptBOT
severe roost
#

(will take a while to debug)

rose drift
#

no problem, but im not crazy right? ๐Ÿ˜… coupon should be there?

severe roost
#

yep that's exactly what I needed, looking

severe roost
#

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

rose drift
#

sure

balmy mantle
#

Hello! Any luck reproducing in test mode?

rose drift
#

sorry, still woprking on it, we don't really have a good stripe test mode setup so having to set everything up

rose drift
#

i can't reproduce in test :/

#

bps_1Or3nyFqArqfkwbMJYg26t1h

and
https://billing.stripe.com/p/session/test_YWNjdF8xR29kZ1VGcUFycWZrd2JNLF9QZ1FmRXFyU1pNYkwxUWphYjV4a0pRZVUwWnJvZkMz0100QvmN4b3n/flow

but the discount is properly applied

balmy mantle
#

Interesting. We couldn't reproduce in test mode either, so it might be an issue specific to live mode.

severe roost
#

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!

rose drift
#

like stripe configuration or just the billing configuration?

severe roost
#

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

rose drift
#

okay will do, thanks for your help