重新编写打包百度支付(百度智能小程序支付)

本站:VPS参考评测推荐,专注分享VPS服务器优惠信息!若您是商家也可以在本站进行投稿,查看详情!此外我们还提供软文收录、PayPal代付、广告赞助等服务,查看详情!
部分文章发布时间较久远,可能存在未知因素,购买时建议在本站搜索商家名称,可查看相关文章充分了解商家!若非中文页面可使用谷歌浏览器同步翻译!PayPal代付/收录合作

因为最近项目重建,百度支付被重新编写封装。这次重写增加了签名处理和用户退款,方便后期开发。

因为百度电商开放平台的升级,支付功能搬到了智能小程序上。具体申请流程:百度收银支付开通指南,(https://smart program . Baidu . com/docs/operations/transform/pay/)

(注:支付业务中,服务电话应填写银行预留手机号码。如果报错[银行预留手机号格式验证失败])

百度支付文档:百度收银接口2.0(https://smartprogram.baidu.com/docs/develop/function/tune _ up _ 2.0/)

一、申请通过后,填写百度支付相关配置:

$ config = array( # 39;deal _ id # 39= gt''、//百度收银的财务结算凭证 # 39;app _ key # 39= gt'',//代表应用程序身份的唯一 # 39private _ key # 39= gt'',//私钥的原始字符串 # 39;public _ key # 39= gt'',//平台公钥 # 39;notify _ url # 39= gt'',//支付回拨地址);第二,调用封装好的支付方法,将返回的信息传递给百度小程序。

lt马鞭phpinclude # 39。/Baidu pay . PHP # 39;;$ Baidu pay = new \ feng \ Baidu pay($ config);$order_sn = time()。兰特(10009999);$ order = array( # 39;正文 # 39;= gt'测试商品 # 39;,//产品描述 # 39;total _ amount # 39= gt'1',//订单金额(积分) # 39;order _ sn # 39= gt$order_sn,//订单号);$re = $baidupay->xcx pay($ order);die(JSON _ encode($ re));// JSON直接返回applet客户端PHP applet支付类xcxPay:

/** * [xcxPay百度小程序支付]* @ param[type]$ order[订单信息数组]* @ return[type][description]* $ order = array(* # 39;正文 # 39;= gt'',//产品描述* # 39;total _ amount # 39= gt'',//订单金额(积分)* # 39;order _ sn # 39= gt'',//订单号*);*/公共静态函数xcxPay($order){ if(!is _ array($ order)| | count($ order) lt;3)模具( 缺少数组数据信息!");$ config = self::$ config;$ requestParamsArr = array( # 39;appKey # 39= gt$ config[ # 39;app _ key # 39], 'dealId # 39= gt$ config[ # 39;deal _ id # 39], 'tpOrderId # 39= gt$ order[ # 39;order _ sn # 39], '总金额 # 39;= gt$ order[ # 39;total _ amount # 39], );$ RSA sign = self::makeSign($ requestParamsArr,$ config[ # 39;private _ key # 39]);//认领百度的支付签名$ bizInfo = array( # 39;tpData # 39= gt数组( appKey = gt$ config[ # 39;app _ key # 39], dealId = gt$ config[ # 39;deal _ id # 39], tpOrderId = gt$ order[ # 39;order _ sn # 39], rsaSign = gt$rsaSign, 总金额 = gt$ order[ # 39;total _ amount # 39], returnData = gt'', 显示数据= gt数组( cashierTopBlock = gtarray(数组([ ;leftCol= gt"订单名称", 右栏 = gt$ order[ # 39;正文 # 39;] ],[ ;leftCol= gt"数量", 右栏 = gt"1 ],[ ;leftCol= gt"订单金额", 右栏 = gt$ order[ # 39;total _ amount # 39] ])、数组([ ;leftCol= gt"地址", 右栏 = gt"北京市海淀区上地十街10号百度大厦],[ ;leftCol= gt"服务", 右栏 = gt"2018/10/29 14:51 ;],[ ;leftCol= gt"服务", 右栏 = gt"百度App ]))), ;交易标题 = gt$ order[ # 39;正文 # 39;], dealSubTitle = gt$ order[ # 39;正文 # 39;], dealThumbView = gt"https://b . BD static . com/search box/icms/search box/img/swan -logo . png ;,), orderDetailData = gt'');$ b order = array( # 39;dealId # 39= gt$ config[ # 39;deal _ id # 39], 'appKey # 39= gt$ config[ # 39;app _ key # 39], '总金额 # 39;= gt$ order[ # 39;total _ amount # 39], 'tpOrderId # 39= gt$ order[ # 39;order _ sn # 39], 'dealTitle # 39= gt$ order[ # 39;正文 # 39;], 'signFieldsRange # 39= gt1, 'rsaSign # 39= gt$rsaSign, # 39;bizInfo # 39= gtjson_encode($bizInfo),);返回$ bdOrder}三、百度智能小程序的使用

天鹅

ltview class = wrap gt ltview class = card -区域 gt lt按钮绑定:tap = requestPolymerPayment type = 主要 悬停-停止-传播= true gt支付0.01元