10000 add stripe subunit override for USDC by davidpatters0n · Pull Request #403 · Shopify/money · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

add stripe subunit override for USDC #403

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

Merged
merged 1 commit into from
May 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
shopify-money (3.1.1)
shopify-money (3.1.2)

GEM
remote: https://rubygems.org/
Expand Down
1 change: 1 addition & 0 deletions lib/money/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module Helpers
STRIPE_SUBUNIT_OVERRIDE = {
'ISK' => 100,
'UGX' => 100,
'USDC' => 1_000_000,
}.freeze

def value_to_decimal(num)
Expand Down
2 changes: 1 addition & 1 deletion lib/money/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

class Money
VERSION = "3.1.1"
VERSION = "3.1.2"
end
6 changes: 6 additions & 0 deletions spec/money_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,12 @@
expect(Money.from_subunits(100, 'UGX', format: :stripe)).to eq(Money.new(1, 'UGX'))
end

it 'overrides the subunit_to_unit amount for USDC' do
configure(experimental_crypto_currencies: true) do
expect(Money.from_subunits(500000, "USDC", format: :stripe)).to eq(Money.new(0.50, 'USDC'))
end
end

it 'fallbacks to the default subunit_to_unit amount if no override is specified' do
expect(Money.from_subunits(100, 'USD', format: :stripe)).to eq(Money.new(1, 'USD'))
end
Expand Down
0