#theahmadzai-setup-future-usage

1 messages · Page 1 of 1 (latest)

left elk
#

Hey! A Setup Intent will facilitate any necessary 3DS/auth requirements by the bank in order for the payment method to be reused off-session

#

Otherwise you're likely to see declines on recurring payments without that 'setup' process

valid river
#

but the payment intent api just takes the payment method to charge the customer

#

So how will setup intent be useful for me with payment intents

left elk
#

What exactly are you trying to achieve?

valid river
#

I want to charge on recurring bases using method method it's working fine

left elk
valid river
#

but stripe says to store setup intents

#

How can I use setup intent to charge later

left elk
#

Which payment method have you created?

left elk
valid river
#
      const paymentIntent = await this.stripe.paymentIntents.create(
        {
          amount: amountInCents,
          application_fee_amount: Math.ceil((this.storeApplicationFee / 100) * amountInCents),
          currency: 'usd',
          setup_future_usage: 'off_session',
          payment_method: paymentMethod,
          customer: stripeCustomerId,
          statement_descriptor: descriptor ?? '',
          confirm: true,
        },
        stripe_id,
      );
#

I use stripe.paymentIntents.create to charge but it takes customer and paymentMethod

left elk
#

You wouldn't pass the payment_method in this instance. You'd use Elements to capture the payment details and pass them to confirmPayment which would created the authenticated Payment Method object to reuse

#

The setup_future_usage parameter essentially emulates a Setup Intent

valid river
#

ah I see If I store payment method I cannot charge account unless I create setupitnent in stripe right

#

so setup intents are just permession for offsession charges

#

currently I do stripe checkouts where I set their cards for future usage of offsession and in the future I get list of payments from stripe and use the paymentIntent

#
      const { data: cards } = await this.stripe.customers.listPaymentMethods(
        stripeCustomerId,
        { type: 'card' },
        stripe_id,
      );
#

like this and sort by latest one

#

now I want to add functionality for customer to add their cards

#

So I would use stripe element to get setup_intent and just store the paymentMethod in my database and use that for future charges in paymentIntents right

left elk
#

Very similar integration to Payment Intents, you're just using a different API and confirmSetup in Stripe.js

left elk
#

You'd pass payment_method and customer parameters when creating a PI with a previously saved payment method

valid river
#

Thank you so much

#

Now I just want to confirm that Do I need t ostore payment method in my sode

#

or can stripe give me default payment method

#

I see that laravel cashier and other libs store last_4 digits and some other info

#

do I need to store payment method as well or use customer id to get his default method and list payment methods

left elk
valid river
#

but API gives me list of ids but how do I know which one is default and which one to use

left elk
#

But that doesn't really work for one-time payments its more for subscriptions. So you'll still need to provide the payment_method parameter when creating the PI

left elk
valid river
#

so


const cus = stripe.customers.retrieve('id', {

})

cus.invoice_settings.default_payment_method

I can use this to charge

#

and no need to store payment method

left elk
#

You could yes

#

But that might have unintended side effects if you ever started using Billing (subscriptions)

valid river
#

We do some recurring payments but not using stripe

#

subscription feature

#

we have our own recurring scheduled infrastructure

left elk
#

Got it

valid river
#

If customer adds 3 payment methods can I set one of them as default by myself

#

I don't see the property on paymentMethods.update

#

And each time I show dashboard to customer I don't see it useful to goto stripe and list payment methods so I can store last_4 card brand etc.. in db right but what's the better way to mark one of them as default

#

thanks!

left elk
left elk