laravel / cashier-paddle

Cashier Paddle provides an expressive, fluent interface to Paddle's subscription billing services.

Home Page:https://laravel.com/docs/cashier-paddle

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Incorrect format amount

dieg0v opened this issue · comments

  • Cashier Paddle Version: 1.5.0
  • Laravel Version: 9.1.0
  • PHP Version: 8.0.2

Description:

Configuring a new plan in Paddle with a value of 9.95 I have realized that it is formatted incorrectly with a value of 9.94, I am using spark-paddle v1.2.1.

Steps To Reproduce:

$price = 9.95 * 100;
var_dump($price);
$formatPrice = \Laravel\Paddle\Cashier::formatAmount($price, 'EUR');
var_dump($formatPrice);
float(994.9999999999999)
string(9) "9,94 €"

It could be fixed in spark-paddle like this:

$price = bcmul(9.95, 100);
var_dump($price);
$formatPrice = \Laravel\Paddle\Cashier::formatAmount($price, 'EUR');
var_dump($formatPrice);
string(3) "995"
string(9) "9,95 €"

But I think this behavior is going to reproduce whenever \Laravel\Paddle\Cashier::formatAmount is called, maybe formatAmount function should solve it.

Thank you!

Thanks, I've attempted a fix that we'll merge and tag soon.

Also: please be aware that this is the cashier issue tracker, not the spark one. Please report any spark issues to Spark support.

Spark v1.2.2 was just released with a fix.

Thanks!... and sorry, I thought I was more related to Cashier than Spark.