我有一个DNN 9定制模块,正在使用新的支付网关进行定制。我需要将异步API调用的结果存储在属于用户控件(.ascx)的TextBox中,并将值写入数据库。
我的异步请求如下:
private static async Task<string> HostedTransactionResponse()
{
var credentials = GetCredentials();
TransactionResult_ProPay result = new TransactionResult_ProPay();
HttpClient client = new HttpClient();
HttpRequestMessage request = new HttpRequestMessage();
HttpResponseMessage response = new HttpResponseMessage();
GatewaySetting_ProPay gatewaySetting = new GatewaySetting_ProPay();
CreateHostedTransactionRequest transactionRequest = new CreateHostedTransactionRequest();
CreateHostedTransactionResponse transactionResponse = new CreateHostedTransactionResponse();
HttpContent content = new StringContent(transactionRequest.ToString());
try
{
request.Headers.Add("Authorizatoin", credentials);
response = await client.PutAsync(gatewaySetting.TestUrl, content);
}
catch (HttpException ex)
{
result.Succeeded = false;
result.ResultMessage = ex.Message;
}
return response.Content.ToString();
}
我后面的部分用户控制代码包括:
objItem.R_ProPay_Enable = chkR_ProPay_Enable.Checked;
objItem.R_ProPay_Id = txtR_ProPay_Id.Text;
UserController.Update(objItem);
当我单击用户界面上的“更新”按钮时,我的意图是获取付款人ID并将其返回到站点,将其写入相应的数据库字段,并在txtR.ProPay_Id.Text属性中进行赋值。
不幸的是,这没有发生。我该如何补救?