mirror of
https://github.com/pretix/pretix.git
synced 2026-05-03 14:54:04 +00:00
PayPal: Event-independent webhooks
This commit is contained in:
@@ -12,7 +12,9 @@ from pretix.base.models import Order, Quota, RequiredAction
|
||||
from pretix.base.payment import BasePaymentProvider, PaymentException
|
||||
from pretix.base.services.mail import SendMailException
|
||||
from pretix.base.services.orders import mark_order_paid, mark_order_refunded
|
||||
from pretix.helpers.urls import build_absolute_uri as build_global_uri
|
||||
from pretix.multidomain.urlreverse import build_absolute_uri
|
||||
from pretix.plugins.paypal.models import ReferencedPayPalObject
|
||||
|
||||
logger = logging.getLogger('pretix.plugins.paypal')
|
||||
|
||||
@@ -55,7 +57,7 @@ class Paypal(BasePaymentProvider):
|
||||
return "<div class='alert alert-info'>%s<br /><code>%s</code></div>" % (
|
||||
_('Please configure a PayPal Webhook to the following endpoint in order to automatically cancel orders '
|
||||
'when payments are refunded externally.'),
|
||||
build_absolute_uri(self.event, 'plugins:paypal:webhook')
|
||||
build_global_uri('plugins:paypal:webhook')
|
||||
)
|
||||
|
||||
def init_api(self):
|
||||
@@ -154,6 +156,7 @@ class Paypal(BasePaymentProvider):
|
||||
|
||||
self.init_api()
|
||||
payment = paypalrestsdk.Payment.find(request.session.get('payment_paypal_id'))
|
||||
ReferencedPayPalObject.objects.get_or_create(order=order, reference=payment.id)
|
||||
if str(payment.transactions[0].amount.total) != str(order.total) or payment.transactions[0].amount.currency != \
|
||||
self.event.currency:
|
||||
logger.error('Value mismatch: Order %s vs payment %s' % (order.id, str(payment)))
|
||||
|
||||
Reference in New Issue
Block a user