使用 Twig 将 API Charge::retrieve(['amount']) 条纹化为货币格式
Stripe API Charge::retrieve(['amount']) into a currency format with Twig
我正在尝试格式化从 Stripe API 检索到的费用金额。 Charge::retrieve(['amount'])
的金额是 14330000
。
在我的 Twig View
中,我有以下内容;
{{ order.amount | number_format(0, '.', ',') }}
哪个应该产生;
143,000
但产生;
14,300,000
我假设 Stripe Charge::retrieve(['amount'])
是 float
任何帮助将金额格式化为 143,000
甚至 143,000.00
都会很好。
order.amount
可能包含分,你只需要除以100即可。
{{ (order.amount / 100) | number_format(0, '.', ',') }}
您确定3
意外吗?
我正在尝试格式化从 Stripe API 检索到的费用金额。 Charge::retrieve(['amount'])
的金额是 14330000
。
在我的 Twig View
中,我有以下内容;
{{ order.amount | number_format(0, '.', ',') }}
哪个应该产生;
143,000
但产生;
14,300,000
我假设 Stripe Charge::retrieve(['amount'])
是 float
任何帮助将金额格式化为 143,000
甚至 143,000.00
都会很好。
order.amount
可能包含分,你只需要除以100即可。
{{ (order.amount / 100) | number_format(0, '.', ',') }}
您确定3
意外吗?