Checkout
NestJS
Mint checkout URLs on the server with OleqPayCheckoutModule.
Install peers
pnpm add @oleq-ai/pay @nestjs/commonRegister the module
import { Module } from '@nestjs/common';
import { OleqPayCheckoutModule } from '@oleq-ai/pay/nest';
@Module({
imports: [
OleqPayCheckoutModule.forRoot({
checkoutBaseUrl: 'https://my.olefi.co',
}),
],
})
export class AppModule {}Async config:
OleqPayCheckoutModule.forRootAsync({
inject: [ConfigService],
useFactory: (config: ConfigService) => ({
checkoutBaseUrl: config.get('CHECKOUT_BASE_URL'),
locale: 'en',
}),
});Mint a session URL
import { Injectable } from '@nestjs/common';
import { OleqPayCheckout } from '@oleq-ai/pay';
@Injectable()
export class CheckoutService {
constructor(private readonly oleqpay: OleqPayCheckout) {}
createSessionUrl(order: Order) {
return this.oleqpay.buildUrl({
apikey: process.env.OLEQPAY_PUBLIC_KEY!,
amount: order.total,
orderid: order.id,
reference: order.reference,
returnurl: order.returnUrl,
});
}
}Return that URL from your API. In the browser, call openIframe(url) or redirect(url) — do not rebuild the payload client-side if amount/orderid must stay trusted.