Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Prevent raising an error for `AUTHORIZATION_SUCESS` in case parallel actions on transaction are performed (#17092)
Iga Karbowiak055da7a6a0bd
diff --git a/saleor/graphql/payment/mutations/transaction/transaction_event_report.py b/saleor/graphql/payment/mutations/transaction/transaction_event_report.pyindex 58a0632871..8bae95af6d 100644--- a/saleor/graphql/payment/mutations/transaction/transaction_event_report.py+++ b/saleor/graphql/payment/mutations/transaction/transaction_event_report.py@@ -356,6 +356,12 @@ class TransactionEventReport(ModelMutation):# The mutation can be called multiple times by the app. That can cause a# thread race. We need to be sure, that we will always create a single event# on our side for specific action.+ _transaction = (+ payment_models.TransactionItem.objects.filter(pk=transaction.pk)+ .select_for_update(of=("self",))+ .first()+ )+existing_event = get_already_existing_event(transaction_event)if existing_event and existing_event.amount != transaction_event.amount:error_code = TransactionEventReportErrorCode.INCORRECT_DETAILS.valuediff --git a/saleor/payment/utils.py b/saleor/payment/utils.pyindex c9898d292e..1e36740a86 100644--- a/saleor/payment/utils.py+++ b/saleor/payment/utils.py@@ -1140,6 +1140,11 @@ def _create_event_from_response(related_granted_refund_id=related_granted_refund_id,)with transaction.atomic():+ _transaction = (+ TransactionItem.objects.filter(pk=transaction_id)+ .select_for_update(of=("self",))+ .first()+ )event, error_msg = deduplicate_event(event, app)if error_msg:return None, error_msg