1 package com.foxinmy.weixin4j.pay.payment.mch;
2
3 import com.alibaba.fastjson.annotation.JSONField;
4 import com.foxinmy.weixin4j.pay.model.WeixinPayAccount;
5 import com.foxinmy.weixin4j.pay.sign.WeixinPaymentSignature;
6 import com.foxinmy.weixin4j.util.Consts;
7 import com.foxinmy.weixin4j.util.RandomUtil;
8
9 import javax.xml.bind.annotation.XmlAccessType;
10 import javax.xml.bind.annotation.XmlAccessorType;
11 import javax.xml.bind.annotation.XmlElement;
12 import javax.xml.bind.annotation.XmlRootElement;
13
14
15
16
17
18
19
20
21
22
23 @XmlRootElement
24 @XmlAccessorType(XmlAccessType.FIELD)
25 public class NativePayResponse extends MerchantResult {
26
27 private static final long serialVersionUID = 6119895998783333012L;
28
29 @XmlElement(name = "prepay_id")
30 @JSONField(name = "prepay_id")
31 private String prepayId;
32
33 protected NativePayResponse() {
34
35 }
36
37
38
39
40
41
42
43
44
45 public NativePayResponse(String returnMsg, String resultMsg) {
46 super(Consts.FAIL, returnMsg);
47 super.setErrCodeDes(resultMsg);
48 super.setResultCode(Consts.FAIL);
49 }
50
51
52
53
54
55
56
57
58
59 public NativePayResponse(WeixinPayAccount weixinAccount, String prepayId) {
60 super(Consts.SUCCESS, "OK");
61 this.setResultCode(Consts.SUCCESS);
62 this.setMchId(weixinAccount.getMchId());
63 this.setAppId(weixinAccount.getId());
64 this.setNonceStr(RandomUtil.generateString(16));
65 this.prepayId = prepayId;
66 this.setSign(new WeixinPaymentSignature(weixinAccount.getPaySignKey())
67 .sign(this));
68 }
69
70 public String getPrepayId() {
71 return prepayId;
72 }
73
74 public void setPrepayId(String prepayId) {
75 this.prepayId = prepayId;
76 }
77
78 @Override
79 public String toString() {
80 return "NativePayResponse [prepayId=" + prepayId + ", "
81 + super.toString() + "]";
82 }
83 }