nest-ali-pay
v1.0.5
Published
@nestjs/alipay扩展模块
Downloads
10
Readme
Description
Alipay utilities module for Nest.
Installation
$ npm i --save nest-ali-pay alipay-sdk
模块注册
import { Module } from '@nestjs/common';
import { AliPayModule } from 'nest-ali-pay';
@Module({
imports: [
AliPayModule.registerAsync({
useFactory: () => ({
// 参考下方 SDK 配置
appId: '2016123456789012',
// 私钥
privateKey: fs.readFileSync('./private-key.pem', 'ascii'),
//可设置AES密钥,调用AES加解密相关接口时需要(可选)
encryptKey: '请填写您的AES密钥,例如:aa4BtZ4tspm2wnXLb1ThQA',
}),
}),
],
})
export class AlipayPaymentModule {}
注入服务
import { Inject, Injectable } from '@nestjs/common';
import AlipaySdk from 'alipay-sdk';
import { ALI_PAY_MANAGER } from 'nest-ali-pay';
@Injectable()
export class AlipayPaymentService {
constructor(@Inject(ALI_PAY_MANAGER) private readonly aliPay: AlipaySdk) {}
public payment() {
this.aliPay.exec("")
}
}
License
Nest is MIT licensed.