forked from CGM_Public/pretix_original
Stripe and PayPal: Issue warning on payments for paid orders
This commit is contained in:
@@ -48,6 +48,8 @@ def pretixcontrol_action_display(sender, action, request, **kwargs):
|
|||||||
template = get_template('pretixplugins/paypal/action_refund.html')
|
template = get_template('pretixplugins/paypal/action_refund.html')
|
||||||
elif action.action_type == 'pretix.plugins.paypal.overpaid':
|
elif action.action_type == 'pretix.plugins.paypal.overpaid':
|
||||||
template = get_template('pretixplugins/paypal/action_overpaid.html')
|
template = get_template('pretixplugins/paypal/action_overpaid.html')
|
||||||
|
elif action.action_type == 'pretix.plugins.paypal.double':
|
||||||
|
template = get_template('pretixplugins/paypal/action_double.html')
|
||||||
|
|
||||||
ctx = {'data': data, 'event': sender, 'action': action}
|
ctx = {'data': data, 'event': sender, 'action': action}
|
||||||
return template.render(ctx, request)
|
return template.render(ctx, request)
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
{% load i18n %}
|
||||||
|
|
||||||
|
<p>
|
||||||
|
{% url "control:event.order" organizer=event.organizer.slug event=event.slug code=data.order as ourl %}
|
||||||
|
{% blocktrans trimmed with payment=data.payment order="<a href='"|add:ourl|add:"'>"|add:data.order|add:"</a>"|safe %}
|
||||||
|
The PayPal transaction {{ payment }} has succeeded, but the order {{ order }} has already been paid by other
|
||||||
|
means. Please double check and refund the money via PayPal's interface.
|
||||||
|
{% endblocktrans %}
|
||||||
|
</p>
|
||||||
@@ -161,6 +161,14 @@ def webhook(request, *args, **kwargs):
|
|||||||
'sale': sale['id']
|
'sale': sale['id']
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
elif order.status not in (Order.STATUS_PENDING, Order.STATUS_EXPIRED) and sale['state'] == 'completed' and \
|
||||||
|
order.payment_provider != "paypal":
|
||||||
|
RequiredAction.objects.create(
|
||||||
|
event=event, action_type='pretix.plugins.paypal.double', data=json.dumps({
|
||||||
|
'order': order.code,
|
||||||
|
'payment': sale['parent_payment']
|
||||||
|
})
|
||||||
|
)
|
||||||
elif order.status in (Order.STATUS_PENDING, Order.STATUS_EXPIRED) and sale['state'] == 'completed':
|
elif order.status in (Order.STATUS_PENDING, Order.STATUS_EXPIRED) and sale['state'] == 'completed':
|
||||||
try:
|
try:
|
||||||
mark_order_paid(order, user=None)
|
mark_order_paid(order, user=None)
|
||||||
|
|||||||
@@ -84,6 +84,8 @@ def pretixcontrol_action_display(sender, action, request, **kwargs):
|
|||||||
template = get_template('pretixplugins/stripe/action_refund.html')
|
template = get_template('pretixplugins/stripe/action_refund.html')
|
||||||
elif action.action_type == 'pretix.plugins.stripe.overpaid':
|
elif action.action_type == 'pretix.plugins.stripe.overpaid':
|
||||||
template = get_template('pretixplugins/stripe/action_overpaid.html')
|
template = get_template('pretixplugins/stripe/action_overpaid.html')
|
||||||
|
elif action.action_type == 'pretix.plugins.stripe.double':
|
||||||
|
template = get_template('pretixplugins/stripe/action_double.html')
|
||||||
|
|
||||||
ctx = {'data': data, 'event': sender, 'action': action}
|
ctx = {'data': data, 'event': sender, 'action': action}
|
||||||
return template.render(ctx, request)
|
return template.render(ctx, request)
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
{% load i18n %}
|
||||||
|
|
||||||
|
<p>
|
||||||
|
{% url "control:event.order" organizer=event.organizer.slug event=event.slug code=data.order as ourl %}
|
||||||
|
{% blocktrans trimmed with charge=data.charge stripe_href="href='https://dashboard.stripe.com/payments/"|add:data.charge|add:"' target='_blank'"|safe order="<a href='"|add:ourl|add:"'>"|add:data.order|add:"</a>"|safe %}
|
||||||
|
The Stripe transaction <a {{ stripe_href }}>{{ charge }}</a> has succeeded, but the order {{ order }} has
|
||||||
|
already been paid by other means. Please double-check and refund the money via Stripe's interface.
|
||||||
|
{% endblocktrans %}
|
||||||
|
</p>
|
||||||
@@ -199,6 +199,15 @@ def charge_webhook(event, event_json, charge_id):
|
|||||||
'charge': charge_id
|
'charge': charge_id
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
elif order.status == Order.STATUS_PAID and not order.payment_provider.startswith('stripe') and charge['status'] == 'succeeded' and not is_refund:
|
||||||
|
RequiredAction.objects.create(
|
||||||
|
event=event,
|
||||||
|
action_type='pretix.plugins.stripe.double',
|
||||||
|
data=json.dumps({
|
||||||
|
'order': order.code,
|
||||||
|
'charge': charge.id
|
||||||
|
})
|
||||||
|
)
|
||||||
elif order.status in (Order.STATUS_PENDING, Order.STATUS_EXPIRED) and charge['status'] == 'succeeded' and not is_refund:
|
elif order.status in (Order.STATUS_PENDING, Order.STATUS_EXPIRED) and charge['status'] == 'succeeded' and not is_refund:
|
||||||
try:
|
try:
|
||||||
mark_order_paid(order, user=None)
|
mark_order_paid(order, user=None)
|
||||||
|
|||||||
Reference in New Issue
Block a user