Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not override info_data on potentially duplicate payment attempt #2

Merged
merged 1 commit into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions pretix_authorizenet/payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,7 @@ def execute_payment(self, request: HttpRequest, payment: OrderPayment):
r.raise_for_status()
resp = json.loads(r.content.decode("utf-8-sig"))

payment.info_data = resp
payment.save(update_fields=["info"])
payment.order.log_action("pretix_authorizenet.result", data=resp)
if resp["messages"]["resultCode"] == "Ok" and resp["transactionResponse"]["responseCode"] == "1":
ReferencedAuthorizeNetObject.objects.create(
order=payment.order,
Expand Down
12 changes: 8 additions & 4 deletions pretix_authorizenet/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,14 @@ def signal_process_response(

@receiver(signal=logentry_display, dispatch_uid="authorizenet_logentry_display")
def pretixcontrol_logentry_display(sender, logentry, **kwargs):
if logentry.action_type != "pretix_authorizenet.event":
if logentry.action_type not in ("pretix_authorizenet.event", "pretix_authorizenet.result"):
return

data = json.loads(logentry.data)
event_type = data.get("eventType", "").replace("net.authorize.", "")
if logentry.action_type == "pretix_authorizenet.event":
data = json.loads(logentry.data)
event_type = data.get("eventType", "").replace("net.authorize.", "")

return _("Authorize.Net reported an event: {}").format(event_type)
elif logentry.action_type == "pretix_authorizenet.result":
return _("Authorize.Net result received.")

return _("Authorize.Net reported an event: {}").format(event_type)
Loading