Transaction Fee Calculator - Status Gate and Regional Rates
Learn this problemProblem statement
Compute the processing fee for each transaction in a CSV and emit a result CSV.
Input: csvData is a single CSV string. The first row is the header; the canonical columns are id,reference,amount,currency,date,merchant_id,buyer_country,transaction_type,payment_provider,status. amount is an integer in cents. payment_provider is one of card, klarna, bank_transfer. status is one of payment_completed, payment_failed, payment_pending.
Fee rules: the fee for a row is floor(amount * rate + fixed) using these rates by (buyer_country, payment_provider):
- Standard (any country except Ireland):
card= 2.9% + 30,klarna= 3.5% + 50,bank_transfer= 0.8% + 0. - Ireland (
buyer_country == "ie"):card= 1.9% + 20,klarna= 2.5% + 40,bank_transfer= 0.6% + 0. Any other country falls back to the standard rates.
A fee is only charged when status == "payment_completed"; for failed or pending transactions the fee is 0. Always floor the final fee to an integer (truncate toward zero).
Output: return a String[] whose first element is the header "id,transaction_type,payment_provider,fee" and then one line "id,transaction_type,payment_provider,fee" per input transaction, in input order.
Function
calculateFees(csvData: String) → String[]Examples
Example 1
csvData = "id,reference,amount,currency,date,merchant_id,buyer_country,transaction_type,payment_provider,status\npy_1,ref1,1000,eur,2026-01-01,m1,ie,payment,card,payment_completed\npy_2,ref2,2500,eur,2026-01-01,m1,ie,payment,card,payment_failed\npy_3,ref3,3400,eur,2026-01-01,m2,ie,payment,klarna,payment_completed\npy_4,ref4,5000,eur,2026-01-01,m2,fr,payment,bank_transfer,payment_completed\npy_5,ref5,2000,eur,2026-01-01,m3,ie,payment,card,payment_pending"return = ["id,transaction_type,payment_provider,fee", "py_1,payment,card,39", "py_2,payment,card,0", "py_3,payment,klarna,125", "py_4,payment,bank_transfer,40", "py_5,payment,card,0"]Example 2
csvData = "id,reference,amount,currency,date,merchant_id,buyer_country,transaction_type,payment_provider,status\npy_1,ref1,1000,usd,2026-01-01,m1,us,payment,card,payment_completed\npy_2,ref2,2500,usd,2026-01-01,m1,us,payment,card,payment_completed\npy_3,ref3,3400,usd,2026-01-01,m2,us,payment,klarna,payment_completed\npy_4,ref4,5000,usd,2026-01-01,m2,us,payment,bank_transfer,payment_completed"return = ["id,transaction_type,payment_provider,fee", "py_1,payment,card,59", "py_2,payment,card,102", "py_3,payment,klarna,169", "py_4,payment,bank_transfer,40"]Constraints
- First CSV row is the header;
amountis integer cents. - Fee =
floor(amount * rate + fixed)by (buyer_country, payment_provider); Ireland has its own rates, all other countries use the standard rates. - Fee is 0 unless
status == "payment_completed". - Floor (truncate) the final fee to an integer.
- Return a
String[]: header"id,transaction_type,payment_provider,fee"then one line per transaction in input order.
More Stripe problems
- Group Linked Merchant RecordsPHONE SCREEN · Seen Jul 2026
- Invoice / Payment ReconciliationPHONE SCREEN · Seen Jul 2026
- Incident MonitorOA · Seen Jul 2026
- Merchant Fraud Risk ScoringOA · Seen Jul 2026
- WebSocket Load Balancer — Basic Load Balancing (Part 1)OA · Seen Jul 2026
- Rule-Driven Transaction Fraud DetectionOA · PHONE SCREEN · Seen Jul 2026
- Deployment Window SchedulerOA · Seen Jul 2026
- Directly Linked UsersOA · Seen Jun 2026