亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Home WeChat Applet WeChat Development WeChat payment development Native payment

WeChat payment development Native payment

Feb 28, 2017 am 10:00 AM

In this WeChat public platform development tutorial, we will introduce how to develop the Native function of WeChat payment.

This article is divided into the following three parts:

Generate Native payment URL

Generate QR code

Generate Package


1. Generate Native payment URL

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

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

The generated code is as follows

<?php
include_once("WxPayHelper.php");
$wxPayHelper = new WxPayHelper();
echo $wxPayHelper->create_native_url("1234567890");
?>

The productid is the unique ID of the product. Developers need to define and maintain their own product ID. This ID is equivalent to an order. The WeChat backend uses this ID to obtain transaction information through the POST merchant backend.

The URL generated by the above code is as follows:

weixin://wxpay/bizpayurl?appid=wxb489e8caeabcdefg&noncestr=BBvdr5atZ9D7s08X&productid=1234567890&sign=e15d2466a85cd62b530e2f690604e7502f67ccb5&timestamp=1408025996

2. Generate QR code

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

PHP QR Code is a PHP QR code generation library that can be used to easily generate QR codes. The official website provides downloads and multiple demonstration demos. View address: http://phpqrcode.sourceforge.net /.

The syntax for generating QR codes is very simple, just fill in the URL as a parameter. The example is as follows

include &#39;phpqrcode.php&#39;; 
QRcode::png(&#39;http://www.cnblogs.com/txw1958/&#39;);

This generates a payment QR code.

3. Generate Package

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

<?php
include_once("WxPayHelper.php");

$commonUtil = new CommonUtil();
$wxPayHelper = new WxPayHelper();
$wxPayHelper->setParameter("bank_type", "WX");
$wxPayHelper->setParameter("body", "方倍工作室微信支付開發(fā)教程");
$wxPayHelper->setParameter("partner", "1900000109");
$wxPayHelper->setParameter("out_trade_no", $commonUtil->create_noncestr());
$wxPayHelper->setParameter("total_fee", "1");
$wxPayHelper->setParameter("fee_type", "1");
$wxPayHelper->setParameter("notify_url", "htttp://www.baidu.com");
$wxPayHelper->setParameter("spbill_create_ip", "127.0.0.1");
$wxPayHelper->setParameter("input_charset", "GBK");
echo $wxPayHelper->create_native_package();
?>

When the user scans the QR code, he will jump directly to the product page, as shown below

微信支付開發(fā) Native支付

Such a Native payment is formed.

For more articles related to WeChat payment development and Native payment, please pay attention to the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

PHP Tutorial
1488
72