Skip to content

Angular — configuration

The Angular SDK has two configuration tiers, similar to the Flutter SDK but with framework-specific bindings:

  • App-wide via PdirectPayModule.forRoot(config) (or standalone providers + injection tokens).
  • Per-checkout via the PdirectPayConfig and PdirectPaymentBody inputs on <pdirect-pay-checkout>.
import { NgModule } from "@angular/core";
import { PdirectPayModule } from "@mms/pdirect-pay";
@NgModule({
imports: [
PdirectPayModule.forRoot({
env: {
baseUrl: "https://app.api.gtwy.pdirect.com",
appKey: "merchant-app-key",
},
defaultConfig: {
isProduction: false,
acceptLanguage: "en",
},
}),
],
})
export class AppModule {}

forRoot registers two injection tokens:

TokenTypePurpose
PDIRECT_ENV_CONFIGPdirectEnvConfigThe base URL + default app key.
PDIRECT_PAY_CONFIGPdirectPayConfigDefaults applied to every <pdirect-pay-checkout> unless overridden.

If you don’t have an AppModule, register the tokens manually in your bootstrap providers:

import { bootstrapApplication } from "@angular/platform-browser";
import { provideHttpClient } from "@angular/common/http";
import {
PDIRECT_ENV_CONFIG,
PDIRECT_PAY_CONFIG,
} from "@mms/pdirect-pay";
import { AppComponent } from "./app/app.component";
bootstrapApplication(AppComponent, {
providers: [
provideHttpClient(),
{ provide: PDIRECT_ENV_CONFIG, useValue: {
baseUrl: "https://app.api.gtwy.pdirect.com",
appKey: "merchant-app-key",
} },
{ provide: PDIRECT_PAY_CONFIG, useValue: {
isProduction: false,
acceptLanguage: "en",
} },
],
});

<pdirect-pay-checkout> reads two inputs:

<pdirect-pay-checkout
[configs]="configs"
[paymentBody]="paymentBody"
[themeConfig]="themeConfig"
[language]="'en'"
[enableHapticFeedback]="true"
(response)="onResponse($event)"
(error)="onError($event)"
(closed)="onClose()" />
interface PdirectPayConfig {
token: string; // Auth-v2 (legacy) — your merchant app key
isProduction?: boolean; // false → sandbox, true → production
customApiUrl?: string; // override the base URL (e.g. for staging)
timeout?: number; // request timeout in ms
acceptLanguage?: string; // ISO 639-1, defaults to 'fr'
}
interface PdirectPayThemeConfig {
primaryColor?: string;
secondaryColor?: string;
tertiaryColor?: string;
accentColor?: string; // @deprecated — use tertiaryColor
backgroundColor?: string;
surfaceColor?: string;
textColor?: string;
secondaryTextColor?: string;
borderColor?: string;
errorColor?: string;
successColor?: string;
warningColor?: string;
borderRadius?: string;
fontFamily?: string;
}

The component sets these as scoped CSS custom properties on its host element — overrides cannot leak into the host app.

Status colours (success / error / warning) render in semantic green / red / amber regardless of theming, the same way the Flutter SDK behaves.

The collect-payment request body. Same shape as the Flutter SDK’s PdirectPaymentBody. See Payment methods for the conditional field table.

Six languages: en, fr, es, ru, zh, ln. Pass to the language input or set PdirectPayConfig.acceptLanguage.

Direct service callers can configure the underlying PdirectHttpClientService:

import { Component, OnInit, inject } from "@angular/core";
import { PdirectHttpClientService } from "@mms/pdirect-pay";
@Component({ /* ... */ })
export class CustomFlowComponent implements OnInit {
private http = inject(PdirectHttpClientService);
ngOnInit() {
this.http.configure({
appKey: "merchant-app-key",
acceptLanguage: "en",
customHeaders: {
// Until v2 wires it automatically:
"Idempotency-Key": crypto.randomUUID(),
},
});
}
}

configure is callable as many times as you need — settings are merged.