Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to pay bills developed by Wechat

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces the development of Wechat how to pay the bill, the article is very detailed, has a certain reference value, interested friends must read it!

Be careful

WeChat Pay is now divided into v2 version and v3 version. The v2 version was applied before September 10, 2014, and the v3 version was applied after. The V3 version of WeChat Pay has no paySignKey parameter. For the introduction of v2, please refer to other articles of Fangbei Studio. WeChat Pay v3 is introduced in this article.

I. statement data interface

WeChat Pay v3 provides a data interface for statement, and the interface it uses is

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

The requested parameters are as follows

Field name

Variable name

Required

Types

Sample valu

Description

Public account ID

Appid

Yes

String (32)

Wx8888888888888888

ID of the public account assigned by Wechat

Merchant number

Mch_id

Yes

String (32)

1900000109

The merchant number assigned by WeChat Pay

Device number

Device_info

No

String (32)

013467007045764

The terminal device number assigned by WeChat Pay. Fill in this field and download only the statement of the device number.

Random string

Nonce_str

Yes

String (32)

5K8264ILTKCH16CQ2502SI8ZNMTM67VS

Random string, no longer than 32 bits. Recommended random number generation algorithm

Signature

Sign

Yes

String (32)

C380BEC2BFD727A4B6845133519F3AD6

Signature. For more information, see signature generation algorithm.

Statement date

Bill_date

Yes

String (8)

20140603

Date when the statement was downloaded, format: 20140603

Billing type

Bill_type

No

String (8)

ALL

ALL, which returns all order information of the day. Default value

SUCCESS, which returns the order successfully paid on the same day

REFUND, return the same-day refund order

REVOKED, cancelled order

The implementation code in Demo is as follows

Include_once (".. / WxPayPubHelper/WxPayPubHelper.php"); / / A pair of billing dates if (! isset ($_ POST ["bill_date"])) {$bill_date = "20150401";} else {$bill_date = $_ POST ["bill_date"]; / / use the billing interface $downloadBill = new DownloadBill_pub () / / set statement API parameters / / set required parameters / / appid has been filled, merchants do not need to repeat / / mch_id has been filled, merchants do not need to repeat / / noncestr, merchants do not need to repeat / / sign has been filled, merchants do not need to repeat $downloadBill- > setParameter ("bill_date", "$bill_date") / / A pair of billing dates $downloadBill- > setParameter ("bill_type", "ALL"); / / Billing type / / optional parameters. Merchants can choose / / $downloadBill- > setParameter ("device_info", "XXXX") according to the actual situation; / / device number / / $downloadBill- > setParameter ("device_info", "Fangbi Studio 1") / / device number / / Billing interface result $downloadBillResult = $downloadBill- > getResult (); echo $downloadBillResult ['return_code']; if ($downloadBillResult [' return_code'] = = "FAIL") {echo "Communication error:". $downloadBillResult ['return_msg'];} else {print_r ('') Echo "[statement details]."; print_r ($downloadBill- > response); print_r ('');}}

The above statement can only query the data for one day at a time.

The bill result returned is as follows

