public static async Task <decimal> PostOrderQueryAsync(long orderid) { XElem x = new XElem("xml"); x.AddChild("appid", appid); x.AddChild("mch_id", mchid); x.AddChild("nonce_str", noncestr); x.AddChild("out_trade_no", orderid.ToString()); string sign = Sign(x); x.AddChild("sign", sign); XElem xe = (await WCPay.PostAsync <XElem>(null, "/pay/orderquery", x.Dump())).B; sign = xe.Child(nameof(sign)); xe.Sort(); if (sign != Sign(xe, "sign")) { return(0); } string return_code = xe.Child(nameof(return_code)); if (return_code != "SUCCESS") { return(0); } decimal cash_fee = xe.Child(nameof(cash_fee)); return(cash_fee); }
public static async Task <string> PostRefundQueryAsync(long orderid) { XElem xo = new XElem("xml"); xo.AddChild("appid", appid); xo.AddChild("mch_id", mchid); xo.AddChild("nonce_str", noncestr); xo.AddChild("out_trade_no", orderid.ToString()); string sign = Sign(xo); xo.AddChild("sign", sign); XElem xi = (await WCPay.PostAsync <XElem>(null, "/pay/refundquery", xo.Dump())).B; sign = xi.Child(nameof(sign)); xi.Sort(); if (sign != Sign(xi, "sign")) { return("返回结果签名错误"); } string return_code = xi.Child(nameof(return_code)); if (return_code != "SUCCESS") { string return_msg = xi.Child(nameof(return_msg)); return(return_msg); } string result_code = xi.Child(nameof(result_code)); if (result_code != "SUCCESS") { return("退款订单查询失败"); } string refund_status_0 = xi.Child(nameof(refund_status_0)); if (refund_status_0 != "SUCCESS") { return(refund_status_0 == "PROCESSING" ? "退款处理中" : refund_status_0 == "REFUNDCLOSE" ? "退款关闭" : "退款异常"); } return(null); }
public static async Task <string> PostRefundAsync(long orderid, decimal total, decimal cash) { string orderno = orderid.ToString(); XElem xo = new XElem("xml"); xo.AddChild("appid", appid); xo.AddChild("mch_id", mchid); xo.AddChild("nonce_str", noncestr); xo.AddChild("op_user_id", mchid); xo.AddChild("out_refund_no", orderno); xo.AddChild("out_trade_no", orderno); xo.AddChild("refund_fee", ((int)(cash * 100)).ToString()); xo.AddChild("total_fee", ((int)(total * 100)).ToString()); string sign = Sign(xo); xo.AddChild("sign", sign); XElem xi = (await WCPay.PostAsync <XElem>(null, "/secapi/pay/refund", xo.Dump())).B; string return_code = xi.Child(nameof(return_code)); if (return_code != "SUCCESS") { string return_msg = xi.Child(nameof(return_msg)); return(return_msg); } string result_code = xi.Child(nameof(result_code)); if (result_code != "SUCCESS") { string err_code_des = xi.Child(nameof(err_code_des)); return(err_code_des); } return(null); }
public static async Task <string> PostUnifiedOrderAsync(long orderid, decimal total, string openid, string ip, string notifyurl) { XElem x = new XElem("xml"); x.AddChild("appid", appid); x.AddChild("body", BODY_DESC); x.AddChild("mch_id", mchid); x.AddChild("nonce_str", noncestr); x.AddChild("notify_url", notifyurl); x.AddChild("openid", openid); x.AddChild("out_trade_no", orderid.ToString()); x.AddChild("spbill_create_ip", ip); x.AddChild("total_fee", ((int)(total * 100)).ToString()); x.AddChild("trade_type", "JSAPI"); string sign = Sign(x); x.AddChild("sign", sign); XElem xe = (await WCPay.PostAsync <XElem>(null, "/pay/unifiedorder", x.Dump())).B; string prepay_id = xe.Child(nameof(prepay_id)); if (prepay_id == null) { prepay_id = xe.Child("err_code"); } return(prepay_id); }
public static async Task <string> PostTransferAsync(int id, string openid, string username, decimal cash, string desc) { XElem x = new XElem("xml"); x.AddChild("amount", ((int)(cash * 100)).ToString()); x.AddChild("check_name", "FORCE_CHECK"); x.AddChild("desc", desc); x.AddChild("mch_appid", appid); x.AddChild("mchid", mchid); x.AddChild("nonce_str", noncestr); x.AddChild("openid", openid); x.AddChild("partner_trade_no", id.ToString()); x.AddChild("re_user_name", username); x.AddChild("spbill_create_ip", spbillcreateip); string sign = Sign(x); x.AddChild("sign", sign); XElem xe = (await WCPay.PostAsync <XElem>(null, "/mmpaymkttransfers/promotion/transfers", x.Dump())).B; string return_code = xe.Child(nameof(return_code)); if ("SUCCESS" == return_code) { string result_code = xe.Child(nameof(result_code)); if ("SUCCESS" != result_code) { string err_code_des = xe.Child(nameof(err_code_des)); return(err_code_des); } } else { string return_msg = xe.Child(nameof(return_msg)); return(return_msg); } return(null); }