working on epay payment
This commit is contained in:
parent
68fce085e7
commit
2287e6dda5
12
shop/urls.py
12
shop/urls.py
|
@ -2,16 +2,8 @@ from django.conf.urls import url
|
||||||
from views import *
|
from views import *
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
#url(
|
url(r'orders/(?P<pk>[0-9]+)/pay/creditcard/$', EpayFormView.as_view(), name='epay_form'),
|
||||||
#r'pay/credit_card/(?P<ticket_id>[a-zA-Z0-9\-]+)/$',
|
url(r'epay_callback/', EpayCallbackViev.as_view(), name='epay_callback'),
|
||||||
#EpayView.as_view(),
|
|
||||||
#name='epay_form'
|
|
||||||
#),
|
|
||||||
#url(
|
|
||||||
#r'epay_callback/',
|
|
||||||
#EpayCallbackView,
|
|
||||||
#name='epay_callback'
|
|
||||||
#),
|
|
||||||
url(r'^$', ShopIndexView.as_view(), name='index'),
|
url(r'^$', ShopIndexView.as_view(), name='index'),
|
||||||
url(r'products/(?P<slug>[-_\w+]+)/$', ProductDetailView.as_view(), name='product_detail'),
|
url(r'products/(?P<slug>[-_\w+]+)/$', ProductDetailView.as_view(), name='product_detail'),
|
||||||
url(r'orders/$', OrderListView.as_view(), name='order_list'),
|
url(r'orders/$', OrderListView.as_view(), name='order_list'),
|
||||||
|
|
149
shop/views.py
149
shop/views.py
|
@ -88,6 +88,7 @@ class OrderDetailView(LoginRequiredMixin, DetailView):
|
||||||
|
|
||||||
# Mark the order as closed
|
# Mark the order as closed
|
||||||
order.open = None
|
order.open = None
|
||||||
|
order.save()
|
||||||
|
|
||||||
reverses = {
|
reverses = {
|
||||||
Order.CREDIT_CARD: reverse_lazy(
|
Order.CREDIT_CARD: reverse_lazy(
|
||||||
|
@ -224,78 +225,76 @@ class CoinifyRedirectView(TemplateView):
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
# class EpayView(TemplateView):
|
class EpayFormView(TemplateView):
|
||||||
# template_name = 'tickets/epay_form.html'
|
template_name = 'epay_form.html'
|
||||||
#
|
|
||||||
# def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
# ticket = Ticket.objects.get(pk=kwargs.get('ticket_id'))
|
ticket = Ticket.objects.get(pk=kwargs.get('ticket_id'))
|
||||||
# accept_url = ticket.get_absolute_url()
|
accept_url = ticket.get_absolute_url()
|
||||||
# amount = ticket.ticket_type.price * 100
|
amount = ticket.ticket_type.price * 100
|
||||||
# order_id = str(ticket.pk)
|
order_id = str(ticket.pk)
|
||||||
# description = str(ticket.user.pk)
|
description = str(ticket.user.pk)
|
||||||
#
|
|
||||||
# hashstring = (
|
hashstring = (
|
||||||
# '{merchant_number}{description}11{amount}DKK'
|
'{merchant_number}{description}11{amount}DKK'
|
||||||
# '{order_id}{accept_url}{md5_secret}'
|
'{order_id}{accept_url}{md5_secret}'
|
||||||
# ).format(
|
).format(
|
||||||
# merchant_number=settings.EPAY_MERCHANT_NUMBER,
|
merchant_number=settings.EPAY_MERCHANT_NUMBER,
|
||||||
# description=description,
|
description=description,
|
||||||
# amount=str(amount),
|
amount=str(amount),
|
||||||
# order_id=str(order_id),
|
order_id=str(order_id),
|
||||||
# accept_url=accept_url,
|
accept_url=accept_url,
|
||||||
# md5_secret=settings.EPAY_MD5_SECRET,
|
md5_secret=settings.EPAY_MD5_SECRET,
|
||||||
# )
|
)
|
||||||
# epay_hash = hashlib.md5(hashstring).hexdigest()
|
epay_hash = hashlib.md5(hashstring).hexdigest()
|
||||||
#
|
|
||||||
# context = super(EpayView, self).get_context_data(**kwargs)
|
context = super(EpayFormView, self).get_context_data(**kwargs)
|
||||||
# context['merchant_number'] = settings.EPAY_MERCHANT_NUMBER
|
context['merchant_number'] = settings.EPAY_MERCHANT_NUMBER
|
||||||
# context['description'] = description
|
context['description'] = description
|
||||||
# context['order_id'] = order_id
|
context['order_id'] = order_id
|
||||||
# context['accept_url'] = accept_url
|
context['accept_url'] = accept_url
|
||||||
# context['amount'] = amount
|
context['amount'] = amount
|
||||||
# context['epay_hash'] = epay_hash
|
context['epay_hash'] = epay_hash
|
||||||
# return context
|
return context
|
||||||
#
|
|
||||||
#
|
|
||||||
# class EpayCallbackView(View):
|
class EpayCallbackView(View):
|
||||||
#
|
def get(self, request, **kwargs):
|
||||||
# def get(self, request, **kwargs):
|
callback = EpayCallback.objects.create(
|
||||||
#
|
payload=request.GET
|
||||||
# callback = EpayCallback.objects.create(
|
)
|
||||||
# payload=request.GET
|
|
||||||
# )
|
if 'orderid' in request.GET:
|
||||||
#
|
order = Order.objects.get(pk=request.GET.get('order_id'))
|
||||||
# if 'orderid' in request.GET:
|
query = dict(
|
||||||
# ticket = Ticket.objects.get(pk=request.GET.get('order_id'))
|
map(
|
||||||
# query = dict(
|
lambda x: tuple(x.split('=')),
|
||||||
# map(
|
request.META['QUERY_STRING'].split('&')
|
||||||
# lambda x: tuple(x.split('=')),
|
)
|
||||||
# request.META['QUERY_STRING'].split('&')
|
)
|
||||||
# )
|
|
||||||
# )
|
hashstring = (
|
||||||
#
|
'{merchant_number}{description}11{amount}DKK'
|
||||||
# hashstring = (
|
'{order_id}{accept_url}{md5_secret}'
|
||||||
# '{merchant_number}{description}11{amount}DKK'
|
).format(
|
||||||
# '{order_id}{accept_url}{md5_secret}'
|
merchant_number=query.get('merchantnumber'),
|
||||||
# ).format(
|
description=query.get('description'),
|
||||||
# merchant_number=query.get('merchantnumber'),
|
amount=query.get('amount'),
|
||||||
# description=query.get('description'),
|
order_id=query.get('orderid'),
|
||||||
# amount=query.get('amount'),
|
accept_url=query.get('accepturl'),
|
||||||
# order_id=query.get('orderid'),
|
md5_secret=settings.EPAY_MD5_SECRET,
|
||||||
# accept_url=query.get('accepturl'),
|
)
|
||||||
# md5_secret=settings.EPAY_MD5_SECRET,
|
epay_hash = hashlib.md5(hashstring).hexdigest()
|
||||||
# )
|
|
||||||
# epay_hash = hashlib.md5(hashstring).hexdigest()
|
if not epay_hash == request.GET['hash']:
|
||||||
#
|
return HttpResponse(status=400)
|
||||||
# if not epay_hash == request.GET['hash']:
|
|
||||||
# return HttpResponse(status=400)
|
EpayPayment.objects.create(
|
||||||
#
|
ticket=ticket,
|
||||||
# EpayPayment.objects.create(
|
callback=callback,
|
||||||
# ticket=ticket,
|
txnid=request.GET['txnid'],
|
||||||
# callback=callback,
|
)
|
||||||
# txnid=request.GET['txnid'],
|
else:
|
||||||
# )
|
return HttpResponse(status=400)
|
||||||
# else:
|
|
||||||
# return HttpResponse(status=400)
|
return HttpResponse('OK')
|
||||||
#
|
|
||||||
# return HttpResponse('OK')
|
|
||||||
|
|
Loading…
Reference in a new issue