public static bool Verify(NameValueCollection form) { var responseSign = form["sign"]; var mySign = form.Sign(Config.key); _log.InfoFormat("alipay, my sign:{0}, resp sign: {1}", mySign, responseSign); var url = string.Format("{0}?service=notify_verify&partner={1}¬ify_id={2}", PayUtil.GetAlipayUrl(Sandbox), Config.partner, form["notify_id"]); var resp = PayUtil.HttpGet(url); _log.InfoFormat("alipay, my sign:{0}, resp sign: {1}", mySign, responseSign); if (mySign.Equals(responseSign, StringComparison.OrdinalIgnoreCase) && "true".Equals(resp, StringComparison.OrdinalIgnoreCase)) { //check status var tradeStatus = form["trade_status"]; _log.InfoFormat("alipay pay status: {0}, order no:{1}, total_fee: {2}", form["trade_status"], form["out_trade_no"], form["total_fee"]); if (tradeStatus == "WAIT_BUYER_PAY") { } else if (tradeStatus == "TRADE_FINISHED") { var orderId = int.Parse(form["out_trade_no"].Trim()); var totalAmountText = form["total_fee"].Trim(); //TODO: handle order _log.InfoFormat("alipay pay success, order:{0}", orderId); } return(true); } else { _log.InfoFormat("alipay pay fail"); return(false); } }