一、App平台支付流程

流程:支付平台功能申请 -> manifest.json 里配置支付参数 -> uni-app 里调用 API 进行支付

二、微信App支付功能申请

  1. 到 微信开放平台 申请移动应用并开通支付功能,申请应用后可以获取 AppIDAppSecret
  2. 应用接入 微信商户平台,选择 App 支付
  3. 开通支付功能后可获取支付业务服务器配置数据:PARTNER(财付通商户号)、PARTNER_KEY(财付通密钥)、PAYSIGNKEY(支付签名密钥)
  4. 需要将从微信开放平台申请的appid,填回到 manifest-App SDK配置-支付-微信支付 中。打包后生效

//微信支付
uni.getProvider({service: 'payment',      //获取服务供应商success: (res)=> {console.log(res.service) //服务类型:paymentconsole.log(res.provider)  //不同服务类型下可能的取值:["alipay","wxpay"]// if(res.provider.indexOf('wxpay')){//服务提供商(从服务供应商中获取,是否包含微信支付)//调取后台接口,获取微信支付的订单号this.$Z.post(this.$url+'/UserOrderNumber',{你要传给后台的参数(具体看后台要什么参数)},{}).then(res=>{console.log('获取微信支付的订单号',res)let orderData = res.data.orderNumber//调取后台接口,获取微信支付的订单数据this.$Z.post(this.$url+'/pay/aliPay',{//把订单号与支付方式传给后台(具体看后台要什么参数)},{}).then(res=>{let weixinOrderInfo = res.data.data;  从后台返回的微信订单数据let weixinorder = this.getPayInfo(weixinOrderInfo);//支付uni.requestPayment({provider: 'wxpay',    //服务提供商(微信)(服务提供商,通过uni.getProvider获取)orderInfo:weixinorder,success(res){console.log('success:' + JSON.stringify(res));},fail(err){console.log('fail:' + JSON.stringify(err));}});})})// }}
});//二次签名
getPayInfo (orderInfo) {let res = orderInfo, // 后台返回的统一下单数据key = "", // 加密Key,微信支付填写的key(后台提供)payInfo = {appid: res.appid,noncestr:res.noncestr,package: res.package,partnerid: res.partnerid,prepayid: res.prepayid,timestamp: Number(res.timestamp),}// 键值对按照ASCII码从小到大排序生成类似:appid=xxx&body=xx&device_info=1000let keyValueStr = this.mapObjToKeyValue(payInfo, true);// 插入加密Key到最后let strSignTemp = `${keyValueStr}&key=${key}`;// 真正的二次加密(需要引入md5.js源码,小编文章最后会附)let sign = md5(strSignTemp).toUpperCase().substr(0, 32);    console.log(sign) // 可以去微信支付文档做校验payInfo.sign = sign;// 返回字符串给uniapp调起支付用return JSON.stringify(payInfo);
},
/** 根据object生成key value字符串* @params obj: any 要map的对象* @params isSort: boolean 是否根据ASCII字典排序*/
mapObjToKeyValue(obj, isSort = false) {let keys = Object.keys(obj);let str = "";if (isSort) keys.sort();keys.forEach(key => {if (obj.hasOwnProperty(key)) {str += `${key}=${obj[key]}&`;}});return str.replace(/&$/, "");
},

后台返回的微信订单参数:参照微信支付文档的统一下单参数进行对比

如在其过程中遇到:

uniapp APP端微信支付 签名错误,是因为uniapp调起微信支付需要进行第二次签名的,即根据后端统一下单返回数据再进行一次签名,签名方式要确保一致。详情请参照uniapp APP端微信支付 签名错误

