<?php
// config/config.php

// Database configuration
define('DB_HOST', '192.249.120.228');
define('DB_NAME', 'bookspublisherhu_invoice-terminal');
define('DB_USER', 'bookspublisherhu_invoice-terminal');
define('DB_PASS', 'bookspublisherhu_invoice-terminal');

// Security configuration
define('INVOICE_HASH_SALT', 'Xp#2sJ9qK$8mF!5tR6yV3wA%7zD*4gH1nB0lP@oIuCeQvWdMxYbNfGhTjUkO');

// Toggle sandbox mode
$EPD_SANDBOX_MODE = true;

// // Square sandbox API credentials
// define('SQUARE_ACCESS_TOKEN', 'EAAAl58nrovoOn8Vx948Khor4pG8RUD9c-fj-2CgcEIuoxJ1r9fRttuCwHWt3FzX');
// define('SQUARE_LOCATION_ID', 'L9J698KKX622N');
// define('SQUARE_APPLICATION_ID', 'sq0idp-AUT07eoQ0a-W0h9VVPVaEg');


// define('PAYPAL_MODE', 'live'); // or 'live'
// define('PAYPAL_CLIENT_ID', PAYPAL_MODE === 'sandbox'
//     ? 'AWsUS-Tr-ybedCScn1QEfcv6ZNkom5_8WjzuihvW4Wm-m3Eq73NJJeYHXd0RU7jc_3xgMWUaf_LsSnrw'
//     : 'AYQFzx81ut6IRJFb7HMsO7iLDH1HIs5_8UNJ-NkUqD5cVS2ZV23ePc3emCWkRh8YpqgM46TaoLAZpOwz');

// // 💡 Stripe Configuration ADDED
// define('STRIPE_MODE', 'live'); // or 'live'
// if (STRIPE_MODE === 'sandbox') {
//     // Replace with your actual Stripe Test Publishable and Secret Keys
//     define('STRIPE_PUBLISHABLE_KEY', 'pk_test_************************'); 
//     define('STRIPE_SECRET_KEY', 'sk_test_************************'); 
// } else {
//     // Replace with your actual Stripe Live Publishable and Secret Keys
//     define('STRIPE_PUBLISHABLE_KEY', 'pk_live_51RGLMzGkxssk52ZPtR6vIUhZ7NZXlbLjBPaRdVfsZFsaoAVmHGLLsGtnpYpcsqxOe0zBW7DsivV5svlP3VB4mtxC001Zu5cqdc');
//     define('STRIPE_SECRET_KEY', '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');
// }

define('PAYPAL_MODE', 'live'); // or 'live'
       // API BASE URL
define('PAYPAL_API', 
    PAYPAL_MODE === 'sandbox'
    ? "https://api-m.sandbox.paypal.com"
    : "https://api-m.paypal.com"
);

// Helper functions
function generateDynamicSalt() {
    return bin2hex(random_bytes(32));
}

function generateUUID() {
    return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
        mt_rand(0, 0xffff), mt_rand(0, 0xffff),
        mt_rand(0, 0xffff),
        mt_rand(0, 0x0fff) | 0x4000,
        mt_rand(0, 0x3fff) | 0x8000,
        mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff)
    );
}

function generateInvoiceHash($id, $dynamicSalt) {
    return hash('sha256', $id . INVOICE_HASH_SALT . $dynamicSalt);
}
