Order details: Display payment information

This commit is contained in:
Raphael Michel
2015-03-20 23:20:12 +01:00
parent 4a72d11c67
commit 5664177bbb
11 changed files with 172 additions and 5 deletions

View File

@@ -1,4 +1,5 @@
from collections import OrderedDict
import json
import logging
from django.contrib import messages
from django.template import Context
@@ -82,3 +83,14 @@ class Stripe(BasePaymentProvider):
ctx = Context({'request': request, 'event': self.event, 'settings': self.settings,
'order': order})
return template.render(ctx)
def order_control_render(self, request, order) -> str:
if order.payment_info:
payment_info = json.loads(order.payment_info)
payment_info['amount'] /= 100
else:
payment_info = None
template = get_template('pretixplugins/stripe/control.html')
ctx = Context({'request': request, 'event': self.event, 'settings': self.settings,
'payment_info': payment_info, 'order': order})
return template.render(ctx)

View File

@@ -0,0 +1,33 @@
{% load i18n %}
{% if payment_info %}
{% if order.status == "p" %}
<p>{% blocktrans trimmed %}
This order has been paid via Stripe.
{% endblocktrans %}</p>
{% else %}
<p>{% blocktrans trimmed %}
This order has been planned to be paid via Stripe, but the payment has not yet been completed.
{% endblocktrans %}</p>
{% endif %}
<dl class="dl-horizontal">
<dt>{% trans "Charge ID" %}</dt>
<dd>{{ payment_info.id }}</dd>
<dt>{% trans "Card type" %}</dt>
<dd>{{ payment_info.source.brand }}</dd>
<dt>{% trans "Card number" %}</dt>
<dd>**** **** **** {{ payment_info.source.last4 }}</dd>
<dt>{% trans "Payer name" %}</dt>
<dd>{{ payment_info.source.name }}</dd>
<dt>{% trans "Total value" %}</dt>
<dd>{{ payment_info.amount|floatformat:2 }}</dd>
<dt>{% trans "Currency" %}</dt>
<dd>{{ payment_info.currency|upper }}</dd>
<dt>{% trans "Status" %}</dt>
<dd>{{ payment_info.status }}</dd>
</dl>
{% else %}
<p>{% blocktrans trimmed %}
This order has been planned to be paid via Stripe, but the payment has not yet been completed.
{% endblocktrans %}</p>
{% endif %}