Skip to content

Conversation

YodaLightsabr
Copy link
Contributor

@YodaLightsabr YodaLightsabr commented Jul 23, 2025

Summary of the problem

Right now, it's hard to see how much a card transaction is for in the local currency. We show the merchant currency, but not the amount. This can make it hard to pair receipts or understand finances in a local context.

Describe your changes

This PR adds a line to the Stripe card partial on HCB codes to include the local currency, if applicable. It references a new method on the Raw Stripe Transaction. This makes it easier for users to see how much a transaction was for in the original currency before it was converted to USD by Visa.

cc @leowilkin

@YodaLightsabr YodaLightsabr requested review from a team as code owners July 23, 2025 02:23
@sampoder
Copy link
Member

Ian and I chatted about this on Slack but this already exists:

Screenshot 2025-07-22 at 10 40 19 PM

Comment on lines +41 to +52
def local_amount
currency = stripe_transaction["merchant_currency"]&.upcase
amount = stripe_transaction["merchant_amount"].abs

return nil if currency.nil? || currency == "USD"

if ZERO_DECIMAL_CURRENCIES.include?(currency)
"#{number_to_delimited(amount)} #{currency}"
else
"#{number_to_currency(BigDecimal((amount || 0).to_s) / 100, unit: "")} #{currency}"
end
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Any reason we can't leverage the money gem here? If has built-in support for subunit handling

Suggested change
def local_amount
currency = stripe_transaction["merchant_currency"]&.upcase
amount = stripe_transaction["merchant_amount"].abs
return nil if currency.nil? || currency == "USD"
if ZERO_DECIMAL_CURRENCIES.include?(currency)
"#{number_to_delimited(amount)} #{currency}"
else
"#{number_to_currency(BigDecimal((amount || 0).to_s) / 100, unit: "")} #{currency}"
end
end
def local_amount
currency = stripe_transaction["merchant_currency"].upcase
amount = stripe_transaction["merchant_amount"].abs
return nil if currency == "USD"
Money.new(amount, currency).format
end

Comment on lines +42 to +45
currency = stripe_transaction["merchant_currency"]&.upcase
amount = stripe_transaction["merchant_amount"].abs

return nil if currency.nil? || currency == "USD"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: as far as I can tell, merchant_currency and merchant_amount are always present (both in the API and in our database)

CleanShot 2025-07-30 at 14 34 57@2x

https://docs.stripe.com/api/issuing/transactions/object?api-version=2024-12-18.acacia#issuing_transaction_object-merchant_amount

Suggested change
currency = stripe_transaction["merchant_currency"]&.upcase
amount = stripe_transaction["merchant_amount"].abs
return nil if currency.nil? || currency == "USD"
currency = stripe_transaction.fetch("merchant_currency").upcase
amount = stripe_transaction.fetch("merchant_amount").abs
return nil if currency == "USD"

@sampoder
Copy link
Member

sampoder commented Jul 30, 2025 via email

@davidcornu
Copy link
Member

@sampoder ah ok so we can close this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants