forked from CGM_Public/pretix_original
Payment provider API: Add payment argument to render_invoice_text and order_pending_mail_render
This commit is contained in:
@@ -296,11 +296,12 @@ class BasePaymentProvider:
|
|||||||
"""
|
"""
|
||||||
return ""
|
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.
|
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
|
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:
|
if order.status == Order.STATUS_PAID:
|
||||||
return pgettext_lazy('invoice', 'The payment for this invoice has already been received.')
|
return pgettext_lazy('invoice', 'The payment for this invoice has already been received.')
|
||||||
@@ -545,13 +546,14 @@ class BasePaymentProvider:
|
|||||||
"""
|
"""
|
||||||
return None
|
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
|
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
|
email. You can return a string from this method if you want to add additional
|
||||||
information to this email.
|
information to this email.
|
||||||
|
|
||||||
:param order: The order object
|
:param order: The order object
|
||||||
|
:param payment: The payment object
|
||||||
"""
|
"""
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import inspect
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import urllib.error
|
import urllib.error
|
||||||
@@ -53,7 +54,10 @@ def build_invoice(invoice: Invoice) -> Invoice:
|
|||||||
additional = invoice.event.settings.get('invoice_additional_text', as_type=LazyI18nString)
|
additional = invoice.event.settings.get('invoice_additional_text', as_type=LazyI18nString)
|
||||||
footer = invoice.event.settings.get('invoice_footer_text', as_type=LazyI18nString)
|
footer = invoice.event.settings.get('invoice_footer_text', as_type=LazyI18nString)
|
||||||
if open_payment and open_payment.payment_provider:
|
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:
|
elif invoice.order.status == Order.STATUS_PAID:
|
||||||
payment = pgettext('invoice', 'The payment for this invoice has already been received.')
|
payment = pgettext('invoice', 'The payment for this invoice has already been received.')
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import inspect
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
from collections import Counter, namedtuple
|
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,
|
def _order_placed_email(event: Event, order: Order, pprov: BasePaymentProvider, email_template, log_entry: str,
|
||||||
invoice):
|
invoice, payment: OrderPayment):
|
||||||
try:
|
try:
|
||||||
invoice_name = order.invoice_address.name
|
invoice_name = order.invoice_address.name
|
||||||
invoice_company = order.invoice_address.company
|
invoice_company = order.invoice_address.company
|
||||||
@@ -679,7 +680,10 @@ def _order_placed_email(event: Event, order: Order, pprov: BasePaymentProvider,
|
|||||||
invoice_company = ""
|
invoice_company = ""
|
||||||
|
|
||||||
if pprov:
|
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:
|
else:
|
||||||
payment_info = None
|
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 = event.settings.mail_send_order_placed_attendee
|
||||||
email_attendees_template = event.settings.mail_text_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:
|
if email_attendees:
|
||||||
for p in order.positions.all():
|
for p in order.positions.all():
|
||||||
if p.addon_to_id is None and p.attendee_email and p.attendee_email != order.email:
|
if p.addon_to_id is None and p.attendee_email and p.attendee_email != order.email:
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ class BankTransfer(BasePaymentProvider):
|
|||||||
def checkout_confirm_render(self, request):
|
def checkout_confirm_render(self, request):
|
||||||
return self.payment_form_render(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')
|
template = get_template('pretixplugins/banktransfer/email/order_pending.txt')
|
||||||
bankdetails = []
|
bankdetails = []
|
||||||
if self.settings.get('bank_details_type') == 'sepa':
|
if self.settings.get('bank_details_type') == 'sepa':
|
||||||
@@ -189,6 +189,7 @@ class BankTransfer(BasePaymentProvider):
|
|||||||
'event': self.event,
|
'event': self.event,
|
||||||
'order': order,
|
'order': order,
|
||||||
'code': self._code(order),
|
'code': self._code(order),
|
||||||
|
'amount': payment.amount,
|
||||||
'details': textwrap.indent(''.join(str(i) for i in bankdetails), ' '),
|
'details': textwrap.indent(''.join(str(i) for i in bankdetails), ' '),
|
||||||
}
|
}
|
||||||
return template.render(ctx)
|
return template.render(ctx)
|
||||||
|
|||||||
@@ -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.
|
Please transfer the full amount to the following bank account.
|
||||||
|
|
||||||
Reference: {{ code }}
|
Reference: {{ code }}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
{% if settings.bank_details_type == "sepa" %}
|
{% if settings.bank_details_type == "sepa" %}
|
||||||
<div class="col-md-3 col-sm-6 hidden-xs text-center">
|
<div class="col-md-3 col-sm-6 hidden-xs text-center">
|
||||||
BezahlCode<br>
|
BezahlCode<br>
|
||||||
<a href="bank://singlepaymentsepa?name={{ settings.bank_details_sepa_name|urlencode }}&iban={{ settings.bank_details_sepa_iban }}&bic={{ settings.bank_details_sepa_bic }}&amount={{ order.total|commadecimal }}&reason={{ code }}¤cy={{ event.currency }}">
|
<a href="bank://singlepaymentsepa?name={{ settings.bank_details_sepa_name|urlencode }}&iban={{ settings.bank_details_sepa_iban }}&bic={{ settings.bank_details_sepa_bic }}&amount={{ amount|commadecimal }}&reason={{ code }}¤cy={{ event.currency }}">
|
||||||
<script type="text/plain" data-size="150" data-replace-with-qr>bank://singlepaymentsepa?name={{ settings.bank_details_sepa_name|urlencode }}&iban={{ settings.bank_details_sepa_iban }}&bic={{ settings.bank_details_sepa_bic }}&amount={{ amount|commadecimal }}&reason={{ code }}¤cy={{ event.currency }}</script>
|
<script type="text/plain" data-size="150" data-replace-with-qr>bank://singlepaymentsepa?name={{ settings.bank_details_sepa_name|urlencode }}&iban={{ settings.bank_details_sepa_iban }}&bic={{ settings.bank_details_sepa_bic }}&amount={{ amount|commadecimal }}&reason={{ code }}¤cy={{ event.currency }}</script>
|
||||||
</a>
|
</a>
|
||||||
<p> </p>
|
<p> </p>
|
||||||
@@ -54,7 +54,7 @@ SCT
|
|||||||
</div>
|
</div>
|
||||||
<div class="visible-xs-block text-center">
|
<div class="visible-xs-block text-center">
|
||||||
<p>
|
<p>
|
||||||
<a href="bank://singlepaymentsepa?name={{ settings.bank_details_sepa_name|urlencode }}&iban={{ settings.bank_details_sepa_iban }}&bic={{ settings.bank_details_sepa_bic }}&amount={{ order.total|commadecimal }}&reason={{ code }}¤cy={{ event.currency }}" class="btn btn-default">
|
<a href="bank://singlepaymentsepa?name={{ settings.bank_details_sepa_name|urlencode }}&iban={{ settings.bank_details_sepa_iban }}&bic={{ settings.bank_details_sepa_bic }}&amount={{ amount|commadecimal }}&reason={{ code }}¤cy={{ event.currency }}" class="btn btn-default">
|
||||||
{% trans "Open banking app" %}
|
{% trans "Open banking app" %}
|
||||||
</a><br>
|
</a><br>
|
||||||
<small>{% trans "Requires that the app supports BezahlCode" %}</small>
|
<small>{% trans "Requires that the app supports BezahlCode" %}</small>
|
||||||
|
|||||||
Reference in New Issue
Block a user