Skip to content

Commit

Permalink
πŸ› fix attachment invoice (#5711)
Browse files Browse the repository at this point in the history
  • Loading branch information
matusdrobuliak66 authored Apr 23, 2024
1 parent c26d3d6 commit 3f7e26f
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,14 @@ async def _create_user_email(
if product.bcc_email:
msg["Bcc"] = product.bcc_email

# Invoice attachment
# Body
text_template = env.get_template("notify_payments.txt")
msg.set_content(text_template.render(data))

html_template = env.get_template("notify_payments.html")
msg.add_alternative(html_template.render(data), subtype="html")

# Invoice attachment (It is important that attachment is added after body)
if pdf_response := await _get_invoice_pdf(payment.invoice_pdf_url):
match = invoice_file_name_pattern.search(
pdf_response.headers["content-disposition"]
Expand All @@ -205,12 +212,6 @@ async def _create_user_email(
attachment["Content-Disposition"] = f"attachment; filename={_file_name}"
msg.attach(attachment)

# Body
text_template = env.get_template("notify_payments.txt")
msg.set_content(text_template.render(data))

html_template = env.get_template("notify_payments.html")
msg.add_alternative(html_template.render(data), subtype="html")
return msg


Expand Down

0 comments on commit 3f7e26f

Please sign in to comment.