WeChat payment development dynamic link Native payment instance code

Source: Internet
Author: User
Tags openid
This article mainly introduces the implementation process of Native payment based on dynamic link QR code, hope to help the development and payment partners. This article mainly introduces the Native payment implementation process based on the dynamic link QR code under payment, hoping to help the development and payment partners.

Note:

Payment is now divided into v2 and v3. the application for payment is v2 before January 1, September 10, 2014, and the application for payment is v3. The paySignKey parameter is not provided for payment in V3. This article describes payment v3.

1. generate product information

During the dynamic link payment process, Mr. Cheng made a commodity transaction and then made a payment transaction.

1. prepare product information

It mainly defines the product name and price, and the transaction number. The code is as follows.

Include_once (".. /WxPayPubHelper. php "); // use the unified payment interface $ unifiedOrder = new UnifiedOrder_pub (); // set the parameters of the unified payment interface // set the required parameter // appid is filled in, the merchant does not need to fill in the/mch_id field repeatedly, the merchant does not need to fill in the/noncestr field repeatedly, the merchant does not need to fill in the/spbill_create_ip field repeatedly, and the merchant does not need to fill in the/sign field repeatedly, the merchant does not need to fill in $ unifiedOrder-> setParameter ("body", "contribute a penny"); // product description $ timeStamp = time (); $ out_trade_no = WxPayConf_pub: APPID. "$ timeStamp"; $ unifiedOrder-> setParameter ("out_trade_no", "$ out_trade_no"); // merchant Order No. $ unifiedOrder-> setParameter ("total_fee", "1 "); // Total Amount $ unifiedOrder-> setParameter ("yy_url", WxPayConf_pub: notify_url); // notification address $ unifiedOrder-> setParameter ("trade_type", "NATIVE "); // transaction type // optional parameter. the merchant can select $ unifiedOrder-> setParameter ("device_info", "100001") based on the actual situation; // device number

The preceding parameters are eventually encapsulated as XML parameters similar to the following:

  贡献一分钱 
  100001_1433009089
   
  
   
1
   
  http://www.doucube.com/weixin/demo/notify_url.php
   
  NATIVE
   
  
   
100001
   wx1d065b0628e21103 
  
   
1237905502
   
  61.129.47.79
   
  gwpdlnn0zlfih21gipjj5z53i7vea8e8
   
  C5A1E210F9B4402D8254F731882F41AC
  
 

2. call the unified payment request

Send the preceding XML to the unified payment interface

Https://api.mch.weixin.qq.com/pay/unifiedorder

Get the following XML data:

  
  SUCCESS
    
  OK
    wx1d065b0628e21103  
  1237905502
    
  100001
    
  6u8ovTtFupTagsiY
    
  E84D8BC2331766DD685591F908367FF1
    
  SUCCESS
    
  wx20150531020450bb586eb2f70717331240
    
  NATIVE
    
  weixin://wxpay/bizpayurl?pr=dNp7omD
   
 

In this way, a code_url is obtained.

The program generates a QR code for the code_url and then provides it to the user

II. user payment

1. user payment

After the payment is successful, the XML notification will be sent to yy_url. the content is as follows:

  wx1d065b0628e21103  
  CFT
    
  1
    
  100001
    
  CNY
    
  N
    
  1237905502
    
  gwpdlnn0zlfih21gipjj5z53i7vea8e8
    
  oMNKHuBTW4YWgNGAVQW00tWK6auM
    
  100001_1433009089
    
  SUCCESS
    
  SUCCESS
    
  03EEDE7ADE2ABB7916795F37F19A3D13
    
  20150531020838
    
  
   1
    
  NATIVE
    
  1002750205201505310187709542
   
 

When notify_url receives the message, it returns the confirmation message to the server.

  
  SUCCESS
  
 

In this way, a dynamic link Native is complete.

Query the order using the order query interface, and the return result is as follows:

Transaction Status: SUCCESS
Device number: 100001
User ID: oMNKHuBTW4YWgNGAVQW00tWK6auM
Public Account: N
Transaction Type: NATIVE
Payment Bank: CFT
Total amount: 1
Cash coupon amount:
Currency type: CNY
Payment Order No.: 1002750205201505310187709542
Merchant Order No.: 2017100001433009089
Merchant data packet: Array
Payment completion time: 20150531020837

The above is to sort out the materials for the dynamic payment link Native payment, hoping to help the development and payment friends.

The above is the details of the Native payment instance code linked to the payment development dynamic link. For more information, see other related articles on php!

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.