Attention:
Micro-credit payment is now divided into V2 version and V3 version, September 10, 2014 before the application for the V2 version, after the application for the V3 version. V3 version of the micro-letter payment has no paysignkey parameters. For V2, please refer to the other articles in the Square Times studio. This paper introduces the payment v3 for micro-letter.
First, the production of commodity information
In the process of dynamic link payment, the transaction is made by the gentleman into the commodity trade and then the payment transaction.
1. Commodity Information Preparation
The first is to define the name and price of the product, and the transaction number. The code is as follows.
Include_once (".. /wxpaypubhelper/wxpaypubhelper.php ");
Use the unified payment interface
$unifiedOrder = new Unifiedorder_pub ();
Set up uniform payment interface Parameters
//Set Required parameters
//appid has been filled out, the merchant does not need to fill in the//mch_id has been filled, the merchant does not need to fill in the duplicate
//noncestr has been filled, the merchant does not need to repeat fill
Spbill_create_ip has been filled, the merchant does not need
to fill in the//sign has filled in, the merchant does not need to fill in
$unifiedOrder->setparameter ("Body", "Contribution a penny"); Product description
$timeStamp = time ();
$out _trade_no = wxpayconf_pub::appid. " $timeStamp ";
$unifiedOrder->setparameter ("Out_trade_no", "$out _trade_no");//Merchant Order number
$unifiedOrder->setparameter (" Total_fee "," 1 ")//Total amount
$unifiedOrder->setparameter (" Notify_url ", wxpayconf_pub::notify_url);//Notification address
$unifiedOrder->setparameter ("Trade_type", "NATIVE"),//transaction type
//non-required parameters, the merchant can fill in the $unifiedOrder according to the actual situation
-> Setparameter ("Device_info", "100001");//device number
The above parameters are eventually encapsulated like XML parameters
<xml>
<body><![ cdata[contribute a penny]]></body>
<out_trade_no><![ cdata[100001_1433009089]]></out_trade_no>
<total_fee>1</total_fee>
<notify_url ><! [cdata[http://www.doucube.com/weixin/demo/notify_url.php]]></notify_url>
<trade_type><![ cdata[native]]></trade_type>
<device_info>100001</device_info>
<appid><![ cdata[wx1d065b0628e21103]]></appid>
<mch_id>1237905502</mch_id>
<spbill_create _ip><! [cdata[61.129.47.79]]></spbill_create_ip>
<nonce_str><![ Cdata[gwpdlnn0zlfih21gipjj5z53i7vea8e8]]></nonce_str>
<sign><![ Cdata[c5a1e210f9b4402d8254f731882f41ac]]></sign>
</xml>
2. Call a unified payment request
Send the above XML to the unified payment interface
Https://api.mch.weixin.qq.com/pay/unifiedorder
Get the following XML data
<xml>
<return_code><![ Cdata[success]]></return_code>
<return_msg><![ Cdata[ok]]></return_msg>
<appid><![ Cdata[wx1d065b0628e21103]]></appid>
<mch_id><![ Cdata[1237905502]]></mch_id>
<device_info><![ Cdata[100001]]></device_info>
<nonce_str><![ Cdata[6u8ovttfuptagsiy]]></nonce_str>
<sign><![ Cdata[e84d8bc2331766dd685591f908367ff1]]></sign>
<result_code><![ Cdata[success]]></result_code>
<prepay_id><![ Cdata[wx20150531020450bb586eb2f70717331240]]></prepay_id>
<trade_type><![ Cdata[native]]></trade_type>
<code_url><![ Cdata[weixin://wxpay/bizpayurl?pr=dnp7omd]]></code_url>
</xml>
So you get a code_url.
The program generates a two-dimensional code for the Code_url and then provides the user with a sweep
Second, the user pays
1. User pays
After the user has paid the success, the micro-letter will send the XML notification to the Notify_url, which reads as follows
<xml> <appid><! [cdata[wx1d065b0628e21103]]></appid> <bank_type><! [cdata[cft]]></bank_type> <cash_fee><! [cdata[1]]></cash_fee> <device_info><! [cdata[100001]]></device_info> <fee_type><! [cdata[cny]]></fee_type> <is_subscribe><! [cdata[n]]></is_subscribe> <mch_id><! [cdata[1237905502]]></mch_id> <nonce_str><! [cdata[gwpdlnn0zlfih21gipjj5z53i7vea8e8]]></nonce_str> <openid><! [cdata[omnkhubtw4ywgngavqw00twk6aum]]></openid> <out_trade_no><! [cdata[100001_1433009089]]></out_trade_no> <result_code><! [cdata[success]]></result_code> <return_code><! [cdata[success]]></return_code> <sign><! [cdata[03eede7ade2abb7916795f37f19a3d13]]></sign> <time_end><! [cdata[20150531020838]]></time_end> <total_fee>1</total_fee> <trade_type><! [cdata[native]]></trade_type> <transaction_id><! [cdata[1002750205201505310187709542]]></transaction_id> </xml>
Notify_url after receiving, return confirm success message to micro-trust server
<xml>
<return_code><![ Cdata[success]]></return_code>
</xml>
In this way, a dynamic link native is completed.
Use the order query interface to query the order and return the following
Trading Status: SUCCESS
Equipment Number: 100001
User id: Omnkhubtw4ywgngavqw00twk6aum
Whether to pay attention to the public account: N
Transaction type: NATIVE
Bank of payment: CFT
Total Amount: 1
Cash Coupon Amount:
Currency type: CNY
Micro-Credit Payment Order No.: 1002750205201505310187709542
Merchant Order Number: 100001_1433009089
Merchant Packets: Array
Payment Completion Time: 20150531020837
The above is to the micro-letter payment dynamic Link native payment of data collation, hoping to help develop micro-letter payment friends.