Payment provider API: Add method cancel_payment

This commit is contained in:
Raphael Michel
2019-11-14 10:39:54 +01:00
parent b876293453
commit 339d7f06ed
7 changed files with 168 additions and 47 deletions
+11
View File
@@ -654,6 +654,17 @@ class BasePaymentProvider:
"""
return False
def cancel_payment(self, payment: OrderPayment):
"""
Will be called to cancel a payment. The default implementation just sets the payment state to canceled,
but in some cases you might want to notify an external provider.
On success, you should set ``payment.state = OrderPayment.PAYMENT_STATE_CANCELED`` (or call the super method).
On failure, you should raise a PaymentException.
"""
payment.state = OrderPayment.PAYMENT_STATE_CANCELED
payment.save()
def execute_refund(self, refund: OrderRefund):
"""
Will be called to execute an refund. Note that refunds have an amount property and can be partial.