✅ Correct: The amount parameter comes in as a decimal (e.g., 10.00) and gets converted to cents internally:
def base_amount_in_cents
(@amount.to_d * 100).to_i
end✅ Correct: The fee_amount parameter should come in as cents (integer), based on this line:
options[:application_fee_amount] = @fee_amount.to_i if @fee_amount.present?The .to_i call suggests it's expected to already be an integer in cents.
This is where it gets nuanced - it depends on the scenario:
When customer_pays_fees: true and fee_amount is not provided:
- Amount does NOT include fee - it's the base service amount
- The service calculates and adds the fee using
booking_feepercentage - Example from spec:
amount: 10.00 # Base amount (decimal) booking_fee: 0.05 # 5% effective_amount: 1050 cents # 10.00 * 1.05 * 100 application_fee: 50 cents # The calculated fee
When fee_amount is explicitly provided:
- Amount DOES include fee - it's the customer-facing total
- The fee is passed separately to Stripe
- No calculation happens - amount is used as-is
When customer_pays_fees: false:
- Amount is exact payment - no fees added
- Customer pays exactly what's passed in
| Parameter | Format | Example | Notes |
|---|---|---|---|
amount |
Decimal | 10.00 |
Always decimal, converted to cents internally |
fee_amount |
Cents | 50 |
Already in cents (integer) |
| Amount semantics | Context-dependent | - | May or may not include fee depending on scenario |
Yes, there is a format inconsistency:
amountparameter is passed as decimal and converted to cents internallyfee_amountparameter is passed as cents (integer)
This is a bit awkward but appears to be the current design of the service.
- Service:
app/services/stripe/create_payment_intent.rb - Spec:
spec/services/stripe/create_payment_intent_spec.rb - Amount conversion:
create_payment_intent.rb:39-41 - Fee handling:
create_payment_intent.rb:44-50 - Stripe API call:
create_payment_intent.rb:97