CmsWeb/App_Code/MicroPay.cs
(开头部分) 7KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Web;
using System.Threading;
/// <summary>
///MicroPay 的摘要说明
/// </summary>
public class MicroPay
{
/**
* 刷卡支付完整业务流程逻辑
* @param body 商品描述
* @param total_fee 总金额
* @param auth_code 支付授权码
* @throws WxPayException
* @return 刷卡支付结果
*/
public static string Run(string body, string total_fee, string auth_code)
{
Log.Info("MicroPay", "Micropay is processing...");
WxPayData data = new WxPayData();
data.SetValue("auth_code", auth_code);//授权码
data.SetValue("body", body);//商品描述
data.SetValue("total_fee", int.Parse(total_fee));//总金额
data.SetValue("out_trade_no", WxPayApi.GenerateOutTradeNo());//产生随机的商户订单号
WxPayData result = WxPayApi.Micropay(data, 10); //提交被扫支付,接收返回结果
//如果提交被扫支付接口调用失败,则抛异常
if (!result.IsSet("return_code") || result.GetValue("return_code").ToString() == "FAIL")
{
string returnMsg = result.IsSet("return_msg") ? result.GetValue("return_msg").ToString() : "";
Log.Error("MicroPay", "Micropay API interface call failure, result : " + result.ToXml());
throw new WxPayException("Micropay API interface call failure, return_msg : " + returnMsg);
}
//签名验证
result.CheckSign();
Log.Debug("MicroPay", "Micropay response check sign success");
//刷卡支付直接成功
if (result.GetValue("return_code").ToString() == "SUCCESS" &&
result.GetValue("result_code").ToString() == "SUCCESS")
{
Log.Debug("MicroPay", "Micropay business success, result : " + result.ToXml());
return result.ToPrintStr();
}
/******************************************************************
* 剩下的都是接口调用成功,业务失败的情况
* ****************************************************************/
//1)业务结果明确失败
if (result.GetValue("err_code").ToString() != "USERPAYING" &&
result.GetValue("err_code").ToString() != "SYSTEMERROR")
{
Log.Error("MicroPay", "micropay API interface call success, business failure, result : " + result.ToXml());
return result.ToPrintStr();
后面还有 124 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
