Skip to content

Lastly1999/nest-ali-pay

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nest Logo X


A progressive Node.js framework for building efficient and scalable server-side applications.

NPM Version Package License NPM Downloads Travis Linux Coverage Discord Backers on Open Collective Sponsors on Open Collective

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.

About

@nestjs/alipay sdk module lib

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published