#ruul_api

1 messages ยท Page 1 of 1 (latest)

fossil capeBOT
#

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

plush plinthBOT
#

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.

stuck drum
#

๐Ÿ‘‹ happy to help

wintry terrace
#

hello

stuck drum
#

you shouldn't be using this flow

wintry terrace
#

hmm

#

so setup session is ok but 2nd part isn't ?

stuck drum
#

no you shouldn't start with a SetupIntent when you're dealing with subscriptions

wintry terrace
#

we did it that way because client wanted users to choose between different cards or set one among them default

stuck drum
#

in that case the first payment might require actions and you would have to deal with that

wintry terrace
#

what can we do from our side

stuck drum
wintry terrace
#

is it sent immediately back from stripe when we try to attempt the purchase ?

stuck drum
#

yes but you should handle it asynchronously using webhooks

#

please read the guide I sent you it explains how to implement this

wintry terrace
#

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 ?

stuck drum
wintry terrace
#

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

stuck drum
#

you're using here Stripe.js

wintry terrace
#

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 }),
    });
  }
fossil capeBOT
wintry terrace
#

I guess when this fails eventually because of the invoice payment

#

invoice.payment_action_required
data.object is an invoice we'll get this ?

wide hedge
#

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.

wintry terrace
#

does the recommended way save user cards/set them default etc ?

wide hedge
wintry terrace
#

ok