From bf390d977ea1bff45079f2750a3b0def441849c6 Mon Sep 17 00:00:00 2001
From: Turan Furkan Topak <39885728+Reqrefusion@users.noreply.github.com>
Date: Sun, 7 Jun 2026 02:27:04 +0300
Subject: [PATCH] Stripe Current Donation
---
donation.php | 104 +++++++++++++++++++++++++++++++++-
stripe-donations-refresh.php | 105 +++++++++++++++++++++++++++++++++++
stripe-donations.json | 0
3 files changed, 207 insertions(+), 2 deletions(-)
create mode 100644 stripe-donations-refresh.php
create mode 100644 stripe-donations.json
diff --git a/donation.php b/donation.php
index ef3ae719..a2007473 100644
--- a/donation.php
+++ b/donation.php
@@ -49,7 +49,7 @@ function send(type, method, amount, currency) {
};
function updateCurrencyDisplay(currency) {
- var symbol = currencySymbols[currency] || currencySymbols[defaultCurrency];
+ var symbol = currencySymbols[currency] || currencySymbols.eur;
Object.keys(presetValues).forEach(function(key) {
var label = document.querySelector("label[for='" + key + "']");
@@ -182,7 +182,7 @@ function showAccordion(amount) {
});
currencySelect.addEventListener('change', function() {
- currency = currencySelect.value || defaultCurrency;
+ currency = currencySelect.value;
updateCurrencyDisplay(currency);
});
@@ -324,6 +324,9 @@ function showAccordion(amount) {
+
+
diff --git a/stripe-donations-refresh.php b/stripe-donations-refresh.php
new file mode 100644
index 00000000..679c2e44
--- /dev/null
+++ b/stripe-donations-refresh.php
@@ -0,0 +1,105 @@
+ true,
+ 'updated_at' => time(),
+ 'donations' => [],
+ ]);
+}
+
+$url = 'https://api.stripe.com/v1/checkout/sessions?' . http_build_query([
+ 'limit' => $limit,
+ 'status' => 'complete',
+]);
+
+$ch = curl_init($url);
+
+curl_setopt_array($ch, [
+ CURLOPT_HTTPGET => true,
+ CURLOPT_HTTPHEADER => [
+ 'Authorization: Bearer ' . $stripeSecretKey,
+ ],
+ CURLOPT_RETURNTRANSFER => true,
+ CURLOPT_TIMEOUT => 20,
+]);
+
+$response = curl_exec($ch);
+$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
+$curlError = $response === false ? curl_error($ch) : '';
+
+curl_close($ch);
+
+$data = json_decode((string) $response, true);
+
+if ($curlError !== '' || $statusCode < 200 || $statusCode >= 300 || !is_array($data)) {
+ if (is_file($outputFile)) {
+ send_file($outputFile);
+ }
+
+ send_json([
+ 'ok' => true,
+ 'updated_at' => time(),
+ 'donations' => [],
+ ]);
+}
+
+$donations = [];
+
+foreach (($data['data'] ?? []) as $session) {
+ if (($session['status'] ?? '') !== 'complete') {
+ continue;
+ }
+
+ $amountTotal = (int) ($session['amount_total'] ?? 0);
+ $currency = strtolower((string) ($session['currency'] ?? 'eur'));
+ $created = (int) ($session['created'] ?? time());
+
+ if ($amountTotal <= 0 || !in_array($currency, ['eur', 'usd'], true)) {
+ continue;
+ }
+
+ $donations[] = [
+ 'id' => $session['id'] ?? '',
+ 'amount' => $amountTotal / 100,
+ 'currency' => $currency,
+ 'created' => $created,
+ ];
+}
+
+$output = [
+ 'ok' => true,
+ 'updated_at' => time(),
+ 'donations' => $donations,
+];
+
+file_put_contents(
+ $outputFile,
+ json_encode($output, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES),
+ LOCK_EX
+);
+
+send_json($output);
diff --git a/stripe-donations.json b/stripe-donations.json
new file mode 100644
index 00000000..e69de29b