1.跳转后可修改金额和备注的方式
先来个二维码举例:
识别之后的内容:
alipays://platformapi/startapp?appId=09999988&actionType=toAccount&goBack=NO&amount=1.00&userId=2088502148745835&memo=备注
这里边有几个重要的参数:
参数 | 含义 |
---|---|
amount | 价格(元) |
userId | 支付宝用户Id |
memo | 转账备注 |
效果图就没有了,你可以扫上面的码打赏我试试
2.跳转后不可修改金额和备注的方式
先来个二维码
识别之后的内容:
alipays://platformapi/startapp?appId=20000067&url=http%3a%2f%2fwww.baidu.com
参数讲解:
参数 | 含义 |
---|---|
appId | 固定即可,支付宝内部定义的一种类型 |
url | 跳转的网址(UrlEncode) |
这种方式需要配合一个网页:通过支付宝AlipayJSBridge的能力来发起支付
网页代码参考(界面部分省略,参数都类似),点我测试
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta content="width=device-width,initial-scale=1.0" name="viewport" />
<title>支付宝收银台</title>
<script src="https://gw.alipayobjects.com/as/g/h5-lib/alipayjsapi/3.1.1/alipayjsapi.min.js"></script>
</head>
<body>
<script>
var money = 1;
money = "" + money.toFixed(2);
var num = "306318921589965701775TSD";
var userId = "2088502148745835";
document.getElementById("money").innerText = money;
document.getElementById("num1").innerText = num;
document.getElementById("num2").innerText = num;
function returnApp() {
AlipayJSBridge.call("exitApp")
}
function closeAlert() {
document.getElementById("alert").style.display = "none";
}
function closeTip() {
document.getElementById("tip").style.display = "none";
}
function closeDialog() {
document.getElementById("dialog-mask").style.display = "none";
document.getElementById("dialog").style.display = "none";
}
function ready(a) {
window.AlipayJSBridge ? a && a() : document.addEventListener("AlipayJSBridgeReady", a, !1)
}
function openAlipay() {
var u = navigator.userAgent, app = navigator.appVersion;
var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //g
var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
if (isAndroid) {
setTimeout(function () {
var a = {
actionType: "scan",
u: userId,
a: money,
m: num,
biz_data: {
s: "money",
u: userId,
a: money,
m: num
}
}
AlipayJSBridge.call("startApp", {
appId: "20000123",
param: a
},
function (a) {
});
}, 50);
}
if (isIOS) {
$payurl = 'alipays://platformapi/startapp?appId=20000123&actionType=scan&biz_data={"s": "money","u": "' + userId + '","a": "' + money + '","m": "' + num + '"}';
AlipayJSBridge.call('scan', {
"type": "qr",
"actionType": "scanAndRoute",
"qrcode": 'alipays://platformapi/startapp?appId=20000123&actionType=scan&biz_data={"s": "money","u": "' + userId + '","a": "' + money + '","m": "' + num + '"}'
}, function (result) {
});
}
}
ready(function () {
openAlipay();
document.addEventListener('resume', function (event) {
AlipayJSBridge.call('popWindow');
});
});
</script>
</body>
</html>