Javen205 / IJPay

IJPay 让支付触手可及,封装了微信支付、QQ支付、支付宝支付、京东支付、银联支付、PayPal 支付等常用的支付方式以及各种常用的接口。不依赖任何第三方 mvc 框架,仅仅作为工具使用简单快速完成支付模块的开发,可轻松嵌入到任何系统里。右上角点下小星星✨
http://javen205.gitee.io/ijpay
Apache License 2.0
5.51k stars 1.35k forks source link

即时到账交易接口 #22

Closed MyOnlyCat closed 5 years ago

MyOnlyCat commented 5 years ago

即时到账交易接口

-文档地址

交流群

Javen205 commented 5 years ago

IJPay 中的支付宝支付是对 alipay-sdk-java-all 的二次封装。在 alipay-sdk-java-all 中目前没有封装此接口,所以目前还不支持,后期想办法扩展一下。

MyOnlyCat commented 5 years ago

好的,已用常规Http请求解决,还是谢谢 大佬开发的轮子

Javen205 commented 5 years ago

@MyOnlyCat 你那边使用常规 Http 请求支付接口,返回的数据是正常的?我这边测试返回的数据是空

@RequestMapping(value = "/wapPayNoSdk")
    @ResponseBody
    public void wapPayNoSdk(HttpServletResponse response) {
        try {
            AliPayApiConfig aliPayApiConfig = AliPayApiConfigKit.getAliPayApiConfig();
            Map<String, String> paramsMap = new HashMap<>();
            paramsMap.put("app_id", aliPayApiConfig.getAppId());
            paramsMap.put("method", "alipay.trade.wap.pay");
            paramsMap.put("return_url", aliPayBean.getDomain() + "aliPay/return_url");
            paramsMap.put("charset", aliPayApiConfig.getCharset());
            paramsMap.put("sign_type", aliPayApiConfig.getSignType());
            paramsMap.put("timestamp", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
            paramsMap.put("version", "1.0");
            paramsMap.put("notify_url", aliPayBean.getDomain() + "/aliPay/notify_url");

            Map<String, String> bizMap = new HashMap<>();
            bizMap.put("body", "IJPay 聚合支付-H5");
            bizMap.put("subject", "IJPay 让支付触手可及");
            bizMap.put("out_trade_no", StringUtils.getOutTradeNo());
            bizMap.put("total_amount", "6.66");
            bizMap.put("product_code", "QUICK_WAP_WAY");

            paramsMap.put("biz_content", JSON.toJSONString(bizMap));

            String content = PayKit.createLinkString(paramsMap);

            System.out.println(content);

            String encrypt = RsaKit.encryptByPrivateKey(content, aliPayApiConfig.getPrivateKey());
            System.out.println(encrypt);
//            encrypt = AlipaySignature.rsaSign(content,aliPayApiConfig.getPrivateKey(), "UTF-8","RSA2");
//            System.out.println(encrypt);
            paramsMap.put("sign", encrypt);
            Map<String, Object> temp = new HashMap<String, Object>(paramsMap.size());
            temp.putAll(paramsMap);

            String form = HttpKit.getDelegate().get(aliPayApiConfig.getServiceUrl(), temp);
            System.out.println(aliPayApiConfig.getServiceUrl() + ">>>结果>>>>" + form);

            response.setContentType("text/html;charset=" + aliPayApiConfig.getCharset());
            OutputStream out = response.getOutputStream();
            out.write(form.getBytes(aliPayApiConfig.getCharset()));
            response.getOutputStream().flush();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }