项目简介
本项目是基于NestJS框架的Galaxy支付配置系统,可作为通用支付配置方案。它不仅适用于galaxy - pay,也能用于任意NestJS项目,提供了丰富的支付宝和微信支付相关接口,能助力开发者快速集成支付功能。
项目的主要特性和功能
- 多支付平台支持:支持支付宝和微信两大主流支付平台。
- 多支付模式支持:支付宝有根证书模式和公钥模式;微信支付涵盖App、小程序、JSAPI、扫码、Native、H5等多种支付模式。
- 丰富接口功能:提供支付、退款、查询、转账、对账单下载等一系列支付相关操作接口。
- 易于集成:通过简单的安装和配置,即可在NestJS项目中使用。
安装使用步骤
安装依赖
在项目根目录下,运行以下命令安装galaxy - pay - config
:
bash
npm i galaxy - pay - config
配置支付参数
根据不同支付方式的要求,配置相应的参数,如支付宝的appid
、private_key
、public_key
;微信的appid
、mch_id
、mch_key
、app_secret
等。
调用支付接口
在代码中引入所需的支付服务,调用相应的支付接口进行支付操作。示例如下: ```typescript constructor( private readonly wechatAppPayService: WeChatAppPayService, private aliPagePayService: AliPagePayService, private antcertUtil: AntcertUtil, ) {}
// 支付宝支付 根证书模式 @Post("aliPagePay") aliPagePay() { const { app_cert_sn, alipay_root_cert_sn, public_key, } = this.antcertUtil.getCertPattern( app_cert_sn_path, alipay_root_cert_sn_path, alipay_public_cert_path );
return this.aliPagePayService.pay({
out_trade_no: '订单编号',
total_amount: "0.01",
body: '不知道',
product_code: 'FAST_INSTANT_TRADE_PAY',
subject: '你猜~~',
}, {
appid: 'appid',
private_key: 'private_key',
return_url: '支付完成时跳转页面',
notify_url: '异步通知地址',
app_cert_sn: app_cert_sn,
alipay_root_cert_sn: alipay_root_cert_sn,
public_key: public_key,
});
}
// 微信支付 @Post("wxAppPay") wxAppPay() { return this.wechatAppPayService.pay({ trade_type: WeChatTradeType.APP, total_fee: '金额', out_trade_no: '订单编号', body: '订单描述', spbill_create_ip: '终端IP' }, { appid: 'appid', mch_id: 'mch_id', mch_key: 'mch_key', app_secret: 'app_secret', return_url: '你的return_url', notify_url: '异步通知地址', apiclient_cert: fs.readFileSync('path') }); } ```
下载地址
点击下载 【提取码: 4003】【解压密码: www.makuang.net】