Search in sources :

Example 1 with NotifyReqBean

use of com.github.liuweijw.commons.pay.beans.NotifyReqBean in project fw-cloud-framework by liuweijw.

the class NotifyServiceImpl method buildNotifyUrl.

private String buildNotifyUrl(PayOrder payOrder) {
    String mchId = payOrder.getMch_id();
    PayMchInfo mchInfo = mchInfoService.findMchInfoByMchId(mchId);
    String resKey = mchInfo.getResKey();
    NotifyReqBean notifyReqBean = new NotifyReqBean();
    // 支付订单号
    notifyReqBean.setPayOrderId(payOrder.getPayOrderId());
    // 商户ID
    notifyReqBean.setMchId(payOrder.getMch_id());
    // 商户订单号
    notifyReqBean.setMchOrderNo(payOrder.getMchOrderNo());
    // 渠道ID
    notifyReqBean.setChannelId(payOrder.getChannelId());
    // 支付金额
    notifyReqBean.setAmount(payOrder.getAmount());
    // 货币类型
    notifyReqBean.setCurrency(payOrder.getCurrency());
    // 支付状态
    notifyReqBean.setStatus(payOrder.getStatus());
    // 客户端IP
    notifyReqBean.setIp(payOrder.getIp());
    // 设备
    notifyReqBean.setDevice(WebUtils.buildURLEncoder(payOrder.getDevice()));
    // 商品标题
    notifyReqBean.setSubject(WebUtils.buildURLEncoder(payOrder.getSubject()));
    // 渠道订单号
    notifyReqBean.setChannelOrderNo(payOrder.getChannelOrderNo());
    // 扩展参数1
    notifyReqBean.setParam1(WebUtils.buildURLEncoder(payOrder.getParam1()));
    // 扩展参数2
    notifyReqBean.setParam2(WebUtils.buildURLEncoder(payOrder.getParam2()));
    // 支付成功时间
    notifyReqBean.setPaySuccTime(payOrder.getPaySuccTime());
    // backType 1:前台页面;2:后台接口
    notifyReqBean.setBackType("2");
    JSONObject jsonObj = (JSONObject) JSON.toJSON(notifyReqBean);
    // 先对原文签名
    String reqSign = PayDigestUtil.getSign(jsonObj, resKey);
    // 签名
    jsonObj.put("sign", reqSign);
    String param = PayUtil.buildUrlParams(jsonObj);
    StringBuffer sb = new StringBuffer();
    sb.append(payOrder.getNotifyUrl()).append("?").append(param);
    log.info("notifyUrl:" + sb);
    return sb.toString();
}
Also used : NotifyReqBean(com.github.liuweijw.commons.pay.beans.NotifyReqBean) PayMchInfo(com.github.liuweijw.business.pay.domain.PayMchInfo) JSONObject(com.alibaba.fastjson.JSONObject)

Aggregations

JSONObject (com.alibaba.fastjson.JSONObject)1 PayMchInfo (com.github.liuweijw.business.pay.domain.PayMchInfo)1 NotifyReqBean (com.github.liuweijw.commons.pay.beans.NotifyReqBean)1