#negative10xprogrammer
1 messages · Page 1 of 1 (latest)
Hello
Idempotency keys are really only meant for performing retries safely when you are unsure of the previous outcome (like a 500 error occurred).
Ideally, for retries, you just re-confirm the same PaymentIntent
ok, but what if they have insufficient funds and decide to use another card instead?
will the client simply use that same paymentintent and automatically attach this new paymentmethod to id?
it
(via stripe elements)
ok, yes well I was thinking that maybe it's a previously used paymentmethod (fetched from stripe), but insufficient funds, and instead of topping up funds they use a different paymentmethod. But the answer is, dont create a newq paymentintent, simply let the client handle that then I take
Yeah if it is a previously used one then you pass the PaymentMethod ID to your confirm
If it is a new one, you don't pass a PaymentMethod ID
and again to be sure, as long as there's a customer attached to teh paymentintent i created on the server and setupfutureusage, stripe will make sure this customer is associated with any successful paymentmethods?
how does klarna come into play here in the creation of the paymentintent? I assume it's as easy as PaymentMethodTypes = new List<string> {"klarna","card"}...
but will this work if the same paymentintent is set to setupfuturesage = off_session?
or should i create a separate paymentintent for klarna payments?
So you can either specify the PaymentMethodTypes directly or (assuming you are on latest API version) you can omit the PaymentMethodTypes parameter and control them via your Dashboard at: https://dashboard.stripe.com/test/settings/payment_methods
In terms of setup_future_usage
You want to instead use the payment_method_options.card.setup_future_usage in this case
Instead of setting it top level
So the PaymentIntent is compatible for both cards and Klarna
how do I do that with the .net SDK?
var options = new PaymentIntentCreateOptions
{
Amount = (long)amount * 100,
Currency = currency.ToString(), // Listing's currency
PaymentMethodTypes = new List<string> { StripePaymentMethods.Klarna, StripePaymentMethods.Card},
TransferGroup = reservationId ,
Customer = customerId,
SetupFutureUsage = "off_session", // Without this the paymentmethod would not be reusable,
ConfirmationMethod = "manual",
Metadata = new Dictionary<string, string>
{
{ "reservationId", reservationId }
},
};
i ahve this
i think card is default tho for paymentintents?
so i dont have to specify it
Well mostly you are the programmer and know how to handle hashes in .NET. If you need specifics about the classes you could look at our SDK itself: https://github.com/stripe/stripe-dotnet
Mostly you want to use PaymentIntentPaymentMethodOptionsCardOptions I believe
But I don't remember the classes off the top of my head (not a .NET dev)
If you aren't on the latest version of the API and you want to use the Dashboard for your PaymentMethodTypes then you specify ```AutomaticPaymentMethods = new PaymentIntentAutomaticPaymentMethodsOptions
{
Enabled = true,
},
hmm alright trying to figure it out, there are a lot of paymentintentpaymentmethodoptions methods
yes, but im not sure how to attach that to the paymentintent, it has paymentmethodoptions but they are not implicitly convertible
PaymentMethodOptions = new PaymentIntentPaymentMethodOptionsOptions
{
Card = new PaymentIntentPaymentMethodOptionsCardOptions { SetupFutureUsage = "off_session"}
}
like so?
it's not the same as PaymentIntentPaymentMethodOptionsCardOptions thyo
the word options is starting to look stupid now haha
lol
That looks right to me
But like I said I'm not intimately familiar with dotnet
I'll try this out then. But this basically means stirpe will accordingly handle teh different paymentintents?
if it's klarna, it iwll ignore the card options
Yep
thanks, appreciate it!