-- Flutterwave Payment Gateway Configuration for SmartPanel v4.1
-- Insert this into your payments table

INSERT INTO `payments` (`id`, `type`, `name`, `min`, `max`, `sort`, `new_users`, `status`, `params`) VALUES
(NULL, 'flutterwave', 'Flutterwave Payment Gateway', 100, 1000000, 2, 1, 1, '{"type":"flutterwave","name":"Flutterwave Payment Gateway","min":"100","max":"1000000","new_users":"1","status":"1","take_fee_from_user":"1","option":{"environment":"test","public_key":"FLWPUBK_TEST-SANDBOXDEMOKEY-X","secret_key":"FLWSECK_TEST-SANDBOXDEMOKEY-X","encryption_key":"FLWSECK_TEST-SANDBOXENCKEY-X","tnx_fee":"2.5","rate_to_usd":"1500","supported_currencies":["NGN","USD","EUR","GBP","KES","UGX","TZS"],"payment_methods":["card","banktransfer","ussd","mobilemoney"]}}');

-- Optional: Update existing payment_methods table if needed
UPDATE `payment_methods` SET `type` = 'automatic', `status` = 1 WHERE `slug` = 'flutterwave';

-- Create transaction logs index for better performance (if not exists)
CREATE INDEX IF NOT EXISTS `idx_transaction_logs_lookup` ON `transaction_logs` (`transaction_id`, `status`, `type`);

-- Notes:
-- 1. Replace the test API keys with your actual Flutterwave test keys:
--    - public_key: Your Flutterwave public key (starts with FLWPUBK_TEST for test mode)
--    - secret_key: Your Flutterwave secret key (starts with FLWSECK_TEST for test mode)  
--    - encryption_key: Your Flutterwave encryption key (optional, for webhook verification)
--
-- 2. Adjust the following values as needed:
--    - min: Minimum payment amount (currently set to 100)
--    - max: Maximum payment amount (currently set to 1,000,000)
--    - tnx_fee: Transaction fee percentage (currently set to 2.5%)
--    - rate_to_usd: Exchange rate from NGN to USD (currently set to 1500)
--
-- 3. For production, change environment from "test" to "live" and use live API keys
--
-- 4. The payment gateway supports multiple currencies and payment methods:
--    - Currencies: NGN, USD, EUR, GBP, KES, UGX, TZS
--    - Methods: Cards, Bank Transfer, USSD, Mobile Money
