I'm using DNN 7 , I'm trying to using await/async when calling payment api , but it's giving error not recognizing to async as below , please help me.
protected async void Page_Load(object sender, EventArgs e) { await getSessionAsync(); }
async System.Threading.Tasks.Task getSessionAsync() { using (var client = new HttpClient()) { string sessionID,successIndecator = ""; string amount = "100.00"; string merchant = "700737"; using (var request = new HttpRequestMessage(new HttpMethod("POST"), "API_URL")) { var contentList = new List(); contentList.Add("apiOperation=XXXXXXX"); contentList.Add("apiPassword=XXXXXXX"); contentList.Add("apiUsername=XXXXXXX"); contentList.Add("merchant=XXXXX"); contentList.Add("interaction.operation=XXXXXX"); contentList.Add("order.id=XXXXXX"); contentList.Add("order.amount=XXXXXX"); contentList.Add("order.currency=XXXXXX"); contentList.Add("order.description=XXXXXX"); contentList.Add("interaction.merchant.url=XXXXXX"); contentList.Add("interaction.merchant.name=XXXXXXX"); contentList.Add("interaction.returnUrl=http://localhost/tResult.aspx"); request.Content = new StringContent(string.Join("&", contentList)); request.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/x-www-form-urlencoded");
var response = await client.SendAsync(request); string result = response.Content.ReadAsStringAsync().Result; if (result.Contains("session")) { string[] details = result.Split('&'); string[] sessionDetails = details[3].ToString().Split('='); sessionID = sessionDetails[1].ToString();
string[] successIndecatorDeatils = details[6].ToString().Split('='); successIndecator = successIndecatorDeatils[1].ToString(); sessionHidden.Text = sessionID; Session["indicator"] = successIndecator; } else { sessionHidden.Text = "Failed"; } }
} }
These Forums are for the discussion of the open source CMS DNN platform and ecosystem.
For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:
Awesome! Simply post in the forums using the link below and we'll get you started.