Hi,
The following code work everywhere except for victors in Iraq:
$(document).ready(function () {
$("#checkout-stripe").click(function () {
var movie = new Object();
movie.UnitPrice = @vblplan;
movie.Description = '@Html.Raw(vblplantype)';
movie.Successit = location.protocol + "//" + location.host + "/shared/thankyou?redirect_status=$@Html.Raw(vblplan +"("+ vblplantype +")")";
movie.Cancelit = "@strQueryString";
$.ajax({
url: '/api/StripePayment',
type: 'POST',
//dataType: 'json',
data: movie,
success: function (data, textStatus, xhr) {
window.location.href = data.SessionUrl;
},
error: function (xhr, textStatus, errorThrown) {
console.log('Error in Operation');
}
});
});
});
<button type="button" class="btn btn-primary mt-1 mb-1 px-4" id="checkout-stripe">
Credit Card or Debit
</button>
public IHttpActionResult Post(StripeData stripeData)
{
var options = new SessionCreateOptions
{
LineItems = new List<SessionLineItemOptions>
{
new SessionLineItemOptions
{
PriceData = new SessionLineItemPriceDataOptions
{
UnitAmount = stripeData.UnitPrice * 100,
Currency = "usd",
ProductData = new SessionLineItemPriceDataProductDataOptions
{
Name = stripeData.Description,
},
},
AdjustableQuantity = new SessionLineItemAdjustableQuantityOptions
{
Enabled = true,
Minimum = 1,
Maximum = 3,
},
Quantity = 1,
},
},
Mode = "payment",
SuccessUrl = stripeData.Successit,
CancelUrl = stripeData.Cancelit,
// CustomerEmail = stripeData.Customeremail,
};
var service = new SessionService();
Session session = service.Create(options);
HttpContext.Current.Response.Headers.Add("Location", session.Url);
return Json(new { SessionUrl = session.Url });
}