| | |
| | | private Boolean verifiable; |
| | | @ApiModelProperty("是否超出限购数量") |
| | | private Boolean purchaseLimit; |
| | | @ApiModelProperty("限购数量") |
| | | private Integer purchaseLimitNum; |
| | | @ApiModelProperty("现金支付") |
| | | private Boolean cashPayment; |
| | | @ApiModelProperty("积分支付") |
| | |
| | | */ |
| | | @TableField("shop_id") |
| | | private Integer shopId; |
| | | /** |
| | | * 角色类型(1=店长,2=店员) |
| | | */ |
| | | @TableField("role_type") |
| | | private Integer roleType; |
| | | /** |
| | | * 角色id |
| | | */ |
| | | @TableField("role_id") |
| | | private Integer roleId; |
| | | } |
| | |
| | | package com.ruoyi.account.util.payment; |
| | | |
| | | import cn.hutool.http.Header; |
| | | import cn.hutool.http.HttpRequest; |
| | | import cn.hutool.http.HttpResponse; |
| | | import cn.hutool.http.HttpUtil; |
| | |
| | | public static UniPayResult uniPay(String orderNo, Double amount, String productName, String productDesc, String mp, String notifyUrl, String openId, String tradeMerchantNo){ |
| | | String url = "https://trade.joinpay.com/tradeRt/uniPay"; |
| | | HttpRequest post = HttpUtil.createPost(url); |
| | | post.header(Header.CONTENT_TYPE, "application/x-www-form-urlencoded"); |
| | | JSONObject body = new JSONObject(); |
| | | //版本号 |
| | | body.put("p0_Version", "2.5"); |
| | |
| | | throw new RuntimeException(e); |
| | | } |
| | | body.put("hmac", sign); |
| | | post.body(body.toString()); |
| | | post.form(body); |
| | | log.info("支付接口请求参数:" + body); |
| | | HttpResponse execute = post.execute(); |
| | | log.info("支付接口请求响应:" + execute.body()); |
| | |
| | | public static QueryOrderResult queryOrder(String orderNo){ |
| | | String url = "https://trade.joinpay.com/tradeRt/queryOrder"; |
| | | HttpRequest post = HttpUtil.createPost(url); |
| | | post.header(Header.CONTENT_TYPE, "application/x-www-form-urlencoded"); |
| | | JSONObject body = new JSONObject(); |
| | | //版本号 |
| | | body.put("p0_Version", "2.5"); |
| | |
| | | throw new RuntimeException(e); |
| | | } |
| | | body.put("hmac", sign); |
| | | post.body(body.toString()); |
| | | post.form(body); |
| | | log.info("查询支付接口请求参数:" + body); |
| | | HttpResponse execute = post.execute(); |
| | | log.info("查询支付接口请求响应:" + execute.body()); |
| | |
| | | public static RefundResult refund(String orderNo, String refundOrderNo, Double refundAmount, String notifyUrl){ |
| | | String url = "https://trade.joinpay.com/tradeRt/refund"; |
| | | HttpRequest post = HttpUtil.createPost(url); |
| | | post.header(Header.CONTENT_TYPE, "application/x-www-form-urlencoded"); |
| | | JSONObject body = new JSONObject(); |
| | | //版本号 |
| | | body.put("p0_Version", "2.3"); |
| | |
| | | throw new RuntimeException(e); |
| | | } |
| | | body.put("hmac", sign); |
| | | post.body(body.toString()); |
| | | post.form(body); |
| | | log.info("退款接口请求参数:" + body); |
| | | HttpResponse execute = post.execute(); |
| | | log.info("退款接口请求响应:" + execute.body()); |
| | |
| | | public static QueryRefundResult queryRefund(String refundOrderNo){ |
| | | String url = "https://trade.joinpay.com/tradeRt/refund"; |
| | | HttpRequest post = HttpUtil.createPost(url); |
| | | post.header(Header.CONTENT_TYPE, "application/x-www-form-urlencoded"); |
| | | JSONObject body = new JSONObject(); |
| | | //版本号 |
| | | body.put("p0_Version", "2.3"); |
| | |
| | | throw new RuntimeException(e); |
| | | } |
| | | body.put("hmac", sign); |
| | | post.body(body.toString()); |
| | | post.form(body); |
| | | log.info("退款接口请求参数:" + body); |
| | | HttpResponse execute = post.execute(); |
| | | log.info("退款接口请求响应:" + execute.body()); |
| | |
| | | public static CloseOrderResult closeOrder(String orderNo){ |
| | | String url = "https://www.joinpay.com/trade/closeOrder.action"; |
| | | HttpRequest post = HttpUtil.createPost(url); |
| | | post.header(Header.CONTENT_TYPE, "application/x-www-form-urlencoded"); |
| | | JSONObject body = new JSONObject(); |
| | | //商户编号 |
| | | body.put("p1_MerchantNo", merchantNo); |
| | |
| | | throw new RuntimeException(e); |
| | | } |
| | | body.put("hmac", sign); |
| | | post.body(body.toString()); |
| | | post.form(body); |
| | | log.info("关闭订单接口请求参数:" + body); |
| | | HttpResponse execute = post.execute(); |
| | | log.info("关闭订单接口请求响应:" + execute.body()); |
| | |
| | | } |
| | | } |
| | | sb.append(key); |
| | | log.info("待签名串:{}", sb.toString()); |
| | | return MD5AndKL.MD5(sb.toString()); |
| | | } |
| | | |
| | | |
| | | public static void main(String[] args) { |
| | | UniPayResult uniPayResult = PaymentUtil.uniPay("123456", 0.01D, "测试商品", "这是用于对接支付测试的商品描述", "", "", "", ""); |
| | | System.err.println(JSON.toJSONString(uniPayResult)); |
| | | // UniPayResult uniPayResult = PaymentUtil.uniPay("852963742", 0.01D, "测试商品", "这是用于对接支付测试的商品描述", |
| | | // "", "/order/shopping-cart/shoppingCartPaymentCallback", "ooOrs64zHLuInkZ_GF0LpIN9_Rxc", "777168500885852"); |
| | | // PaymentUtil.queryOrder("852963742"); |
| | | // PaymentUtil.closeOrder("852963742"); |
| | | |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.account.util.payment; |
| | | |
| | | import cn.hutool.http.ContentType; |
| | | import cn.hutool.http.HttpRequest; |
| | | import cn.hutool.http.HttpResponse; |
| | | import cn.hutool.http.HttpUtil; |
| | |
| | | public static SinglePayResult singlePay(SinglePay singlePay){ |
| | | String url = "https://www.joinpay.com/payment/pay/singlePay"; |
| | | HttpRequest post = HttpUtil.createPost(url); |
| | | post.contentType(ContentType.JSON.toString()); |
| | | JSONObject body = new JSONObject(); |
| | | //商户编号 |
| | | body.put("userNo", merchantNo); |
| | |
| | | */ |
| | | body.put("paidUse", singlePay.getPaidUse()); |
| | | //商户通知地址 |
| | | body.put("callbackUrl", callbackUrl + singlePay.getCallbackUrl()); |
| | | body.put("callbackUrl", singlePay.getCallbackUrl()); |
| | | String sign = null; |
| | | try { |
| | | sign = sign(body); |
| | |
| | | public static SinglePayQueryResult singlePayQuery(String merchantOrderNo){ |
| | | String url = "https://www.joinpay.com/payment/pay/singlePayQuery"; |
| | | HttpRequest post = HttpUtil.createPost(url); |
| | | post.contentType(ContentType.JSON.toString()); |
| | | JSONObject body = new JSONObject(); |
| | | //商户编号 |
| | | body.put("userNo", merchantNo); |
| | |
| | | public static AccountBalanceQueryResult accountBalanceQuery(){ |
| | | String url = "https://www.joinpay.com/payment/pay/accountBalanceQuery"; |
| | | HttpRequest post = HttpUtil.createPost(url); |
| | | post.contentType(ContentType.JSON.toString()); |
| | | JSONObject body = new JSONObject(); |
| | | //商户编号 |
| | | body.put("userNo", merchantNo); |
| | |
| | | return MD5AndKL.MD5(sb.toString()); |
| | | } |
| | | |
| | | |
| | | public static void main(String[] args) { |
| | | TransferUtil.accountBalanceQuery(); |
| | | } |
| | | |
| | | } |
| | |
| | | <artifactId>sdk</artifactId> |
| | | <version>1.0.11</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>com.github.wechatpay-apiv3</groupId> |
| | | <artifactId>wechatpay-java</artifactId> |
| | | <version>0.2.15</version> |
| | | </dependency> |
| | | |
| | | </dependencies> |
| | | |
| | | <build> |
| | |
| | | sum = orderGoodList.stream().mapToInt(OrderGood::getNum).sum(); |
| | | } |
| | | vo.setPurchaseLimit((num + sum) > goods.getPurchaseLimit()); |
| | | vo.setPurchaseLimitNum(goods.getPurchaseLimit() - sum); |
| | | } |
| | | vo.setDistributionMode(goods.getDistributionMode()); |
| | | vo.setEarnSpendingPoints(price.getEarnSpendingPoints()); |
| | |
| | | package com.ruoyi.order.util.payment; |
| | | |
| | | import cn.hutool.http.HttpRequest; |
| | | import cn.hutool.http.HttpResponse; |
| | | import cn.hutool.http.HttpUtil; |
| | | import cn.hutool.http.*; |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.ruoyi.order.util.payment.model.*; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import java.util.*; |
| | | |
| | | /** |
| | |
| | | public static UniPayResult uniPay(String orderNo, Double amount, String productName, String productDesc, String mp, String notifyUrl, String openId, String tradeMerchantNo){ |
| | | String url = "https://trade.joinpay.com/tradeRt/uniPay"; |
| | | HttpRequest post = HttpUtil.createPost(url); |
| | | post.header(Header.CONTENT_TYPE, "application/x-www-form-urlencoded"); |
| | | JSONObject body = new JSONObject(); |
| | | //版本号 |
| | | body.put("p0_Version", "2.5"); |
| | |
| | | throw new RuntimeException(e); |
| | | } |
| | | body.put("hmac", sign); |
| | | post.body(body.toString()); |
| | | post.form(body); |
| | | log.info("支付接口请求参数:" + body); |
| | | HttpResponse execute = post.execute(); |
| | | log.info("支付接口请求响应:" + execute.body()); |
| | |
| | | public static QueryOrderResult queryOrder(String orderNo){ |
| | | String url = "https://trade.joinpay.com/tradeRt/queryOrder"; |
| | | HttpRequest post = HttpUtil.createPost(url); |
| | | post.header(Header.CONTENT_TYPE, "application/x-www-form-urlencoded"); |
| | | JSONObject body = new JSONObject(); |
| | | //版本号 |
| | | body.put("p0_Version", "2.5"); |
| | |
| | | throw new RuntimeException(e); |
| | | } |
| | | body.put("hmac", sign); |
| | | post.body(body.toString()); |
| | | post.form(body); |
| | | log.info("查询支付接口请求参数:" + body); |
| | | HttpResponse execute = post.execute(); |
| | | log.info("查询支付接口请求响应:" + execute.body()); |
| | |
| | | public static RefundResult refund(String orderNo, String refundOrderNo, Double refundAmount, String notifyUrl){ |
| | | String url = "https://trade.joinpay.com/tradeRt/refund"; |
| | | HttpRequest post = HttpUtil.createPost(url); |
| | | post.header(Header.CONTENT_TYPE, "application/x-www-form-urlencoded"); |
| | | JSONObject body = new JSONObject(); |
| | | //版本号 |
| | | body.put("p0_Version", "2.3"); |
| | |
| | | throw new RuntimeException(e); |
| | | } |
| | | body.put("hmac", sign); |
| | | post.body(body.toString()); |
| | | post.form(body); |
| | | log.info("退款接口请求参数:" + body); |
| | | HttpResponse execute = post.execute(); |
| | | log.info("退款接口请求响应:" + execute.body()); |
| | |
| | | public static QueryRefundResult queryRefund(String refundOrderNo){ |
| | | String url = "https://trade.joinpay.com/tradeRt/refund"; |
| | | HttpRequest post = HttpUtil.createPost(url); |
| | | post.header(Header.CONTENT_TYPE, "application/x-www-form-urlencoded"); |
| | | JSONObject body = new JSONObject(); |
| | | //版本号 |
| | | body.put("p0_Version", "2.3"); |
| | |
| | | throw new RuntimeException(e); |
| | | } |
| | | body.put("hmac", sign); |
| | | post.body(body.toString()); |
| | | post.form(body); |
| | | log.info("退款接口请求参数:" + body); |
| | | HttpResponse execute = post.execute(); |
| | | log.info("退款接口请求响应:" + execute.body()); |
| | |
| | | public static CloseOrderResult closeOrder(String orderNo){ |
| | | String url = "https://www.joinpay.com/trade/closeOrder.action"; |
| | | HttpRequest post = HttpUtil.createPost(url); |
| | | post.header(Header.CONTENT_TYPE, "application/x-www-form-urlencoded"); |
| | | JSONObject body = new JSONObject(); |
| | | //商户编号 |
| | | body.put("p1_MerchantNo", merchantNo); |
| | |
| | | throw new RuntimeException(e); |
| | | } |
| | | body.put("hmac", sign); |
| | | post.body(body.toString()); |
| | | post.form(body); |
| | | log.info("关闭订单接口请求参数:" + body); |
| | | HttpResponse execute = post.execute(); |
| | | log.info("关闭订单接口请求响应:" + execute.body()); |
| | |
| | | } |
| | | } |
| | | sb.append(key); |
| | | log.info("待签名串:{}", sb.toString()); |
| | | return MD5AndKL.MD5(sb.toString()); |
| | | } |
| | | |
| | | |
| | | public static void main(String[] args) { |
| | | UniPayResult uniPayResult = PaymentUtil.uniPay("123456", 0.01D, "测试商品", "这是用于对接支付测试的商品描述", "", "", "", ""); |
| | | System.err.println(JSON.toJSONString(uniPayResult)); |
| | | // UniPayResult uniPayResult = PaymentUtil.uniPay("852963742", 0.01D, "测试商品", "这是用于对接支付测试的商品描述", |
| | | // "", "/order/shopping-cart/shoppingCartPaymentCallback", "ooOrs64zHLuInkZ_GF0LpIN9_Rxc", "777168500885852"); |
| | | // PaymentUtil.queryOrder("852963742"); |
| | | // PaymentUtil.closeOrder("852963742"); |
| | | |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.order.util.payment; |
| | | |
| | | import cn.hutool.http.ContentType; |
| | | import cn.hutool.http.HttpRequest; |
| | | import cn.hutool.http.HttpResponse; |
| | | import cn.hutool.http.HttpUtil; |
| | |
| | | public static SinglePayResult singlePay(SinglePay singlePay){ |
| | | String url = "https://www.joinpay.com/payment/pay/singlePay"; |
| | | HttpRequest post = HttpUtil.createPost(url); |
| | | post.contentType(ContentType.JSON.toString()); |
| | | JSONObject body = new JSONObject(); |
| | | //商户编号 |
| | | body.put("userNo", merchantNo); |
| | |
| | | public static SinglePayQueryResult singlePayQuery(String merchantOrderNo){ |
| | | String url = "https://www.joinpay.com/payment/pay/singlePayQuery"; |
| | | HttpRequest post = HttpUtil.createPost(url); |
| | | post.contentType(ContentType.JSON.toString()); |
| | | JSONObject body = new JSONObject(); |
| | | //商户编号 |
| | | body.put("userNo", merchantNo); |
| | |
| | | public static AccountBalanceQueryResult accountBalanceQuery(){ |
| | | String url = "https://www.joinpay.com/payment/pay/accountBalanceQuery"; |
| | | HttpRequest post = HttpUtil.createPost(url); |
| | | post.contentType(ContentType.JSON.toString()); |
| | | JSONObject body = new JSONObject(); |
| | | //商户编号 |
| | | body.put("userNo", merchantNo); |
| | |
| | | return MD5AndKL.MD5(sb.toString()); |
| | | } |
| | | |
| | | |
| | | public static void main(String[] args) { |
| | | com.ruoyi.order.util.payment.wechat.TransferUtil.accountBalanceQuery(); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.order.util.payment.wechat; |
| | | |
| | | import com.wechat.pay.java.core.Config; |
| | | import com.wechat.pay.java.core.RSAAutoCertificateConfig; |
| | | import com.wechat.pay.java.service.transferbatch.TransferBatchService; |
| | | import com.wechat.pay.java.service.transferbatch.model.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 微信支付工具类 |
| | | * @author zhibing.pu |
| | | * @Date 2025/1/3 11:25 |
| | | */ |
| | | public class TransferUtil { |
| | | |
| | | |
| | | |
| | | public static TransferBatchService service; |
| | | |
| | | |
| | | /** |
| | | * 初始化转账服务 |
| | | */ |
| | | public static void init(){ |
| | | // 初始化商户配置 |
| | | Config config = new RSAAutoCertificateConfig.Builder() |
| | | .merchantId(WechatProperty.merchantId) |
| | | // 使用 com.wechat.pay.java.core.util |
| | | // 中的函数从本地文件中加载商户私钥,商户私钥会用来生成请求的签名 |
| | | .privateKeyFromPath(WechatProperty.privateKeyPath) |
| | | .merchantSerialNumber(WechatProperty.merchantSerialNumber) |
| | | .apiV3Key(WechatProperty.apiV3Key) |
| | | .build(); |
| | | |
| | | // 初始化服务 |
| | | service = new TransferBatchService.Builder().config(config).build(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 通过微信批次单号查询批次单 |
| | | * @return |
| | | */ |
| | | public static TransferBatchEntity getTransferBatchByNo() { |
| | | if(null == service){ |
| | | init(); |
| | | } |
| | | GetTransferBatchByNoRequest request = new GetTransferBatchByNoRequest(); |
| | | |
| | | return service.getTransferBatchByNo(request); |
| | | } |
| | | |
| | | /** 通过商家批次单号查询批次单 */ |
| | | public static TransferBatchEntity getTransferBatchByOutNo() { |
| | | GetTransferBatchByOutNoRequest request = new GetTransferBatchByOutNoRequest(); |
| | | return service.getTransferBatchByOutNo(request); |
| | | } |
| | | |
| | | /** |
| | | * 发起商家转账 |
| | | * @param outBatchNo |
| | | * @param batchName |
| | | * @param batchRemark |
| | | * @param totalAmount |
| | | * @param totalNum |
| | | * @param notifyUrl |
| | | * @param out_detail_no |
| | | * @param transfer_amount |
| | | * @param transferRemark |
| | | * @param openid |
| | | * @return |
| | | */ |
| | | public static InitiateBatchTransferResponse initiateBatchTransfer(String outBatchNo, String batchName, String batchRemark, Long totalAmount, |
| | | Integer totalNum, String notifyUrl, String out_detail_no, Long transfer_amount, |
| | | String transferRemark, String openid) { |
| | | InitiateBatchTransferRequest request = new InitiateBatchTransferRequest(); |
| | | request.setAppid(WechatProperty.appid); |
| | | request.setOutBatchNo(outBatchNo); |
| | | request.setBatchName(batchName); |
| | | request.setBatchRemark(batchRemark); |
| | | request.setTotalAmount(totalAmount); |
| | | request.setTotalNum(totalNum); |
| | | |
| | | List<TransferDetailInput> transferDetailList = new ArrayList<>(); |
| | | TransferDetailInput transferDetailInput = new TransferDetailInput(); |
| | | transferDetailInput.setOutDetailNo(out_detail_no); |
| | | transferDetailInput.setTransferAmount(transfer_amount); |
| | | transferDetailInput.setTransferRemark(transferRemark); |
| | | transferDetailInput.setOpenid(openid); |
| | | transferDetailList.add(transferDetailInput); |
| | | request.setTransferDetailList(transferDetailList); |
| | | request.setNotifyUrl(notifyUrl); |
| | | return service.initiateBatchTransfer(request); |
| | | } |
| | | |
| | | /** |
| | | * 通过微信明细单号查询明细单 |
| | | * @return |
| | | */ |
| | | public static TransferDetailEntity getTransferDetailByNo() { |
| | | GetTransferDetailByNoRequest request = new GetTransferDetailByNoRequest(); |
| | | return service.getTransferDetailByNo(request); |
| | | } |
| | | |
| | | /** |
| | | * 通过商家明细单号查询明细单 |
| | | * @return |
| | | */ |
| | | public static TransferDetailEntity getTransferDetailByOutNo() { |
| | | GetTransferDetailByOutNoRequest request = new GetTransferDetailByOutNoRequest(); |
| | | return service.getTransferDetailByOutNo(request); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.order.util.payment.wechat; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @Date 2025/1/3 14:26 |
| | | */ |
| | | public interface WechatProperty { |
| | | |
| | | /** 商户号 */ |
| | | String merchantId = "1703304170"; |
| | | |
| | | /** 商户API私钥路径 */ |
| | | String privateKeyPath = "/Users/yourname/your/path/apiclient_key.pem"; |
| | | |
| | | /** 商户证书序列号 */ |
| | | String merchantSerialNumber = "42779097B2477E9996D3B2A4F237F663FD33B9DB"; |
| | | |
| | | /** 商户APIV2密钥 */ |
| | | String apiV2Key = "YGdzX23JseBf45JPfQtXNQSBHjSaJwrc"; |
| | | |
| | | /** 商户APIV3密钥 */ |
| | | String apiV3Key = "yaNFEA3mA5FPGr9DDWM4dP3F0RpkF0yt"; |
| | | /** |
| | | * appid |
| | | */ |
| | | String appid = ""; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.order.util.payment.wechat.model; |
| | | |
| | | import com.google.gson.annotations.SerializedName; |
| | | import com.wechat.pay.java.core.cipher.Encryption; |
| | | import com.wechat.pay.java.service.transferbatch.model.TransferDetailInput; |
| | | import lombok.Data; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @Date 2025/1/3 16:27 |
| | | */ |
| | | @Data |
| | | public class InitiateBatchTransfer { |
| | | /** |
| | | * 申请商户号的appid或商户号绑定的appid |
| | | */ |
| | | private String appid; |
| | | /** |
| | | * 商户系统内部的商家批次单号 |
| | | */ |
| | | private String outBatchNo; |
| | | @SerializedName("batch_name") |
| | | private String batchName; |
| | | @SerializedName("batch_remark") |
| | | private String batchRemark; |
| | | @SerializedName("total_amount") |
| | | private Long totalAmount; |
| | | @SerializedName("total_num") |
| | | private Integer totalNum; |
| | | @Encryption |
| | | @SerializedName("transfer_detail_list") |
| | | private List<TransferDetailInput> transferDetailList = new ArrayList(); |
| | | @SerializedName("transfer_scene_id") |
| | | private String transferSceneId; |
| | | @SerializedName("notify_url") |
| | | private String notifyUrl; |
| | | } |
| | |
| | | package com.ruoyi.other.util.payment; |
| | | |
| | | import cn.hutool.http.Header; |
| | | import cn.hutool.http.HttpRequest; |
| | | import cn.hutool.http.HttpResponse; |
| | | import cn.hutool.http.HttpUtil; |
| | |
| | | public static UniPayResult uniPay(String orderNo, Double amount, String productName, String productDesc, String mp, String notifyUrl, String openId, String tradeMerchantNo){ |
| | | String url = "https://trade.joinpay.com/tradeRt/uniPay"; |
| | | HttpRequest post = HttpUtil.createPost(url); |
| | | post.header(Header.CONTENT_TYPE, "application/x-www-form-urlencoded"); |
| | | JSONObject body = new JSONObject(); |
| | | //版本号 |
| | | body.put("p0_Version", "2.5"); |
| | |
| | | throw new RuntimeException(e); |
| | | } |
| | | body.put("hmac", sign); |
| | | post.body(body.toString()); |
| | | post.form(body); |
| | | log.info("支付接口请求参数:" + body); |
| | | HttpResponse execute = post.execute(); |
| | | log.info("支付接口请求响应:" + execute.body()); |
| | |
| | | public static QueryOrderResult queryOrder(String orderNo){ |
| | | String url = "https://trade.joinpay.com/tradeRt/queryOrder"; |
| | | HttpRequest post = HttpUtil.createPost(url); |
| | | post.header(Header.CONTENT_TYPE, "application/x-www-form-urlencoded"); |
| | | JSONObject body = new JSONObject(); |
| | | //版本号 |
| | | body.put("p0_Version", "2.5"); |
| | |
| | | throw new RuntimeException(e); |
| | | } |
| | | body.put("hmac", sign); |
| | | post.body(body.toString()); |
| | | post.form(body); |
| | | log.info("查询支付接口请求参数:" + body); |
| | | HttpResponse execute = post.execute(); |
| | | log.info("查询支付接口请求响应:" + execute.body()); |
| | |
| | | public static RefundResult refund(String orderNo, String refundOrderNo, Double refundAmount, String notifyUrl){ |
| | | String url = "https://trade.joinpay.com/tradeRt/refund"; |
| | | HttpRequest post = HttpUtil.createPost(url); |
| | | post.header(Header.CONTENT_TYPE, "application/x-www-form-urlencoded"); |
| | | JSONObject body = new JSONObject(); |
| | | //版本号 |
| | | body.put("p0_Version", "2.3"); |
| | |
| | | throw new RuntimeException(e); |
| | | } |
| | | body.put("hmac", sign); |
| | | post.body(body.toString()); |
| | | post.form(body); |
| | | log.info("退款接口请求参数:" + body); |
| | | HttpResponse execute = post.execute(); |
| | | log.info("退款接口请求响应:" + execute.body()); |
| | |
| | | public static QueryRefundResult queryRefund(String refundOrderNo){ |
| | | String url = "https://trade.joinpay.com/tradeRt/refund"; |
| | | HttpRequest post = HttpUtil.createPost(url); |
| | | post.header(Header.CONTENT_TYPE, "application/x-www-form-urlencoded"); |
| | | JSONObject body = new JSONObject(); |
| | | //版本号 |
| | | body.put("p0_Version", "2.3"); |
| | |
| | | throw new RuntimeException(e); |
| | | } |
| | | body.put("hmac", sign); |
| | | post.body(body.toString()); |
| | | post.form(body); |
| | | log.info("退款接口请求参数:" + body); |
| | | HttpResponse execute = post.execute(); |
| | | log.info("退款接口请求响应:" + execute.body()); |
| | |
| | | public static CloseOrderResult closeOrder(String orderNo){ |
| | | String url = "https://www.joinpay.com/trade/closeOrder.action"; |
| | | HttpRequest post = HttpUtil.createPost(url); |
| | | post.header(Header.CONTENT_TYPE, "application/x-www-form-urlencoded"); |
| | | JSONObject body = new JSONObject(); |
| | | //商户编号 |
| | | body.put("p1_MerchantNo", merchantNo); |
| | |
| | | throw new RuntimeException(e); |
| | | } |
| | | body.put("hmac", sign); |
| | | post.body(body.toString()); |
| | | post.form(body); |
| | | log.info("关闭订单接口请求参数:" + body); |
| | | HttpResponse execute = post.execute(); |
| | | log.info("关闭订单接口请求响应:" + execute.body()); |
| | |
| | | } |
| | | } |
| | | sb.append(key); |
| | | log.info("待签名串:{}", sb.toString()); |
| | | return MD5AndKL.MD5(sb.toString()); |
| | | } |
| | | |
| | | |
| | | public static void main(String[] args) { |
| | | UniPayResult uniPayResult = PaymentUtil.uniPay("123456", 0.01D, "测试商品", "这是用于对接支付测试的商品描述", "", "", "", ""); |
| | | System.err.println(JSON.toJSONString(uniPayResult)); |
| | | // UniPayResult uniPayResult = PaymentUtil.uniPay("852963742", 0.01D, "测试商品", "这是用于对接支付测试的商品描述", |
| | | // "", "/order/shopping-cart/shoppingCartPaymentCallback", "ooOrs64zHLuInkZ_GF0LpIN9_Rxc", "777168500885852"); |
| | | // PaymentUtil.queryOrder("852963742"); |
| | | // PaymentUtil.closeOrder("852963742"); |
| | | |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.other.util.payment; |
| | | |
| | | import cn.hutool.http.ContentType; |
| | | import cn.hutool.http.HttpRequest; |
| | | import cn.hutool.http.HttpResponse; |
| | | import cn.hutool.http.HttpUtil; |
| | |
| | | public static SinglePayResult singlePay(SinglePay singlePay){ |
| | | String url = "https://www.joinpay.com/payment/pay/singlePay"; |
| | | HttpRequest post = HttpUtil.createPost(url); |
| | | post.contentType(ContentType.JSON.toString()); |
| | | JSONObject body = new JSONObject(); |
| | | //商户编号 |
| | | body.put("userNo", merchantNo); |
| | |
| | | public static SinglePayQueryResult singlePayQuery(String merchantOrderNo){ |
| | | String url = "https://www.joinpay.com/payment/pay/singlePayQuery"; |
| | | HttpRequest post = HttpUtil.createPost(url); |
| | | post.contentType(ContentType.JSON.toString()); |
| | | JSONObject body = new JSONObject(); |
| | | //商户编号 |
| | | body.put("userNo", merchantNo); |
| | |
| | | public static AccountBalanceQueryResult accountBalanceQuery(){ |
| | | String url = "https://www.joinpay.com/payment/pay/accountBalanceQuery"; |
| | | HttpRequest post = HttpUtil.createPost(url); |
| | | post.contentType(ContentType.JSON.toString()); |
| | | JSONObject body = new JSONObject(); |
| | | //商户编号 |
| | | body.put("userNo", merchantNo); |
| | |
| | | return MD5AndKL.MD5(sb.toString()); |
| | | } |
| | | |
| | | |
| | | public static void main(String[] args) { |
| | | TransferUtil.accountBalanceQuery(); |
| | | } |
| | | |
| | | } |