首页 > 编程知识 正文

做一个可以支付的小程序需要多少钱,小程序可以接入第三方支付接口吗

时间:2023-05-03 09:32:51 阅读:129964 作者:2958

文章目录【微信开发】SpringBoot集成微信小程序支付1、SprinBoot后端2、Uniapp前端(1)提醒支付)2)测试用例技术共享区域

【微信开发】SpringBoot集成微信小程序支付

在上一篇文章的基础上,实现小程序的支付很简单,直接支付界面和前端如何激发微信小程序的支付就OK了

【微信开发】SpringBoot集成微信小程序授权注册1、向SprinBoot后端添加控制器两种方法,一种创建订单,另一种支付正常回调

@ API操作(批量订单) postmapping (创建订单) ) publicAjaxresultcreateorder (请求订单) Rettity } @ API操作(“回调支付”)请求映射(“通告URL”)公共字符串通告URL ) { return weixin service.notify URL }

/** *批量采购订单接口* * @ param entity * @ return */ajaxresultcreateorder (订单信息); /** *回调的支付* * @return */String notifyUrl (; service两个方法的实现类

@ overridepublicajaxresultcreateorder (orderinfoentity ) try ) wxpayunifiedorderrequestorderrequest=newxpayunifiedorderderrrrequest 订单请求. setbody (tell sea技术); order request.setouttradeno (uuid.random uuid ).toString ).substring (0,32 ); order request.settrade type (wxpayconstants.trade type.jsapi; order request.settotalfee (basewxpayrequest.yuant ofen (entity.get money ) ); order request.set OpenID (entity.get OpenID ) ); order request.setspbillcreateip (servlet utils.get clientip () ); order request.setnotifyurl (wxpayproperties.getnotifyurl (); object order=wxpayservice.create order (order request ); log.error (订单成功。 )、order.toString ); return AjaxResult.success (,JSON.Tojsonstring ),order ); }catch(wxpayexceptione ) {log.error ) (订单失败(),e.toString ) ); return AjaxResult.error ('订单失败); } @ overridepublicstringnotifyurl () try ) httpservletrequestrequest=servlet utils.getrequest ); htpservletresponseresponse=servlet utils.getresponse (stringxmlresult=I outils.tostring (request.get inputstream ) (,) wxpayordernotifyresultresult=wxpayservice.parseordernotifyresult (XML result ); //需要加入自己处理订单的业务逻辑,判断订单是否已支付。 否则,可能会重复调用string orderid=result.getouttradeno ()。 stringt radeno=result.gettransactionid (; stringtotalfee=basewxpayresult.fentoyuan (result.gettotalfee (); returnwxpaynotifyresponse.success ('处理成功! ' ); }catch(exceptione ) {log.error )、(微信回调结果异常、异常原因)、e.getMessage ); returnwxpaynotifyresponse.fail (e.getmessage ) ); }订单参数模拟

导入lombok.data; /** *模拟订单参数* * @ authortellsea * @ date 2021/11/11 */@ datapublicclassorderinfo {专用订单操作系统id; 隐私字符串监视; ) 2、Uniapp前端(1)的支付提醒在第一个集成小程序注册文章中有所有应该配置,这里只需要通过统一订单接口返回的参数来提醒支付

let param={ OpenID :’成功登录获取的OpenID’,money: 1}; that.$ u.post ('/au/weixin/create order ',param ).then(RES={letdata=Json.parse ) RES.data ); wx.request payment (timestamp : data.timestamp,nonceStr: data.nonceStr,package: data.packageValue,sign ) )2)测试用例这里微信开发者工具的测试情况

技术共享区域

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。