working on coinify payments
This commit is contained in:
parent
6016a6b605
commit
07d74878c5
|
@ -240,6 +240,7 @@ class CoinifyAPIInvoice(CreatedUpdatedModel):
|
|||
|
||||
class CoinifyCallback(CreatedUpdatedModel):
|
||||
payload = JSONField()
|
||||
order = models.ForeignKey('shop.Order')
|
||||
|
||||
def __str__(self):
|
||||
return 'callback at %s' % self.created
|
||||
|
|
13
shop/templates/coinify_thanks.html
Normal file
13
shop/templates/coinify_thanks.html
Normal file
|
@ -0,0 +1,13 @@
|
|||
{% extends 'shop_base.html' %}
|
||||
{% load bootstrap3 %}
|
||||
|
||||
{% block shop_content %}
|
||||
<h2>Thank you for your payment!</h2>
|
||||
<p class="lead">
|
||||
{% if order.paid %}
|
||||
Thank you for your payment. Your order has been marked as paid.
|
||||
{% else %}
|
||||
Thank you for your payment. Your order will be marked as paid as soon as we register a callback from our payment provider.</p>
|
||||
{% endif %}
|
||||
</p>
|
||||
{% endblock %}
|
|
@ -306,20 +306,10 @@ class EpayCallbackView(View):
|
|||
return HttpResponse('OK')
|
||||
|
||||
|
||||
class EpayThanksView(LoginRequiredMixin, EnsureUserOwnsOrderMixin, DetailView):
|
||||
class EpayThanksView(LoginRequiredMixin, EnsureUserOwnsOrderMixin, EnsureClosedOrderMixin, DetailView):
|
||||
model = Order
|
||||
template_name = 'epay_thanks.html'
|
||||
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
order = self.get_object()
|
||||
if order.open:
|
||||
### this order is open, what is the user doing here?
|
||||
return HttpResponseRedirect(reverse_lazy('shop:order_detail', kwargs={'pk': order.pk}))
|
||||
|
||||
return super(EpayThanksView, self).dispatch(
|
||||
request, *args, **kwargs
|
||||
)
|
||||
|
||||
|
||||
class BankTransferView(LoginRequiredMixin, EnsureUserOwnsOrderMixin, EnsureUnpaidOrderMixin, EnsureOrderHasProductsMixin, DetailView):
|
||||
model = Order
|
||||
|
@ -375,9 +365,9 @@ class CoinifyRedirectView(LoginRequiredMixin, EnsureUserOwnsOrderMixin, EnsureUn
|
|||
return context
|
||||
|
||||
|
||||
class CoinifyCallbackView(View):
|
||||
class CoinifyCallbackView(SingleObjectMixin, View):
|
||||
def post(self, request, *args, **kwargs):
|
||||
# Get the signature from the HTTP or email headers
|
||||
# Get the signature from the HTTP headers
|
||||
signature = request.META['HTTP_X_COINIFY_CALLBACK_SIGNATURE']
|
||||
sdk = CoinifyCallback(
|
||||
settings.COINIFY_API_KEY,
|
||||
|
@ -387,7 +377,8 @@ class CoinifyCallbackView(View):
|
|||
if sdk.validate_callback(request.body, signature):
|
||||
# callback is valid, save it to db
|
||||
callbackobject = CoinifyCallback.objects.create(
|
||||
payload=request.body
|
||||
payload=request.body,
|
||||
order=self.get_object()
|
||||
)
|
||||
|
||||
# parse json
|
||||
|
@ -411,3 +402,8 @@ class CoinifyCallbackView(View):
|
|||
else:
|
||||
HttpResponseBadRequest('something is fucky')
|
||||
|
||||
|
||||
class CoinifyThanksView(LoginRequiredMixin, EnsureUserOwnsOrderMixin, EnsureClosedOrderMixin, DetailView):
|
||||
model = Order
|
||||
template_name = 'coinify_thanks.html'
|
||||
|
||||
|
|
Loading…
Reference in a new issue