|
|
package com.yohoufo.order.service.pay.alipay;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yohobuy.ufo.model.order.bo.OrderInfo;
|
|
|
import com.yohoufo.common.utils.DateUtil;
|
|
|
import com.yohoufo.order.config.AlipayConfig;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.net.URLEncoder;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
|
|
|
@Service
|
|
|
public class AlipayOuyinWapService extends AbstractAlipayService {
|
|
|
@Override
|
|
|
protected AlipaySignatureSetting getAlipaySignatureSetting() {
|
|
|
return new AlipaySignatureSetting(
|
|
|
AlipayConfig.OUYIN_APPID,
|
|
|
AlipayConfig.OUYIN_PARTNER,
|
|
|
false,
|
|
|
"RSA"
|
|
|
);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
protected String getAccountUserName() {
|
|
|
return AlipayConfig.OUYIN_USER_NAME;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
protected String getAccountEmail() {
|
|
|
return AlipayConfig.OUYIN_EMAIL;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
protected Map<String, String> buildOpenApiPayParams(OrderInfo orderInfo) {
|
|
|
long orderCode= orderInfo.getOrderCode();
|
|
|
String tradeNo = orderInfo.getOutTradeNo();
|
|
|
BigDecimal amount = orderInfo.getAmount();
|
|
|
int payExpireTime = orderInfo.getPayExpireTime();
|
|
|
//build
|
|
|
Map<String, String> params = new HashMap<String, String>();
|
|
|
params.put("app_id", getAppId());
|
|
|
params.put("method", "alipay.trade.wap.pay");
|
|
|
params.put("charset", AlipayConfig.input_charset);
|
|
|
params.put("sign_type", "RSA");
|
|
|
params.put("timestamp", DateUtil.getCurrentTime());
|
|
|
params.put("version", "1.0");
|
|
|
params.put("notify_url", getNotifyURL());
|
|
|
|
|
|
if (paymentSupportService.isForbidVirtualPayChannel(orderCode)){
|
|
|
params.put("disable_pay_channels", "credit_group"); // 禁用信用卡
|
|
|
}
|
|
|
|
|
|
JSONObject bizJson = new JSONObject(true);
|
|
|
bizJson.put("timeout_express", payExpireTime+"m"); //该订单允许的最晚付款时间
|
|
|
bizJson.put("seller_id", "");
|
|
|
bizJson.put("product_code", "QUICK_MSECURITY_PAY");
|
|
|
bizJson.put("total_amount", amount.toPlainString());
|
|
|
|
|
|
String subject = "ufoOrder-" + tradeNo;
|
|
|
bizJson.put("subject", subject);
|
|
|
bizJson.put("body", subject);
|
|
|
bizJson.put("out_trade_no", tradeNo);
|
|
|
|
|
|
params.put("biz_content", bizJson.toJSONString());
|
|
|
|
|
|
String preSignStr = getOpenApiSignString(params, false);
|
|
|
String sign = helper().signWithRsa(preSignStr,AlipayConfig.input_charset);
|
|
|
params.put("sign", URLEncoder.encode(sign));
|
|
|
|
|
|
// 对biz_content进行encode
|
|
|
String encodeUrl = URLEncoder.encode(bizJson.toJSONString());
|
|
|
params.put("biz_content", encodeUrl);
|
|
|
|
|
|
return params;
|
|
|
}
|
|
|
} |
...
|
...
|
|