com.github.binarywang.wxpay.constant.WxPayConstants Java Examples

The following examples show how to use com.github.binarywang.wxpay.constant.WxPayConstants. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WxPayConfiguration.java    From mall4j with GNU Affero General Public License v3.0 6 votes vote down vote up
private WxPayService getWxMpPayServiceByAppId(String appid) {
        WxPayConfig payConfig = new WxPayConfig();
        payConfig.setAppId(appid);
        payConfig.setMchId(wxPay.getMchId());
        payConfig.setMchKey(wxPay.getMchKey());
        payConfig.setKeyPath(wxPay.getKeyPath());
        payConfig.setSignType(WxPayConstants.SignType.MD5);

        WxPayService wxPayService = new WxPayServiceImpl();

//      打开下面的代码,开启沙箱模式
//        if (Objects.equals(profile, "dev")) {
//            String sandboxSignKey = null;
//            try {
//                wxPayService.setConfig(payConfig);
//                sandboxSignKey = wxPayService.getSandboxSignKey();
//            } catch (WxPayException e) {
//                e.printStackTrace();
//            }
//            payConfig.setUseSandboxEnv(true);
//            payConfig.setMchKey(sandboxSignKey);
//        }

        wxPayService.setConfig(payConfig);
        return wxPayService;
    }
 
Example #2
Source File: PayController.java    From mall4j with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * 支付接口
 */
@PostMapping("/pay")
@ApiOperation(value = "根据订单号进行支付", notes = "根据订单号进行支付")
@SneakyThrows
public ResponseEntity<WxPayMpOrderResult> pay(@RequestBody PayParam payParam) {
    YamiUser user = SecurityUtils.getUser();
    String userId = user.getUserId();
    String openId = user.getBizUserId();


    PayInfoDto payInfo = payService.pay(userId, payParam);

    WxPayUnifiedOrderRequest orderRequest = new WxPayUnifiedOrderRequest();
    orderRequest.setBody(payInfo.getBody());
    orderRequest.setOutTradeNo(payInfo.getPayNo());
    orderRequest.setTotalFee((int) Arith.mul(payInfo.getPayAmount(), 100));
    orderRequest.setSpbillCreateIp(IPHelper.getIpAddr());
    orderRequest.setNotifyUrl(apiConfig.getDomainName() + "/notice/pay/order");
    orderRequest.setTradeType(WxPayConstants.TradeType.JSAPI);
    orderRequest.setOpenid(openId);

    return ResponseEntity.ok(wxMiniPayService.createOrder(orderRequest));
}
 
Example #3
Source File: StockUserChargeServiceImpl.java    From charging_pile_cloud with MIT License 6 votes vote down vote up
@Override
@Transactional(rollbackFor = {})
public Object createUserCharge(StockUser stockUser, StockUserCharge charge) throws WxPayException {
    BigDecimal fee = charge.getFee().setScale(CommonConstant.DECIMAL_PLACE, RoundingMode.DOWN);
    WxPayUnifiedOrderRequest orderRequest =new WxPayUnifiedOrderRequest();
    String orderNum = System.currentTimeMillis() + StringUtils.getRandom(9);
    orderRequest.setOpenid(stockUser.getOpenId());
    orderRequest.setOutTradeNo(orderNum);
    orderRequest.setTradeType(WxPayConstants.TradeType.JSAPI);
    orderRequest.setSpbillCreateIp(HttpRequestUtil.getIpAddr(request));
    orderRequest.setTotalFee(BaseWxPayRequest.yuanToFen(fee.toPlainString()));
    orderRequest.setBody("充电付款");
    orderRequest.setNonceStr(String.valueOf(System.currentTimeMillis()));

    StockUserCapitalFund stockUserCapitalFund = stockUserCapitalFundService.getOne(new QueryWrapper<StockUserCapitalFund>()
    .eq("stock_user_id",stockUser.getId()));
    if(stockUserCapitalFund ==null){
        throw  new CommonException("用户未办卡,暂不能充值");
    }
    WxPayMpOrderResult object = wxPayService.createOrder(orderRequest);
    addChargeRecord(null,stockUser.getId(), charge.getFee(),
            stockUserCapitalFund.getStockCode(),PayTypeEnum.STATUS_1, WithdrawStatusEnum.STATUS_4, orderNum);
    return  object;
}