Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to develop and realize the Native function of WeChat Pay

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces how to develop and achieve WeChat Pay's Native function, with a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

First, generate Native payment URL

Native (Native) payment URL is a series of weixin://wxpay/bizpayurl? The prefix URL is followed by a series of key-value pairs that identify the merchant. The rules for Native (native) to pay URL are as follows:

Weixin://wxpay/bizpayurl?sign=XXXXX&appid=XXXXXX&productid=XXXXXX×tamp=XXXXXX&noncestr=XXXXXX

The generated code is as follows

Productid is the only id for goods. Developers need to define and maintain their own product id, which is equivalent to an order. Wechat backend uses this id to obtain transaction information through POST merchant backend.

The URL generated by the above code is as follows:

Weixin://wxpay/bizpayurl?appid=wxb489e8caeabcdefg&noncestr=BBvdr5atZ9D7s08X&productid=1234567890&sign=e15d2466a85cd62b530e2f690604e7502f67ccb5×tamp=1408025996

Second, generate QR codes

You can use a third-party interface to generate a QR code, or you can use your own code or plug-in. PHP QR Code is introduced here.

PHP QR Code is a PHP QR code generation class library, which can easily generate QR codes. Downloads and multiple demo demo are available on the official website. Check the address: http://phpqrcode.sourceforge.net/.

The syntax for generating the QR code is very simple, just fill in the URL as a parameter. Examples are as follows

Include 'phpqrcode.php'; QRcode::png (' http://www.cnblogs.com/txw1958/');

This generates a QR code for payment.

Third, generate Package

When the user scans the above QR code, the Native payment URL,URL needs to call the order information Package to return to the user, and the Package is implemented by create_native_package () of the WxPayHelper class. The call code is as follows:

When the user scans the QR code, it jumps directly to the product page, as shown below

Such a Native payment is formed.

Thank you for reading this article carefully. I hope the article "how to develop and realize WeChat Pay's Native function" shared by the editor will be helpful to everyone. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report