<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Hacienda ATV Invoicing Configuration
    |--------------------------------------------------------------------------
    | Url's for sending electronic invoices to Hacienda using the ATV system.
    |
    */
    'api_base_url_prod' => env('HACIENDA_URL_PROD', 'https://api1.comprobanteselectronicos.go.cr/recepcion/v1/'),
    'api_base_url_stag' => env('HACIENDA_URL_STAG', 'https://api-sandbox.comprobanteselectronicos.go.cr/recepcion/v1/'),
    'api_url_recepcion' => env('HACIENDA_URL_RECEPCION_STAG','recepcion'),
    'api_url_comprobantes' => env('HACIENDA_URL_COMPROBANTES_STAG','comprobantes'),



    /*
    |--------------------------------------------------------------------------
    | Firma Digital (XAdES-EPES)
    |--------------------------------------------------------------------------
    |
    | Ruta al archivo .p12 de Firma Digital SINPE o llave criptográfica ATV.
    | Guarda el .p12 en storage/certificates/ y NUNCA lo subas al repositorio.
    |
    | Agrega en tu .env:
    |   FIRMA_DIGITAL_P12_PATH=/ruta/absoluta/al/certificado.p12
    |   FIRMA_DIGITAL_PASSWORD=tu_contraseña
    |
    */
    'firma_digital' => [
        'p12_path' => env('FIRMA_DIGITAL_P12_PATH'),
        'password' => env('FIRMA_DIGITAL_PASSWORD'),
    ],

    /*
    |--------------------------------------------------------------------------
    | XAdES-EPES Signing Policy
    |--------------------------------------------------------------------------
    |
    | URLs and digests for XAdES-EPES digital signature policy as required by
    | Hacienda. These values are part of the Hacienda digital signature
    | specification and should not change unless Hacienda updates them.
    |
    */
    'xades_signing_policy' => [
        'policy_url' => env('XADES_POLICY_URL', 'https://cdn.comprobanteselectronicos.go.cr/xml-schemas/Resoluci%C3%B3n_General_sobre_disposiciones_t%C3%A9cnicas_comprobantes_electr%C3%B3nicos_para_efectos_tributarios.pdf'),
        'policy_digest' => env('XADES_POLICY_DIGEST', 'DWxin1xWOeI8OuWQXazh4VjLWAaCLAA954em7DMh0h8='),
    ],

    /*
    |--------------------------------------------------------------------------
    | Hacienda IdP (Identity Provider)
    |--------------------------------------------------------------------------
    |
    | Credentials OAuth 2.0 for the API of the Identity Provider (IdP) of Hacienda,
    | used to obtain access tokens for authenticating API requests to 
    | Hacienda's Electronic Invoicing system. The IdP uses Keycloak with the 
    | Resource Owner Password Credential grant type.
    |
    | Add to your .env:
    |   HACIENDA_IDP_ENVIRONMENT=stag   (stag or prod)
    |   HACIENDA_IDP_USERNAME=your_username
    |   HACIENDA_IDP_PASSWORD=your_password
    |
    */
    'hacienda_idp' => [
        'environment' => env('HACIENDA_IDP_ENVIRONMENT', 'stag'),
        'username'    => env('HACIENDA_IDP_USERNAME'),
        'password'    => env('HACIENDA_IDP_PASSWORD'),
    ],

    /*
    |--------------------------------------------------------------------------
    | Provider ID
    |--------------------------------------------------------------------------
    |
    | Id of the system provider to send the documents to.
    |
    */
    'provider_id' => env('HACIENDA_PROVIDER_ID',''),

    /*
    |--------------------------------------------------------------------------
    | Webhook Validation
    |--------------------------------------------------------------------------
    |
    | Security settings for validating incoming webhooks from Hacienda.
    |
    | allowed_ips: Comma-separated list of trusted IP addresses. Leave empty
    |              to disable IP validation. Format: "192.0.2.1,192.0.2.2"
    |
    | max_age_seconds: Maximum age (in seconds) of webhook timestamps.
    |                  Prevents replay attacks. Default: 600 (10 minutes)
    |
    */
    'webhook_validation' => [
        'allowed_ips' => env('HACIENDA_WEBHOOK_ALLOWED_IPS', ''),
        'max_age_seconds' => (int) env('HACIENDA_WEBHOOK_MAX_AGE', 600),
    ],

];  