monopay-nest
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

NestJS Monopay wrapper

A monopay wrapper for NestJS.

Installation

npm install monopay-nest monopay
yarn add monopay-nest monopay

Usage

Register the module:

import { Zarinpal } from 'monopay';
import { MonopayModule } from 'monopay-nest';

@Module({
  imports: [
    MonopayModule.forRoot<Zarinpal>({
      isGlobal: true,
      config: { merchantId: 'zarinpal-merchant' },
      driver: 'zarinpal',
    }),
    // ...
  ],
})
export class AppModule {}

If you're using Javascript, omit the typing after forRoot

Now inject the service:

import { Zarinpal } from 'monopay';
import { MonopayService } from 'monopay-nest';

@Controller()
export class SomeController {
  constructor(private readonly monopayService: MonopayService<Zarinpal>) {}

  @Get('/')
  someEndpoint() {
    this.monopayService.requestPayment({
      amount: 50000,
      callbackUrl: 'https://my-site.com/callback',
      description: 'Description about the transaction',
    });
  }
}

Package Sidebar

Install

npm i monopay-nest

Weekly Downloads

1

Version

0.0.2

License

MIT

Unpacked Size

73.7 kB

Total Files

19

Last publish

Collaborators

  • kasraghoreyshi