附:md5.js源码
/** JavaScript MD5* https://github.com/blueimp/JavaScript-MD5** Copyright 2011, Sebastian Tschan* https://blueimp.net** Licensed under the MIT license:* https://opensource.org/licenses/MIT** Based on* A JavaScript implementation of the RSA Data Security, Inc. MD5 Message* Digest Algorithm, as defined in RFC 1321.* Version 2.2 Copyright (C) Paul Johnston 1999 - 2009* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet* Distributed under the BSD License* See http://pajhome.org.uk/crypt/md5 for more info.*//* global define */;(function ($) {'use strict'/** Add integers, wrapping at 2^32. This uses 16-bit operations internally* to work around bugs in some JS interpreters.*/function safeAdd (x, y) {var lsw = (x & 0xffff) + (y & 0xffff)var msw = (x >> 16) + (y >> 16) + (lsw >> 16)return (msw << 16) | (lsw & 0xffff)}/** Bitwise rotate a 32-bit number to the left.*/function bitRotateLeft (num, cnt) {return (num << cnt) | (num >>> (32 - cnt))}/** These functions implement the four basic operations the algorithm uses.*/function md5cmn (q, a, b, x, s, t) {return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b)}function md5ff (a, b, c, d, x, s, t) {return md5cmn((b & c) | (~b & d), a, b, x, s, t)}function md5gg (a, b, c, d, x, s, t) {return md5cmn((b & d) | (c & ~d), a, b, x, s, t)}function md5hh (a, b, c, d, x, s, t) {return md5cmn(b ^ c ^ d, a, b, x, s, t)}function md5ii (a, b, c, d, x, s, t) {return md5cmn(c ^ (b | ~d), a, b, x, s, t)}/** Calculate the MD5 of an array of little-endian words, and a bit length.*/function binlMD5 (x, len) {/* append padding */x[len >> 5] |= 0x80 << (len % 32)x[((len + 64) >>> 9 << 4) + 14] = lenvar ivar oldavar oldbvar oldcvar olddvar a = 1732584193var b = -271733879var c = -1732584194var d = 271733878for (i = 0; i < x.length; i += 16) {olda = aoldb = boldc = coldd = da = md5ff(a, b, c, d, x[i], 7, -680876936)d = md5ff(d, a, b, c, x[i + 1], 12, -389564586)c = md5ff(c, d, a, b, x[i + 2], 17, 606105819)b = md5ff(b, c, d, a, x[i + 3], 22, -1044525330)a = md5ff(a, b, c, d, x[i + 4], 7, -176418897)d = md5ff(d, a, b, c, x[i + 5], 12, 1200080426)c = md5ff(c, d, a, b, x[i + 6], 17, -1473231341)b = md5ff(b, c, d, a, x[i + 7], 22, -45705983)a = md5ff(a, b, c, d, x[i + 8], 7, 1770035416)d = md5ff(d, a, b, c, x[i + 9], 12, -1958414417)c = md5ff(c, d, a, b, x[i + 10], 17, -42063)b = md5ff(b, c, d, a, x[i + 11], 22, -1990404162)a = md5ff(a, b, c, d, x[i + 12], 7, 1804603682)d = md5ff(d, a, b, c, x[i + 13], 12, -40341101)c = md5ff(c, d, a, b, x[i + 14], 17, -1502002290)b = md5ff(b, c, d, a, x[i + 15], 22, 1236535329)a = md5gg(a, b, c, d, x[i + 1], 5, -165796510)d = md5gg(d, a, b, c, x[i + 6], 9, -1069501632)c = md5gg(c, d, a, b, x[i + 11], 14, 643717713)b = md5gg(b, c, d, a, x[i], 20, -373897302)a = md5gg(a, b, c, d, x[i + 5], 5, -701558691)d = md5gg(d, a, b, c, x[i + 10], 9, 38016083)c = md5gg(c, d, a, b, x[i + 15], 14, -660478335)b = md5gg(b, c, d, a, x[i + 4], 20, -405537848)a = md5gg(a, b, c, d, x[i + 9], 5, 568446438)d = md5gg(d, a, b, c, x[i + 14], 9, -1019803690)c = md5gg(c, d, a, b, x[i + 3], 14, -187363961)b = md5gg(b, c, d, a, x[i + 8], 20, 1163531501)a = md5gg(a, b, c, d, x[i + 13], 5, -1444681467)d = md5gg(d, a, b, c, x[i + 2], 9, -51403784)c = md5gg(c, d, a, b, x[i + 7], 14, 1735328473)b = md5gg(b, c, d, a, x[i + 12], 20, -1926607734)a = md5hh(a, b, c, d, x[i + 5], 4, -378558)d = md5hh(d, a, b, c, x[i + 8], 11, -2022574463)c = md5hh(c, d, a, b, x[i + 11], 16, 1839030562)b = md5hh(b, c, d, a, x[i + 14], 23, -35309556)a = md5hh(a, b, c, d, x[i + 1], 4, -1530992060)d = md5hh(d, a, b, c, x[i + 4], 11, 1272893353)c = md5hh(c, d, a, b, x[i + 7], 16, -155497632)b = md5hh(b, c, d, a, x[i + 10], 23, -1094730640)a = md5hh(a, b, c, d, x[i + 13], 4, 681279174)d = md5hh(d, a, b, c, x[i], 11, -358537222)c = md5hh(c, d, a, b, x[i + 3], 16, -722521979)b = md5hh(b, c, d, a, x[i + 6], 23, 76029189)a = md5hh(a, b, c, d, x[i + 9], 4, -640364487)d = md5hh(d, a, b, c, x[i + 12], 11, -421815835)c = md5hh(c, d, a, b, x[i + 15], 16, 530742520)b = md5hh(b, c, d, a, x[i + 2], 23, -995338651)a = md5ii(a, b, c, d, x[i], 6, -198630844)d = md5ii(d, a, b, c, x[i + 7], 10, 1126891415)c = md5ii(c, d, a, b, x[i + 14], 15, -1416354905)b = md5ii(b, c, d, a, x[i + 5], 21, -57434055)a = md5ii(a, b, c, d, x[i + 12], 6, 1700485571)d = md5ii(d, a, b, c, x[i + 3], 10, -1894986606)c = md5ii(c, d, a, b, x[i + 10], 15, -1051523)b = md5ii(b, c, d, a, x[i + 1], 21, -2054922799)a = md5ii(a, b, c, d, x[i + 8], 6, 1873313359)d = md5ii(d, a, b, c, x[i + 15], 10, -30611744)c = md5ii(c, d, a, b, x[i + 6], 15, -1560198380)b = md5ii(b, c, d, a, x[i + 13], 21, 1309151649)a = md5ii(a, b, c, d, x[i + 4], 6, -145523070)d = md5ii(d, a, b, c, x[i + 11], 10, -1120210379)c = md5ii(c, d, a, b, x[i + 2], 15, 718787259)b = md5ii(b, c, d, a, x[i + 9], 21, -343485551)a = safeAdd(a, olda)b = safeAdd(b, oldb)c = safeAdd(c, oldc)d = safeAdd(d, oldd)}return [a, b, c, d]}/** Convert an array of little-endian words to a string*/function binl2rstr (input) {var ivar output = ''var length32 = input.length * 32for (i = 0; i < length32; i += 8) {output += String.fromCharCode((input[i >> 5] >>> (i % 32)) & 0xff)}return output}/** Convert a raw string to an array of little-endian words* Characters >255 have their high-byte silently ignored.*/function rstr2binl (input) {var ivar output = []output[(input.length >> 2) - 1] = undefinedfor (i = 0; i < output.length; i += 1) {output[i] = 0}var length8 = input.length * 8for (i = 0; i < length8; i += 8) {output[i >> 5] |= (input.charCodeAt(i / 8) & 0xff) << (i % 32)}return output}/** Calculate the MD5 of a raw string*/function rstrMD5 (s) {return binl2rstr(binlMD5(rstr2binl(s), s.length * 8))}/** Calculate the HMAC-MD5, of a key and some data (raw strings)*/function rstrHMACMD5 (key, data) {var ivar bkey = rstr2binl(key)var ipad = []var opad = []var hashipad[15] = opad[15] = undefinedif (bkey.length > 16) {bkey = binlMD5(bkey, key.length * 8)}for (i = 0; i < 16; i += 1) {ipad[i] = bkey[i] ^ 0x36363636opad[i] = bkey[i] ^ 0x5c5c5c5c}hash = binlMD5(ipad.concat(rstr2binl(data)), 512 + data.length * 8)return binl2rstr(binlMD5(opad.concat(hash), 512 + 128))}/** Convert a raw string to a hex string*/function rstr2hex (input) {var hexTab = '0123456789abcdef'var output = ''var xvar ifor (i = 0; i < input.length; i += 1) {x = input.charCodeAt(i)output += hexTab.charAt((x >>> 4) & 0x0f) + hexTab.charAt(x & 0x0f)}return output}/** Encode a string as utf-8*/function str2rstrUTF8 (input) {return unescape(encodeURIComponent(input))}/** Take string arguments and return either raw or hex encoded strings*/function rawMD5 (s) {return rstrMD5(str2rstrUTF8(s))}function hexMD5 (s) {return rstr2hex(rawMD5(s))}function rawHMACMD5 (k, d) {return rstrHMACMD5(str2rstrUTF8(k), str2rstrUTF8(d))}function hexHMACMD5 (k, d) {return rstr2hex(rawHMACMD5(k, d))}function md5 (string, key, raw) {if (!key) {if (!raw) {return hexMD5(string)}return rawMD5(string)}if (!raw) {return hexHMACMD5(key, string)}return rawHMACMD5(key, string)}if (typeof define === 'function' && define.amd) {define(function () {return md5})} else if (typeof module === 'object' && module.exports) {module.exports = md5} else {$.md5 = md5}
})(this)

uni-app app平台微信支付相关推荐

  1. 阿里多个App已接入微信支付;Facebook年薪中位数170万元;恶意软件感染超1000万台安卓设备 | EA周报...

    EA周报 2021年9月30日 每个星期7分钟,元宝带你喝一杯IT人的浓缩咖啡,了解天下事.掌握IT核心技术. 周报看点 1.恶意软件感染超1000万台安卓设备 2.阿里回应App接入微信支付:会继续 ...

  2. APP内拉起微信支付的解决方案

    APP内拉起微信支付的解决方案 目录 需求背景 解决方案 同业情况 补充说明 目录 需求背景 个人APP拥有者,在不直连微信的情况下,希望用户在APP中选择微信支付后可直接跳转微信APP完成支付. 解 ...

  3. 个人开发者如何在App中调起微信支付

    主要内容   关于企业资质开发者申请的微信支付,如何调起微信支付的,官方文档已经很详细,且百度上也有很多相关资料,这里不再介绍.本篇主要讲的是个人资质的支付如何在自己的App中调起微信支付. 演示 实 ...

  4. APP如何调用微信支付H5支付?

    有一种奇特的需求叫做,在app上使用h5支付.这个实际上是有优势的,比如有多个app要做微信支付,只要h5做一套就可以全部通用.网上搜了一圈,讲的有很多,但是都不太细致,有些坑没有说.下面是我的实现: ...

  5. 微信公众平台微信支付打通流程

    //针对v3版本,jsapi支付,php 1.收到邮件后先去设置api密钥,下载api证书,多次需要手机验证码 2.到公众平台找到开发者中心-接口中找到'网页授权获取用户基本信息',点击修改,加入支付 ...

  6. 微信企业支付 服务器根证书,微信第三方平台微信支付配置没有rootca.pem根证书文件的解决办法-蜘蛛网博客...

    微信第三方平台微信支付配置没有rootca.pem根证书文件的解决办法我们在通过微信第三方平台制作微信活动的时候,很多情况下都需要用到微信支付接口,例如商城类的微信功能,微砍价.微助力.微秒杀.微拼团 ...

  7. 关于实现uni-app项目在APP端使用微信支付功能

    首先在对项目开启支付功能,在项目的manifest.json文件中勾选APP模块配置中的Payment支付模块,并将需要的信息填写完整,如下图 除此之外还需要其他的一些配置,下面开结合图片来一步步的详 ...

  8. 微信支付报错:app没有获取微信支付权限

    调试微信支付的时候报错: Array ( [return_code] => FAIL [return_msg] => 您没有APP支付权限 ) 查询了,发现自己将之前的公众号支付的APPI ...

  9. 开放外链后,阿里旗下多个App已接入微信支付:更方便了

    移动支付工具与我们生活是密不可分的.近日,据相关媒体报道,继淘宝App8月接入银联云闪付以来,目前已覆盖全量用户.同时,阿里旗下饿了么.优酷.大麦.考拉海购.书旗等应用均已接入微信支付.此外,目前淘特 ...

