You are given:
1. A CSV string with header user,status,payment_provider,buyer_country,currency,amount
2. A dictionary exchange_rates where exchange_rates[currency] is the USD value of 1 unit of that currency
Compute the total fee charged to each user and return a dictionary mapping user -> total fee in USD cents.
First convert every amount to USD:
converted_usd = amount * exchange_rates[currency]
Fee rules:
- payment_completed:
- card: US/CA 2.9%, GB 2.5%, DE/FR/AT 2.3%, all other countries 3.1%
- bank_transfer: US/CA 1.2%, GB 1.1%, DE/FR/AT 1.0%, all other countries 1.4%
- wallet: any country 1.8%
- fee = converted_usd * rate + 0.30 USD
- payment_failed, payment_pending: use the Part 1 provider-only rates on the converted USD amount
- card: 2.9%
- bank_transfer: 1.0%
- wallet: 1.5%
- plus 0.30 USD fixed fee
- refund_completed: 0 USD
- dispute_lost: 15.00 USD flat
- dispute_won: 0 USD
Round each transaction fee to the nearest cent using half-up rounding before adding it to the user's total. Ignore blank lines. Return every user that appears in the CSV, even if that user's total fee is 0. If the CSV input is empty or whitespace only, return {}.
Examples
Input: ("user,status,payment_provider,buyer_country,currency,amount\nalice,payment_completed,card,DE,EUR,100.00\nbob,payment_pending,bank_transfer,US,USD,50.00\nalice,dispute_lost,wallet,GB,GBP,80.00", {"USD": 1.0, "EUR": 1.10, "GBP": 1.25})
Expected Output: {"alice": 1783, "bob": 80}
Explanation: alice: 100 EUR -> 110 USD, DE card rate 2.3%, so fee is 110 * 0.023 + 0.30 = 2.83 => 283 cents, plus 1500 cents for dispute_lost. bob: 50 USD pending bank transfer uses Part 1 logic, 50 * 1.0% + 0.30 = 0.80 => 80 cents.
Input: ("user,status,payment_provider,buyer_country,currency,amount\nu1,payment_completed,card,JP,JPY,10000\nu1,payment_completed,wallet,FR,EUR,10.00\nu2,refund_completed,card,US,USD,9.99", {"USD": 1.0, "EUR": 1.10, "JPY": 0.0068})
Expected Output: {"u1": 291, "u2": 0}
Explanation: 10000 JPY -> 68 USD, JP card uses the default 3.1% rate, so fee is 68 * 0.031 + 0.30 = 2.408 => 241 cents. 10 EUR -> 11 USD, wallet completed fee is 11 * 1.8% + 0.30 = 0.498 => 50 cents. Total for u1 is 291.
Input: ("", {"USD": 1.0})
Expected Output: {}
Explanation: Empty CSV input produces an empty result.
Input: ("user,status,payment_provider,buyer_country,currency,amount\nsam,payment_completed,bank_transfer,GB,GBP,0.99\nsam,dispute_won,card,US,USD,20.00", {"USD": 1.0, "GBP": 1.25})
Expected Output: {"sam": 31}
Explanation: 0.99 GBP -> 1.2375 USD. GB bank transfer completed fee is 1.2375 * 1.1% + 0.30 = 0.3136125 => 31 cents after half-up rounding. dispute_won adds 0.