#holykent
1 messages · Page 1 of 1 (latest)
public async Task<string> CreateSetupIntent(string paymentMethodId)
{
var options = new SetupIntentCreateOptions
{
PaymentMethodTypes = new List<string>
{
StripePaymentMethods.Card
},
PaymentMethod = paymentMethodId,
Usage = "off_session"
};
var service = new SetupIntentService();
var setupIntent = await service.CreateAsync(options);
return setupIntent.ClientSecret;
}
Currently it looks like this without exception handling and retries.
is that "enough"?
We mark all the required params in the api spec
Yeah I mean that looks fine
But whether or not it's enough depends on your integration
Recommend reading the different options to see if you might need them
The above is plenty if you're just going to accept card payments
Do you have a link to that? I find it hard navigating the stripe website tbh
yeah thats all im going to do
off-session payments
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
and i assume i need to pass client secret to make sure that they do whatever further authentication may be required
like with paymentIntent.Confirm()
yep
But follow that second link I sent above
That should guide you through everything
Is step 3 in the docs you sent really necessary? Creating a customer? I have my own customer entity but it's just for record keeping on our end.
Hi, taking over and catching up
Gotcha. It says "Create a Customer object when your customer creates an account with your business. "
In my case, u dont need to be a user with an account to make reservations on my website.
a customer is created in my db only after the first reservation is successful
it would seem like all i need is a setup intent
yes, you need that step. It ties the payment method object id to that customer object and then be able to re-use it later.
Ok and does every setup intent need to be authorized in the client?
Like, with paymentIntent, when you do Confirm, if it's "requires_action" i send the clientsecret for further authoirzation, and the client code explicitly looks for this status to initiate the authorization.
But with setup intent, there is no "requires_action" or anything since no payment has actually been made, so what's teh difference?
it's only off-session usage mind you
There is a next_action parameter on the SetupIntent: https://stripe.com/docs/api/setup_intents/object#setup_intent_object-next_action
There is no payment, but you're trying to collect a Payment Method and use that later. I also recommend that you read through this document: https://stripe.com/docs/payments/intents?intent=setup to see how SetupIntents work.
I think the difference in those docs is, it's attached to a customer instead of a paymentMethodId, and i don't see why that is necessary unless the code logic mandates it.
is this flow not possible?
- user inputs card details into stripe element form
- paymentMethodId is sent to my server
- Create setup intent with paymentMethodId
- Save setupintent Id to db to my custom Customer entity (which is created after reservation is actually finalized)
- return clientsecret for further authoirzation
- A month from now, I create a paymentIntent using the setup intent id (it has the paymentMethodID)
- Confirm intent
if that wont work, im not sure WHEN to create a customer. It doesn't seem very obvious from the docs.
"When the customer submits your payment form, create a SetupIntent on your server."
this makes it seem like the customer is created before they've even interacted with the stripe element form.. and that's like, how? they are just anonymous guests, they dont need to be logged in to book a hotel room.
I want to create the setup intent AFTER they've submitted the stripe element form
In my situation, I dont really care who the setup intent belongs to, I just know that I need to extract some money frm that setup intent at some point. And when and if it fails, we will eat the costs of that.
So you need to attach the Payment Method to the customer id to later re-use it. That is just how it's built.
and multiple setup intents can be associated with one customer object?
we have anonymous guests on our website who can book. they can attach a name or whatever, but that is hardly reliable identification.
So... how do i make sure that when the same anonymous guest makes another reservation in the future, that we reuse the same customer object?
is paymentmethod property literally a specific payment method (card, bank account, whatever) (as in that combination of card details) and not just a "type of payment method"?
Can you reword this ask please?