new:jsapi合单支付

This commit is contained in:
曾浩
2020-08-24 20:21:07 +08:00
parent 10e0ca568e
commit 5db9706ba0
4 changed files with 38 additions and 6 deletions

View File

@@ -7,6 +7,10 @@ import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.List;
/**
* 二级商户进件 查询申请状态结果响应
*
*/
@Data
@NoArgsConstructor
public class ApplymentsStatusResult implements Serializable {

View File

@@ -6,10 +6,24 @@ import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* 合单支付 JSAPI支付结果响应
*/
@Data
@NoArgsConstructor
public class CombineTransactionsJsResult implements Serializable {
/**
* <pre>
* 字段名:预支付交易会话标识
* 变量名prepay_id
* 是否必填:是
* 类型string(64)
* 描述:
* 数字和字母。微信生成的预支付会话标识,用于后续接口调用使用。
* 示例值wx201410272009395522657a690389285100
* </pre>
*/
@SerializedName("prepay_id")
private String prepayId;

View File

@@ -1,8 +1,6 @@
package com.github.binarywang.wxpay.service;
import com.github.binarywang.wxpay.bean.ecommerce.ApplymentsRequest;
import com.github.binarywang.wxpay.bean.ecommerce.ApplymentsResult;
import com.github.binarywang.wxpay.bean.ecommerce.ApplymentsStatusResult;
import com.github.binarywang.wxpay.bean.ecommerce.*;
import com.github.binarywang.wxpay.exception.WxPayException;
/**
@@ -55,4 +53,15 @@ public interface EcommerceService {
*/
ApplymentsStatusResult queryApplyStatusByOutRequestNo(String outRequestNo) throws WxPayException;
/**
* <pre>
* 合单下单-JS支付API.
* 请求URLhttps://api.mch.weixin.qq.com/v3/combine-transactions/jsapi
* 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/pay/combine/chapter3_2.shtml
* </pre>
*
* @param request 请求对象
* @return 预支付交易会话标识, 数字和字母。微信生成的预支付会话标识,用于后续接口调用使用。
*/
CombineTransactionsJsResult combineTransactions(CombineTransactionsJsRequest request) throws WxPayException;
}

View File

@@ -1,8 +1,6 @@
package com.github.binarywang.wxpay.service.impl;
import com.github.binarywang.wxpay.bean.ecommerce.ApplymentsRequest;
import com.github.binarywang.wxpay.bean.ecommerce.ApplymentsResult;
import com.github.binarywang.wxpay.bean.ecommerce.ApplymentsStatusResult;
import com.github.binarywang.wxpay.bean.ecommerce.*;
import com.github.binarywang.wxpay.exception.WxPayException;
import com.github.binarywang.wxpay.service.EcommerceService;
import com.github.binarywang.wxpay.service.WxPayService;
@@ -41,5 +39,12 @@ public class EcommerceServiceImpl implements EcommerceService {
return GSON.fromJson(result, ApplymentsStatusResult.class);
}
@Override
public CombineTransactionsJsResult combineTransactions(CombineTransactionsJsRequest request) throws WxPayException {
String url = String.format("%s/v3/combine-transactions/jsapi", this.payService.getPayBaseUrl());
String response = this.payService.postV3(url, GSON.toJson(request));
return GSON.fromJson(response, CombineTransactionsJsResult.class);
}
}