赞
踩
Uinty高效开发系列主要包含一系列的Unity开发实例,主要来源于笔者的一个3D游戏项目和一个手机APP项目,适合利用Unity开发游戏或手机APP场景。
。
MI_GetTradeInfo_Req m_GetTradeInfo_Req = new MI_GetTradeInfo_Req(); m_GetTradeInfo_Req.userid = GlobalObj.g_UserId; string uid = GlobalObj.g_UserId.ToString("X2").PadLeft(8, '0'); m_GetTradeInfo_Req.tradeno = ConvertDateTimep(DateTime.Now).ToString("X2") + uid; m_GetTradeInfo_Req.zhifutype = ZhiFuTypeEnum.ZFE_WeiXin; GoodsInfo goodsInfo = new GoodsInfo(); goodsInfo.id = "id1"; goodsInfo.count = 1; m_GetTradeInfo_Req.goodsinfos.Add(goodsInfo); MsgCenter.Instance.SendNetMsg<MI_GetTradeInfo_Req>(MsgType.MsgTp_GetTradeInfo_Req, m_GetTradeInfo_Req); Log.w("Pay: " + m_GetTradeInfo_Req.zhifutype.ToString());
zhiFuRsp.set_userid(zhiFuReq.userid());
string tradeinfo = "";
string payAmount = "1";
string strRet = "";
string currentDir = get_current_dir_name();
string strcmd = "php " + currentDir + "/Php/wxpay/wxPay.php " + mchid_1 + " " + WX_APPID + " " + apiKey_3 + " \'" + privateKey_4 + "\' " + serialNumber_5 + " " + payAmount + " " + tradeno + " " + orderName_8 + " " + notifyUrl_9;
MsgCenter::SystemForPhp(strcmd.c_str(), tradeinfo);
zhiFuRsp.set_appid(WX_APPID);
zhiFuRsp.set_partnerid(mchid_1);
zhiFuRsp.set_tradeinfo(tradeinfo);
zhiFuRsp.set_zhifutype(ZFE_WeiXin);
SendMsg<MI_GetTradeInfo_Rsp>(zhiFuRsp, MsgTp_GetTradeInfo_Rsp, ((MsgHead*)pMsgData)->MsgIndex, fd, client_addr);
string[] tradeinfo = zhiFu_Rsp.tradeinfo.Split(' ');
wxPayTest.AndroidWxPay(zhiFu_Rsp.appid, zhiFu_Rsp.partnerId, tradeinfo[0], tradeinfo[1], tradeinfo[2], tradeinfo[3]);
MI_GetTradeInfo_Req m_GetTradeInfo_Req = new MI_GetTradeInfo_Req();
m_GetTradeInfo_Req.userid = GlobalObj.g_UserId;
m_GetTradeInfo_Req.tradeno = DateTime.Now.ToString("yyyyMMddHHmmssfff");
m_GetTradeInfo_Req.zhifutype = ZhiFuTypeEnum.ZFE_ZhiFuBao;
GoodsInfo goodsInfo = new GoodsInfo();
goodsInfo.id = "id1";
goodsInfo.count = 1;
m_GetTradeInfo_Req.goodsinfos.Add(goodsInfo);
MsgCenter.Instance.SendNetMsg<MI_GetTradeInfo_Req>(MsgType.MsgTp_GetTradeInfo_Req, m_GetTradeInfo_Req);
Log.w("Pay: " + m_GetTradeInfo_Req.zhifutype.ToString());
string strRet = "";
string currentDir = get_current_dir_name();
string strcmd = "php " + currentDir + "/Php/zfbpay/zfbPay.php " + ZFB_APPID + " " + tradeno + " " + zfb_private_key + " " + ali_public_key + " " + zfbNotifyUrl + " " + payAmount;
LOG(Info, strcmd.c_str());
MsgCenter::SystemForPhp(strcmd.c_str(), tradeinfo);
zhiFuRsp.set_appid(ZFB_APPID);
zhiFuRsp.set_partnerid(mchid_1);
zhiFuRsp.set_tradeinfo(tradeinfo);
zhiFuRsp.set_zhifutype(ZFE_ZhiFuBao);
SendMsg<MI_GetTradeInfo_Rsp>(zhiFuRsp, MsgTp_GetTradeInfo_Rsp, ((MsgHead*)pMsgData)->MsgIndex, fd, client_addr);
支付宝支付服务端日志截图
客户端接收交易信息,调用微信客户端发起交易:
Log.w("prepay_id:" + zhiFu_Rsp.tradeinfo);
string tradeinfo = zhiFu_Rsp.tradeinfo;
wxPayTest.AndroidAliPay(zhiFu_Rsp.appid, tradeinfo);
支付宝交易完成支付宝平台通知交易结果,服务器处理回调服务端日志截图
解压WeiXinAndZhiFuBaoPay.zip,可得到如下目录:
ProtoGen: ProtoBuf编译目录,不用关注
WeiXinAndZhiFuBaoPay_UnityClient: 示例工程Unity客户端,使用unity
2019.2.2f1版本打开WeiXinAndZhiFuBaoPay_UnityClient文件夹,在设置中将工程切换至Android平台。
打开Project Settings,导入和设置Keystore,测试工程中带的l00108587.keystore的密码是l00108587
设置Player和Package Name信息(与微信平台注册移动应用信息一致):
Build成xx.apk安装至手机。测试客户端截图
WeiXinAndZhiFuBaoPay_C++Server: 示例工程服务器端,采用C++编译。
编译环境:
LSB Version: :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOS
Description: CentOS Linux release 8.5.2111
protobuf-3.13.0
gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-4)
g++ (GCC) 8.5.0 20210514 (Red Hat 8.5.0-4)
cmake version 3.20.2
PHP 8.0.26 (cli) (built: Dec 1 2022 03:47:54) ( NTS )
编译方法
将文件上传至centos系统,以”/xxfw/WeiXinAndZhiFuBaoPay/”目录为例,在MsgCenter.cpp中修改支付相关参数,及WeiXinAndZhiFuBaoPay_C++Server\Php\wxpay目录下的证书和私钥(apiclient_key.pem/cert.pem/serial_no.text)。
cd /xxfw/WeiXinAndZhiFuBaoPay/
ls
make
链接:https://pan.baidu.com/s/1hNACupGmk9KQpGJ3oStD-g?pwd=jabf
提取码:jabf
获取解压密码
链接:http://jiajiatong.store/target.html?id=17
上一章:
链接:Unit 高效开发系列 - 第七章 基于微信和支付宝登录
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。