<?php
// b2c/b2c_config.php
require_once dirname(__DIR__) . '/includes/config_loader.php';
//require_once 'includes/config_loader.php';

/**
 * B2C Configuration
 */

// Base domain for all callbacks
define('MPESA_BASE_URL', 'https://cbs.creativewebsolutions.co.ke');

// Environment and Site
define('B2C_MPESA_ENVIRONMENT', getenv('B2C_MPESA_ENVIRONMENT'));
define('B2C_SITE_NAME', getenv('B2C_MPESA_SITE_NAME'));

// API Credentials
define('B2C_MPESA_CONSUMER_KEY', getenv('B2C_MPESA_CONSUMER_KEY'));
define('B2C_MPESA_CONSUMER_SECRET', getenv('B2C_MPESA_CONSUMER_SECRET'));
define('B2C_MPESA_SHORTCODE', getenv('B2C_MPESA_SHORTCODE'));

// Note: B2C typically doesn't use PASSKEY, that's for C2B STK Push
// define('B2C_MPESA_PASSKEY', getenv('B2C_MPESA_PASSKEY')); // Remove if not needed

// Security Credentials
define('B2C_MPESA_INITIATOR_NAME', getenv('B2C_MPESA_INITIATOR_NAME'));
define('B2C_MPESA_INITIATOR_PASSWORD', getenv('B2C_MPESA_INITIATOR_PASSWORD'));

// Command Type
define('B2C_MPESA_COMMAND_ID', getenv('B2C_MPESA_COMMAND_ID'));

// B2C Callback URLs (using direct file paths)
define('B2C_MPESA_RESULT_URL', MPESA_BASE_URL . '/b2c_result.php');
define('B2C_MPESA_TIMEOUT_URL', MPESA_BASE_URL . '/b2c_timeout.php');
define('B2C_MPESA_QUEUE_TIMEOUT_URL', MPESA_BASE_URL . '/b2c_timeout.php'); // Sometimes needed

// Ledger Configuration
define('B2C_MPESA_LEDGER_ID', getenv('B2C_MPESA_LEDGER_ID'));
define('B2C_MPESA_LEDGER_CODE', getenv('B2C_MPESA_LEDGER_CODE'));

// Logging
define('B2C_MPESA_LOG_FILE', __DIR__ . getenv('B2C_MPESA_LOG_FILE'));

// Optional: Define B2C API URLs based on environment
if (B2C_MPESA_ENVIRONMENT === 'sandbox') {
    define('B2C_MPESA_API_URL', 'https://sandbox.safaricom.co.ke/mpesa/b2c/v1/paymentrequest');
    define('B2C_MPESA_AUTH_URL', 'https://sandbox.safaricom.co.ke/oauth/v1/generate?grant_type=client_credentials');
} else {
    define('B2C_MPESA_API_URL', 'https://api.safaricom.co.ke/mpesa/b2c/v1/paymentrequest');
    define('B2C_MPESA_AUTH_URL', 'https://api.safaricom.co.ke/oauth/v1/generate?grant_type=client_credentials');
}