1 package com.foxinmy.weixin4j.payment.mch;
2
3 import com.alibaba.fastjson.JSON;
4 import com.foxinmy.weixin4j.model.WeixinPayAccount;
5 import com.foxinmy.weixin4j.payment.PayRequest;
6 import com.foxinmy.weixin4j.type.SignType;
7 import com.foxinmy.weixin4j.type.TradeType;
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 @Deprecated
28 public class JSAPIPayRequest extends AbstractPayRequest {
29
30 public JSAPIPayRequest(String prePayId, WeixinPayAccount payAccount) {
31 super(prePayId, payAccount);
32 }
33
34 @Override
35 public TradeType getPaymentType() {
36 return TradeType.JSAPI;
37 }
38
39 @Override
40 public PayRequest toRequestObject() {
41 PayRequest payRequest = new PayRequest(getPaymentAccount().getId(),
42 "prepay_id=" + getPrePayId());
43 payRequest.setSignType(SignType.MD5);
44 payRequest.setPaySign(weixinSignature.sign(payRequest));
45 return payRequest;
46 }
47
48 @Override
49 public String toRequestString() {
50 return JSON.toJSONString(toRequestObject());
51 }
52 }