fix: remplacer bcmul/bccomp par round/float dans StripePriceService
src/Service/StripePriceService.php: - bcmul() remplace par (int) round((float) $amountHt * 100) pour convertir le montant HT en centimes (bcmath non installe) - bccomp() remplace par (float) cast pour comparer monthPrice a 0 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -38,7 +38,7 @@ class StripePriceService
|
||||
}
|
||||
|
||||
// Prix abonnement (si monthPrice > 0)
|
||||
if (bccomp($price->getMonthPrice(), '0.00', 2) > 0) {
|
||||
if ((float) $price->getMonthPrice() > 0) {
|
||||
if (null === $price->getStripeAbonnementId() || '' === $price->getStripeAbonnementId()) {
|
||||
$stripePrice = $this->createStripePrice($productId, $price->getMonthPrice(), true, $price->getPeriod());
|
||||
$price->setStripeAbonnementId($stripePrice->id);
|
||||
@@ -113,7 +113,7 @@ class StripePriceService
|
||||
|
||||
private function createStripePrice(string $productId, string $amountHt, bool $recurring, int $periodMonths = 1): Price
|
||||
{
|
||||
$amountCents = (int) bcmul($amountHt, '100', 0);
|
||||
$amountCents = (int) (int) round((float) $amountHt * 100);
|
||||
|
||||
$params = [
|
||||
'product' => $productId,
|
||||
@@ -148,7 +148,7 @@ class StripePriceService
|
||||
{
|
||||
try {
|
||||
$existingPrice = $this->stripe->prices->retrieve($stripePriceId);
|
||||
$expectedCents = (int) bcmul($amountHt, '100', 0);
|
||||
$expectedCents = (int) (int) round((float) $amountHt * 100);
|
||||
|
||||
if ($existingPrice->unit_amount !== $expectedCents) {
|
||||
// Archiver l'ancien prix
|
||||
|
||||
Reference in New Issue
Block a user