#negative10xprogrammer

1 messages ยท Page 1 of 1 (latest)

rain belfryBOT
novel scarab
#

Hi ๐Ÿ‘‹

There are multiple ways to add or attach a Payment Method to a customer. How are you creating the payment methods?

torn shell
#

Hmm, havent thought of that. At first i created customers with paymentmethods (so just the paymentmethod token)

What is the preferred way of creating payment methods?

I think it happens at checkout, and since I use stripe elements and my flow assumes the client has fetched a paymentmethod token from stripe, I think I will be passing this token into the backend as usual

#

so... payment method token

novel scarab
#

Okay well Tokens have been deprecated for a while now. How are you processing payments? Do you use Payment Intents?

torn shell
#

Ah ok... yes. So what is the alternative then? I'm, not sure if token is what i mean

#

paymentmethod is what i mean

#

a string object

novel scarab
#

OR

torn shell
#

I do that in another flow

novel scarab
torn shell
#

the setup intent thing

novel scarab
#

Okay well that will create and attach payment methods to customers.

#

If you have already created payment methods you can use the attach API I linked above, as long as the payment method has not been charged

torn shell
#

yeah alright, the customer alraedy exists

novel scarab
#

the customer alraedy exists
That doesn't change anything

torn shell
#

Gotcha thanks!

novel scarab
#

Sure thing, happy to help ๐Ÿ™‚

torn shell
#

will stripe dedupe it?

novel scarab
#

The save during payment means you both create & save the payment method at the same time as collecting payment.

#

If the customer comes back you can re-use the existing payment method.

#

What is it you are actually trying to do?

torn shell
#

my current flow is like this:

stripe customer is created upon user registration. So all users in our system is a stripe customer. No paymnet methods at this point tho.

Upon purchase/checkout -> client, stripe elements. They input their card details, a paymentmethod is returned from stripe?

this paymentmethod retrieved from stripe is sent to our backend, and we use this to create a paymentintent

Now, obviously I want this to be saved to that customer. And then I ask stripe for that customers payment methods whenever they're in the custom checkout so they dont have to input that info again

#

this is a viable approach, no?

novel scarab
#

No I don't think so. If you didn't attach the payment method to the customer before the purchase then it's a one-time payment method and is consumed.

But I think you can simplify your approach

torn shell
#

alright, because paymentintent takes customerid

novel scarab
#

If you use the "Save during payment" flow for your initial Checkout it will create the Payment Method and attach it to the customer when you confirm the Payment Intent

torn shell
#
        var options = new PaymentIntentCreateOptions
        {
            Amount = (long)amount * 100,
            Currency = currency.ToString(), // Listing's currency
            PaymentMethodTypes = new List<string> { StripePaymentMethods.Klarna },
            TransferGroup = reservationId.ToString(),
            Customer = customerId
        };
torn shell
novel scarab
#

Okay now there appears to be Connect involved and I don't know what you trying to do. Also you cannot use Klarna payment methods for additonal charges

torn shell
#

No in this case klarna is not for additional charges. I ahve a flag for payment method

#

so it's not relevant i think. What I'm trying to do is what I outlined above: get paymentmethod from client stripe elements, pass it to our backend, create paymentintent

#

but i want to "remember" that paymentmethod

novel scarab
#

Yup, It will get saved to the Customer object so you can retrieve it from the API but you can also save it to your DB.

torn shell
#

Yes ok so this will work? Because you said above

"No I don't think so. If you didn't attach the payment method to the customer before the purchase then it's a one-time payment method and is consumed."

novel scarab
#

Correct, but if you use the flow I linked above it will attach the PM and it is designed specifically to be reused

torn shell
#

so both flows work but the one you suggest is more correct?

and last question, what happens if every time I create a payment intent its the same customer and paymentmethod? will stripe ignore the duplicate?

novel scarab
#

Even if the same customer provides the same card info, it will create a new Payment Method

torn shell
#

ah ok gotcha.

#

thanks, that clears it all up