Public Access
Mise en veille PayPal, synchro solde OpenRouter et modale de rejet financier
Build and Push Docker Image / build-and-push (push) Successful in 34s
Build and Push Docker Image / build-and-push (push) Successful in 34s
This commit is contained in:
1 parent
2ea18701b5
commit
3e140d7d6f
8 files changed
+380
-293
No files matched your search
+49
-14
@@ -1,19 +1,54 @@
|
||||
import os
|
||||
from fasthtml.common import *
|
||||
|
||||
def render_paypal_donation_widget():
|
||||
"""Génère le bouton de don PayPal pour l'interface sidebar avec le lien configuré."""
|
||||
def render_paypal_recharge_widget(montant_usd: float = 10.00):
|
||||
client_id = os.getenv("PAYPAL_CLIENT_ID")
|
||||
|
||||
# Récupération depuis l'environnement ou utilisation directe de votre lien officiel
|
||||
paypal_url = os.environ.get("PAYPAL_DONATION_LINK", "https://www.paypal.com/donate/?hosted_button_id=2B6T9UESCN2W6")
|
||||
if not client_id:
|
||||
return Div("Clé PayPal manquante dans .env", style="color: red;")
|
||||
|
||||
script_paypal = Script(src=f"https://www.paypal.com/sdk/js?client-id={client_id}¤cy=USD")
|
||||
container_id = f"paypal-button-container-{str(montant_usd).replace('.', '')}"
|
||||
|
||||
return Div(
|
||||
A(
|
||||
"☕ Soutenir l'hébergeur",
|
||||
href=paypal_url,
|
||||
target="_blank",
|
||||
cls="export-btn",
|
||||
style="text-align: center; color: #00e5ff; border-color: #00e5ff; display: block; text-decoration: none; margin-top: 10px;"
|
||||
),
|
||||
style="margin-top: 10px;"
|
||||
)
|
||||
script_logique = Script(f"""
|
||||
function chargerBoutonPayPal() {{
|
||||
if (typeof paypal !== 'undefined') {{
|
||||
paypal.Buttons({{
|
||||
createOrder: function(data, actions) {{
|
||||
return actions.order.create({{
|
||||
purchase_units: [{{ amount: {{ value: '{montant_usd}' }} }}]
|
||||
}});
|
||||
}},
|
||||
onApprove: function(data, actions) {{
|
||||
return actions.order.capture().then(function(details) {{
|
||||
alert('Paiement Sandbox validé par ' + details.payer.name.given_name + ' !');
|
||||
// Fermer la fenêtre après paiement
|
||||
document.getElementById('modal-recharge-paypal').style.display = 'none';
|
||||
}});
|
||||
}}
|
||||
}}).render('#{container_id}');
|
||||
}} else {{
|
||||
setTimeout(chargerBoutonPayPal, 100);
|
||||
}}
|
||||
}}
|
||||
chargerBoutonPayPal();
|
||||
""")
|
||||
|
||||
# La boîte centrale de paiement
|
||||
paypal_box = Div(
|
||||
H3(f"Recharge de {montant_usd}$", style="color: #fff; margin-top: 0; margin-bottom: 15px; font-size: 1.2em; text-align: center;"),
|
||||
Div(id=container_id, style="min-height: 150px; width: 100%;"),
|
||||
Button("Fermer", type="button", onclick="document.getElementById('modal-recharge-paypal').style.display='none'", cls="btn-submit", style="background-color: #555; width: 100%; margin-top: 15px; border-radius: 8px; font-size: 0.9em;"),
|
||||
style="background: #1a1a1a; padding: 25px; border-radius: 12px; border: 2px solid #00e5ff; width: 400px; max-width: 90vw; box-shadow: 0 10px 30px rgba(0,0,0,0.8);"
|
||||
)
|
||||
|
||||
# L'arrière-plan sombre (overlay)
|
||||
modal_overlay = Div(
|
||||
script_paypal,
|
||||
paypal_box,
|
||||
script_logique,
|
||||
id="modal-recharge-paypal",
|
||||
style="display: none; position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0,0,0,0.8); align-items: center; justify-content: center; z-index: 10000;"
|
||||
)
|
||||
|
||||
return modal_overlay
|
||||
Reference in new issue
Block a user