Skip to content

Installation ​

Install the Package ​

Requires Node.js 20+ and NestJS 10 to 12, on the Express (@nestjs/platform-express) or Fastify (@nestjs/platform-fastify) adapter.

bash
npm install @laranex/nestjs-myanmar-payments@next

Until v4.0.0 is released the package ships 4.0.0-dev.* pre-releases, so install the next tag.

The package is a thin NestJS layer over @laranex/myanmar-payments, which npm installs alongside it.

Register the Module ​

ts
import { MyanmarPaymentsModule } from '@laranex/nestjs-myanmar-payments';
import { Module } from '@nestjs/common';

@Module({
  imports: [MyanmarPaymentsModule.forRoot({ isGlobal: true })],
})
export class AppModule {}

Registering the module provides MyanmarPaymentsService, which you inject into your own controllers and services. Options are optional: every setting you leave out is read from its environment variable. See Configuration for forRootAsync() with @nestjs/config.

Keep the Raw Body ​

Gateway signatures are computed over the exact bytes they send. Create the app with rawBody: true so the package can verify against them:

ts
import { NestFactory } from '@nestjs/core';

import { AppModule } from './app.module';

const app = await NestFactory.create(AppModule, { rawBody: true });
ts
import { NestFactory } from '@nestjs/core';
import {
  FastifyAdapter,
  type NestFastifyApplication,
} from '@nestjs/platform-fastify';

import { AppModule } from './app.module';

const app = await NestFactory.create<NestFastifyApplication>(
  AppModule,
  new FastifyAdapter(),
  { rawBody: true },
);

Without it the package reads the unread request stream when no body parser consumed it (Express). A JSON body that was already parsed is never encoded again, since that can change how numbers are written and break the signature: the callback answers 400 with Enable rawBody: true in NestFactory.create() to verify JSON callbacks. Only CyberSource's form callbacks verify without it.

What It Provides ​

ExportWhat it is
MyanmarPaymentsModuleforRoot(), forRootAsync()
MyanmarPaymentsServicekbzPay(), wavePay(), wavePayMiniApp(), ayaPay(), yomaMmqr(), cyberSource(), gateway(name), handleCallback(), autoSubmitUrl(), resolveFormPayment(), tokenCache
@InjectKbzPay(), @InjectWavePay(), @InjectWavePayMiniApp(), @InjectAyaPay(), @InjectYomaMmqr(), @InjectCyberSource()Inject one SDK gateway
@VerifiedCallback(), @AcknowledgeCallback(), @RawCallback()Callback decorators; see Callbacks & Status
VerifiedCallbackPipe, CallbackRequestPipe, AcknowledgementInterceptorThe pipes and the interceptor behind those decorators; AcknowledgementInterceptor also works with @UseInterceptors()
callbackRequestFrom(), acknowledge()Callback helpers for handlers that use @Req() and @Res()
NestRequestLike, FastifyReplyLikeThe request and reply shapes those helpers accept (types)
FormPaymentControllerThe auto-submit form route's controller; the module mounts it at formRoute.path
CacheManagerTokenCache, CacheManagerLikeThe Yoma MMQR and Wave Pay Mini App token cache over @nestjs/cache-manager, and the cache shape it needs
GATEWAY_NAMES, GatewayName'kbz-pay', 'wave-pay', 'wave-pay-mini-app', 'aya-pay', 'yoma-mmqr', 'cyber-source'
MyanmarPaymentsGatewayKbzPay | WavePay | WavePayMiniApp | AyaPay | YomaMmqr | CyberSource, what gateway(name) returns (type)
MYANMAR_PAYMENTS_OPTIONS, KBZ_PAY, WAVE_PAY, WAVE_PAY_MINI_APP, AYA_PAY, YOMA_MMQR, CYBER_SOURCEInjection tokens of the options and of each gateway
DEFAULT_FORM_PATH'myanmar-payments/form'
MyanmarPaymentsModuleOptions, MyanmarPaymentsModuleExtras, MyanmarPaymentsModuleRootOptions, MyanmarPaymentsModuleAsyncOptions, MyanmarPaymentsOptionsFactory, FormLinkOptions, FormRouteOptions, FormNonceResolver, GatewaySettings, ConfigReaderOption types; see Configuration

Everything about payments themselves (Amount, payment data, results, PaymentCallback, PaymentStatus, errors) is imported from @laranex/myanmar-payments.

Module Formats ​

The package ships ES modules and CommonJS with type declarations, like the SDK. NestJS 10 and 11 apps are usually CommonJS and load the require build; NestJS 12 is ESM-only and loads the import build. Both builds use the SDK build of the same format, so classes such as PaymentCallback are the ones your code imports.

Without NestJS ​

Use the SDK directly: see Node Myanmar Payments.