From c4843095b23825e644c944d49a69504ec19b837c Mon Sep 17 00:00:00 2001 From: Wrongecho Date: Tue, 22 Sep 2026 16:01:46 +0000 Subject: [PATCH] Potential fix for Stripe charges being off by a cent --- agent/post/payment.php | 2 +- client/post.php | 2 +- cron/nightly_tasks.php | 2 +- guest/guest_ajax.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/agent/post/payment.php b/agent/post/payment.php index 46b6fa881..37a79f063 100644 --- a/agent/post/payment.php +++ b/agent/post/payment.php @@ -410,7 +410,7 @@ if (isset($_POST['add_payment_stripe'])) { // Create a payment intent try { $payment_intent = $stripe->paymentIntents->create([ - 'amount' => intval($balance_to_pay * 100), // Times by 100 as Stripe expects values in cents + 'amount' => intval(round($balance_to_pay * 100)), // Times by 100 as Stripe expects values in cents 'currency' => $invoice_currency_code, 'customer' => $payment_provider_client, 'payment_method' => $saved_payment_method, diff --git a/client/post.php b/client/post.php index 8d527f435..6dd5128dc 100644 --- a/client/post.php +++ b/client/post.php @@ -848,7 +848,7 @@ if (isset($_GET['add_payment_by_provider'])) { // Create a payment intent try { $payment_intent = $stripe->paymentIntents->create([ - 'amount' => intval($balance_to_pay * 100), // Times by 100 as Stripe expects values in cents + 'amount' => intval(round($balance_to_pay * 100)), // Times by 100 as Stripe expects values in cents 'currency' => $invoice_currency_code, 'customer' => $payment_provider_client, 'payment_method' => $saved_payment_method, diff --git a/cron/nightly_tasks.php b/cron/nightly_tasks.php index de23b7b4d..e165b5e1b 100644 --- a/cron/nightly_tasks.php +++ b/cron/nightly_tasks.php @@ -953,7 +953,7 @@ while ($row = mysqli_fetch_assoc($sql_recurring_payments)) { try { $payment_intent = $stripe->paymentIntents->create([ - 'amount' => intval($balance_to_pay * 100), + 'amount' => intval(round($balance_to_pay * 100)), 'currency' => $recurring_payment_currency_code, 'customer' => $stripe_customer_id, 'payment_method' => $stripe_payment_method_id, diff --git a/guest/guest_ajax.php b/guest/guest_ajax.php index 54f4b6cf6..a405bc1eb 100644 --- a/guest/guest_ajax.php +++ b/guest/guest_ajax.php @@ -88,7 +88,7 @@ if (isset($_GET['stripe_create_pi'])) { \Stripe\Stripe::setApiKey($stripe_secret_key); $paymentIntent = \Stripe\PaymentIntent::create([ - 'amount' => intval($balance_to_pay * 100), // Stripe expects cents + 'amount' => intval(round($balance_to_pay * 100)), // Stripe expects cents 'currency' => $invoice_currency_code, 'description' => $pi_description, 'metadata' => [