Transaction time, public account ID, merchant number, sub-merchant number, device number, Wechat order number, merchant order number, user ID, transaction type, transaction status, payment bank, currency, total amount, corporate red packet amount, Wechat refund order number, merchant refund order number, refund amount, corporate red packet refund amount, refund type, refund status, commodity name, merchant data packet, handling fee Rates: '2015-04-12 20:27:22, `wx554f0b3e56067c9d, `10024142, `0, `WJ4, `1000690206201504120059461630, `wx554f0b3e56067c9d1428841627, `oMfX0jgJjSPVvYOz3p_BP8LclWO0, `NATIVE, `SUCCESS, `CMB_CREDIT, `CNY, `71.00, `0.00, `0,0,`0,0,0,0,0,0,0,0,0,0.60% `2015-04-12 18:08:38, `wx554f0b3e56067c9d, `10024142,`0, `WJ1, `10013702062014501200599734, `wx554f0b3e56067c9d1428833308, `oMfX0jhbQ1xd0B6Vm-kuizH9e9rs, `NATIVE, `SUCCESS, `COMM_DEBIT, `CNY, `92.00, `0.00, `0,0 `0, `0, `0.60% `2015-04-12 19:12:06, `wx554f0b3e56067c9d, `10024142, `0, `WJ1, `1001520206201504120059346120, `wx554f0b3e56067c9d1428837103, `oMfX0jj6h3ls1TsZEORs8WXRtSrE, `NATIVE, `SUCCESS, `CEB_CREDIT, `CNY, `69.60, `0.00, `0, `0, `0pint `0pm `Wechat public platform development best practices, `, `0.41760, `0.60` 2015-04-12 13:03:25, `wx554f0b3e56067c9d, `10024142, `0, `WJ1, `100212062014504120058869224 `wx554f0b3e56067c9d1428814993, `oMfX0jtHOXPrCCWebdJEYl1eIzVg, `NATIVE, `SUCCESS, `CFT, `CNY, `16.80, `0.00, `0, `0, `0, `0, `0, `0, `0.60% `2015-04-12 12:20:39, `wx554f0b3e56067c9d, `10024142, `0, `WJ2, `1002560206201504120058795541, `wx554f0b3e56067c9d1428812423, `oMfX0jhBckNfxRDHp2lUiFxXlCYE, `NATIVE, `SUCCESS, `CCB_DEBIT, `CNY, `0.00, `0.00, `0,0,`0, `0pen` Wechat public platform development best practices,`, `0.75960 `0.60% `2015-04-12 09:35:03, `0.60%, `0, `WJ6, `1003310206201504120058568869, `wx554f0b3e56067c9d1428802486, `oMfX0jmQtv9nBfol_-e83xYdXacM, `NATIVE, `SUCCESS, `CMBC_DEBIT, `CNY, `0.10, `0.00, `0, `0, `0.60% `2015-04-12 09:23:20, `wx554f0b3e56067c9d, `10024142, `0, `WJ6, `1003324142, `0, `WJ6, `1003310206201450120058569203, `wx554f0b3e56067c9d1428801789, `oMfX0jmQtv9nBfol_-e83xYdXacM, `NATIVE, `SUCCESS, `CMBC_DEBIT, `CNY, `0.10, `0.00 `0, `0, `0, `0, `0, `0, `0.60%, 2015-04-12 10:15:27, `wx554f0b3e56067c9d, `10024142, `0, `WJ5, `1003310206201504120058606779, `wx554f0b3e56067c9d1428804915, `oMfX0jmQtv9nBfol_-e83xYdXacM, `NATIVE, `SUCCESS, `CFT, `CNY, `0.10, `0.00, `0, `0, `0, `0, `0min `Wechat public platform development best practices, `, `0.00060, `0.60% `2015-04-12 10:10:09, `wx554f0b3e56067c9d, `10024142 `0, `WJ5, `1003310206201504120058610924, `wx554f0b3e56067c9d1428804597, `oMfX0jmQtv9nBfol_-e83xYdXacM, `NATIVE, `SUCCESS, `CFT, `0.10, `0.00, `0, `0, `0, `0, `Wechat public platform development best practices,`, `0, `0.60% `2015-04-12 10:06:19, `wx554f0b3e56067c9d, `10033106201504120058617007, `wx554f0b3e56067c9d1428804368, `oMfX0jmQtv9nBfol_-e83xYdXacM, `NATIVE, `SUCCESS, `CFT, `CNY, `0.10, `0.00, `0, `0, `0, `0, `0, `0, `,` `Best practices in the development of Wechat public platform, `, `0.00060, `0.60%, 2015-04-12 11:07:04, `wx554f0b3e56067c9d1428808013, `10024142, `0, `WJ1, `1003310206201504120058692567, `wx554f0b3e56067c9d1428808013, `oMfX0jmQtv9nBfol_-e83xYdXacM, `NATIVE, `SUCCESS, `CFT, `CNY, `0.10, `0.00, `0, `0, `0, `0pian `Wechat public platform development best practices,`, `0.00060, `0.60` 2015-04-12 11:27:07, `wx554f0b3e56067c9d, `10024142, `0, `WJ6, `10033102062014120058735881, `wx554f0b3e56067c9d1428809215, `oMfX0jmQtv9nBfol_-e83xYdXacM `NATIVE, `SUCCESS, `CFT, `CNY, `0.10, `0.00, `0, `0, `0, `0, `Wechat public platform development best practices,`, `0.00060, `0.60% `2015-04-12 16:24:48, `wx554f0b3e56067c9d, `10024142, `0, `WJ1, `1003310206201504120059131508, `wx554f0b3e56067c9d1428827074, `oMfX0jk-zqqeyv7yZYEc4W1lWPVg, `NATIVE, `SUCCESS, `CFT, `CNY, `15.80, `0.00, `0,`0,`014. `0.60% `2015-04-12 14:56:41, `wx554f0b3e56067c9d, `10024142, `0, `WJ1, `1005430206201504120058999894, `wx554f0b3e56067c9d1428821791, `oMfX0jnw_NpAlwgSuJsyR8ocGSjI, `NATIVE, `SUCCESS, `CCB_DEBIT, `CNY, `42.00, `0.00, `0, `0, `0.60% `2015-04-12 13:00:00, `wx554f0b3e56067c9d, `10024142,0,` WJ1, `10061206201450120058836372, `wx554f0b3e56067c9d1428814787, `oMfX0jnVvUaoR84XV8cP4ugcd9dk, `NATIVE, `SUCCESS,` PAB_CREDIT, `CNY, `16.80,`0.00,0,0` `0, `0, `0.60% `2015-04-12 16:13:48, `wx554f0b3e56067c9d, `10024142, `0, `WJ4, `1007560206201504120059119673, `wx554f0b3e56067c9d1428826408, `oMfX0jlf4aVHBY1nel1XuNvb2m1A, `NATIVE, `SUCCESS, `ABC_DEBIT, `CNY, `120.00, `0.00, `0, `0, `0, `0.60` Wechat public platform development best practices, `, `0.72000, `0.60` 2015-04-12 09:49:04, `wx554f0b3e56067c9d, `10024142, `0, `WJ1, `10095502062014501200587546 `wx554f0b3e56067c9d1428803335, `oMfX0juZ58OdofLgirvkqK0FPq-w, `NATIVE, `SUCCESS, `CFT, `CNY, `0.10, `0.00, `0, `0, `0, `0, `0, `0, `0, `0.60% total number of transactions, total transaction volume, total refund amount, total enterprise red packet refund amount, total handling fee `17, `571.40, `0.00, `0.00, `0.00

