#ian-wilson_code

1 messages ยท Page 1 of 1 (latest)

reef daggerBOT
#

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

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

scenic temple
#

Hi! Great question. Let me dig.

#

Why are you using both Checkout and a Payment Element?

turbid kite
#

There is a lot of docs so its hard to tell but this is the only way I can tell to have line items in the invoice + customize the shipping rates + customize how the shipping address is collected + allow for pickup orders. I can't seem to figure out a way to do that with a PaymentIntent but there is a lot of docs.

scenic temple
#

Ok let's step back a bit.

Without using any Stripey words, can you tell me what you're trying to accomplish here?

turbid kite
#

Can I include images in here?

#

This is the prototype form I have right now. If the customer wants to ship their order I want to show a dynamic rate estimate. If the customer wants to pickup their order I don't want to do that but they will have to enter a billing address. This is on a pre-existing site.

#

Here is a version filled out with a test card.

scenic temple
#

Cool. And what's the issue you're having exactly?

turbid kite
#

All the examples use a clientSecret to call initCheckout anytime an instance is needed but it seems that it cannot be called twice without breaking the PaymentElement. But if I just initCheckout and then store a global reference to it I can keep re-using it in the page. Is that how I'm supposed to use it? For example here initCheckout appears to be called twice: https://docs.stripe.com/checkout/custom/quickstart?server-lang=python#initialize-checkout https://docs.stripe.com/checkout/custom/quickstart?server-lang=python#submit-payment

Use Elements and the Checkout Sessions API to build a checkout page.

#

When I call initCheckout twice I get an error on confirm() that looks like this: "Could not retrieve elements store because group elements-11edcc29-9f62-4ff0-8075-50e9147d3be7-4485 does not exist" which I think means I destroyed the payment element somehow. I'm not sure but you can't checkout.

scenic temple
#

Sounds like it, ya. I'm not really sure why you're doing it this way; what was wrong with a Payment Intent, or just fully using Checkout?

turbid kite
#

I don't know if this is correct but it seems that I cannot create line items in an invoice if I use a payment intent. Is there a way to do that?

scenic temple
#

So again, let's step back. With words, what are you trying to accomplish here?

#

Because it sounds like you want to create an Invoice, and then use a Payment Element to collect the payment details that should be used to pay the Invoice.

turbid kite
#

The invoice needs to have line items so that I can make refunds later based on it and possibly create more invoices based on it. It is just how the current business works.

scenic temple
#

You also could just have your own 'invoice' model and just use a Payment Intent and Payment Elements.

turbid kite
#

Then when initCheckout is called once the ref is toggled on and then initCheckout is not called again and the checkout instance is just stuffed into memory to be used again.

scenic temple
#

I don't really think you need Checkout in this process. It makes more sense to either just use Stripe Invoices, or your own 'invoice' model and Payment Intents, along with the Payment Element.

turbid kite
#

You have to create an invoice and move it to the paying state to show the card form but then if people change anything like their billing info then the invoice has to be voided and remade and the payment would have to be re-collected. Its just not a good fit for checking out.

#

This solution looks like it will work I just need to cross reference the stripe react library with the stripe docs. It is just hard to find good examples.

scenic temple
#

Which solution?

turbid kite
#

Storing the result of initCheckout and never calling it again.

#

But in general using Checkout Sessions + Payment Element to create an invoice.

scenic temple
#

Ok cool. I don't see how this makes sense for what you're trying to do vs just using a PaymentIntent or an Invoice, but it's your app. ๐Ÿ™‚

turbid kite
#

Well thanks for trying to figure it out. I wish I could use the workflows but there are blocking issues with both of them. I gotta go offline though. Thanks and talk to you later.