forked from PingPlusPlus/pingpp-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRedEnvelopeExample.java
More file actions
59 lines (47 loc) · 1.71 KB
/
RedEnvelopeExample.java
File metadata and controls
59 lines (47 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import java.util.HashMap;
import java.util.Map;
import com.pingplusplus.Pingpp;
import com.pingplusplus.exception.PingppException;
import com.pingplusplus.model.RedEnvelope;
public class RedEnvelopeExample {
public static void main(String[] args) {
// TODO Auto-generated method stub
Pingpp.apiKey = "YOUR-KEY";
RedEnvelopeExample example = new RedEnvelopeExample();
example.redEnvelope();
}
public void redEnvelope() {
Map<String, Object> redenvelope = new HashMap<String, Object>();
redenvelope.put("amount", 100);
redenvelope.put("currency", "cny");
redenvelope.put("subject", "Your Subject");
redenvelope.put("body", "Your Body");
redenvelope.put("order_no", "123456789");
redenvelope.put("channel", "wx_pub");
redenvelope.put("recipient", "Openid");
redenvelope.put("description", "Your Description");
Map<String, String> app = new HashMap<String, String>();
app.put("id", "YOUR-APP-ID");
redenvelope.put("app", app);
Map<String, String> extra = new HashMap<String, String>();
extra.put("nick_name", "Nick Name");
extra.put("send_name", "Send Name");
redenvelope.put("extra", extra);
try {
//发送红包
RedEnvelope red = RedEnvelope.create(redenvelope);
System.out.println(red);
} catch (PingppException e) {
e.printStackTrace();
}
}
public void retrieve(String id){
try {
//查询指定红包
RedEnvelope red = RedEnvelope.retrieve(id);
System.out.println(red);
} catch (PingppException e) {
e.printStackTrace();
}
}
}