tj
2025-04-11 f71719bf3e2b433b790cfaa83265611faf1f1a1c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package com.mzl.flower.config.pay;
 
import com.github.binarywang.wxpay.config.WxPayConfig;
import com.github.binarywang.wxpay.service.WxPayService;
import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
 
/**
 * @author  Taojie
 *  微信APP支付
 */
@Configuration
public class WechatClientConfigurator {
 
    @Autowired
    private WechatAppProperties wechatProperties;
 
 
    @Bean
    public WxPayConfig wxPayConfig() {
        WxPayConfig payConfig = new WxPayConfig();
        payConfig.setAppId(wechatProperties.getAppid());
        payConfig.setMchId(wechatProperties.getMerchantId());             // 商户号
        payConfig.setMchKey(wechatProperties.getMerchantKey());
//        payConfig.setMchKey(wechatProperties.getSecret());
        payConfig.setTradeType(wechatProperties.getTradeType());
        payConfig.setNotifyUrl(wechatProperties.getNotifyUrl());                 // 关键!APP支付必须指定
        return payConfig;
    }
 
    @Bean
    public WxPayService wxPayService(WxPayConfig wxPayConfig) {
        WxPayService wxPayService = new WxPayServiceImpl();
        wxPayService.setConfig(wxPayConfig);
        return wxPayService;
    }
 
 
}