Building out the iframe and charge cardToken on the sandbox in C# and localhost, the iframe works, the cardToken is returned, and the charge is made.
When it is deployed on the live server, the following error occurs:
"The request was aborted: Could not create an SSL/TLS secure channel."
I've seen this before and it is usually fixed by setting the TLS to TLS12 with:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
Local machine environment: Windows 10 Pro, .NET Framework 4.5, IIS version 10
Live server environment: Windows Server 2008 R2, .NET Framework 4.5, IIS version 8
[HttpPost] public async Task<ActionResult> Charge(string cloverToken) { string Message = ""; try { // Amount in cents, change this to the actual amount int amount = 10000; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; // Set up the request var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://scl-sandbox.dev.clover.com/v1/charges"); httpWebRequest.ContentType = "application/json"; httpWebRequest.Method = "POST"; //private key-sandbox - Ecommerce API Tokens httpWebRequest.Headers["Authorization"] = "Bearer xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; using (var streamWriter = new StreamWriter(await httpWebRequest.GetRequestStreamAsync())) { // Create the json object string json = $"{ {\"source\": \"{cloverToken}\", \"amount\": {amount}, \"ecomind\": \"ecom\", \"capture\": \"true\", \"currency\": \"USD\"}}"; // Write the json object to the request stream streamWriter.Write(json); } // Get the response var httpResponse = (HttpWebResponse)await httpWebRequest.GetResponseAsync(); using (var streamReader = new StreamReader(httpResponse.GetResponseStream())) { // Read the response into a string var responseText = streamReader.ReadToEnd(); Message = responseText; // TODO: Parse this response to handle success/failure appropriately. } } catch (Exception ex) { Message = "exception" + ex.Message; } return Json(Message); }