QQ micro letter made triple Alipay payment code

Disclaimer: This article is the original article, please indicate the source transfer (http://blog.csdn.net/kesixin) https://blog.csdn.net/kesixin/article/details/79358803

Blog address: http://blog.mambaxin.com

Found that many blog have brought a reward function, although people may rarely a reward, but is always a token that allows bloggers to write their own articles useful to know, to be able to help people. So, I would also like to add a function of a reward ~

analysis

Can QQ micro letter Alipay triple, just sweep a collection code on the line it?
Here involves a knowledge point, it is the User-Agent, manufacturers webview UA will carry their own information, such as:

QQ:MQQBrowser/6.2 TBS/043221 Safari/537.36 QQ/7.0.0.3135
微信:MQQBrowser/6.2 TBS 043220 Safari/537.36 MicroMessenger/6.5.8.1060 NetType/4G Language/zh_CN
支付宝:UCBrowser/11.5.0.939 UCBS/2.10.1.6 Mobile Safari/537.36 AliApp(AP/10.0.15.051805) AlipayClient/10.0.15.051805 Language/zh-Hans

So it is easy to distinguish or QQ micro letter or Alipay sweep yards:

User-Agent containing QQ / QQ as
User-Agent is a micro-channel comprising MicroMessenger
User-Agent containing AlipayClient Alipay

Since the software can distinguish each, it can be self-built a web site, generated by two-dimensional code scanning this URL, the browser UA judgment, to distribute different payment code

The process was substantially:
Client scan code -> User-Agent The server determines the client type -> return the different treatment

Form

First decoding QQ, micro-channel and Alipay payment generated code, you can go here online decoding.

QQ: https://i.qianbao.qq.com/wallet/sqrcode.htm?m=tenpay&a=1&u=462369233&ac=85CCA61B3297A14170CA733F85CFD04570EA3B81CB753F421194E5C79701B294&n=Mamba&f=wallet
(HTTPS protocol, can not wake up QQ)
Alipay: HTTPS://QR.ALIPAY.COM/FKX028454NIDTGHALS3WAF
(HTTPS protocol, can be directly wake Alipay APP)
micro letter: wxp://f2f0OI0K-DjKTUUo5ijir72IR4EeOdb9__8h
(micro-channel pay their agreement, can not wake up micro-Letter)

Here you can write code directly, the User-Agent to determine if it is a direct jump Alipay Alipay links, if QQ and QQ micro letter jump and micro-channel links.

However, due to QQ and micro-channel can not wake up directly APP, so the direct output of a two-dimensional code QQ micro letter, then press scan code to achieve the payment.

code show as below:

<?php
$ua = $_SERVER['HTTP_USER_AGENT'];
if (strpos($ua, 'MicroMessenger')) {
    $type = 'wepay';
    $name = '微信支付';
    //微信支付链接
    $url = 'wxp://f2f0OI0K-DjKTUUo5ijir72IR4EeOdb9__8h';
    $icon_img = '<img src="http://ww2.sinaimg.cn/large/005zWjpngy1fojrwgr20oj303k03kglg.jpg" width="48px" height="48px" alt="'.$name.'">';
}
elseif (strpos($ua, 'AlipayClient')) {
    //支付宝链接
    $url = 'HTTPS://QR.ALIPAY.COM/FKX028454NIDTGHALS3WAF';
    header('location: ' . $url);
}
elseif (strpos($ua, 'QQ/')) {
    $type = 'qq';
    $name = 'QQ钱包支付';
    //QQ钱包支付链接
    $url = 'https://i.qianbao.qq.com/wallet/sqrcode.htm?m=tenpay&a=1&u=462369233&ac=85CCA61B3297A14170CA733F85CFD04570EA3B81CB753F421194E5C79701B294&n=Mamba&f=wallet';
    $icon_img = '<img src="http://ww2.sinaimg.cn/large/005zWjpngy1fojrvmp427j303k03kjrb.jpg" width="48px" height="48px" alt="'.$name.'">';
}
else {
    $type = 'other';
    $name = '打赏作者';
    $url = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
    $icon_img = '<img src="http://ww2.sinaimg.cn/large/005zWjpngy1fojs089x6tj303k03kjr6.jpg" width="48px" height="48px" alt="'.$name.'">';
}
$qr_img = '<img src="http://qr.liantu.com/api.php?text='.urlencode($url).'">';
?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge, chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?=$name?></title>
    <style type="text/css">
        * {margin: auto;padding: 0;border: 0;}
        html {-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%}
        body {font-family: -apple-system, SF UI Text, Arial, Microsoft YaHei, Hiragino Sans GB, WenQuanYi Micro Hei, sans-serif;color: #333;}
        img {max-width: 100%;}
        h3 {padding: 10px;}
        .container {text-align: center;}
        .title {padding: 2em 0;background-color: #fff;}
        .content {padding: 2em 1em;color: #fff;}
        .wepay {background-color: #23ac38;}
        .qq {background-color: #4c97d5;}
        .other {background-color: #ff7055;}
    </style>
</head>
<body class="<?=$type?>">
    <div class="container">
        <div class="title"><?=$icon_img?><h1><?=$name?></h1></div>
        <div class="content"><?=$type=='other'?$qr_img.'<h3>请使用支付宝、微信、QQ客户端扫码付款</h3>':$qr_img.'<h3>扫描或长按识别二维码,向TA付款</h3>'?></div>
    </div>
</body>
</html>

Demo demo

Demo can be tested by two-dimensional code scanning at the bottom of the article, or click on the following:
http://pay.mambaxin.com/


Original link: http://blog.mambaxin.com/article/56

Guess you like

Origin blog.csdn.net/kesixin/article/details/79358803