View Javadoc
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   * 公众号JS支付:get_brand_wcpay_request</br>
11   * <p>
12   * get_brand_wcpay_request:ok 支付成功<br>
13   * get_brand_wcpay_request:cancel 支付过程中用户取消<br>
14   * get_brand_wcpay_request:fail 支付失败
15   * </p>
16   * 
17   * @className JSAPIPayRequest
18   * @author jinyu(foxinmy@gmail.com)
19   * @date 2015年12月25日
20   * @since JDK 1.6
21   * @see com.foxinmy.weixin4j.payment.mch.PrePay
22   * @see com.foxinmy.weixin4j.payment.PayRequest
23   * @see <a
24   *      href="https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=7_1">网页端调起支付API</a>
25   * @deprecated 迁移到子模块weixin4j-pay
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  }