From 887f9e719f9043f31a6c4a08c4f85f11bfa79fd3 Mon Sep 17 00:00:00 2001 From: Goury Date: Sat, 6 Jul 2024 13:41:25 +0300 Subject: [PATCH] fix #411 Manually following process URL results in a crash --- payments/paypal/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/payments/paypal/__init__.py b/payments/paypal/__init__.py index c4fe30c3e..b0f36a16b 100644 --- a/payments/paypal/__init__.py +++ b/payments/paypal/__init__.py @@ -8,7 +8,7 @@ from functools import wraps import requests -from django.http import HttpResponseForbidden +from django.http import HttpResponseForbidden, HttpResponseBadRequest from django.shortcuts import redirect from django.utils import timezone from requests.exceptions import HTTPError @@ -267,7 +267,10 @@ def create_payment(self, payment, extra_data=None): def execute_payment(self, payment, payer_id): post = {"payer_id": payer_id} links = self._get_links(payment) - execute_url = links["execute"]["href"] + try: + execute_url = links["execute"]["href"] + except KeyError: + return HttpResponseBadRequest() return self.post(payment, execute_url, data=post) def get_amount_data(self, payment, amount=None):