-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Setup Checkout (Update Payment Method) (#36)
* impl setup checkout * update example * fix onload err * remove * update names * update logs * update shared model * resolve comments" * update event name * use format utils
- Loading branch information
1 parent
417b378
commit 2ec8d17
Showing
9 changed files
with
139 additions
and
32 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
export const CurrencyEnum = { | ||
Usd: 'usd', | ||
Brl: 'brl', | ||
} as const; | ||
export type CurrencyEnum = (typeof CurrencyEnum)[keyof typeof CurrencyEnum]; | ||
|
||
// Define conversion rates or atomic units for different currencies | ||
export const ConversionRates: Record<string, number> = { | ||
[CurrencyEnum.Usd]: 100, // e.g., 1 USD = 100 atoms (cents) | ||
[CurrencyEnum.Brl]: 100, // e.g., 1 BRL = 100 atoms (centavos) | ||
}; | ||
|
||
export const CurrencySymbolMap: Record<string, string> = { | ||
[CurrencyEnum.Usd]: `$`, | ||
[CurrencyEnum.Brl]: `R$`, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import Fraction from 'fraction.js'; | ||
import { ConversionRates } from './currency'; | ||
|
||
export const sum = (arr: number[]): number => { | ||
return arr.reduce((a, b) => a + b, 0); | ||
}; | ||
|
||
export const atomToCurrency = (num: number, currency: string): number => { | ||
return new Fraction(num).div(ConversionRates[currency]).valueOf(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters