You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to use stripe hosted page in my Blazor WASM application. I have a test account.
Describe the bug
The problem is I am getting this error and can't reach the stripe-hosted page. There is no error on the browser console.
To Reproduce
Here is the code I am using;
[HttpPost]
[Authorize]
[ActionName("Create")]
public async Task<IActionResult> Create([FromBody] StripePaymentDTO paymentDTO)
{
try
{
var domain = _configuration.GetValue<string>("Client_URL");
var options = new SessionCreateOptions
{
SuccessUrl = domain+paymentDTO.SuccessUrl,
CancelUrl = domain+paymentDTO.CancelUrl,
LineItems = new List<SessionLineItemOptions>(),
Mode = "payment",
PaymentMethodTypes = new List<string> { "card" }
};
foreach (var item in paymentDTO.Order.OrderDetails)
{
var sessionLineItem = new SessionLineItemOptions
{
PriceData = new SessionLineItemPriceDataOptions
{
UnitAmount = (long)(item.Price*100), //20.00 -> 2000
Currency="usd",
ProductData= new SessionLineItemPriceDataProductDataOptions
{
Name= item.Product.Name
}
},
Quantity= item.Count
};
options.LineItems.Add(sessionLineItem);
}
var service = new SessionService();
Session session = service.Create(options);
return Ok(new SuccessModelDTO()
{
Data = session.Id+";"+session.PaymentIntentId
}) ;
}
catch (Exception ex)
{
return BadRequest(new ErrorModelDTO()
{
ErrorMessage = ex.Message
});
}
}
And here is how I am calling the API:
public async Task<SuccessModelDTO> Checkout(StripePaymentDTO model)
{
try
{
var content = JsonConvert.SerializeObject(model);
var bodyContent = new StringContent(content, Encoding.UTF8, "application/json");
var response = await _httpClient.PostAsync("api/stripepayment/create", bodyContent);
string responseResult = response.Content.ReadAsStringAsync().Result;
if (response.IsSuccessStatusCode)
{
var result = JsonConvert.DeserializeObject<SuccessModelDTO>(responseResult);
return result;
}
else
{
var errorModel = JsonConvert.DeserializeObject<ErrorModelDTO>(responseResult);
throw new Exception(errorModel.ErrorMessage);
}
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
I tried with the latest Stripe version and an older one but I am getting the same error. I also created a new test account and used the secret and publishable keys but no luck!
Expected behavior
Supposed to get the stripe-hosted page like the one below but unfortunately, I am getting the error I mentioned.
System information
OS: Windows 10
Browser (if applies) [FF 118, Edge 125]
Server environment [.net core Blazor]
Here is the Stripe dashboard:
The text was updated successfully, but these errors were encountered:
Bug report
I am trying to use stripe hosted page in my Blazor WASM application. I have a test account.
Describe the bug
The problem is I am getting this error and can't reach the stripe-hosted page. There is no error on the browser console.
To Reproduce
Here is the code I am using;
And here is how I am calling the API:
I tried with the latest Stripe version and an older one but I am getting the same error. I also created a new test account and used the secret and publishable keys but no luck!
Expected behavior
Supposed to get the stripe-hosted page like the one below but unfortunately, I am getting the error I mentioned.
System information
Here is the Stripe dashboard:
The text was updated successfully, but these errors were encountered: