-
Notifications
You must be signed in to change notification settings - Fork 58
Include local amount on HCB code partial #11063
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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 |
There was a problem hiding this comment.
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
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 |
currency = stripe_transaction["merchant_currency"]&.upcase | ||
amount = stripe_transaction["merchant_amount"].abs | ||
|
||
return nil if currency.nil? || currency == "USD" |
There was a problem hiding this comment.
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)

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" |
Ian and talked about this on Slack but also putting this here, we already
have this built out
…On Wed, Jul 30, 2025 at 2:38 PM David Cornu ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In app/models/raw_stripe_transaction.rb
<#11063 (comment)>:
> + 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
*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
------------------------------
In app/models/raw_stripe_transaction.rb
<#11063 (comment)>:
> + currency = stripe_transaction["merchant_currency"]&.upcase
+ amount = stripe_transaction["merchant_amount"].abs
+
+ return nil if currency.nil? || currency == "USD"
*suggestion*: as far as I can tell, merchant_currency and merchant_amount
are always present (both in the API and in our database)
***@***.*** (view on web)
<https://github.com/user-attachments/assets/0fa98c2a-1f6d-4643-93b2-aaa594934dc9>
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"
—
Reply to this email directly, view it on GitHub
<#11063 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AJP3VRACUGPSTRMZ7Z2ANST3LEGLJAVCNFSM6AAAAACCEP2YU2VHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZTANZSHEYDQMRZGY>
.
You are receiving this because your review was requested.Message ID:
***@***.***>
|
@sampoder ah ok so we can close this? |
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