diff --git a/src/pretix/base/payment.py b/src/pretix/base/payment.py index fa1204523..7c4094870 100644 --- a/src/pretix/base/payment.py +++ b/src/pretix/base/payment.py @@ -296,11 +296,12 @@ class BasePaymentProvider: """ return "" - def render_invoice_text(self, order: Order) -> str: + def render_invoice_text(self, order: Order, payment: OrderPayment) -> str: """ This is called when an invoice for an order with this payment provider is generated. The default implementation returns the content of the _invoice_text configuration - variable (an I18nString), or an empty string if unconfigured. + variable (an I18nString), or an empty string if unconfigured. For paid orders, the + default implementation always renders a string stating that the invoice is already paid. """ if order.status == Order.STATUS_PAID: return pgettext_lazy('invoice', 'The payment for this invoice has already been received.') @@ -545,13 +546,14 @@ class BasePaymentProvider: """ return None - def order_pending_mail_render(self, order: Order) -> str: + def order_pending_mail_render(self, order: Order, payment: OrderPayment) -> str: """ After the user has submitted their order, they will receive a confirmation email. You can return a string from this method if you want to add additional information to this email. :param order: The order object + :param payment: The payment object """ return "" diff --git a/src/pretix/base/services/invoices.py b/src/pretix/base/services/invoices.py index 979148de5..b1791e3f8 100644 --- a/src/pretix/base/services/invoices.py +++ b/src/pretix/base/services/invoices.py @@ -1,3 +1,4 @@ +import inspect import json import logging import urllib.error @@ -53,7 +54,10 @@ def build_invoice(invoice: Invoice) -> Invoice: additional = invoice.event.settings.get('invoice_additional_text', as_type=LazyI18nString) footer = invoice.event.settings.get('invoice_footer_text', as_type=LazyI18nString) if open_payment and open_payment.payment_provider: - payment = open_payment.payment_provider.render_invoice_text(invoice.order) + if 'payment' in inspect.signature(open_payment.payment_provider.render_invoice_text).parameters: + payment = open_payment.payment_provider.render_invoice_text(invoice.order, open_payment) + else: + payment = open_payment.payment_provider.render_invoice_text(invoice.order) elif invoice.order.status == Order.STATUS_PAID: payment = pgettext('invoice', 'The payment for this invoice has already been received.') else: diff --git a/src/pretix/base/services/orders.py b/src/pretix/base/services/orders.py index fbf8efa12..5797aa5ee 100644 --- a/src/pretix/base/services/orders.py +++ b/src/pretix/base/services/orders.py @@ -1,3 +1,4 @@ +import inspect import json import logging from collections import Counter, namedtuple @@ -670,7 +671,7 @@ def _create_order(event: Event, email: str, positions: List[CartPosition], now_d def _order_placed_email(event: Event, order: Order, pprov: BasePaymentProvider, email_template, log_entry: str, - invoice): + invoice, payment: OrderPayment): try: invoice_name = order.invoice_address.name invoice_company = order.invoice_address.company @@ -679,7 +680,10 @@ def _order_placed_email(event: Event, order: Order, pprov: BasePaymentProvider, invoice_company = "" if pprov: - payment_info = str(pprov.order_pending_mail_render(order)) + if 'payment' in inspect.signature(pprov.order_pending_mail_render).parameters: + payment_info = str(pprov.order_pending_mail_render(order, payment)) + else: + payment_info = str(pprov.order_pending_mail_render(order)) else: payment_info = None @@ -825,7 +829,7 @@ def _perform_order(event: Event, payment_provider: str, position_ids: List[str], email_attendees = event.settings.mail_send_order_placed_attendee email_attendees_template = event.settings.mail_text_order_placed_attendee - _order_placed_email(event, order, pprov, email_template, log_entry, invoice) + _order_placed_email(event, order, pprov, email_template, log_entry, invoice, payment) if email_attendees: for p in order.positions.all(): if p.addon_to_id is None and p.attendee_email and p.attendee_email != order.email: diff --git a/src/pretix/plugins/banktransfer/payment.py b/src/pretix/plugins/banktransfer/payment.py index 499cf4d37..6408ebe01 100644 --- a/src/pretix/plugins/banktransfer/payment.py +++ b/src/pretix/plugins/banktransfer/payment.py @@ -172,7 +172,7 @@ class BankTransfer(BasePaymentProvider): def checkout_confirm_render(self, request): return self.payment_form_render(request) - def order_pending_mail_render(self, order) -> str: + def order_pending_mail_render(self, order, payment) -> str: template = get_template('pretixplugins/banktransfer/email/order_pending.txt') bankdetails = [] if self.settings.get('bank_details_type') == 'sepa': @@ -189,6 +189,7 @@ class BankTransfer(BasePaymentProvider): 'event': self.event, 'order': order, 'code': self._code(order), + 'amount': payment.amount, 'details': textwrap.indent(''.join(str(i) for i in bankdetails), ' '), } return template.render(ctx) diff --git a/src/pretix/plugins/banktransfer/templates/pretixplugins/banktransfer/email/order_pending.txt b/src/pretix/plugins/banktransfer/templates/pretixplugins/banktransfer/email/order_pending.txt index 0c9cb390e..da176985b 100644 --- a/src/pretix/plugins/banktransfer/templates/pretixplugins/banktransfer/email/order_pending.txt +++ b/src/pretix/plugins/banktransfer/templates/pretixplugins/banktransfer/email/order_pending.txt @@ -1,4 +1,4 @@ -{% load i18n %}{% load l10n %}{% load money %}{% blocktrans with bank=details|safe total=order.total|money:event.currency %} +{% load i18n %}{% load l10n %}{% load money %}{% blocktrans with bank=details|safe total=amount|money:event.currency %} Please transfer the full amount to the following bank account. Reference: {{ code }} diff --git a/src/pretix/plugins/banktransfer/templates/pretixplugins/banktransfer/pending.html b/src/pretix/plugins/banktransfer/templates/pretixplugins/banktransfer/pending.html index 6143369ea..65e99e43e 100644 --- a/src/pretix/plugins/banktransfer/templates/pretixplugins/banktransfer/pending.html +++ b/src/pretix/plugins/banktransfer/templates/pretixplugins/banktransfer/pending.html @@ -31,7 +31,7 @@ {% if settings.bank_details_type == "sepa" %}

- + {% trans "Open banking app" %}
{% trans "Requires that the app supports BezahlCode" %}