#blackbearftw_docs
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/1227692717950242847
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hello
Can you clarify how the guide is outdated? Are you hitting a specific error or confused about something in particular?
well react is outdated, it still uses create-react-app, which is no longer recommended
dotnet is using asp.net core 3
even tho the LTS is 8
and I still have no clue how this currently works, I just need someone to help me with that
The only guide I found so far is https://github.com/oopcoders/Stripe-Course
but that doesn't show me which parts the system require
and where
and what they do
Alright well first to clarify, these quickstarts are meant as demos and a place to get you started. They are not meant to be production code snippets that you just drop in.
Second, you are expected as the developer to work through problems you have. I am happy to help with specific questions or errors but I can't walk you through the entire thing or write your code for you.
So what have you tried so far and are you running into a specific error?
I do not have any error, since I don't have any code
I am simply trying to figure out what I need
to get this setup
Well that mostly depends on your own application. The basic code snippets are indeed included in the quickstart, or you can look at the step-by-step guide at https://docs.stripe.com/payments/accept-a-payment?platform=web&ui=elements which also includes the ability to look at React snippets
https://docs.stripe.com/payments/accept-a-payment?platform=web&ui=stripe-hosted
What is the point of adding products to stripe and then in the request having to specify this information again?
That is for Stripe Checkout specifically. The API is built around surfacing information based on the Products/Prices that are created. But when you create the Checkout Session itself you specify the Price(s) you want to charge
You linked the Subscription Quickstart initially
That is what I would like to do
Are you trying to create Subscriptions here or take one-time payments?
subscriptions
Okay my bad, I linked you the wrong guide in that case. You want to follow https://docs.stripe.com/billing/subscriptions/build-subscriptions
I would allow the user to click one of the subscription options -> redirect them to stripe checkout -> (where to go from here?)
what is the lookup key?
Yep, once they complete payment they are sent back to your success_url. You want to implemenet Webhooks to track fulfillment: https://docs.stripe.com/payments/checkout/fulfill-orders
The lookup key is a way to dynamically change prices without adjusting your code (see: https://docs.stripe.com/products-prices/manage-prices#lookup-keys). But not required to use these.
Also do I have to hardcode the price id in the frontend?
<input type="hidden" name="priceId" value="price_G0FvDp6vZvdwRZ" />
No you don't have to. That's up to you really. You can if you want to, or you can map these Price IDs to your own identifier and then look them up based on that identifier in your backend
or is that the purpose of the lookup key?
Yep
You basically would use that to dictate what is returned to your frontend instead of hard coding text.
But once again, not required.
I'd recommend not worrying about that to just get up and running here
Alright
But one thing that I am going to do different from the docs is that I won't redirect, I have a rest api, I am making a fetch request to my backend. So this code block isn't totally accurate at the end.
// Set your secret key. Remember to switch to your live secret key in production.
// See your keys here: https://dashboard.stripe.com/apikeys
StripeConfiguration.ApiKey = "";
// The price ID passed from the front end.
// You can extract the form value with the following:
// var priceId = Request.Form["priceId"];
var priceId = "{{PRICE_ID}}";
var options = new SessionCreateOptions
{
// See https://stripe.com/docs/api/checkout/sessions/create
// for additional parameters to pass.
// {CHECKOUT_SESSION_ID} is a string literal; do not change it!
// the actual Session ID is returned in the query parameter when your customer
// is redirected to the success page.
SuccessUrl = "https://example.com/success.html?session_id={CHECKOUT_SESSION_ID}",
CancelUrl = "https://example.com/canceled.html",
Mode = "subscription",
LineItems = new List<SessionLineItemOptions>
{
new SessionLineItemOptions
{
Price = priceId,
// For metered billing, do not pass quantity
Quantity = 1,
},
},
};
var service = new SessionService();
var session = await service.CreateAsync(options);
// Redirect to the URL returned on the Checkout Session.
// Response.Headers.Add("Location", session.Url);
// return new StatusCodeResult(303);
Please redact your secret key above
Even though it is your test key it still gives access to your account
alright
And this is a public server
Done
anyhow
I won't redirect the user
my api endpoint would just return a response
but what would it respond with
and what would happen after that?
I'm not sure I understand what you mean by that. You are saying you don't want to use Stripe Checkout? You want to use a custom form in your own site?
No
this example assumes I have a html form in the frontend
that I will submit it, that the post request will redirect the user to the backend and that will redirect them to stripe checkout
Yep
but I won't have a form like that, I will have a simple button, which makes a fetch request to my backend and my backend will return a json response
it can't redirect the user
That's fine, you can just return the Checkout Session URL to your frontend and redirect client-side
That works fine too
so you would do that and not the session id?
The session.Url is where the customer is going to get redirected
So instead of redirecting to that URL server-side, you respond to your fetch request with that URL and then redirect client-side to that URL
From the code snippet above?
yeah
Yeah, the rest of the code there just creates the Checkout Session
@sleek kettle I am trying to figure out what property to return, its not session.url
sorry
it was
is it possible to allow the user on the checkout page to decide if they want to pay monthly or yearly?
or do I have to do that before creating the session?
No that would have to be decided beforehand
alright that redirect url works
the question is what do I now do with that session id that was returned?
Have you looked at https://docs.stripe.com/payments/checkout/fulfill-orders ?
does that just allow me to customize the success page?
Yes
You can retrieve the Checkout Session using that ID to show relevant details to your customer
mhm alright
Thanks for now, ill continue tommorow
Sorry that I was a bit rude in the beginning, but I was just frustrated I have been trying to fix this for the last couple of weeks
All good. We are around 24/5 to help with any specific questions that you have!