Configuration¶
There are three main "environments" which are required to determine which ZATCA API endpoint to use. Additionally, the type of environment changes the signing/validation process slightly.
-
"Non-Production" Sometimes also called the "Sandbox". It's open to anyone to use without registration for initial testing. It's a dummy environment with mainly hardcoded values and responses. For instance, the OTP "123345" is always considered valid.
Endpoint: ["https://gw-fatoora.zatca.gov.sa/e-invoicing/developer-portal/"]
-
"Simulation": The simulation environment requires registration at the developer portal. It's also used for testing only.
Endpoint: ["https://gw-fatoora.zatca.gov.sa/e-invoicing/simulation/"]
-
"Production": This is the real deal environment for in-production systems where real invoices are to be reported.
Endpoint: ["https://gw-fatoora.zatca.gov.sa/e-invoicing/core/"]
Environment¶
from_str¶
Parse environment
Convert a string value to an environment enum.
EnvironmentType::from_str(env: &str) -> Result<EnvironmentType, EnvironmentParseError>
Environment(value: str) -> Environment
/* parse is not exposed in C; use FfiEnvironment enum constants directly */
as_str¶
Get canonical string
Return the canonical string value of the environment.
EnvironmentType::as_str(&self) -> &'static str
Environment.value: str
/* not exposed; use enum value directly */
endpoint_url¶
Resolve API base URL
Return the ZATCA API base URL for the selected environment.
EnvironmentType::endpoint_url(&self) -> &'static str
# not directly exposed
/* not exposed */
Config¶
new¶
Create config
Create an environment-aware config handle.
Config::new(env: EnvironmentType) -> Config
Config(env: Environment = Environment.NON_PRODUCTION)
FfiConfig* fatoora_config_new(FfiEnvironment env);
env¶
Read config environment
Return the environment value stored in a config.
Config::env(&self) -> EnvironmentType
Config.env() -> Environment
FfiResult_FfiEnvironment fatoora_config_env(FfiConfig* config);
default¶
Default config
Create a default config using non-production environment.
Config::default() -> Config
Config() -> Config
/* call fatoora_config_new(FfiEnvironment_NonProduction) */