Worldpay.Config (Worldpay v1.0.0)

Copy Markdown View Source

Runtime configuration for the Worldpay client.

Application config

config :worldpay,
  username: "your-username",
  password: "your-password",
  environment: :try,
  api_version: "2025-01-01",
  wpg_merchant_code: "MYMERCHANT",
  wpg_username: "wpg-user",
  wpg_password: "wpg-pass",
  timeout: 30_000,
  retry_count: 3,
  circuit_breaker: true

Environment variable overrides (take precedence)

  • WORLDPAY_USERNAME
  • WORLDPAY_PASSWORD
  • WORLDPAY_ENVIRONMENT"try" or "live"
  • WORLDPAY_API_VERSION
  • WORLDPAY_WPG_MERCHANT_CODE
  • WORLDPAY_WPG_USERNAME
  • WORLDPAY_WPG_PASSWORD

Summary

Functions

Encode Basic Auth header value for Access APIs.

Default Access API base URL (try environment).

Default WPG base URL (try environment).

Build a Config from application env and environment variables.

Encode Basic Auth header value for WPG.

Types

environment()

@type environment() :: :try | :live

t()

@type t() :: %Worldpay.Config{
  api_version: String.t(),
  base_url: String.t(),
  circuit_breaker: boolean(),
  environment: environment(),
  password: String.t() | nil,
  retry_count: non_neg_integer(),
  timeout: non_neg_integer(),
  username: String.t() | nil,
  wpg_base_url: String.t(),
  wpg_merchant_code: String.t() | nil,
  wpg_password: String.t() | nil,
  wpg_username: String.t() | nil
}

Functions

basic_auth(config)

@spec basic_auth(t()) :: String.t()

Encode Basic Auth header value for Access APIs.

default_access_url()

@spec default_access_url() :: String.t()

Default Access API base URL (try environment).

default_wpg_url()

@spec default_wpg_url() :: String.t()

Default WPG base URL (try environment).

new(overrides \\ [])

@spec new(keyword()) :: t()

Build a Config from application env and environment variables.

Environment variables take precedence over application config. The overrides keyword list takes the highest precedence.

wpg_basic_auth(config)

@spec wpg_basic_auth(t()) :: String.t()

Encode Basic Auth header value for WPG.