Skip to content

qpay-sdk/qpay-nestjs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@qpay-sdk/nestjs

npm CI License: MIT

QPay V2 payment module for NestJS.

Install

npm install @qpay-sdk/nestjs qpay-js

Usage

import { QPayModule } from '@qpay-sdk/nestjs';

@Module({
  imports: [
    QPayModule.forRoot({
      baseUrl: 'https://merchant.qpay.mn',
      username: 'your_username',
      password: 'your_password',
      invoiceCode: 'YOUR_CODE',
      callbackUrl: 'https://yoursite.com/qpay/webhook',
    }),
  ],
})
export class AppModule {}

Async Configuration

QPayModule.forRootAsync({
  imports: [ConfigModule],
  useFactory: (config: ConfigService) => ({
    baseUrl: config.get('QPAY_BASE_URL'),
    username: config.get('QPAY_USERNAME'),
    password: config.get('QPAY_PASSWORD'),
    invoiceCode: config.get('QPAY_INVOICE_CODE'),
    callbackUrl: config.get('QPAY_CALLBACK_URL'),
  }),
  inject: [ConfigService],
})

Inject Service

import { QPayService } from '@qpay-sdk/nestjs';

@Injectable()
export class PaymentService {
  constructor(private readonly qpay: QPayService) {}

  async createPayment() {
    return this.qpay.createSimpleInvoice({
      invoiceCode: 'YOUR_CODE',
      senderInvoiceNo: 'ORDER-001',
      amount: 10000,
      callbackUrl: 'https://yoursite.com/qpay/webhook',
    });
  }
}

License

MIT

About

No description, website, or topics provided.

Resources

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors