Skip to content

Commit bac328d

Browse files
committed
charge list 需要 app[id] 参数
1 parent 64ad127 commit bac328d

File tree

4 files changed

+34
-12
lines changed

4 files changed

+34
-12
lines changed

example/list.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
// api_key 获取方式:登录 [Dashboard](https://dashboard.pingxx.com)->点击管理平台右上角公司名称->开发信息-> Secret Key
2-
var API_KEY = "sk_test_ibbTe5jLGCi5rzfH4OqPW9KC"
2+
var API_KEY = 'sk_test_ibbTe5jLGCi5rzfH4OqPW9KC';
33
// 设置 api_key
44
var pingpp = require('../lib/pingpp')(API_KEY);
55

6-
pingpp.charges.list({ limit: 3 }, function(err, charges) {
7-
if (err != null) {
8-
console.log("pingpp.charges.list fail:", err);
6+
pingpp.charges.list(
7+
{ limit: 3, app: { id: 'app_1Gqj58ynP0mHeX1q' } },
8+
function(err, charges) {
9+
if (err != null) {
10+
console.log('pingpp.charges.list fail:', err);
11+
}
12+
// YOUR CODE
13+
console.log(charges);
914
}
10-
// YOUR CODE
11-
});
15+
);

lib/PingppMethod.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict';
22

3-
var path = require('path');
43
var utils = require('./utils');
54
var OPTIONAL_REGEX = /^optional!/;
65

lib/pingpp.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Pingpp.USER_AGENT = {
1616
platform: process.platform,
1717
publisher: 'pingplusplus',
1818
uname: null
19-
}
19+
};
2020

2121
Pingpp.USER_AGENT_SERIALIZED = null;
2222

@@ -37,7 +37,7 @@ var resources = {
3737
var wxPubOauth = require('./WxPubOauth');
3838
var _ = require('lodash');
3939
var HEADERS_TO_PARSE = ['Pingpp-One-Version', 'Pingpp-Sdk-Version'];
40-
var fs = require("fs");
40+
var fs = require('fs');
4141

4242
Pingpp.PingppResource = require('./PingppResource');
4343
Pingpp.resources = resources;
@@ -137,7 +137,7 @@ Pingpp.prototype = {
137137
},
138138

139139
setPrivateKeyPath: function(path) {
140-
this._privateKey = fs.readFileSync(path, "utf8");
140+
this._privateKey = fs.readFileSync(path, 'utf8');
141141
},
142142

143143
_prepResources: function() {
@@ -161,7 +161,7 @@ Pingpp.prototype = {
161161
var self = this;
162162
this['wxPubOauth'] = wxPubOauth;
163163
this['parseHeaders'] = function (headers){
164-
if (typeof headers == "undefined") {
164+
if (typeof headers == 'undefined') {
165165
return;
166166
}
167167
for (var k in headers) {

lib/resources/Charges.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,35 @@
11
'use strict';
22

33
var PingppResource = require('../PingppResource');
4+
var Error = require('../Error');
45
var pingppMethod = PingppResource.method;
6+
var hasOwn = {}.hasOwnProperty;
57

68
module.exports = PingppResource.extend({
79

810
path: 'charges',
911

1012
includeBasic: [
11-
'create', 'list', 'retrieve'
13+
'create', 'retrieve'
1214
],
1315

16+
_listCharges: pingppMethod({
17+
method: 'GET'
18+
}),
19+
20+
list: function(params, cb) {
21+
if (!hasOwn.call(params, 'app')
22+
|| typeof params.app != 'object'
23+
|| !hasOwn.call(params.app, 'id')
24+
) {
25+
cb.call(null, new Error.PingppInvalidRequestError({
26+
message: 'Please pass app[id] as parameter.'
27+
}));
28+
} else {
29+
this._listCharges(params, cb);
30+
}
31+
},
32+
1433
/**
1534
* Charge: Refund methods
1635
*/

0 commit comments

Comments
 (0)