Payment received

Collect Payment is a three-in-one integrated system of Alipay, WeChat, and QQ payment codes.

Completed using thinkPHP5.0 + MySQL + layui

Demo website: Collect payment

Project address: GitHub

Preface

Whether it’s tutorials or ready-made codes, they are almost everywhere on the Internet. Why should I write my own?

It is a set of words that includes uploading QR codes, identifying QR codes, generating three-in-one payment codes, and a complete set of process services.

The vast majority of three-in-ones are only for personal use, while Collect can provide three-in-one services to multiple users.

But it has no backend, for two main reasons:

  1. There is no need to check or modify the configuration frequently, configure it once and use it for life.

  2. The author suffers from laziness (which also leads to the lack of installation wizard)

  3. If it’s really necessary, we’ll talk about it later.

The code itself is relatively lightweight, but the size increases due to the use of a framework.

Well, there is no technical content in itself, and I hardly use it. I write it for humans in need, and by the way, I am familiar with hydrology~~Escape(-

Principle

The three-in-one payment code sounds magical, but the principle is actually very simple!

The so-called QR code is actually a picture containing a series of character strings. Whether it is Alipay or WeChat’s payment code, it is essentially a QR code containing a payment link. So our idea is: if the detection page is Alipay browsing, the Alipay payment link will be given; if it is WeChat, the WeChat link will be given…

Then there is a knowledge point involved here, User-Agent. The webviews of major manufacturers will carry their own UA information, for example:

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

Alipay: 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

In this way, it is easy to distinguish whether you are scanning the QR code on QQ, WeChat or Alipay:

User-Agent contains QQ/ is QQ

User-Agent contains MicroMessenger for WeChat

User-Agent contains AlipayClient for Alipay

Since each software can be distinguished, you can create a self-made URL, generate a QR code and scan the URL to determine the UA of the browser to distribute different payment codes.

The rough process is:

The client scans the QR code -> the server determines the client type based on User-Agent -> returns different processes respectively

Also worth noting:

QQ: https protocol, unable to wake up QQ

Alipay: https protocol, can directly wake up Alipay APP

WeChat: WeChat’s own payment protocol cannot wake up WeChat

download

Download now

Install

  1. PHP >= 5.6 + MySQL

  2. Deploy the application to your server

  3. Set the public subdirectory as a public directory

  4. Import the root directory pay.sql into your database

  5. Modify application\database.php to your own database information

  6. Set the pseudo-static website to thinkPHP

  7. Modify the relevant information in config.php in the root directory

  8. Enter your domain name to access (must follow the steps)

It needs to be on the external network to be valid! It needs to be on the external network to be valid! It needs to be on the external network to be valid! Say important things three times (the LAN should also be valid, but what’s the point?)

Author

© 阿珏, Released under the GPL License. If possible, please reward the author mahua

Blog · GitHub @阿珏