|
|
|
|
@ -3,13 +3,13 @@ import short_url |
|
|
|
|
import arrow |
|
|
|
|
import json |
|
|
|
|
import logging |
|
|
|
|
|
|
|
|
|
from datetime import timedelta |
|
|
|
|
from urllib.parse import urlsplit |
|
|
|
|
|
|
|
|
|
import datetime |
|
|
|
|
import calendar |
|
|
|
|
import random |
|
|
|
|
|
|
|
|
|
from cloudpayments import CloudPayments |
|
|
|
|
from django.contrib import messages |
|
|
|
|
from django.contrib.auth.decorators import login_required |
|
|
|
|
from django.http import HttpResponse, Http404 |
|
|
|
|
@ -397,3 +397,29 @@ class GiftCertificateGetView(TemplateView): |
|
|
|
|
context = self.get_context_data(**kwargs) |
|
|
|
|
return self.render_to_response(context) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CloudPaymentsTestView(TemplateView): |
|
|
|
|
template_name = 'payment/cloud_payments_test.html' |
|
|
|
|
|
|
|
|
|
def get(self, request, *args, **kwargs): |
|
|
|
|
context = self.get_context_data(**kwargs) |
|
|
|
|
context['invoice_id'] = random.randrange(1000, 100000000) |
|
|
|
|
return self.render_to_response(context) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CloudPaymentsCallbackTestView(TemplateView): |
|
|
|
|
template_name = 'payment/cloud_payments_callback_test.html' |
|
|
|
|
|
|
|
|
|
def get(self, request, *args, **kwargs): |
|
|
|
|
context = self.get_context_data(**kwargs) |
|
|
|
|
invoice_id = request.GET.get('invoice_id') |
|
|
|
|
client = CloudPayments('pk_9ae020cd5fed74499dee247067d17', 'a7d5f88ea69ef59f8b5db2252e39cedf') |
|
|
|
|
context['test_ok'] = bool(client.test()) |
|
|
|
|
try: |
|
|
|
|
t = client.find_payment(int(invoice_id)) |
|
|
|
|
print('transaction.status', t.status, 'transaction.reason', t.reason) |
|
|
|
|
# status = 'Completed', reason = 'Approved' |
|
|
|
|
context['transaction'] = t |
|
|
|
|
except: |
|
|
|
|
context['transaction'] = None |
|
|
|
|
return self.render_to_response(context) |
|
|
|
|
|