#ian-wilson_code
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.
โฑ๏ธ 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.
Hi! Great question. Let me dig.
Why are you using both Checkout and a Payment Element?
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.
Ok let's step back a bit.
Without using any Stripey words, can you tell me what you're trying to accomplish here?
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.
Cool. And what's the issue you're having exactly?
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
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.
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?
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?
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.
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.
You also could just have your own 'invoice' model and just use a Payment Intent and Payment Elements.
I think the doc discrepancy might just be an issue of React being incorrectly translated to plain JavaScript. I don't know much react so I guess I'm going to look into it, there seems to be a lock here: https://github.com/stripe/react-stripe-js/blob/009923767bf51ca236e7c945596d8d7c06ad60b6/src/components/CheckoutProvider.tsx#L124
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.
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.
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.
Which solution?
Storing the result of initCheckout and never calling it again.
But in general using Checkout Sessions + Payment Element to create an invoice.
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. ๐
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.