← 返回 stripe 的题目列表Transaction Fee with Status- and Type-specific Rates
类型:online_judge
Problem: Compute Transaction Fees (Rates by Payment Status and Payment Type)
You are given a list of transactions and a fee rate table. Each transaction contains:
amount: transaction amount (integer, in the smallest currency unit, e.g., cents)
payment_status: payment status (string/enum)
payment_type: payment type (string/enum)
The fee rate table determines the fee rule by (payment_status, payment_type). For each transaction, compute the fee as:
fee = amount * rate_percent + rate_fixed
rate_percent is a percentage rate (e.g., 0.029 means 2.9%)
rate_fixed is a fixed fee (integer, same unit as amount, e.g., 30 cents)
Tasks
Implement a function/program that:
Computes the fee for each transaction.
Returns/prints the sum of fees across all transactions as total_fee.
Constraints / Notes
amount is a non-negative integer.
If a transaction’s (payment_status, payment_type) is not found in the rate table:
either raise an error, or apply a default rate (confirm with the interviewer).
Amounts/fees must be represented as integers (smallest currency unit). Any rounding rule for percentage calculations (floor/round-to-nearest) should be clarified with the interviewer.