-
Notifications
You must be signed in to change notification settings - Fork 9
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
Update the payment due date for banktransfers, when the order is changed #22
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,23 +2,22 @@ | |
import time | ||
from collections import OrderedDict | ||
|
||
import requests | ||
from django import forms | ||
from django.dispatch import receiver | ||
from django.utils.translation import gettext_lazy as _ | ||
from django_scopes import scopes_disabled | ||
|
||
from pretix.base.forms import SecretKeySettingsField | ||
from pretix.base.models import Event_SettingsStore | ||
from pretix.base.settings import GlobalSettingsObject, settings_hierarkey | ||
from pretix.base.models import Event_SettingsStore, Order, OrderPayment | ||
from pretix.base.settings import settings_hierarkey | ||
from pretix.base.signals import ( | ||
logentry_display, periodic_task, register_global_settings, | ||
register_payment_providers, | ||
register_payment_providers, order_modified, | ||
) | ||
from pretix.helpers.urls import build_absolute_uri | ||
|
||
from .forms import MollieKeyValidator | ||
from .utils import refresh_mollie_token | ||
from .tasks import extend_payment_deadline | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
@@ -101,3 +100,14 @@ def refresh_mollie_tokens(sender, **kwargs): | |
if rt not in seen: | ||
refresh_mollie_token(es.object, True) | ||
seen.add(rt) | ||
|
||
|
||
@receiver(order_modified, dispatch_uid='mollie_order_modified') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pretix.base.services.orders.extend_order does not seem to trigger this signal There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, that kinda makes this whole thing obsolete... I guess we could either introduce a new |
||
def order_placed(order, **kwargs): | ||
payment = order.payments.last() | ||
if ( | ||
order.status == Order.STATUS_PENDING | ||
and payment.provider == 'mollie_banktransfer' | ||
and payment.state in (OrderPayment.PAYMENT_STATE_CREATED, OrderPayment.PAYMENT_STATE_PENDING) | ||
): | ||
extend_payment_deadline.apply_async(args=(payment.pk,)) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from django_scopes import scopes_disabled | ||
|
||
from pretix.base.models import OrderPayment | ||
from pretix.celery_app import app | ||
|
||
|
||
@app.task() | ||
@scopes_disabled() | ||
def extend_payment_deadline(payment): | ||
payment = OrderPayment.objects.get(pk=payment) | ||
pprov = payment.payment_provider | ||
|
||
pprov.update_payment_due(payment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we create a log entry for this as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, can do.