Back to PGH Made by e45ra

PGH Documentation

Use PGH to configure multiple gateways, enable/disable them, and connect checkout with simple backend routes.

Express Setup

mountGatewayDashboard(app, {
  mountPath: "/gateway",
  configFilePath: ".payment-gateway.config.json",
  adminToken: process.env.GATEWAY_ADMIN_TOKEN!
});

Vanilla Node Setup

const dashboard = createNodeGatewayDashboard({
  mountPath: "/gateway",
  configFilePath: ".payment-gateway.config.json",
  adminToken: process.env.GATEWAY_ADMIN_TOKEN!
});

Checkout Gateways

const payment = createClientFromSavedConfig();
const gateways = payment.listCheckoutGateways();

Use checkoutMode:
- default_only: only default gateway is shown in checkout
- multi_enabled: all enabled gateways are shown

Learning Path

Scaffold Gateways (IdPay, PayPing)

You can add scaffold gateways now. Credentials are validated, but payment methods are not implemented yet.

const payment = new PaymentGatewayClient({
  defaultGateway: "zarinpal",
  enabledGateways: ["zarinpal", "zibal", "idpay", "payping"],
  checkoutMode: "multi_enabled",
  gateways: {
    zarinpal: { merchantId: process.env.ZARINPAL_MERCHANT_ID!, sandbox: true },
    zibal: { merchant: process.env.ZIBAL_MERCHANT! },
    idpay: { apiKey: process.env.IDPAY_API_KEY!, sandbox: true },
    payping: { accessToken: process.env.PAYPING_ACCESS_TOKEN!, sandbox: true }
  }
});

Custom Gateway (Any Provider)

Use your own backend endpoints for any provider by adding custom gateway config.

{
  "mygateway": {
    "initiateUrl": "https://your-backend.com/api/custom-gateway/initiate",
    "verifyUrl": "https://your-backend.com/api/custom-gateway/verify",
    "headers": {
      "x-internal-key": "your-secret"
    }
  }
}

In dashboard:
- add mygateway to custom enabled gateways
- set default gateway to mygateway if needed
- paste JSON in Custom Gateways JSON

initiateUrl must return { authority, paymentUrl }, and verifyUrl must return { success, refId? }.

Security