1 package com.foxinmy.weixin4j.mp.oldpayment;
2
3 import java.util.HashMap;
4 import java.util.Map;
5
6 import javax.xml.bind.annotation.XmlAccessType;
7 import javax.xml.bind.annotation.XmlAccessorType;
8 import javax.xml.bind.annotation.XmlElement;
9 import javax.xml.bind.annotation.XmlRootElement;
10
11 import com.alibaba.fastjson.annotation.JSONField;
12 import com.foxinmy.weixin4j.payment.PayRequest;
13
14
15
16
17
18
19
20
21
22
23 @XmlRootElement
24 @XmlAccessorType(XmlAccessType.FIELD)
25 public class NativePayResponseV2 extends PayRequest {
26
27 private static final long serialVersionUID = 6119895998783333012L;
28
29
30
31 @JSONField(name = "RetCode")
32 @XmlElement(name = "RetCode")
33 private String retCode;
34
35
36
37 @JSONField(name = "RetErrMsg")
38 @XmlElement(name = "RetErrMsg")
39 private String retMsg;
40
41 protected NativePayResponseV2() {
42
43 }
44
45
46
47
48
49
50
51 public NativePayResponseV2(String errorMsg) {
52 this.retCode = "-1";
53 this.retMsg = errorMsg;
54 }
55
56
57
58
59
60
61
62
63 public NativePayResponseV2(WeixinOldPayAccount weixinAccount,
64 PayPackageV2 payPackage) {
65 super(weixinAccount.getId(), null);
66 this.retCode = "0";
67 this.retMsg = "OK";
68 WeixinOldPaymentSignature weixinSignature = new WeixinOldPaymentSignature(
69 weixinAccount.getPaySignKey(), weixinAccount.getPartnerKey());
70 setPackageInfo(weixinSignature.sign(payPackage));
71 Map<String, String> map = new HashMap<String, String>();
72 map.put("appid", weixinAccount.getId());
73 map.put("appkey", weixinAccount.getPaySignKey());
74 map.put("timestamp", getTimeStamp());
75 map.put("noncestr", getNonceStr());
76 map.put("package", getPackageInfo());
77 map.put("retcode", getRetCode());
78 map.put("reterrmsg", getRetMsg());
79 this.setPaySign(weixinSignature.sign(map));
80 }
81
82 public String getRetCode() {
83 return retCode;
84 }
85
86 public String getRetMsg() {
87 return retMsg;
88 }
89
90 @Override
91 public String toString() {
92 return "NativePayResponseV2 [retCode=" + retCode + ", retMsg=" + retMsg
93 + ", " + super.toString() + "]";
94 }
95 }