mirror of
https://github.com/pretix/pretix.git
synced 2026-09-13 16:14:40 +00:00
cleanup abort_pending_allowed methods
This commit is contained in:
@@ -330,17 +330,22 @@ class BasePaymentProvider:
|
||||
payment method. This returns ``False`` by default which is no guarantee that
|
||||
aborting a pending payment can never happen, it just hides the frontend button
|
||||
to avoid users accidentally committing double payments.
|
||||
If the decision doesn't depend on the specific payment, then only implementing
|
||||
``abort_pending_allowed`` is enough, ``payment_abort_pending_allowed(payment: OrderPayment)``
|
||||
is expected to take this into account.
|
||||
As a consumer only evaluate ``payment_abort_pending_allowed(payment: OrderPayment)``
|
||||
to check if aborting this pending payment is possible.
|
||||
"""
|
||||
return False
|
||||
|
||||
def abort_pending_payment_allowed(self, payment) -> bool:
|
||||
def payment_abort_pending_allowed(self, payment: OrderPayment) -> bool:
|
||||
"""
|
||||
Whether this specific payment can be aborted in pending state or not.
|
||||
If both ``abort_pending_allowed`` and ``abort_pending_payment_allowed`` are True,
|
||||
then the frontend button will be shown to users.
|
||||
This returns ``True`` by default, which makes implementing this method optional.
|
||||
Whether or not a user can abort a payment in pending state to switch to another
|
||||
payment method. This returns ``self.abort_pending_allowed`` by default which is
|
||||
no guarantee that aborting a pending payment can never happen, it just hides the
|
||||
frontend button to avoid users accidentally committing double payments.
|
||||
"""
|
||||
return True
|
||||
return True and self.abort_pending_allowed
|
||||
|
||||
@property
|
||||
def requires_invoice_immediately(self):
|
||||
@@ -1030,7 +1035,7 @@ class BasePaymentProvider:
|
||||
"""
|
||||
|
||||
if payment.state == OrderPayment.PAYMENT_STATE_PENDING:
|
||||
if not (self.abort_pending_allowed and self.abort_pending_payment_allowed(payment)):
|
||||
if not self.payment_abort_pending_allowed(payment):
|
||||
raise PaymentException(_(
|
||||
"This payment is already being processed and can not be canceled any more."
|
||||
))
|
||||
|
||||
Reference in New Issue
Block a user