public int ExecuteCardCharge(string cnum, string amount, string userName, string description) { string cardid = string.Empty, amt = string.Empty, desc = string.Empty, oMsg = string.Empty; cardid = cnum; amt = amount; desc = description;// "For Purchasing Categories"; int rc = -1; JavaScriptSerializer jsSerializer = new JavaScriptSerializer(); var jsonBody = jsSerializer.Serialize(""); WcrClassLibrary.WcrHttpClient client = new WcrClassLibrary.WcrHttpClient(userName); HttpResponseMessage resp = client.PostAsync(Gateway.apiroute_immediatecharge + Gateway.getkey_subscriberid + "/" + cardid + "/" + amt + "/" + desc, new StringContent(jsonBody)).GetAwaiter().GetResult(); if (resp.IsSuccessStatusCode) { oMsg = resp.Content.ReadAsStringAsync().GetAwaiter().GetResult(); if (!oMsg.Contains("EXCEPTION")) { rc = 0; } } return(rc); }
/// <summary> /// RetrieveCardByAssociateID /// Fires the call to the WebAPI to prepare retrieval of all cards for associate ID /// </summary> /// <param name="associateId"></param> /// <returns></returns> /// public int RetrieveCardByAssociateID(int associateId, string inUserName) { int rc = -1; WcrClassLibrary.WcrHttpClient client = new WcrClassLibrary.WcrHttpClient(inUserName); HttpResponseMessage resp = client.GetAsync(Gateway.apiroute_retrievebyassociateid + Gateway.getkey_subscriberid + "/" + associateId.ToString()).GetAwaiter().GetResult(); if (resp.IsSuccessStatusCode) { rc = Convert.ToInt32(resp.Content.ReadAsStringAsync().GetAwaiter().GetResult()); } return(rc); }