If there is no bill for that day, return XML as follows

Second, the bill is stored in the warehouse

The above billing data is a string and is only one day's data, which is not conducive to statistics and query. It also needs to be downloaded to the database.

1. Build a table

These are in the fields of the bill

Transaction time, public account ID, merchant number, sub-merchant number, device number, Wechat order number, merchant order number, user ID, transaction type, transaction status, payment bank, currency, total amount, voucher or deduction discount amount, Wechat refund order number, merchant refund order number, refund amount, voucher or deduction discount refund amount, refund type Refund status, commodity name, merchant data packet, handling fee, rate

Based on the above fields, the table is as follows

CREATE TABLE IF NOT EXISTS `wx_ bill` (`id` int (10) NOT NULL AUTO_INCREMENT, `tradetime` varchar (20) NOT NULL, `ghid` varchar (20) NOT NULL, `mchid` varchar (20) NOT NULL, `submch` varchar (10) NOT NULL, `deviceid` varchar (16) NOT NULL, `wxorder` varchar (30) NOT NULL, `bzorder` varchar (30) NOT NULL, `openid` varchar (30) NOT NULL, `tradetype` varchar (10) NOT NULL, `tradestatus` varchar (10) NOT NULL, `bank`varchar (16) NOT NULL, `currency` varchar (20) NOT NULL `totalmoney` varchar (20) NOT NULL, `redpacketmoney` varchar (20) NOT NULL, `wxrefund` varchar (10) NOT NULL, `bzrefund` varchar (10) NOT NULL, `refundmoney` varchar (20) NOT NULL, `redpacketrefund` varchar (20) NOT NULL, `refundtype` NOT NULL, `refundstatus` varchar (10) NOT NULL, `productname` varchar (30) NOT NULL, `bzdatapacket` varchar (10) NOT NULL, `product` varchar (10) NOT NULL, `rate` varchar (10) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `wxorder` (wxorder`) UNIQUE KEY `bzorder` (`bzorder`) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=272 two。 Storage

Insert the data of Wechat bill into the database and implement the following

INSERT INTO `bill` (`id`, `tradetime`, `ghid`, `mchid`, `submch`, `deviceid`, `wxorder`, `bzorder`, `openid`, `tradetype`, `tradestatus`, `bank`, `currency`, `totalmoney`, `redpacketmoney`, `wxrefund`, `bzrefund`, `refundmoney`, `redpacketrefund`, `refundtype`, `refundstatus`, `productname`, `bzdatacket`, `room`, `rate`) VALUES (32, '1428843600bread,' wx554f0b3e56067c9d', '1006120620504200588237,' wx554f0b3e56067c9d1428814787', 'NATIVE',' PAB_CREDIT', 'CNY',' Best practices for the development of Wechat public platforms, '0.10080,' 0.60%), (31, '1428850601,' wx554f0b3e56067c9d', '10024142,' 0here, 'WJ1',' 1005430206201504120058999894, 'wx554f0b3e56067c9d1428821791',' oMfX0jnw_NpAlwgSuJsyR8ocGSjI', 'NATIVE',' SUCCESS' 'CCB_DEBIT',' CNY', '42.00,' 0.005, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.25200, 0.60%), (30, '14288558888, wx554f0b3e56067c9d',' 10024142, 0,000,1003310206201504120059131508, 'wx554f0b3e56067c9d1428827074'' 'oMfX0jk-zqqeyv7yZYEc4W1lWPVg',' NATIVE', 'SUCCESS',' CFT', 'CNY',' 15.80, '0.004,' 0,'0, 0, 0, 0, 0, 'best practices for the development of Wechat public platform,', '0.09480,' 0.60%') II. Statistical analysis

With local data, various statistical analyses can be carried out.

1. Conditional combination

The following is an interface implementation for combinatorial query of bills. You need to query the equipment used, the type of payment used, and the specified time range.

The result of its query is as follows

The above is all the contents of the article "how to pay bills in Wechat development". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report