public Tansaction PaymentCheck(string storeId, string authKey, string refs) { Tansaction xs = null; if (client.BaseAddress == null) { GetBaseAddress(); } client.Timeout.Add(new TimeSpan(0, 0, 5)); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", ConfigurationManager.AppSettings["bearerToken"].ToString()); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var jsonString = "{\"ivp_method\":\"check\",\"ivp_store\":\"" + storeId + "\",\"ivp_authkey\":\"" + authKey + "\",\"order_ref\":\"" + refs + "\"}"; var httpContent = new StringContent(jsonString, Encoding.UTF8, "application/json"); HttpResponseMessage response = client.PostAsync("finpay/2.0.0/check-transactions", httpContent).Result; if (response.IsSuccessStatusCode) { //att = await response.Content.ReadAsAsync<AirportTransferTransaction>(); string resultJSON = response.Content.ReadAsStringAsync().Result; xs = JsonConvert.DeserializeObject <Tansaction>(resultJSON); } return(xs); }
public Tansaction PostPayment(string amount, string traId, string desc) { Tansaction xs = null; if (client.BaseAddress == null) { GetBaseAddress(); } client.Timeout.Add(new TimeSpan(0, 0, 5)); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", ConfigurationManager.AppSettings["bearerToken"].ToString()); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var pairs = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("ivp_method", "create"), new KeyValuePair <string, string>("ivp_store", ConfigurationManager.AppSettings["finpayStoreId"].ToString()), new KeyValuePair <string, string>("ivp_authkey", ConfigurationManager.AppSettings["finpayAuthKey"].ToString()), new KeyValuePair <string, string>("ivp_amount", amount), new KeyValuePair <string, string>("ivp_currency", "idr"), new KeyValuePair <string, string>("ivp_test", "0"), new KeyValuePair <string, string>("ivp_cart", traId), new KeyValuePair <string, string>("ivp_desc", desc), new KeyValuePair <string, string>("return_auth", ConfigurationManager.AppSettings["finpayAuthURL"].ToString() + Base64Encode(traId)), new KeyValuePair <string, string>("return_decl", ConfigurationManager.AppSettings["finpayAuthURL"].ToString() + Base64Encode(traId)), new KeyValuePair <string, string>("return_can", ConfigurationManager.AppSettings["finpayAuthURL"].ToString() + Base64Encode(traId)) }; var content = new FormUrlEncodedContent(pairs); //var jsonString = "{\"ivp_method\":\"create\",\"ivp_store\":\"" + ConfigurationManager.AppSettings["finpayStoreId"].ToString() + "\",\"ivp_authkey\":\"" + ConfigurationManager.AppSettings["finpayAuthKey"].ToString() + "\",\"ivp_amount\":\"" + amount + "\",\"ivp_currency\":\"idr\",\"ivp_test\":\"1\",\"ivp_cart\":\"" + traId + "\",\"ivp_desc\":\"" + desc + "\",\"return_auth\":\"" + ConfigurationManager.AppSettings["finpayAuthURL"].ToString() + "\",\"return_decl\":\"" + ConfigurationManager.AppSettings["finpayDeclinedURL"].ToString() + "\",\"return_can\":\"" + ConfigurationManager.AppSettings["finpayCancelledURL"].ToString() + "\"}"; //var httpContent = new StringContent(jsonString, Encoding.UTF8, "application/json"); HttpResponseMessage response = client.PostAsync("finpay/2.0.0/transactions", content).Result; if (response.IsSuccessStatusCode) { //att = await response.Content.ReadAsAsync<AirportTransferTransaction>(); string resultJSON = response.Content.ReadAsStringAsync().Result; xs = JsonConvert.DeserializeObject <Tansaction>(resultJSON); } return(xs); }