Post

Replies

Boosts

Views

Activity

Reply to Apple Pay on the WEB > Requesting Apple Pay Session > "An existing connection was forcibly closed by the remote host "
We use the next code to obtain the apple session (but it keeps failing): ServicePointManager.Expect100Continue = True System.Net.ServicePointManager.SecurityProtocol = Net.SecurityProtocolType.Tls12 Dim Merchant_ID_Key As String = Server.MapPath("./cert/merchant_id.key") Dim Merchant_ID_Cert As String = Server.MapPath("./cert/merchant_id.pem") Dim encoding As ASCIIEncoding = New ASCIIEncoding() Dim postData As String postData = "{""merchantIdentifier"":""merchant.com.xxxxxx.www"", ""initiative"":""web"", ""domainName"":""xxxxxx.com"", ""displayName"":""xxxxxx""}" Dim data() As Byte data = encoding.GetBytes(postData) Dim SrvCertificate As System.Security.Cryptography.X509Certificates.X509Certificate2Collection = New System.Security.Cryptography.X509Certificates.X509Certificate2Collection() SrvCertificate.Import(Merchant_ID_Cert, Merchant_ID_Key, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags.MachineKeySet Or System.Security.Cryptography.X509Certificates.X509KeyStorageFlags.PersistKeySet) 'Prepare web request... Dim myRequest As HttpWebRequest myRequest = CType(WebRequest.Create("https://apple-pay-gateway.apple.com/paymentservices/paymentSession "), HttpWebRequest) myRequest.Method = "POST" myRequest.ContentType = "application/x-www-form-urlencoded" myRequest.ContentLength = data.Length myRequest.ClientCertificates = SrvCertificate Dim newStream As Stream = myRequest.GetRequestStream() 'Send the data. newStream.Write(data, 0, data.Length) 'Get the response Dim myResponse As HttpWebResponse myResponse = myRequest.GetResponse() We still get the same error: System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send. --- System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. --- System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host We don't know how to fix it or where in the code the bug is. We don't know what exactly we are doing wrong. Does anyone have any .NET tutorials on Apple Pay on web? Please, we would appreciate it if someone could help us to solve it so that we can continue with the integration. Thank you so much!
Mar ’21