最新文章

  1. 技嘉z68pds3刷中文bios_技嘉RTX 3080 VISION OC雪鹰显卡评测:内容创作、3A游戏两不误之选...
  2. jQuery 判断元素是否存在
  3. 【MySQL】深入浅出剖析mysql事务锁机制 - 笔记
  4. 数据库设计笔记——关系型数据库基础知识(三)
  5. 前端学习(2463):vue中 关于$emit的用法
  6. 用计算机说唱的 那个男的是谁,中国男rapper排名 中国rap说唱饶舌歌手排名
  7. arm 饱和指令_ARM aarch64汇编学习笔记(九):使用Neon指令(一)
  8. php网站渗透实战_【案例分析】记一次综合靶场实战渗透
  9. Magicodes.Admin.Core开源框架总体介绍
  10. Exp3:MAL_免杀原理与实践
  11. 声网 环信:是的,我们在一起了!
  12. #C++初学记录(算法测试2019/5/5)(深度搜索)
  13. 通过Jquery异步获取股票实时数据
  14. 207.课程表(力扣leetcode) 博主可答疑该问题
  15. D-star Lite算法及其动态路径规划实验研究
  16. 动态数据源,帆软报表同一个sql语句,根据不同的角色使用不同的连接
  17. 6个优秀平面设计网站
  18. umi封装request方法 ts版
  19. linux centos 恢复 还原 备份 Snapper 快照说明
  20. 组建一个网络需要哪些网络设备和安全设备呢?

热门文章

  1. html文档半结构化数据,什么是半结构化数据(semi-structured data)?
  2. 《程序员的自我修养》笔记
  3. python 线性回归显著性检验_回归方程及回归系数的显著性检验_stata显著性检验...
  4. 请问在 1 到 2020 中,有多少个数既是 4 的整数倍,又是 6 的整数倍。
  5. Android Studio实现内容丰富的旅游App
  6. win 10 输入法自定义切换快捷键(rime)
  7. 大专生三面蚂蚁金服,Java中高级核心知识全面解析(7)
  8. [Unity3D] Unity3D连接安卓设备调试unity程序
  9. 【IVIF:特征聚合网络】
  10. The Evils of Duplication