View Javadoc
1   package com.foxinmy.weixin4j.pay.payment.mch;
2   
3   import com.foxinmy.weixin4j.pay.model.WeixinPayAccount;
4   import com.foxinmy.weixin4j.pay.payment.PayRequest;
5   import com.foxinmy.weixin4j.pay.type.TradeType;
6   
7   /**
8    * WAP支付
9    * 
10   * @className WAPPayRequest
11   * @author jinyu(foxinmy@gmail.com)
12   * @date 2015年12月25日
13   * @since JDK 1.6
14   * @see PrePay
15   * @see PayRequest
16   * @see <a
17   *      href="https://pay.weixin.qq.com/wiki/doc/api/wap.php?chapter=15_1">WAP支付</a>
18   */
19  public class WAPPayRequest extends AbstractPayRequest {
20  	/**
21  	 * 微信支付URL
22  	 */
23  	private final String payUrl;
24  
25  	public WAPPayRequest(String prePayId, String payUrl,
26  			WeixinPayAccount payAccount) {
27  		super(prePayId, payAccount);
28  		this.payUrl = payUrl;
29  
30  	}
31  
32  	@Override
33  	public TradeType getPaymentType() {
34  		return TradeType.MWEB;
35  	}
36  
37  	/**
38  	 * <font color="red">只做查看之用,请不要尝试作为支付请求</font>
39  	 */
40  	@Override
41  	public PayRequest toRequestObject() {
42  		PayRequest payRequest = new PayRequest(getPaymentAccount().getId(),
43  				getPaymentType().name());
44  		payRequest.setPrepayId(getPrePayId());
45  		return payRequest;
46  	}
47  
48  	@Override
49  	public String toRequestString() {
50  		// PayRequest payRequest = toRequestObject();
51  		// String original = MapUtil.toJoinString(payRequest, true, true);
52  		// String sign = DigestUtil.MD5(
53  		// String.format("%s&key=%s", original, getPaymentAccount()
54  		// .getPaySignKey())).toUpperCase();
55  		// return String.format("weixin://wap/pay?%s",
56  		// URLEncodingUtil.encoding(
57  		// String.format("%s&sign=%s", original, sign),
58  		// Consts.UTF_8, true));
59  		return this.payUrl;
60  	}
61  }