UNPKG

3.05 kBJavaScriptView Raw
1'use strict';
2
3var util = require('./util');
4var wrapper = util.wrapper;
5var postJSON = util.postJSON;
6
7/**
8 * 微信公众号支付: 发货通知
9 * 详情请见:<http://mp.weixin.qq.com/htmledition/res/bussiness-faq/wx_mp_pay.zip> 接口文档订单发货通知
10 *
11 * Data:
12 * ```
13 * {
14 * "appid" : "wwwwb4f85f3a797777",
15 * "openid" : "oX99MDgNcgwnz3zFN3DNmo8uwa-w",
16 * "transid" : "111112222233333",
17 * "out_trade_no" : "555666uuu",
18 * "deliver_timestamp" : "1369745073",
19 * "deliver_status" : "1",
20 * "deliver_msg" : "ok",
21 * "app_signature" : "53cca9d47b883bd4a5c85a9300df3da0cb48565c",
22 * "sign_method" : "sha1"
23 * }
24 * ```
25 * Examples:
26 * ```
27 * api.deliverNotify(data, callback);
28 * ```
29 * Callback:
30 *
31 * - `err`, 调用失败时得到的异常
32 * - `result`, 调用正常时得到的对象
33 *
34 * Result:
35 * ```
36 * {"errcode":0, "errmsg":"ok"}
37 * ```
38 *
39 * @param {Object} package package对象
40 * @param {Function} callback 回调函数
41 */
42exports.deliverNotify = function (data, callback) {
43 this.preRequest(this._deliverNotify, arguments);
44};
45
46/*!
47 * 发货通知的未封装版本
48 */
49exports._deliverNotify = function (data, callback) {
50 var url = this.endpoint + '/pay/delivernotify?access_token=' + this.token.accessToken;
51 this.request(url, postJSON(data), wrapper(callback));
52};
53
54/**
55 * 微信公众号支付: 订单查询
56 * 详情请见:<http://mp.weixin.qq.com/htmledition/res/bussiness-faq/wx_mp_pay.zip> 接口文档订单查询部分
57 *
58 * Package:
59 * ```
60 * {
61 * "appid" : "wwwwb4f85f3a797777",
62 * "package" : "out_trade_no=11122&partner=1900090055&sign=4e8d0df3da0c3d0df38f",
63 * "timestamp" : "1369745073",
64 * "app_signature" : "53cca9d47b883bd4a5c85a9300df3da0cb48565c",
65 * "sign_method" : "sha1"
66 * }
67 * ```
68 * Examples:
69 * ```
70 * api.orderQuery(query, callback);
71 * ```
72 * Callback:
73 *
74 * - `err`, 调用失败时得到的异常
75 * - `result`, 调用正常时得到的对象
76 *
77 * Result:
78 * ```
79 * {
80 * "errcode":0,
81 * "errmsg":"ok",
82 * "order_info": {
83 * "ret_code":0,
84 * "ret_msg":"",
85 * "input_charset":"GBK",
86 * "trade_state":"0",
87 * "trade_mode":"1",
88 * "partner":"1900000109",
89 * "bank_type":"CMB_FP",
90 * "bank_billno":"207029722724",
91 * "total_fee":"1",
92 * "fee_type":"1",
93 * "transaction_id":"1900000109201307020305773741",
94 * "out_trade_no":"2986872580246457300",
95 * "is_split":"false",
96 * "is_refund":"false",
97 * "attach":"",
98 * "time_end":"20130702175943",
99 * "transport_fee":"0",
100 * "product_fee":"1",
101 * "discount":"0",
102 * "rmb_total_fee":""
103 * }
104 * }
105 * ```
106 *
107 * @param {Object} query query对象
108 * @param {Function} callback 回调函数
109 */
110exports.orderQuery = function (query, callback) {
111 this.preRequest(this._orderQuery, arguments);
112};
113
114/*!
115 * 发货通知的未封装版本
116 */
117exports._orderQuery = function (query, callback) {
118 var url = this.endpoint + '/pay/orderquery?access_token=' + this.token.accessToken;
119 this.request(url, postJSON(query), wrapper(callback));
120};