ASAP PAY Gateway

Forward requests from ASAP PAY to a target application using a provider URL header. The calling application must either send the gateway public key or come from a whitelisted IP/domain, then send the provider credentials, payload, and request headers itself.

Forward route: /provider

Request Format

PartExample
Gateway URLPOST /provider
Gateway public keyX-Gateway-Public-Key: d92fd53e0f49c0adca152aea0c32de380c52cb546a5aa4d2883aee36211360f0
Target URLX-Provider-URL: http://127.0.0.1:9090/v1/payments
Body and authSend the exact body and provider auth headers required by the target application.

Example

curl -X POST http://localhost:8080/provider \
  -H "X-Gateway-Public-Key: d92fd53e0f49c0adca152aea0c32de380c52cb546a5aa4d2883aee36211360f0" \
  -H "X-Provider-URL: https://api.provider.com/v1/payments" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: unique-payment-reference" \
  -d '{"amount":1000,"currency":"NGN"}'

Local Mock Provider

Run the included mock provider when you want to test without calling the real provider. It returns the request details it received, with sensitive headers redacted.

MOCK_PROVIDER_PORT=9090 go run ./cmd/provider-mock

For local testing, keep ALLOWED_PROVIDER_HOSTS=127.0.0.1:9090 in .env, then start the gateway.

go run ./cmd/gateway

Then send an ASAP PAY-style request through the gateway.

curl -X POST http://localhost:8080/provider \
  -H "X-Gateway-Public-Key: d92fd53e0f49c0adca152aea0c32de380c52cb546a5aa4d2883aee36211360f0" \
  -H "X-Provider-URL: http://127.0.0.1:9090/v1/payments" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: local-test-001" \
  -d '{"amount":1000,"currency":"NGN"}'

Response

The gateway returns the target application's status code, safe transport response headers, and response body.

If the public key is missing or invalid and the caller is not whitelisted, the gateway returns 401 with {"error":"invalid gateway public key"}.

Configuration

EnvCurrent / DefaultPurpose
APP_PORT8080HTTP port for this gateway.
PROXY_PREFIX/providerRoute prefix used for forwarding.
GATEWAY_PRIVATE_KEYsetPrivate key held by this gateway.
GATEWAY_PUBLIC_KEY_HEADERX-Gateway-Public-KeyHeader where callers send the gateway public key.
GATEWAY_WHITELISTnot setComma-separated caller IPs, CIDRs, or Origin/Referer domains that can skip the public key.
PROVIDER_URL_HEADERX-Provider-URLHeader where ASAP PAY sends the full target URL.
ALLOWED_PROVIDER_HOSTSnot setComma-separated host allowlist. Recommended in production.