PayPal: Fixed URL names and exception handling

This commit is contained in:
Raphael Michel
2015-06-24 17:18:28 +02:00
parent fa642ddffe
commit 224eaeee48
2 changed files with 18 additions and 14 deletions

View File

@@ -108,6 +108,7 @@ class Paypal(BasePaymentProvider):
return self._create_payment(request, payment) return self._create_payment(request, payment)
def _create_payment(self, request, payment): def _create_payment(self, request, payment):
try:
if payment.create(): if payment.create():
if payment.state not in ('created', 'approved', 'pending'): if payment.state not in ('created', 'approved', 'pending'):
messages.error(request, _('We had trouble communicating with PayPal')) messages.error(request, _('We had trouble communicating with PayPal'))
@@ -121,6 +122,9 @@ class Paypal(BasePaymentProvider):
else: else:
messages.error(request, _('We had trouble communicating with PayPal')) messages.error(request, _('We had trouble communicating with PayPal'))
logger.error('Error on creating payment: ' + str(payment.error)) logger.error('Error on creating payment: ' + str(payment.error))
except Exception as e:
messages.error(request, _('We had trouble communicating with PayPal'))
logger.error('Error on creating payment: ' + str(e))
def checkout_confirm_render(self, request) -> str: def checkout_confirm_render(self, request) -> str:
""" """

View File

@@ -5,8 +5,8 @@ from .views import success, abort, retry
urlpatterns = [ urlpatterns = [
url(r'^paypal/', include([ url(r'^paypal/', include([
url(r'^abort/$', abort, name='paypal.abort'), url(r'^abort/$', abort, name='abort'),
url(r'^return/$', success, name='paypal.return'), url(r'^return/$', success, name='return'),
url(r'^retry/(?P<order>[^/]+)/', retry, name='paypal.retry') url(r'^retry/(?P<order>[^/]+)/', retry, name='retry')
])), ])),
] ]