I am using Stripe to integrate iDeal checkout in my pizzeria website. The process is split up into two parts:
Some javascript to call the checkout .NET (asmx) webservice
function iDealCheckout() { $.ajax({ type: "POST", url: "iDealSession.asmx/CreateiDealSession", data: "{'Guid':'" + bestelguid + "'}", contentType: "application/json; charset=utf-8", dataType: "json", success: function (data) { //alert("session Id: " + data.d.sessionId + " totaal: " + data.d.totaal); Id = data.d.sessionId; var stripe = Stripe('--------------------------------------'); //key is masked here stripe.redirectToCheckout({ // Make the id field from the Checkout Session creation API response // available to this file, so you can provide it as parameter here // instead of the {{CHECKOUT_SESSION_ID}} placeholder. sessionId: Id }).then(function (result) { // If `redirectToCheckout` fails due to a browser or network // error, display the localized error message to your customer // using `result.error.message`. alert(result.error.message); }); }, error: function () { alert("CreateiDealSession mislukt"); } }); }
The ajax call returns a Session ID that is used to call stripe.redirectToCheckout which redirects to the iDeal payment page.
An .asmx webmethod that returns the Session ID:
public class values { public string sessionId; public string totaal; } [WebMethod(EnableSession = true)] public values CreateiDealSession(string Guid) { DataTable dt = new DataTable(); string query = "SELECT * FROM Bestellingen WHERE Hashcode=@Guid"; string constr = ConfigurationManager.ConnectionStrings["Pizzas"].ConnectionString; using (SqlConnection con = new SqlConnection(constr)) { using (SqlCommand cmd = new SqlCommand(query)) { cmd.Connection = con; cmd.Parameters.AddWithValue("@Guid", Guid); using (SqlDataAdapter sda = new SqlDataAdapter(cmd)) { sda.Fill(dt); } } } double totaal = 0; foreach (DataRow row in dt.Rows) { double stukprijs = double.Parse(row["Prijs"].ToString()); var subtotaal = stukprijs * int.Parse(row["Aantal"].ToString()); totaal += subtotaal; } totaal = totaal * 100; long amount = Convert.ToInt32(totaal); StripeConfiguration.ApiKey = "-------------------------------------"; //apikey is masked here var options = new SessionCreateOptions { PaymentMethodTypes = new List<string> { "ideal", }, LineItems = new List<SessionLineItemOptions> { new SessionLineItemOptions { Name = "Uw bestelling bij pizzeria I Colori", Description = "Pasta's & Pizza's", Amount = amount, Currency = "eur", Quantity = 1, }, }, SuccessUrl = "https://pizzeria.aspworld.nl/Success.html?session_id={CHECKOUT_SESSION_ID}", CancelUrl = "https://example.com/cancel", }; var service = new Stripe.Checkout.SessionService(); Stripe.Checkout.Session session = service.Create(options); values values = new values(); values.sessionId = session.Id; values.totaal = amount.ToString(); return values; }
Now all of this is running without problems in mobile and desktop Chrome and Firefox, and the browser redirects to the iDeal payment page. But the stripe.redirectToCheckout does not work in mobile Safari, both Android and iOS.