use of co.yixiang.exception.ErrorRequestException in project yshopmall by guchengwuyue.
the class YxMiniPayService method wxPay.
/**
* 小程序支付
*
* @param orderId
* @param openId 小程序openid
* @param body
* @param totalFee
* @return
* @throws WxPayException
*/
public WxPayMpOrderResult wxPay(String orderId, String openId, String body, Integer totalFee, String attach) throws WxPayException {
String apiUrl = redisHandler.getVal(ShopKeyUtils.getApiUrl());
if (StrUtil.isBlank(apiUrl)) {
throw new ErrorRequestException("请配置api地址");
}
WxPayService wxPayService = WxPayConfiguration.getWxAppPayService();
WxPayUnifiedOrderRequest orderRequest = new WxPayUnifiedOrderRequest();
orderRequest.setTradeType("JSAPI");
orderRequest.setOpenid(openId);
orderRequest.setBody(body);
orderRequest.setOutTradeNo(orderId);
orderRequest.setTotalFee(totalFee);
orderRequest.setSpbillCreateIp("127.0.0.1");
orderRequest.setNotifyUrl(apiUrl + "/api/wechat/notify");
orderRequest.setAttach(attach);
WxPayMpOrderResult orderResult = wxPayService.createOrder(orderRequest);
return orderResult;
}
use of co.yixiang.exception.ErrorRequestException in project yshopmall by guchengwuyue.
the class YxPayService method wxPay.
/**
* 微信公众号支付
*
* @param orderId
* @param openId 公众号openid
* @param body
* @param totalFee
* @return
* @throws WxPayException
*/
public WxPayMpOrderResult wxPay(String orderId, String openId, String body, Integer totalFee, String attach) throws WxPayException {
String apiUrl = redisHandler.getVal(ShopKeyUtils.getApiUrl());
if (StrUtil.isBlank(apiUrl)) {
throw new ErrorRequestException("请配置api地址");
}
WxPayService wxPayService = WxPayConfiguration.getPayService();
WxPayUnifiedOrderRequest orderRequest = new WxPayUnifiedOrderRequest();
orderRequest.setTradeType("JSAPI");
orderRequest.setOpenid(openId);
orderRequest.setBody(body);
orderRequest.setOutTradeNo(orderId);
orderRequest.setTotalFee(totalFee);
orderRequest.setSpbillCreateIp("127.0.0.1");
orderRequest.setNotifyUrl(apiUrl + "/api/wechat/notify");
orderRequest.setAttach(attach);
WxPayMpOrderResult orderResult = wxPayService.createOrder(orderRequest);
return orderResult;
}
use of co.yixiang.exception.ErrorRequestException in project yshopmall by guchengwuyue.
the class YxPayService method refundOrder.
/**
* 退款
* @param orderId
* @param totalFee
* @throws WxPayException
*/
public void refundOrder(String orderId, Integer totalFee) throws WxPayException {
String apiUrl = redisHandler.getVal(ShopKeyUtils.getApiUrl());
if (StrUtil.isBlank(apiUrl)) {
throw new ErrorRequestException("请配置api地址");
}
WxPayService wxPayService = WxPayConfiguration.getPayService();
WxPayRefundRequest wxPayRefundRequest = new WxPayRefundRequest();
// 订单总金额
wxPayRefundRequest.setTotalFee(totalFee);
wxPayRefundRequest.setOutTradeNo(orderId);
wxPayRefundRequest.setOutRefundNo(orderId);
// 退款金额
wxPayRefundRequest.setRefundFee(totalFee);
wxPayRefundRequest.setNotifyUrl(apiUrl + "/api/notify/refund");
wxPayService.refund(wxPayRefundRequest);
}
use of co.yixiang.exception.ErrorRequestException in project yshopmall by guchengwuyue.
the class YxPayService method routinePay.
/**
* 微信小程序支付
*
* @param orderId
* @param body
* @param totalFee
* @return
* @throws WxPayException
*/
public WxPayMpOrderResult routinePay(String orderId, String body, String openId, Integer totalFee, String attach) throws WxPayException {
String apiUrl = redisHandler.getVal(ShopKeyUtils.getApiUrl());
if (StrUtil.isBlank(apiUrl)) {
throw new ErrorRequestException("请配置api地址");
}
WxPayService wxPayService = WxPayConfiguration.getWxAppPayService();
WxPayUnifiedOrderRequest orderRequest = new WxPayUnifiedOrderRequest();
orderRequest.setOpenid(openId);
orderRequest.setTradeType("JSAPI");
orderRequest.setBody(body);
orderRequest.setOutTradeNo(orderId);
orderRequest.setTotalFee(totalFee);
orderRequest.setSpbillCreateIp("127.0.0.1");
orderRequest.setNotifyUrl(apiUrl + "/api/wechat/notify");
orderRequest.setAttach(attach);
WxPayMpOrderResult orderResult = wxPayService.createOrder(orderRequest);
return orderResult;
}
use of co.yixiang.exception.ErrorRequestException in project yshopmall by guchengwuyue.
the class YxPayService method wxH5Pay.
/**
* 微信H5支付
*
* @param orderId
* @param body
* @param totalFee
* @return
* @throws WxPayException
*/
public WxPayMwebOrderResult wxH5Pay(String orderId, String body, Integer totalFee, String attach) throws WxPayException {
String apiUrl = redisHandler.getVal(ShopKeyUtils.getApiUrl());
if (StrUtil.isBlank(apiUrl)) {
throw new ErrorRequestException("请配置api地址");
}
WxPayService wxPayService = WxPayConfiguration.getPayService();
WxPayUnifiedOrderRequest orderRequest = new WxPayUnifiedOrderRequest();
orderRequest.setTradeType("MWEB");
orderRequest.setBody(body);
orderRequest.setOutTradeNo(orderId);
orderRequest.setTotalFee(totalFee);
orderRequest.setSpbillCreateIp("127.0.0.1");
orderRequest.setNotifyUrl(apiUrl + "/api/wechat/notify");
orderRequest.setAttach(attach);
WxPayMwebOrderResult orderResult = wxPayService.createOrder(orderRequest);
return orderResult;
}
Aggregations