#cordev-subs
1 messages · Page 1 of 1 (latest)
that's the main issue, everything runs fine. Just goes nowhere
I tried creating a button to call the stripe checkout session through httpPost
string result = "Success";
var domain = "http://localhost:44370";
//MemoryStream stream = new MemoryStream();
//Request.Body.CopyTo(stream);
//stream.Position = 0;
//using (StreamReader reader = new StreamReader(stream))
//{
// string requestBody = reader.ReadToEnd();
// if (requestBody.Length > 0)
// {
try
{
//var obj = JsonConvert.DeserializeObject<SubscriptionFormData>(requestBody);
if (Price != null)
{
var priceOptions = new PriceListOptions
{
LookupKeys = new List<string> {
Price
}
};
var priceService = new PriceService();
StripeList<Price> prices = priceService.List(priceOptions);
var options = new SessionCreateOptions
{
LineItems = new List<SessionLineItemOptions>
{
new SessionLineItemOptions
{
Price = prices.Data[0].Id,
Quantity = 1,
},
},
Mode = "subscription",
SuccessUrl = domain + "/home/ThankYou?compname={CHECKOUT_SESSION_ID}",
CancelUrl = domain + "/home/ThankYou",
};
var service = new SessionService();
Session session = service.Create(options);
Response.Headers.Add("Location", session.Url);
return new StatusCodeResult(303);
one sec, let's hold off on code sharing for now
let's talk higher level first
1/ does the CheckoutSession end up being created (i.e. is your server side code being called)
Yes, its being called successfully
great, so
2/ are you able to redirect to Checkout page? looks like you're redirecting server side
Yes, I am trying to redirect server side
that's where I am confused at the moment
So, I am able to get the session running
I am following the quickstart doc
so the Checkout page is appearing?
that is what you mean by
So, I am able to get the session running
if I have that right?
ok so that means your code at
Response.Headers.Add("Location", session.Url);
return new StatusCodeResult(303);
has issues.
Do you have a webpage that is making requests to your dotnet backend? or are you doing everything server-side
yes
everything serverside as soon as you click register
that is an ajax post call
I get an error of parameter index out of range
I believe it has something to do with the list of prices
I get an error of parameter index out of range
well that would be it
that is something you'll have to devug
you are accessing an index outside of the length of the aray
debug*
Yup, but the thing is I added one product and it still isn't returning it
That product's price is the same as the one I am selecting
the list of price comes from stripe. I don't control it.
sorry I mean that this is your code and your Stripe account, meaning you would have to debug things like
"are you fetching the right Prices"
why are you not getting back Prices, did you create a live mode Price and instead are fetching a test mode Price?
you know where the problem lies, so you can narrow down and debug that part, to see why your Prices list is not returning what you want it to