用户支付完成后,V2版本微信支付需要调用发货接口,否则微信会告警并且用户也可以进行维权,总之会有灰常多的事情:
1 public void DeliverNotify() 2 { 3 string openId = string.Empty; //买家openid 4 string transactionId = string.Empty;//微信交易单号 5 string orderNo = string.Empty;//我们自己的订单号,文档中的out_trade_no 6 7 8 WxPayModel model = WxPayModel.Create(); 9 string postData = model.CreateDeliverNotifyPackage(openId, transactionId, orderNo); 10 WeiXinHelper.DeliverNotify(postData); 11 }
下面是创建发货通知json的方法:
1 /// <summary> 2 /// 创建发货成功 Package (已测试通过) 3 /// </summary> 4 /// <returns></returns> 5 public string CreateDeliverNotifyPackage(string openId, string transId, string out_trade_no) 6 { 7 Dictionary<string, string> nativeObj = new Dictionary<string, string>(); 8 9 nativeObj.Add("appid", AppId); 10 nativeObj.Add("openid", openId); 11 nativeObj.Add("transid", transId); 12 nativeObj.Add("out_trade_no", out_trade_no); 13 nativeObj.Add("deliver_timestamp", ((DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000).ToString()); 14 nativeObj.Add("deliver_status", "1"); 15 nativeObj.Add("deliver_msg", "ok"); 16 nativeObj.Add("app_signature", GetBizSign(nativeObj)); 17 nativeObj.Add("sign_method", "sha1"); 18 19 var entries = nativeObj.Select(d => string.Format(""{0}": "{1}"", d.Key, d.Value)); 20 21 return "{" + string.Join(",", entries.ToArray()) + "}"; 22 }