修改微信封装
This commit is contained in:
@@ -15,7 +15,6 @@ import org.jiayunet.tool.UserSecurityTool;
|
||||
import org.jiayunet.wxPay.WxNativePayAbility;
|
||||
import org.jiayunet.alipay.AlipayPagePayAbility;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -58,12 +57,6 @@ public class MemberProductService {
|
||||
@Autowired
|
||||
private PayAlipayFlowMapper payAlipayFlowMapper;
|
||||
|
||||
@Value("${wx_pay.merchant_id:}")
|
||||
private String merchantId;
|
||||
|
||||
@Value("${app.wx.app_id:}")
|
||||
private String appId;
|
||||
|
||||
/**
|
||||
* 商品列表
|
||||
* <p>查询上架商品,按sort_order排序</p>
|
||||
@@ -169,8 +162,6 @@ public class MemberProductService {
|
||||
payWechatFlowMapper.insert(flow);
|
||||
|
||||
PrepayRequest request = new PrepayRequest();
|
||||
request.setAppid(appId);
|
||||
request.setMchid(merchantId);
|
||||
request.setDescription(product.getProductName());
|
||||
request.setOutTradeNo(orderNo);
|
||||
Amount amount = new Amount();
|
||||
|
||||
@@ -24,6 +24,7 @@ email:
|
||||
wx_pay:
|
||||
# status close:关闭 open:打开
|
||||
status: close
|
||||
app_id: your_app_id
|
||||
merchant_id: ${MERCHANT_ID:your_merchant_id}
|
||||
private_key: ${WX_PRIVATE_KEY:your_private_key}
|
||||
merchant_serial_number: ${MERCHANT_SERIAL_NUMBER:your_merchant_serial_number}
|
||||
@@ -74,10 +75,7 @@ app:
|
||||
interval_time: 20
|
||||
limit_number: 20
|
||||
|
||||
# 微信小程序
|
||||
wx:
|
||||
app_id: wx7d75957cbd35e36b
|
||||
app_secret: d70ef5baa4b9c046f396736d9a42cdc3
|
||||
|
||||
|
||||
#开放接口
|
||||
ignore:
|
||||
|
||||
@@ -55,7 +55,7 @@ public class WxJsPayAbility {
|
||||
/**
|
||||
* 小程序id
|
||||
*/
|
||||
@Value("${app.wx.app_id}")
|
||||
@Value("${wx_pay.app_id}")
|
||||
private String appId;
|
||||
|
||||
|
||||
|
||||
@@ -26,18 +26,31 @@ public class WxNativePayAbility {
|
||||
*/
|
||||
@Value("${wx_pay.notify_domain}")
|
||||
private String notifyDomain;
|
||||
/**
|
||||
* 商户号
|
||||
*/
|
||||
@Value("${wx_pay.merchant_id}")
|
||||
private String merchantId;
|
||||
/**
|
||||
* 应用id(与商户号绑定的appId,用于微信支付)
|
||||
*/
|
||||
@Value("${wx_pay.app_id}")
|
||||
private String appId;
|
||||
|
||||
|
||||
/**
|
||||
* 预支付
|
||||
* @param request 请求头
|
||||
* @return
|
||||
* 预支付(自动填充appId、merchantId、notifyUrl)
|
||||
*
|
||||
* @param paramRequest 请求参数(调用方只需设置业务字段:description、outTradeNo、amount等)
|
||||
* @return codeUrl 二维码链接
|
||||
*/
|
||||
public String prepay(PrepayRequest request) {
|
||||
public String prepay(PrepayRequest paramRequest) {
|
||||
try {
|
||||
request.setNotifyUrl(notifyDomain+"/public/wxNotify/pay");
|
||||
log.info("以默认设置支付回调地址为:{}",request.getNotifyUrl());
|
||||
PrepayResponse prepay = nativePayService.prepay(request);
|
||||
paramRequest.setNotifyUrl(notifyDomain + "/public/wxNotify/pay");
|
||||
log.info("以默认设置支付回调地址为:{}", paramRequest.getNotifyUrl());
|
||||
paramRequest.setAppid(appId);
|
||||
paramRequest.setMchid(merchantId);
|
||||
PrepayResponse prepay = nativePayService.prepay(paramRequest);
|
||||
return prepay.getCodeUrl();
|
||||
} catch (Exception e) {
|
||||
log.error("nativePay支付下单出现异常,错误信息:{}", e.getMessage());
|
||||
|
||||
Reference in New Issue
Block a user