Skip to content

Commit

Permalink
Make name and email acquisition more reliable
Browse files Browse the repository at this point in the history
  • Loading branch information
kvdveer committed Sep 17, 2024
1 parent d3e51db commit 9fc6fe9
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -291,14 +291,17 @@ def _paypal_transaction_to_lines(self, data):
transaction_note = transaction.get("transaction_note")
invoice = transaction.get("invoice_id")
payer_name = payer.get("payer_name", {})
payer_email = payer_name.get("email_address")
payer_email = payer_name.get("email_address") or payer.get("email_address")
payer_full_name = payer_name.get("full_name") or payer_name.get(
"alternate_full_name"
)
if invoice:
invoice = _("Invoice %s") % invoice
note = transaction_id
if transaction_subject or transaction_note:
note = f"{note}: {transaction_subject or transaction_note}"
if payer_email:
note += " (%s)" % payer_email
if payer_email or payer_full_name:
note += f" ({payer_email or payer_full_name})"
unique_import_id = f"{transaction_id}-{int(date.timestamp())}"
name = (
invoice
Expand All @@ -315,9 +318,6 @@ def _paypal_transaction_to_lines(self, data):
"unique_import_id": unique_import_id,
"raw_data": transaction,
}
payer_full_name = payer_name.get("full_name") or payer_name.get(
"alternate_full_name"
)
if payer_full_name:
line.update({"partner_name": payer_full_name})
lines = [line]
Expand Down

0 comments on commit 9fc6fe9

Please sign in to comment.