-- ============================================================
-- GoPay Gateway Integration — SQL Setup
-- Run this on the luckrgur_pakclub database
-- ============================================================

-- Insert GoPay credentials into admin_settings
INSERT INTO admin_settings (setting_key, setting_value) VALUES 
    ('gopay_merchant_id', '16352478'),
    ('gopay_payin_api_key', 'fd1535879ba6723c213ecc1b7c9279606de027b01e31b7c2'),
    ('gopay_payin_api_secret', '39316324b948128c512d3d6297230691c1adcb99fa238f70a37f78e368446ec1'),
    ('gopay_payout_api_key', 'ac23f30056e3999c39e8b0aefff42e0aef7d177e6fed86bf'),
    ('gopay_payout_api_secret', 'e24d583908ca7d1481b50f9309920af9ae071837f8e4a6269b120920c5a6ea3e'),
    ('gopay_webhook_secret', 'f0445771a4fd0f060385bd1a963b8be9eb19f963fe1867e52da66325f71340de')
ON DUPLICATE KEY UPDATE setting_value = VALUES(setting_value);

-- Update payment_routing to include go_pay gateway
-- This adds GoPay with easypaisa and jazzcash methods (editable codes in admin)
UPDATE admin_settings 
SET setting_value = JSON_SET(
    setting_value,
    '$.gateways.go_pay', JSON_OBJECT(
        'status', 'active',
        'methods', JSON_OBJECT(
            'easypaisa', JSON_OBJECT(
                'status', 'active',
                'code', 'easypaisa',
                'label', 'Easypaisa',
                'payin_code', 'easypaisa',
                'payout_code', 'easypaisa'
            ),
            'jazzcash', JSON_OBJECT(
                'status', 'active',
                'code', 'jazzcash',
                'label', 'Jazz Cash',
                'payin_code', 'jazzcash',
                'payout_code', 'jazzcash'
            )
        )
    )
)
WHERE setting_key = 'payment_routing';

-- ============================================================
-- NOTE: If the JSON_SET above fails (older MySQL), use this 
-- alternative: just go to Admin > Payments and click Save.
-- The PHP code will auto-add go_pay to the routing JSON.
-- ============================================================
