#ben-hamilton_best-practices

1 messages ยท Page 1 of 1 (latest)

frozen brookBOT
#

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

โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

๐Ÿ”— 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/1433185779554844703

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

acoustic pewter
#

The guide above seems to assume that you'll collect the user's email before creating the checkout session -> initializing Web Elements -> mounting the element(s)

stone tide
#

Hi there

acoustic pewter
#

hello again!

#

My main confusion is how sites implement e.g. Express Checkout elements if you can't even display them before collecting the user's email and looking up / creating the Stripe Customer ID

#

We got added to the Private Preview for dynamically updating checkout sessions, but it only allows updating a very few things (line items, shipping info) and not customer ID

stone tide
acoustic pewter
#

Oh, super interesting โ€” that's only possible on the client side, not the server side?

#

I was looking at the Node.js server-side API to update a checkout session, not the Stripe.JS client-side API

stone tide
acoustic pewter
#

Huh, I see

#

we wanted to be able to dynamically update the description in specific based on what the user enters

stone tide
#

Yeah no that's not possible without creating a new Checkout Session. By description I assume you mean the description of the line items?

#

For the subscription_data.description you can't update that -- really after you create a Checkout Session itself you never update the Session.

#

You update the objects that have been generated.

#

So you would create a new Checkout Session if you wanted different subscription_data

acoustic pewter
#

Right. Our use-case is our product supports:

  1. The customer purchasing a subscription for themselves (the customer can have only 0 or 1 of these)
  2. The customer purchasing a subscription as a gift for someone else (the customer can have 0 or more of these)

We wanted to make sure the customer can distinguish the subscriptions in the Stripe Customer Portal, so we have two options, the line item or the description

The UI at https://plant.staging.terraformation.com allows toggling between these two modes, so we either have to juggle two checkout sessions for the two modes, or update one checkout session dynamically

Terraformation

Climate action, for the rest of us. Help restore global forests and fight climate change.

#

Whenever we create a new checkout session, AFAIK we have to unmount the Web Elements UI and remount it, which causes a lot of pain if the user half-filled out their info

stone tide
#

The easiest way imo is just to set the corresponding product descripitons used for the line items.

acoustic pewter
#

That requires the Private Preview API to dynamically update the line items, right?

stone tide
#

No

acoustic pewter
#

oh! what'd I miss

stone tide
#

The customer is selecting what subscription(s) to purchase and then you are rendering Payment Element, right?

acoustic pewter
#

I was hoping to render the Payment and Express Checkout elements immediately

#

most users are not going to select the gift checkout

stone tide
#

Ah okay well we don't handle private features here as this is a public server so I can't really speak to that. But overall if you wanted to render Payment Element / ECE immediately then yes you would need to be able to update the line items.

acoustic pewter
#

Right. That's why I was asking about best practices. Do most Stripe customers delay rendering Payment Elements until after collecting the user's email and other product choices?

stone tide
#

Generally yes. The most common flow is to have an email tied to a login/auth for your customer so you would already have that stored. And yes, generally you would wait to render Payment Element until the customer "views their cart" -- basically after they have selected what they are purchasing.

acoustic pewter
#

Got it. OK, I'll give that a go!

#

Thanks for explaining.

stone tide
#

Sure thing