提问人:Jimmy 提问时间:9/21/2023 更新时间:9/21/2023 访问量:18
我向支付提供商提出的请求可能陷入僵局
Likely deadlock to my request to payment provider
问:
我已经从控制台项目中翻译了代码,并且似乎遇到了死锁,因为代码没有向服务器发送请求,它们的日志什么也没显示。当我调试时什么也没发生,它只是在等待一些东西。
如何为 web.forms 或任何其他基于 Web 的处理程序更改此设置?
Public Function MakePaymentRequest(ByVal swishNumberToPay As String, ByVal amount As Decimal, ByVal message As String, ByVal instructionUUID As String) As PaymentRequestECommerceResponse
Try
Dim requestData = New PaymentRequestECommerceData() With {
.payeePaymentReference = _payeePaymentReference,
.callbackUrl = _callbackUrl,
.payerAlias = swishNumberToPay,
.payeeAlias = _merchantAlias,
.amount = Math.Round(amount, 2).ToString().Replace(",", "."),
.currency = "SEK",
.message = message
}
Dim handler As New HttpClientHandler
Dim client As New HttpClient
PrepareHttpClientAndHandler(handler, client)
Dim requestURL As String = URL.ProductionPaymentRequest & instructionUUID
Dim mhttpMethod = HttpMethod.Put
Select Case _environment
Case "EMULATOR"
requestURL = URL.EmulatorPaymentRequest & instructionUUID
Case "SANDBOX"
requestURL = URL.SandboxPaymentRequest
mhttpMethod = HttpMethod.Post
End Select
Dim httpRequestMessage = New HttpRequestMessage With {
.Method = mhttpMethod,
.RequestUri = New Uri(requestURL),
.Content = New StringContent(JsonConvert.SerializeObject(requestData), Encoding.UTF8, "application/json")
}
httpRequestMessage.Headers.Add("host", httpRequestMessage.RequestUri.Host)
Dim response = client.SendAsync(httpRequestMessage).Result <-- I cant get past here. Nothing happens at this step and i think its deadlocked.
Dim errorMessage As String = String.Empty
Dim location As String = String.Empty
If response.IsSuccessStatusCode Then
Dim headers = response.Headers.ToList()
If headers.Any(Function(x) x.Key = "Location") Then
location = response.Headers.GetValues("Location").FirstOrDefault()
End If
Else
Dim readAsStringAsync = response.Content.ReadAsStringAsync()
errorMessage = readAsStringAsync.Result
End If
client.Dispose()
handler.Dispose()
Return New PaymentRequestECommerceResponse() With {
.[Error] = errorMessage,
.Location = location
}
Catch ex As Exception
Return New PaymentRequestECommerceResponse() With {
.[Error] = ex.ToString(),
.Location = ""
}
End Try
End Function
答: 暂无答案
评论