// POST api/charge public JsonResult<Charge> Post([FromBody]ChargeModel form) { var clientIP = HttpContext.Current.Request.UserHostAddress; if (clientIP == "::1") { clientIP = "127.0.0.1"; } var orderID = Guid.NewGuid().ToString().Replace("-", ""); var pingpp = new Pingpp.Lib.Pingpp(ConfigurationManager.AppSettings["pingpp_key"], ConfigurationManager.AppSettings["pingpp_api_base"]); Error error; var charge = pingpp.CreateCharge(new ChargeCreateParam() { OrderNo = orderID, App = new Dictionary<string, string>() { { "id", ConfigurationManager.AppSettings["pingpp_appid"] } }, Amount = form.Amount, Channel = form.Channel, Currency = "cny", ClientIp = clientIP, Subject = "Your Subject", Body = "Your Body", Extra = null }, out error); if (error == null) { return Json(charge, new JsonSerializerSettings() { ContractResolver = new CamelCasePropertyNamesContractResolver() }); } else { return null; } }
// POST api/charge public JsonResult <Charge> Post([FromBody] ChargeModel form) { var clientIP = HttpContext.Current.Request.UserHostAddress; if (clientIP == "::1") { clientIP = "127.0.0.1"; } var orderID = Guid.NewGuid().ToString().Replace("-", ""); var pingpp = new Pingpp.Lib.Pingpp(ConfigurationManager.AppSettings["pingpp_key"], ConfigurationManager.AppSettings["pingpp_api_base"]); Error error; var charge = pingpp.CreateCharge(new ChargeCreateParam() { OrderNo = orderID, App = new Dictionary <string, string>() { { "id", ConfigurationManager.AppSettings["pingpp_appid"] } }, Amount = form.Amount, Channel = form.Channel, Currency = "cny", ClientIp = clientIP, Subject = "Your Subject", Body = "Your Body", Extra = null }, out error); if (error == null) { return(Json(charge, new JsonSerializerSettings() { ContractResolver = new CamelCasePropertyNamesContractResolver() })); } else { return(null); } }