Added name to paypal order

This commit is contained in:
Joan
2025-09-17 19:27:41 +02:00
parent b02e327aaf
commit 8bcf8c8819
2 changed files with 4 additions and 3 deletions

View File

@@ -527,9 +527,10 @@ async def confirm_callback(update: Update, context: CallbackContext):
await query.answer("Error: Ha habido un problema desconocido, contacta con el administrador.", show_alert=True) await query.answer("Error: Ha habido un problema desconocido, contacta con el administrador.", show_alert=True)
return return
user_name = participant['user_name']
total_price = len(reserved_numbers) * price_per_number total_price = len(reserved_numbers) * price_per_number
paypal_link, invoice_id = create_paypal_order(get_paypal_access_token(), total_price, raffle_info['id'], reserved_numbers) paypal_link, invoice_id = create_paypal_order(get_paypal_access_token(), total_price, raffle_info['id'], reserved_numbers, user_name)
mark_reservation_pending(participant_db_id, invoice_id) mark_reservation_pending(participant_db_id, invoice_id)
# Log the PayPal link for debugging # Log the PayPal link for debugging

View File

@@ -412,7 +412,7 @@ def get_paypal_access_token():
store_paypal_access_token(response.json()["access_token"], response.json()["expires_in"]) store_paypal_access_token(response.json()["access_token"], response.json()["expires_in"])
return response.json()["access_token"] return response.json()["access_token"]
def create_paypal_order(access_token, value, raffle_id, numbers): def create_paypal_order(access_token, value, raffle_id, numbers, user_name):
url = f"{PAYPAL_URL}/v2/checkout/orders" url = f"{PAYPAL_URL}/v2/checkout/orders"
headers = { headers = {
"Content-Type": "application/json", "Content-Type": "application/json",
@@ -423,7 +423,7 @@ def create_paypal_order(access_token, value, raffle_id, numbers):
"purchase_units": [ "purchase_units": [
{ {
"amount": {"currency_code": "EUR", "value": f"{value:.2f}"}, "amount": {"currency_code": "EUR", "value": f"{value:.2f}"},
"description": f"Donación para participar en el sorteo de HomeLabs Club (ID: {raffle_id}, Números: {numbers})", "description": f"Donación para participar en el sorteo de HomeLabs Club (ID: {raffle_id}, Números: {numbers}, Usuario: {user_name})",
} }
], ],
"application_context": { "application_context": {