-- ================================================================
-- TCOM ISP — Daraja API Update
-- Run this on your existing tcomco_mwananchi database to add
-- the new Daraja payment provider config keys.
-- ================================================================

USE `tcomco_mwananchi`;

-- Add payment provider toggle (default: daraja)
INSERT IGNORE INTO `config` (`key_name`, `key_value`, `description`) VALUES
('payment_provider',       'daraja',                                                                'Payment provider: megapay or daraja'),
('daraja_consumer_key',    '8lVguz5cNQ0BDb63CbImV6sEqfoLQeo5AoFFvpHLkJoyqBys',                     'Daraja API consumer key'),
('daraja_consumer_secret', 'ajGR7bGvglYS4VSp6i613w968KlDiHu4oV3KACOYRongpYYhWBLDZp3Pft9Vs0lt',    'Daraja API consumer secret'),
('daraja_passkey',         'c1adef2bce5e688feacaa06b26b7c5099ade683b4116cb9ea4da0c3b3d8e6754',      'Daraja API passkey for STK Push'),
('daraja_shortcode',       '4189519',                                                               'Daraja business shortcode'),
('daraja_environment',     'production',                                                             'Daraja environment: sandbox or production');

-- Update the shortcode to match (was empty before)
UPDATE `config` SET `key_value` = '4189519' WHERE `key_name` = 'mpesa_business_shortcode' AND (`key_value` = '' OR `key_value` IS NULL);

-- Update callback URL description (cosmetic)
UPDATE `config` SET `description` = 'Payment callback URL' WHERE `key_name` = 'callback_url';

-- ================================================================
-- DONE! Verify with:  SELECT * FROM config WHERE key_name LIKE 'daraja%' OR key_name = 'payment_provider';
-- ================================================================
