C#(Winform)+H5(Html)微信/支付宝对接接口及前端支付页面

由于工作需要,开了一个C#(Winform)+H5(Html)的微信/支付宝对接接口,需要使用的小伙伴可通过链接进行下载,欢迎各位小伙伴交流探讨。

  • 测试链接:http://dumikj.com/pay.html (必须用手机浏览器打开)

  • 支付页面

在这里插入图片描述

  • 后台服务
    在这里插入图片描述
  • 支付相关信息存储表
    在这里插入图片描述
  • 核心代码
        [HttpPost]
        public PayResponse pay(PayRequest request)
        {
            PayResponse response = new PayResponse();
            response.isSuccess = false;
            response.errorMsg = "";

            try
            {
                LogHelper.LogHelper.AddShowLog("Request:" + Serializer<PayRequest>(request));

                request = GetPayDefaultParam(request);

                decimal realMoney = request.amount;

                CreatePayRecord(request.pforder, request.amount, realMoney, request.rolename, request.roleid, request.serverid, request.payType);

                checkSing(request);

                string returnUrl = request.returnurl;
                string notifyUrl = request.notifyurl;
                string productInfo = "game";
              
                string orderId = request.pforder;
                decimal totalFee = realMoney;

                notifyUrl = System.Web.HttpUtility.UrlDecode(notifyUrl);
                returnUrl = System.Web.HttpUtility.UrlDecode(returnUrl);

                if (request.payType == 1)
                {
                    response.url = WxH5Service.GetRequestUrl(returnUrl,
                        notifyUrl,
                        orderId,
                        totalFee,
                        productInfo,
                        request.mch_id,
                        request.appid,
                        request.appsecret);

                }
                else if (request.payType == 2)
                {
                    response.url = AliWAPService.GetRequestUrl(returnUrl,
                        notifyUrl,
                        orderId,
                        totalFee,
                        productInfo,
                        request.appid,
                        request.signkey,
                        request.appsecret);
                }
                else
                {
                    response.errorMsg = "不支持的支付方式" + request.payType;
                }

                if (data.ContainsKey(request.appid))
                {
                    decimal amount = data[request.appid];
                    amount += request.amount;
                    data[request.appid] = amount;
                }
                else
                {
                    data.Add(request.appid, request.amount);
                }

                string json = Serializer(data);
                File.WriteAllText(filePath, json);

                response.isSuccess = true;

                LogHelper.LogHelper.AddShowLog("Response:" + Serializer<PayResponse>(response));
            }
            catch (Exception ex)
            {
                response.errorMsg = ex.Message;
            }

            response.sign = GetResponseSign(response);

            return response;
        }
  • 源码文件清单
    在这里插入图片描述

  • 源码下载链接

https://download.csdn.net/download/qq_27352959/15639776
  • 2
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

愤怒的爱码仕

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值