From 9a36ad2cea9f598b31433334c60badfb1a61dbd5 Mon Sep 17 00:00:00 2001 From: wrongecho Date: Tue, 14 Jan 2025 00:28:49 +0000 Subject: [PATCH] Initial add Stripe Auto-payment with saved card --- portal/autopay.php | 22 +++++--- portal/index.php | 1 - portal/portal_header.php | 6 +- portal/portal_post.php | 116 ++++++++++++++++++++++++--------------- post/user/invoice.php | 5 +- scripts/cron.php | 7 ++- 6 files changed, 97 insertions(+), 60 deletions(-) diff --git a/portal/autopay.php b/portal/autopay.php index d1178d81..9f458574 100644 --- a/portal/autopay.php +++ b/portal/autopay.php @@ -92,14 +92,22 @@ if (!$config_stripe_enable || !$config_stripe_publishable || !$config_stripe_sec customers->retrievePaymentMethod( - $stripe_id, - $stripe_pm, - [] - ); + // Get payment method info (last 4 digits etc) + $payment_method = $stripe->customers->retrievePaymentMethod( + $stripe_id, + $stripe_pm, + [] + ); + + } catch (Exception $e) { + $error = $e->getMessage(); + error_log("Stripe payment error - encountered exception when fetching payment method info for $stripe_pm: $error"); + logApp("Stripe", "error", "Exception when fetching payment method info for $stripe_pm: $error"); + } $card_name = nullable_htmlentities($payment_method->billing_details->name); $card_brand = nullable_htmlentities($payment_method->card->display_brand); diff --git a/portal/index.php b/portal/index.php index a80c9bf9..eef09ea1 100644 --- a/portal/index.php +++ b/portal/index.php @@ -8,7 +8,6 @@ header("Content-Security-Policy: default-src 'self'"); require_once "inc_portal.php"; - ?>
New ticket diff --git a/portal/portal_header.php b/portal/portal_header.php index 53b34769..4bf730f5 100644 --- a/portal/portal_header.php +++ b/portal/portal_header.php @@ -57,17 +57,17 @@ header("X-Frame-Options: DENY"); // Legacy