Is Stripe SessionService ThreadSafe?
HoomanBahreini opened this issue · 1 comments
Is your feature request related to a problem? Please describe.
The documentation says that: We recommend creating a new Session each time your customer attempts to pay.
But I am not clear if we need to create one SessionService
each time the client attempts to pay as well, or could I reuse the same instance of SessionService
?
Describe the solution you'd like
I am following the documentation here: https://stripe.com/docs/api/checkout/sessions/create
StripeConfiguration.ApiKey = "sk_test_caMvYwP1Yi6bLLEpJ2nzk3r100NCxrTiGt";
var options = new Stripe.Checkout.SessionCreateOptions
{
SuccessUrl = "https://example.com/success",
LineItems = new List<Stripe.Checkout.SessionLineItemOptions>
{
new Stripe.Checkout.SessionLineItemOptions
{
Price = "price_1MotwRLkdIwHu7ixYcPLm5uZ",
Quantity = 2,
},
},
Mode = "payment",
};
var service = new Stripe.Checkout.SessionService();
service.Create(options);
I am not sure if I can reuse the SessionService
instead of creating a new one each time user wants to pay? Would I be able to make SessionService
static
and reuse it for the entire lifetime of the application?
Describe alternatives you've considered
I cannot see anything in the documentation about thread safety of SessionService
, would be useful to include it please.
Additional context
No response
As long as you don't change the global API key for example then it's totally fine to have a static SessionService instance. That's what a lot of developers do today in my experience!
If you need more support help I'd recommend reaching out to our support team https://support.stripe.com/contact for 1:1 support instead.