#_nerder

1 messages ยท Page 1 of 1 (latest)

reef berryBOT
#

Hello! We'll be with you shortly. 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.

whole grove
#

Hi there ๐Ÿ‘‹ what's the error you're running into, and is it being surfaced in a response to a request you're making? If so, can you share that request ID as well?

lucid fulcrum
#

req_dty6TIySHR0BH3

#

here you have it

#

is something to do with how i confirm the payment intent

#

but there must be a mistake on how i create the invoice

#

because for subscriptions it works fine

whole grove
#

I think Checkout is the piece that is handling this. I'm currently looking to see how you're creating that one-off Invoice.

lucid fulcrum
#

ok

#

there is this piece of code which is kinda sus:

    const paymentIntent = await this.stripe.paymentIntents.update(
      invoice.payment_intent as string,
      {
        setup_future_usage: 'off_session',
      },
      {
        stripeAccount,
      },
    );
whole grove
#

You're trying to use a Payment Method that has already been set up for future usage, correct? If so, I don't think you need to set setup_future_usage the way you're showing in that code snippet.

lucid fulcrum
#

Umm, i'm always a bit confused with this

#

the checkout session will setup the payment for future usage I guess

#

but for instance in subscriptions i do something similar

#
    const stripeSub: Stripe.Subscription = await this.stripe.subscriptions.create(
      {
        customer: customerId,
        items: [
          {
            price: subscriptionPlan.code,
          },
        ],
        ///..other stuff
        off_session: true,
      },
      {
        stripeAccount: stripeAccount,
      },
    );
#

and the docs says: Indicates if a customer is on or off-session while an invoice payment is attempted.

#

so my idea here was that by updating the payment intent for the invoice that i'm creating manually this will basically be the same as setting off_session for the subscription to true

reef berryBOT
whole grove
#

But the confirmation attempt for the Payment Intent is coming from your frontend code, which makes it seem like that does happen when the customer is on session.

lucid fulcrum
#

Well yes, my integration returns the client_secret back to the frontend the the payment intent is confirmed there

#

so you mean that I should simply remove that update?

whole grove
#

Yup, that's what I would suggest trying. I think it's causing the intent to try to re-setup the Payment Method, which requires mandate information be provided.

lucid fulcrum
#

ok let me try real quick

#

there is a way to expand the payment_intent of an invoice?

tawny anvil
#

๐Ÿ‘‹ there's a payment_intent parameter on the invoice

you'd do something like expand: 'invoice.payment_intent'

lucid fulcrum
#

in create or finalize?

tawny anvil
#

the payment intent only exists after invoice has been finalized

#

draft invoices won't have a PaymentIntent

lucid fulcrum
#

ok makes sense ๐Ÿ™‚

#

@whole grove was right!

#

indeed by removing that piece of code that was updating the payment intent it fixes it

#

what a weird thing tho

tawny anvil
#

Great! glad that worked ๐Ÿ™‚

lucid fulcrum
#

so let me rephrase real quick to see if i've understood correctly:

  1. With manual one-off invoices, there is no need to update the PI to setup_future_usage, because they will likely being paid on-session. (even if the payment method is indeed setup for off-session by checkout)
  2. With subscriptions instead we need to enable off-session because of subsequent subscription updates that will be paid off-session
tawny anvil
#
  1. Correct
  2. If you're using SetupIntents prior to creating subscriptions, then you don't need to set off_session really as the payment method was already setup previously. If you don't have a payment method setup then you can use save_default_payment_method under payment_settings parameter
    https://stripe.com/docs/api/subscriptions/object#subscription_object-payment_settings-save_default_payment_method
    That'd would let you store the payment method on the subscription which then will be charged for subsequent payments.

So overall, you don't need to update the payment intent separately for above to work.

lucid fulcrum
#

ok I see

#

it's always a bit confused how this thing works

#

that's more clear now tho

#

i need to the one-off because for in another scenario I support i clone payment methods from the platform to the connected account

#

and they are considered like off-session payments

tawny anvil
lucid fulcrum
#

basically in my integration I'm using setup intents with checkout for all payment methods which are not possible to be cloned

#

and cloning from platform in any other case

#

and i do both subscriptions and manual invoices so i need to find the right balance of settings ๐Ÿ˜†

#

by the way the issue is solved for now, I don't want to waste any more of your time

#

thank you @tawny anvil !

#

have a good rest of the day