#darthvader2.0.
1 messages · Page 1 of 1 (latest)
We don't recommend storing client secrets in a database. Those are intended only for the client.
As for incomplete Subscriptions, I would say it's a matter of preference for how you handle those. A user with their own custom login portal with a shopping cart view might prefer to store those and surface them in the user's shopping cart on their website. That might be a lot of work for a different user that only wants to show the customer their acive subscriptions. It depends on what your desired flow is
Hi @sinful moon,
Appreciate your response! My concern revolves around a scenario where I initiate a session to purchase my subscription multiple times (let's say 5). This is necessary on the frontend to obtain the client secret. However, in Stripe, it results in the creation of 5 incomplete subscriptions. When the subscription is finally purchased on the 5th attempt, it leaves me with 4 incomplete subscriptions and only one active.
I'm curious if it's advisable, perhaps through a cron job or similar mechanism, to automatically clear those incomplete subscriptions that haven't been finalized. Any thoughts or recommendations on handling this situation?
Because that date is not needed anymore also what should I do when let's say I wanna render the <CardElement /> witch also needs a client_secret? I create another incomplete subscription or what?
You could create a cron job that deletes orphaned subscriptions, that would work fine. That being said, you might consider creating the subscription when the customer is checking out. So only create the Subscription once they navigate to the payment flow and are ready to pay.
But what I do with the <CardElement/> from React witch needs a client_secret also?
I don't think the Card Element takes a client secret, does it?
Ah, it doesn't necessarily require it, since you can create Elements objects without them. All the same, though, you can just create your Setup Intent right before rendering the card element
What elements object means? Can you explain please?
You can either create an Elements object with a client secret (which works for the Card Element and other elements too): https://stripe.com/docs/js/elements_object/create
Or you can create an Elements object without a client secret (which may or may not work with the Card Element): https://stripe.com/docs/js/elements_object/create_without_intent
Ah, ok, I see it's optional ... Have to test to see if my payment method is saved
by any chance do you have for React any usefull link how the CardElement should be implemented?
If this is a net-new integration (i.e. you don't have any exisitng card element integration) I would recommend not using the Card Element at all, since it's a legacy technology. The recommended integration path is the Payment Element, which is much better documented and easier to use: https://stripe.com/docs/payments/quickstart
ok, but what I wanna do initially is for the user be able to manage his payment methods
How were you planning to do that with the Card Element?
I thought would be possible, is not?
It depends on what you mean by "manage his payment methods".
Add new payment methods, make one default, delete payment methods even may update existing one?
I wanna collect the details of the cards and using the CardElement or the subcomponents would make sense, right?
Payment Element would allow you to do the same things as the Card Element, except better. As for updating that information, that's going to be a lot of custom code either way. You would need to build a view where your customer logs in. Once their, your system would need to be able to retrieve the Customer's payment methods via a back-end API call (https://stripe.com/docs/api/payment_methods/customer_list), and render them on the screen with more custom code. There isn't an front-end Element or UI component for rendering this information through Stripe
It definitely is used to collect payments and payment methods, but it's not used to delete or modify payment methods
for delete and modifiy, yah, would make sens to be via API request
I agree
The payment element uses the client_secret to load the payment_methods allowed, right? Like card payment, paypal etc, right?
Hello, @soft berry
damn the PaymentElement requires the client_secret since I get an error
of
what?
Uncaught IntegrationError: In order to create a payment element, you must pass a clientSecret or mode when creating the Elements group.
Wait why aren't you passing client secret?
let me try
If you just need to add a new payment method to a customer and you don't want to charge them then this is the flow you should use: https://stripe.com/docs/payments/save-and-reuse?platform=web&ui=elements
If you want to attach them to a customer and not charge them right away, then yes you should use setupintent
I just wanna let them add more than one payment mothod since in time the can change
so using the setup intent client secret is the way to go always?
If you want to attach them to a customer and not charge them right away, then yes you should use setupintent
If you want to charge them and attach payment method at the same time, then paymetn intent should be used instead
got it thanks
and with what method I should use when submitting the form?
createPaymentMethod?
No...
Did you click the link I sent you?
It shows you how to do everything
Step 6
confirmSetup