Skip to content

Commit e10d055

Browse files
committed
增加实例代码注释
1 parent c990287 commit e10d055

7 files changed

Lines changed: 134 additions & 9 deletions

File tree

example/SimpleExample/src/example/ChargeExample.java

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,32 +18,42 @@
1818
/**
1919
* Charge 对象相关示例
2020
* @author sunkai
21-
*
21+
*
22+
* 该实例程序演示了如何从 ping++ 服务器获得 charge ,查询 charge。
23+
*
24+
* 开发者需要填写 apiKey 和 appId , apiKey 可以在 ping++ 管理平台【应用信息里面查看】
25+
*
26+
* apiKey 有 TestKey 和 LiveKey 两种。
27+
*
28+
* TestKey 模式下不会产生真实的交易。
2229
*/
2330
public class ChargeExample {
2431

2532
/**
26-
* pingpp 管理平台对应的API key
33+
* pingpp 管理平台对应的 API key
2734
*/
2835
public static String apiKey = "YOUR-KEY";
2936
/**
30-
* pingpp 管理平台对应的应用ID
37+
* pingpp 管理平台对应的应用 ID
3138
*/
3239
public static String appId = "YOUR-APPID";
3340

3441
public static void main(String[] args) {
3542
Pingpp.apiKey = apiKey;
3643
ChargeExample ce = new ChargeExample();
37-
System.out.println("---------创建charge");
44+
System.out.println("---------创建 charge");
3845
Charge charge = ce.charge();
39-
System.out.println("---------查询charge");
46+
System.out.println("---------查询 charge");
4047
ce.retrieve(charge.getId());
41-
System.out.println("---------查询charge列表");
48+
System.out.println("---------查询 charge列表");
4249
ce.all();
4350
}
4451

4552
/**
46-
* 创建Charge
53+
* 创建 Charge
54+
*
55+
* 创建 Charge 用户需要组装一个 map 对象作为参数传递给 Charge.create();
56+
* map 里面参数的具体说明请参考:https://pingxx.com/document/api#api-c-new
4757
* @return
4858
*/
4959
public Charge charge() {
@@ -70,7 +80,13 @@ public Charge charge() {
7080
}
7181

7282
/**
73-
* 查询Charge
83+
* 查询 Charge
84+
*
85+
* 该接口根据 charge Id 查询对应的 charge 。
86+
* 参考文档:https://pingxx.com/document/api#api-c-inquiry
87+
*
88+
* 该接口可以传递一个 expand , 返回的 charge 中的 app 会变成 app 对象。
89+
* 参考文档: https://pingxx.com/document/api#api-expanding
7490
* @param id
7591
*/
7692
public void retrieve(String id) {
@@ -98,6 +114,11 @@ public void retrieve(String id) {
98114

99115
/**
100116
* 分页查询Charge
117+
*
118+
* 该接口为批量查询接口,默认一次查询10条。
119+
* 用户可以通过添加 limit 参数自行设置查询数目,最多一次不能超过 100 条。
120+
*
121+
* 该接口同样可以使用 expand 参数。
101122
* @return
102123
*/
103124
public ChargeCollection all() {

example/SimpleExample/src/example/EventExample.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,17 @@
1818

1919
/**
2020
* Created by sunkai on 15/5/14.
21+
*
22+
* Event 事件参考文档:https://pingxx.com/document/api#api-event
23+
*
24+
* 该实例演示如何查询 Event
25+
*
26+
* 开发者需要填写 apiKey 和 appId , apiKey 可以在 ping++ 管理平台【应用信息里面查看】
27+
*
28+
* apiKey 有 TestKey 和 LiveKey 两种。
29+
*
30+
* TestKey 模式下不会产生真实的交易。
31+
*
2132
*/
2233
public class EventExample {
2334
/**
@@ -46,6 +57,9 @@ public static void main(String args[]) {
4657

4758
/**
4859
* 根据 ID 查询 Evnet
60+
*
61+
* 传递 Event 的 Id 查询 Event。
62+
* 参考文档:https://pingxx.com/document/api#api-event-inquiry
4963
* @param id
5064
*/
5165
public void retrieve(String id) {
@@ -75,6 +89,10 @@ public void retrieve(String id) {
7589

7690
/**
7791
* 批量查询
92+
*
93+
* 该接口为批量查询接口,默认一次查询10条。
94+
* 用户可以通过添加 limit 参数自行设置查询数目,最多一次不能超过 100 条。
95+
*
7896
*/
7997
public void all() {
8098
Map<String, Object> params = new HashMap<String, Object>();

example/SimpleExample/src/example/RedEnvelopeExample.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@
1515

1616
/**
1717
* Created by sunkai on 15/7/2.
18+
*
19+
* 该实例演示如何操作微信红包
20+
*
21+
* 开发者需要填写 apiKey 、appId 和 openId 。 apiKey 可以在 ping++ 管理平台【应用信息里面查看】
22+
*
23+
* apiKey 有 TestKey 和 LiveKey 两种。
24+
*
25+
* TestKey 模式下不会产生真实的交易。
26+
*
27+
* openId 是发送红包的对象在公共平台下的openId ,获得 openId 的方法可以参考微信文档:http://mp.weixin.qq.com/wiki/17/c0f37d5704f0b64713d5d2c37b468d75.html
28+
*
1829
*/
1930
public class RedEnvelopeExample {
2031

@@ -45,6 +56,9 @@ public static void main(String[] args) {
4556

4657
/**
4758
* 创建红包
59+
*
60+
* 创建红包需要传递一个 map 到 RedEnvelope.create(redenvelope)
61+
* map 里面的具体参数参考:https://pingxx.com/document/api#api-e-new
4862
* @return
4963
*/
5064
public RedEnvelope create() {
@@ -84,6 +98,9 @@ public RedEnvelope create() {
8498

8599
/**
86100
* 查询红包
101+
*
102+
* 根据红包的 Id 查询红包。
103+
* 参考文档:https://pingxx.com/document/api#api-e-inquiry
87104
* @param id
88105
*/
89106
public void retrieve(String id) {
@@ -103,6 +120,8 @@ public void retrieve(String id) {
103120

104121
/**
105122
* 批量查询红包
123+
*
124+
* 批量查询接口,默认一次查询 10 条。用户可以通过 limit 自定义查询数目,最多不超过 100 条。
106125
*/
107126
public void all() {
108127
RedEnvelopeCollection redEnvelopeCollection = null;

example/SimpleExample/src/example/RefundsExample.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@
1515
/**
1616
* 退款相关示例
1717
* Created by sunkai on 15/4/22.
18+
*
19+
* 该实例程序演示了如何从 ping++ 服务器进行退款操作。
20+
*
21+
* 开发者需要填写 apiKey 和 chargeId , apiKey 可以在 ping++ 管理平台【应用信息里面查看】
22+
*
23+
* apiKey 有 TestKey 和 LiveKey 两种。
24+
*
25+
* TestKey 模式下不会产生真实的交易。
1826
*/
1927
public class RefundsExample {
2028

@@ -54,6 +62,12 @@ public static void main(String args[]) {
5462

5563
/**
5664
* 退款
65+
*
66+
* 创建退款,需要先获得 charge ,然后调用 charge.getRefunds().create();
67+
* 参数具体说明参考:https://pingxx.com/document/api#api-r-new
68+
*
69+
* 可以一次退款,也可以分批退款。
70+
*
5771
* @param charge
5872
* @return
5973
*/
@@ -79,6 +93,10 @@ public Refund refund(Charge charge) {
7993

8094
/**
8195
* 查询退款
96+
*
97+
* 根据 Id 查询退款记录。需要传递 charge。
98+
* 参考文档:https://pingxx.com/document/api#api-r-inquiry
99+
*
82100
* @param id
83101
* @param charge
84102
*/
@@ -100,6 +118,10 @@ public void retrieve(String id, Charge charge) {
100118

101119
/**
102120
* 分页查询退款
121+
*
122+
* 批量查询退款。默认一次 10 条,用户可以通过 limit 自定义查询数目,但是最多不超过 100 条。
123+
* 参考文档:https://pingxx.com/document/api#api-r-list
124+
*
103125
* @param charge
104126
*/
105127
public void all(Charge charge) {

example/SimpleExample/src/example/TransferExample.java

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@
2020

2121
/**
2222
* Created by sunkai on 15/5/11.
23+
*
24+
* 该实例演示如何使用 ping++ 进行企业转账。
25+
*
26+
* 开发者需要填写 apiKey ,openId 和 appId , apiKey 可以在 ping++ 管理平台【应用信息里面查看】
27+
*
28+
* apiKey 有 TestKey 和 LiveKey 两种。
29+
*
30+
* TestKey 模式下不会产生真实的交易。
31+
*
32+
* openId 是发送红包的对象在公共平台下的openId ,获得 openId 的方法可以参考微信文档:http://mp.weixin.qq.com/wiki/17/c0f37d5704f0b64713d5d2c37b468d75.html
33+
*
2334
*/
2435
public class TransferExample {
2536

@@ -31,6 +42,11 @@ public class TransferExample {
3142
* pingpp 管理平台对应的应用ID
3243
*/
3344
public static String appId = "YOUR-APPID";
45+
46+
/**
47+
* 接收者的 openId
48+
*/
49+
public static String openId ="OPEN_ID";
3450

3551
public static void main(String args[]) {
3652

@@ -47,6 +63,10 @@ public static void main(String args[]) {
4763

4864
/**
4965
* 创建企业转账
66+
*
67+
* 创建企业转账需要传递一个 map 给 Transfer.create();
68+
* map 填写的具体介绍可以参考:https://pingxx.com/document/api#api-t-new
69+
*
5070
* @return
5171
*/
5272
public Transfer transfer() {
@@ -58,7 +78,7 @@ public Transfer transfer() {
5878
transferMap.put("amount", "10");
5979
transferMap.put("type", "b2c");
6080
transferMap.put("currency", "cny");
61-
transferMap.put("recipient", "o9zpMs5MW2-62GAy5hRrjdYVCktU");
81+
transferMap.put("recipient", openId);
6282
transferMap.put("description", "your description");
6383
Map<String, String> app = new HashMap<String, String>();
6484
app.put("id", appId);
@@ -81,6 +101,9 @@ public Transfer transfer() {
81101

82102
/**
83103
* 根据 ID 查询
104+
*
105+
* 根据 ID 查询企业转账记录。
106+
* 参考文档:https://pingxx.com/document/api#api-t-inquiry
84107
* @param id
85108
*/
86109
public void retrieve(String id) {
@@ -113,6 +136,8 @@ public void retrieve(String id) {
113136

114137
/**
115138
*批量查询
139+
*
140+
*批量查询企业转账记录,默认一次查询 10 条,用户可以使用 limit 自定义查询数目,但是最多不超过 100 条。
116141
*/
117142
public void all() {
118143
Map<String, Object> parm = new HashMap<String, Object>();

example/SimpleExample/src/example/WebHooksVerifyExample.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@
1313

1414
/**
1515
* Created by sunkai on 15/5/19. webhooks 验证签名示例
16+
*
17+
* 该实例演示如何对 ping++ webhooks 通知进行验证。
18+
* 验证是为了让开发者确认该通知来自 ping++ ,防止恶意伪造通知。用户如果有别的验证机制,可以不进行验证签名。
19+
*
20+
* 验证签名需要 签名、公钥、验证信息,该实例采用文件存储方式进行演示。
21+
* 实际项目中,需要用户从异步通知的 HTTP header 中读取签名,从 HTTP body 中读取验证信息。公钥的存储方式也需要用户自行设定。
22+
*
23+
* 该实例仅供演示如何验证签名,请务必不要直接 copy 到实际项目中使用。
24+
*
1625
*/
1726
public class WebHooksVerifyExample {
1827
private static String filePath = "src/my-server.pub";

example/SimpleExample/src/example/WxPubOAuthExample.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@
1313
* 微信公共账号,付款签名示例
1414
* @author sunkai
1515
*
16+
* 开发者需要填写 apiKey 、appId 、url 和 openId 。 apiKey 可以在 ping++ 管理平台【应用信息里面查看】
17+
*
18+
* apiKey 有 TestKey 和 LiveKey 两种。
19+
*
20+
* TestKey 模式下不会产生真实的交易。
21+
*
22+
* openId 是发送红包的对象在公共平台下的openId ,获得 openId 的方法可以参考微信文档:http://mp.weixin.qq.com/wiki/17/c0f37d5704f0b64713d5d2c37b468d75.html
23+
*
1624
*/
1725
public class WxPubOAuthExample {
1826

@@ -64,6 +72,9 @@ public static void main(String args[]) {
6472

6573
/**
6674
* 创建Charge
75+
*
76+
* 创建 Charge 用户需要组装一个 map 对象作为参数传递给 Charge.create();
77+
* map 里面参数的具体说明请参考:https://pingxx.com/document/api#api-c-new
6778
* @return
6879
*/
6980
public static Charge charge() {

0 commit comments

Comments
 (0)