| 1 | /* |
| 2 | * @Author: nevin |
| 3 | * @Date: 2024-06-17 16:12:27 |
| 4 | * @LastEditTime: 2025-02-25 09:47:37 |
| 5 | * @LastEditors: nevin |
| 6 | * @Description: |
| 7 | */ |
| 8 | import { Module } from '@nestjs/common'; |
| 9 | import { ConfigModule, ConfigService } from '@nestjs/config'; |
| 10 | import { WxService } from './wx.service'; |
| 11 | import wxConfig from '../../../config/wx.config'; |
| 12 | import { WxPayService } from './wxPay.service'; |
| 13 | import { WeChatPayModule } from 'nest-wechatpay-node-v3'; |
| 14 | import { WxGzhService } from './wxGzh.service'; |
| 15 | |
| 16 | @Module({ |
| 17 | imports: [ |
| 18 | ConfigModule.forRoot({ |
| 19 | load: [wxConfig], // 加载自定义配置项 |
| 20 | }), |
| 21 | WeChatPayModule.registerAsync({ |
| 22 | inject: [ConfigService], |
| 23 | useFactory: async (configService: ConfigService) => { |
| 24 | return { |
| 25 | appid: configService.get('WX_CONFIG.APP_ID'), |
| 26 | mchid: configService.get('WX_CONFIG.MCH_ID'), |
| 27 | publicKey: configService.get('WX_CONFIG.PUBLIC_KEY'), |
| 28 | privateKey: configService.get('WX_CONFIG.PRIVATE_KEY'), |
| 29 | }; |
| 30 | }, |
| 31 | }), |
| 32 | ], |
| 33 | providers: [WxService, WxPayService, WxGzhService], |
| 34 | exports: [WxService, WxPayService, WxGzhService], |
| 35 | }) |
| 36 | export class WxModule {} |
| 37 |