WeChat payment Development (one) native payment, native payment _php tutorial

Source: Internet
Author: User

Payment development (one) native payment, native payment


Keywords: public platform payment native native payment
Author: Fang Times studio
Original: http://www.cnblogs.com/txw1958/p/wxpay-native.html

In this public platform development tutorial, we will show you how to develop the native function for payment.

This article is divided into the following three sections:


First, generate native payment URL

The Native (native) Payment URL is a series of URLs with a weixin://wxpay/bizpayurl prefix, followed by a series of key-value pairs that identify the merchant. The Native (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 
   PHP2include_once("wxpayhelper.php"); 3 $wxPayHelper New Wxpayhelper (); 4 Echo $wxPayHelper->create_native_url ("1234567890"); 5 ?>

Where ProductID is the unique ID of the product, the developer needs to define and maintain its own product ID, which is equivalent to an order, and the backend obtains the transaction information through the post merchant background with that ID.

The above code generates the following URLs:

WEIXIN://WXPAY/BIZPAYURL?APPID=WXB489E8CAEABCDEFG&noncestr=bbvdr5atz9d7s08x&productid =1234567890&sign=e15d2466a85cd62b530e2f690604e7502f67ccb5&timestamp=1408025996

Second, generate two-dimensional code

Generate QR code can use a third-party interface, you can also use their own code or plug-in, here is the introduction of PHP QR code.

PHP QR code is a php two-dimensional code generation library, using it can easily generate two-dimensional code, the official website provides a download and demo demo, view address: http://phpqrcode.sourceforge.net/.

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

include ' phpqrcode.php '; QRCode::p ng (' http://www.cnblogs.com/txw1958/');

This generates a paid QR code.

Iii. Building the Package

When the user scans the QR code above, it calls the native payment Url,url needs to call the order information package is returned to the user, and the package is implemented by the Wxpayhelper class Create_native_package (), the calling code is as follows:

1 
 Php2 include_once("wxpayhelper.php");3 4 $commonUtil=Newcommonutil ();5 $wxPayHelper=NewWxpayhelper ();6 $wxPayHelper->setparameter ("Bank_type", "WX");7 $wxPayHelper->setparameter ("Body", "square double studio payment development tutorial");8 $wxPayHelper->setparameter ("partner", "1900000109");9 $wxPayHelper->setparameter ("Out_trade_no",$commonUtil-create_noncestr ());Ten $wxPayHelper->setparameter ("Total_fee", "1"); One $wxPayHelper->setparameter ("Fee_type", "1"); A $wxPayHelper->setparameter ("Notify_url", "htttp://www.baidu.com"); - $wxPayHelper->setparameter ("Spbill_create_ip", "127.0.0.1"); - $wxPayHelper->setparameter ("Input_charset", "GBK"); the Echo $wxPayHelper-create_native_package (); -?>

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

Such a native payment was formed.


Public platform payment must be developer mode or work with a third party?

This is usually to find a third-party to write the payment interface, the trouble of their own

Payment Interface Technology Development documentation

Look for the official website Ah, yesterday paid open application

http://www.bkjia.com/PHPjc/866466.html www.bkjia.com true http://www.bkjia.com/PHPjc/866466.html techarticle Payment Development (one) native payment, native pay keyword: public platform payment native original payment Author: Fang Times studio Original: 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.