Configuration management for RazorpayEx client.
This module handles configuration loading from application environment, environment variables, and provides convenience functions for setup.
Configuration Sources
Configuration is loaded in this order:
- Explicit configuration via
RazorpayEx.Config.set/1 - Application environment (
config :razorpay_ex ...) - Environment variables
- Default values
Examples
# Configure via application config
config :razorpay_ex
key_id: "rzp_test_key_id",
key_secret: "test_secret"
# Configure programmatically
RazorpayEx.Config.set(%{
key_id: "rzp_test_key_id",
key_secret: "test_secret"
})
# Setup OAuth
RazorpayEx.Config.setup_oauth("oauth_token_123")
# Setup Basic Auth
RazorpayEx.Config.setup_basic_auth("key_id", "key_secret")
Summary
Functions
Returns the OAuth access token.
Returns the API base URL.
Returns the auth base URL.
Returns the authentication type.
Returns custom headers.
Returns whether logging is enabled.
Returns the current configuration.
Returns the RazorpayEx key ID.
Returns the RazorpayEx key secret.
Sets configuration from a map.
Configures basic authentication.
Configures OAuth authentication.
Returns the request timeout.
Types
Functions
@spec access_token() :: String.t() | nil
Returns the OAuth access token.
@spec api_base_url() :: String.t()
Returns the API base URL.
@spec auth_base_url() :: String.t()
Returns the auth base URL.
@spec auth_type() :: :basic | :oauth
Returns the authentication type.
@spec custom_headers() :: map()
Returns custom headers.
@spec enable_logging() :: boolean()
Returns whether logging is enabled.
@spec get() :: t()
Returns the current configuration.
@spec key_id() :: String.t()
Returns the RazorpayEx key ID.
@spec key_secret() :: String.t()
Returns the RazorpayEx key secret.
@spec set(map()) :: :ok
Sets configuration from a map.
Examples
RazorpayEx.Config.set(%{
key_id: "rzp_test_key_id",
key_secret: "test_secret",
timeout: 60000
})
Configures basic authentication.
Parameters
key_id: RazorpayEx key IDkey_secret: RazorpayEx key secretopts: Additional options
Examples
RazorpayEx.Config.setup_basic_auth("rzp_test_key_id", "test_secret")
RazorpayEx.Config.setup_basic_auth("key_id", "secret", timeout: 60000)
Configures OAuth authentication.
Parameters
access_token: OAuth access tokenopts: Additional options (custom_headers, timeout, etc.)
Examples
RazorpayEx.Config.setup_oauth("oauth_token_123")
RazorpayEx.Config.setup_oauth("oauth_token_123", timeout: 60000)
@spec timeout() :: integer()
Returns the request timeout.