#B33fb0n3
1 messages · Page 1 of 1 (latest)
Hello! We don't typically reopen closed threads. Can you summarize your new question here?
Hi, hanzo descripted, That I should fetch the prices from my backend from my backend. My mission is to Build an online Shop with a Custom checkout. The Problem was, that if I Just create the paymentintent, the Client can modify it (because For a paymentintent creation you Provide Just the amount and no price ids). So we thought about invoices. But That way is very inefficent, because you Need to create For each lineitem a invoiceitem and this For every order. We checked, what Solution you can offer and (please read the First sentence in this Message again)
If you want people to be able to pay for multiple Products/Prices at once I recommend Stripe Checkout. You can specify the specific Prices to charge someone for in a Checkout Session's line items: https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-line_items
Yeah, but there‘s the Problem, That I cannot customize it. I like the Stripe checkout and it does was I want and offer many options. The Problem is, That it’s Stripe, and Not my Website. The customer may be confused or even Break up the whole process. So I want to do a Custom checkout
Okay, in that case you're going to need to build the functionality you want on your own site.
Yes, but I Need to charge my customer somehow 😅
You would use a Payment Intent for that.
But you would need to handle the cart and line item logic on your end.
You can't use Stripe Products and Prices with a Payment Intent.
On your end you would allow your customer to add things to your cart, and then during the checkout process you would create a Payment Intent for the total amount you want to charge them.
I know. Please Check out my First Message:
The Problem was, that if I Just create the paymentintent, the Client can modify it (because For a paymentintent creation you Provide Just the amount and no price ids).
The logic for cart and lineitems is already build
I thought about resolving the Problem by creating a checkout Session with the lineitems, expand the paymentintent and than work with the payment intent. Does this work?
No, that won't work.
I don't understand what you mean by "the Client can modify it"?
Why Not?
The only way you can modify a Payment Intent's amount and other properties is with your secret API key, which is not something the client has.
A Checkout Session won't create a Payment Intent until the URL is visited, for one thing. For another, the Payment Intent associated with a Checkout Session is only designed to be confirmed with Checkout.
The Client handles the Amount, Which will be send to the backend to create it. Thats a Problem from my side
Hm thats a Problem… the paymentintent is Not Free floating?
You would only create the Payment Intent when you know the full amount you want to charge.
Payment Intents are low-level objects designed to charge someone for a specified amount. They don't have any concept of line items or quantities or things like that.
You would keep track of line items and quantities on your end.
Yes, so I thought they are free floating?
I'm not sure what you mean by "free floating"?
For me, if an Object is „free floating“ it works everywhere the Same. If it will be create by a checkout session or by me, it will work in Both cases the Same
Sorry, I'm not following. Let's back up a bit. What is blocking you and how can I help further?
Sure, I thought about creating the paymentintent via a checkout session. For the checkout Session I can provide priceIds and I also have the paymentintent, when I expand the paymentintent. So I can use it to collect payment Details via the payment elements
I do not believe that will work. Even if it does work today, there's no guarantee it will work tomorrow. I do not recommend that approach.
What way I should Go Else:
We had, what does Not work For me:
- Invoices (inefficent)
- Checkout (Not Custom)
- Paymentintent (modifiable by customer in my Case)
- Checkout with paymentintent expand (Not recommended)
- ???
Hi there 👋 taking over for @waxen geyser
Give me a few minutes to get caught up.
Ah sure 👍
I'm not sure I fully understand your most recent question. Why would you create a Payment Intent with Checkout? Why can't you use Payment Intents as is if you're creating a custom checkout workflow?
Because ⬆️ (See Point 3)
I feel like it would make more sense to tackle the problem of how your customers are able to modify your Payment Intent, rather than trying to build a hacky thing that's going to make the workflow even more prone to breakage.
I can't really think of a different option other than scrapping your current checkout flow and using the Payment Element instead (which I assume you do not want to do)
The payment Elements would be Perfect, But to initiate the payment Elemente, I Need to have a paymentintent.
Currently I cannot ask my own database from the backend For clean amounts from products. If I ask Stripe (their backend) I can only do this very inefficent, to get clean amounts
I don't understand what you're saying. Terms like "clean amounts" and "products" are ambiguous. I'm also not sure what you mean by:
"If I ask Stripe (their backend) I can only do this very inefficent,".
You're assuming that I have context about your integration, but I'm afraid I don't, so you need to be explicit and define your terms, otherwise we're going to end up going around in circles.
The payment Elements would be Perfect, But to initiate the payment Elemente, I Need to have a paymentintent.
I think this one is clear. Payment Elements need paymentintent to be able to get filled with payment Details by the Customer
Currently I cannot ask my own database from the backend
For clean amounts from products.
My backend has a database. In this database there are entries (products). These products have some details. Like a title, one or More categories and so on. A product also have a priceID. The user cant modify this priceID, cause if he change, the priceID will be Invalid and the checkout cannot be completed.
What do I mean by „clean prices“?
A clean price is For me a readable price. A priceID like „price_1737488374“ is not readable For me as human to see Which Price I will pay. So a „clean price“ is for me For example „100“ for 100 Cents or 1 Euro.
If I ask Stripe (their backend) I can only do this very inefficent, to get clean amounts
Now you know what I ment by this. I can receive a price by Stripe to get More Data about the Price and with this the „clean Price.“
It’s inefficent, because Stripe only offers
- a list from ALL prices OR
- a specifiy object.
But not a mix from Both (ask for a List of specific PriceIds)
Ah, okay. Now I understand. This is a pretty uncommon situation where the back-end is not talking to the database, so I can see why the workarounds are kind of hacky. Can you set metadata on the Price ID when it is created and then just use the Search API to get just that one Price?
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
I think I can do this. Or I just use this: https://stripe.com/docs/api/prices/retrieve
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
In what kind of direction have you thought? 🙂
I guess I'm unsure of what to advise, since it seems like you have all the possible options already in front of you. If you cannot access your database in this workflow, then you're unfortunately going to have to use methods that are less efficient.
Hm ok. Do you have an api, thats serves like the order api?
What do you mean?
That's in beta and shouldn't be used for this flow as far as I can tell
Yeah, I am in the Beta, but it will Not be supported in the Future
Right, exactly. Also, I'm not sure if it would solve any of your problems.
Hm ok. Do you have an api, thats serves like the order api?
Again, I don't know what you mean. What do you mean by "serves"? What specific functionality are you looking for?
I am looking For the functionality the orders api offers
Which functionality?
The functionality, That the order api offers:
Accept PriceIds, convert it into clean prices and make a perfectly paymentintent (and also walkthouht the standard steps from an order)
The Orders API is deprecated, as you've noted, and there is not currently another API with equivalent functionality
Oh ok. Does a beta to one exists, That can offer the functionality?
Not currently, no. You can build similar functionality by passing a cart of price/product ids to your server and building a payment intent with the correct total.
Alternatively, you can explore whether Checkout might fit your use case if you want to have taxes calculated for you, and offer promotion codes, shipping rates etc
Hm ok. Than I will Just try the unrecommended way (create checkout Session, explode the paymentintent and Work with it)
IIRC you can't confirm the payment intent managed by Checkout manually, so I don't think that's going to work as you're expecting
I cant confirm it? Can I confirm the checkout Session?
You can by redirecting to the Checkout url and completing payment there. you can't do it manually, no.
Oh I thought my Problem solved 😭😭
You could use one-off Invoices for this, to make use of the line_items, for example -- the payment intents created within invoices can be confirmed directly. We don't recommend this, but it's possible.
I don’t understand what you mean. Do you have docs about it?
I get that you like working with the Orders API beta, and I hope we can offer functionality like that again in future, but right now that doesn't exist. I would recommend using Checkout if you want all that functionality without the custom build, but that's up to you.
No, there are no docs because it's not a recommended pattern. But when you create and finalize an invoice, it has a payment intent used for payment and that can be confirmed directly, using the API or Stripe.js with the client_secret:
https://stripe.com/docs/invoicing/integration
Yeah I do. When the Orders api beta comes out and I was able to work with it, it was like a dream. And thing That was so simple to use and working perfectly. But then it turns out, That it will Not be supported in the Future… a nightmare began…
Wait, invoice? To create I Need to create invoiceitems For each lineitem? This one?
yes sorry, invoice items lead to line items.
Yes unfortunately this is happens from time to time with betas
Why For the Orders api?
I can't speak to why but the impact is that its not going to be moving forward
Ok. How do I resolve the Problem?
By building out the flow yourself using payment intents, or using Checkout or potentially this other invoice option