Skip to content

Commit

Permalink
Some payment types don't need to be captured
Browse files Browse the repository at this point in the history
  • Loading branch information
Daverball committed Feb 11, 2025
1 parent 3ba40b1 commit 0fd8e79
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/onegov/pay/models/payment_providers/worldline_saferpay.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,8 @@ def charge(

# ensure the transaction can be settled
tx = self.client.assert_transaction(token)
tx.raise_if_cannot_be_captured()
if tx.type != 'PAYMENT' or tx.status not in ('AUTHORIZED', 'CAPTURED'):
raise SaferpayPaymentError('Invalid transaction type')
if (
tx.amount.currency_code != currency
or tx.amount.value != round(amount * 100)
Expand All @@ -681,11 +682,13 @@ def charge(
remote_id=tx.id,
order_id=tx.order_id,
six_transaction_reference=tx.six_transaction_reference,
state='open'
state='paid' if tx.status == 'CAPTURED' else 'open'
)

assert self.customer_id is not None
SaferpayCaptureManager.capture_charge(self.client, tx)
if tx.status == 'AUTHORIZED':
# we need to capture the charge
assert self.customer_id is not None
SaferpayCaptureManager.capture_charge(self.client, tx)

# we do *not* want to lose this information, so even though the
# caller should make sure the payment is stored, we make sure
Expand Down

0 comments on commit 0fd8e79

Please sign in to comment.