npm install monopay-nest monopay
yarn add monopay-nest monopay
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',
});
}
}