Closed patrickomeara closed 1 year ago
How are you displaying the price?
I've tried ->price()->gross()
as in the docs and tried using Cashier::formatAmount()
directly.
Route::get('cashier', function() {
return Cashier::productPrices(
$planIds,
['customer_country' => 'JP'],
)->map(fn (ProductPrice $price) => $price->price()->gross());
});
Hah, actually, it's not showing any decimal at all. You're being displayed 120000 Japanese Yen. This is because the modifier for other currencies shouldn't apply here. I've attempted to fix this here: https://github.com/laravel/cashier-paddle/pull/184
Can you try out that PR and let me know if things look better?
Yep, sorry if that wasn't clear. Your solution in #184 will definitely work, as it's the same workaround I've just put live.
$multiplier = $productPrice->currency === 'JPY' ? 1 : 100;
return Cashier::formatAmount(
(int) $productPrice->price()->rawGross() * $multiplier,
$productPrice->price()->currency(),
null,
['min_fraction_digits' => 0]
);
Cashier Paddle Version
1.8.1
Laravel Version
9.52.6
PHP Version
8.2.3
Database Driver & Version
No response
Description
As mentioned here https://github.com/moneyphp/money/issues/684 by @driesvints there is an issue formatting JPY. The mentioned solution looks to be implemented in
Cashier::formatAmount()
However I am still getting an extra 2 zeroes for JPY, all other currencies work fine.@driesvints Is this a known issue that we have to handle in our application code?
Steps To Reproduce
Format a paddle price using
JP
country_code