#alex6743_code
1 messages ¡ Page 1 of 1 (latest)
đ Welcome to your new thread!
â˛ď¸ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
âąď¸ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
đ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1360294945595986080
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- alex6743_code, 4 hours ago, 27 messages
This is related to the question from earlier today
Hi! Do you have the Customer ID from Stripe for that customer?
I'm not sure I've created a customer yet. I can share my entire C# code:
{
const string domain = "https://localhost:44344/";
var options = new SessionCreateOptions
{
UiMode = "embedded",
LineItems = new List<SessionLineItemOptions>
{
new SessionLineItemOptions
{
Quantity = 1,
PriceData = new SessionLineItemPriceDataOptions
{
Currency = "usd",
UnitAmount = 5000,
ProductData = new SessionLineItemPriceDataProductDataOptions
{
Name = "T-Shirt",
Metadata = new Dictionary<string, string>
{
{ "Color", "Blue"}
}
},
},
},
},
Mode = "payment",
RedirectOnCompletion = "never",
Customer = "12345",
SavedPaymentMethodOptions
= new SessionSavedPaymentMethodOptionsOptions
{
AllowRedisplayFilters
= new List<string> { "always", "limited", "unspecified" },
},
};
var service = new SessionService();
var session = service.Create(options);
return Json(new {clientSecret = session.ClientSecret});
}```
If you haven't yet created a Stripe customer, then don't include the Customer ID.
Here's my checkout.html:
<html>
<head>
<meta charset="utf-8" />
<title></title>
<script src="https://js.stripe.com/v3/"></script>
<script src="Scripts/checkout/stripe.checkout.js" defer></script>
</head>
<body>
<!-- Display a payment form -->
<div id="checkout">
<!-- Checkout will insert the payment form here -->
</div>
</body>
</html>```
How do I create a customer?
If I don't, it blows up with this error: 'saved_payment_method_options requires a customer'
Which makes sense, because there's no customer
The guide you're following is for payments for existing Customers, but you don't have an existing Stripe Customer object, so that's likely not the right guide for you to be using here.
Oh, okay.
Here's the scenario: we need users to be able to save their credit card information with Stripe so they can use it later for quick payments
Awesome. This is the guide you want: https://docs.stripe.com/payments/checkout/save-during-payment