com.foxinmy.weixin4j.payment.mch.APPPayRequest Maven / Gradle / Ivy
package com.foxinmy.weixin4j.payment.mch;
import com.foxinmy.weixin4j.model.WeixinPayAccount;
import com.foxinmy.weixin4j.payment.PayRequest;
import com.foxinmy.weixin4j.type.TradeType;
import com.foxinmy.weixin4j.util.DigestUtil;
import com.foxinmy.weixin4j.util.MapUtil;
/**
* APP支付
*
* @className APPPayRequest
* @author jy
* @date 2015年12月25日
* @since JDK 1.6
* @see com.foxinmy.weixin4j.payment.mch.PrePay
* @see com.foxinmy.weixin4j.payment.PayRequest
* @see APP支付
*/
public class APPPayRequest extends AbstractPayRequest {
public APPPayRequest(String prePayId, WeixinPayAccount payAccount) {
super(prePayId, payAccount);
}
@Override
public TradeType getPaymentType() {
return TradeType.APP;
}
/**
* 只做查看之用,请不要尝试作为支付请求
*/
@Override
public PayRequest toRequestObject() {
PayRequest payRequest = new PayRequest(getPaymentAccount().getId(),
"Sign=WXPay");
payRequest.setPrepayId(getPrePayId());
return payRequest;
}
@Override
public String toRequestString() {
PayRequest payRequest = toRequestObject();
String sign = DigestUtil.MD5(
String.format("%s&key=%s",
MapUtil.toJoinString(payRequest, false, true),
getPaymentAccount().getPaySignKey())).toUpperCase();
StringBuilder content = new StringBuilder();
content.append("");
content.append(String.format(" ",
payRequest.getAppId()));
content.append(String.format(" ",
getPaymentAccount().getPartnerId()));
content.append(String.format(" ",
payRequest.getPrepayId()));
content.append(String.format(" ",
payRequest.getPackageInfo()));
content.append(String.format(" ",
payRequest.getNonceStr()));
content.append(String.format(" ",
payRequest.getTimeStamp()));
content.append(String.format(" ", sign));
content.append(" ");
return content.toString();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy