#ruul_api
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/1265239367212073011
๐ 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.
- ruul_webhooks, 4 days ago, 20 messages
๐ happy to help
hello
you shouldn't be using this flow
no you shouldn't start with a SetupIntent when you're dealing with subscriptions
we did it that way because client wanted users to choose between different cards or set one among them default
in that case the first payment might require actions and you would have to deal with that
what can we do from our side
is it sent immediately back from stripe when we try to attempt the purchase ?
yes but you should handle it asynchronously using webhooks
please read the guide I sent you it explains how to implement this
alright ty
also
is it possible to use 2 checkout sessions first to setup & then when they select a card to pay with we create a real one with payment id in the params ?
yes but it's a terrible UX for your customers
yep
Monitor for the invoice.payment_action_required event notification with webhooks. This indicates that authentication is required.
Notify your customer that they must authenticate.
Retrieve the client secret for the payment intent and pass it in a call to stripe.ConfirmCardPayment. This displays an authentication modal to your customers, attempts payment, then closes the modal and returns context to your application.
Monitor the invoice.paid event on your webhook endpoint to verify that the payment succeeded. Users can leave your application before confirmCardPayment() finishes. Verifying whether the payment succeeded allows you to correctly provision your product.```
so according to this
I think we can keep the flow same but add an additional handler for this specific webhook event
sorry to keep on going with questions
this is not a Checkout Session
you're using here Stripe.js
yep sorry if I caused confusion
we use setup checkout session to save cards & then use the api from backend to attempt purchases
with the payment id etc
* Purchase subscription
* @param customer customer id
* @param price stripe price id
* @param paymentMethodId id of the payment method (optional)
* @param quantity number of items (optional)
* @param trialDays trial days (optional)
* @returns subscription object
*/
public async purchaseSubscriptionWithPaymentMethodPresent(input: {
customer: string;
price: string;
paymentMethodId: string;
quantity?: number;
trialDays?: number;
coupon?: string;
}): Promise<Stripe.Subscription> {
const { customer, price, paymentMethodId, quantity, trialDays, coupon } =
input;
return this.stripe.subscriptions.create({
customer,
items: [{ price, ...(quantity && { quantity }) }],
default_payment_method: paymentMethodId,
...(trialDays && { trial_period_days: trialDays }),
...(coupon && { coupon }),
});
}
I guess when this fails eventually because of the invoice payment
invoice.payment_action_required
data.object is an invoice we'll get this ?
I highly suggest you rebuild this in the recommended way instead of trying to use a SetupIntent and create a Subscription. Your current flow has multiple issues and potentials for customer confusion.
does the recommended way save user cards/set them default etc ?
webhooks are not massively relevant since you need to be handling this synchrnously(catching the exception thrown by the .create call). But overall, you should build this the recommended way with client-side PaymentIntent confirmation.
ok