WeChat payment development (11) Native payment, native payment _ PHP Tutorial

Source: Internet
Author: User
Payment development (11) Native payment and native payment. Payment development (11) Native payment, native payment keyword: public platform payment Native payment author: Fang times studio original: www. cnblogs. comtxw1958p payment development (11) Native payment, native payment

Keywords: public platform payment Native payment
Author: Fang times Studio
Original article: http://www.cnblogs.com/txw1958/p/wxpay-native.html

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

This article consists of the following three parts:


1. generate a Native payment URL

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

Weixin: // wxpay/bizpayurl? Sign = XXXXX & appid = XXXXXX & productid = XXXXXX & timestamp = XXXXXX & noncestr = XXXXXX

The generated code is as follows:

1 
 create_native_url("1234567890");5 ?>

Productid is the unique id of a product. developers need to define and maintain their own product IDs. this id is equivalent to an order. the background obtains the transaction information through the POST merchant background.

The URL generated by the above code is as follows:

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

II. generate a QR code

You can use a third-party interface or your own Code or plug-in to generate a QR Code. here we will introduce php qr Code.

Php qr Code is a php qr Code generation class library that allows you to easily generate QR codes. the official website provides download and multiple demo demos at: http://phpqrcode.sourceforge.net /.

The syntax for generating a QR code is very simple. you just need to enter the URL as a parameter. Example:

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

In this way, a QR code for payment is generated.

3. generate a Package

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

1
 SetParameter ("bank_type", "WX"); 7 $ wxPayHelper-> setParameter ("body", "Fang times studio payment development tutorial "); 8 $ wxPayHelper-> setParameter ("partner", "1900000109"); 9 $ wxPayHelper-> setParameter ("out_trade_no", $ commonUtil-> create_noncestr ()); 10 $ wxPayHelper-> setParameter ("total_eter", "1"); 11 $ wxPayHelper-> setParameter ("fee_type", "1 "); 12 $ wxPayHelper-> setParameter ("notify_url", "htttp: // www.baidu.com"); 13 $ wxPayHelper-> se TParameter ("spbill_create_ip", "127.0.0.1"); 14 $ wxPayHelper-> setParameter ("input_charset", "GBK"); 15 echo $ wxPayHelper-> login (); 16?>

After scanning the QR code, the user will jump directly to the product page, as shown below:

Such a Native payment is formed.


Must the developer mode or third-party cooperation be required for the opening and payment of public platforms?

This usually requires a third party to write the payment interface, which is difficult for you

Payment Interface Technical Development documentation

Go to the official website. I applied for an open payment yesterday.
 

Copyright (11) Native payment, native payment Keywords: public platform payment Native payment author: Fang times studio Original article: http://www.cnblogs.com/txw1958/p...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.