Перейти с PaymentWall на cloudpayments

remotes/origin/feature/cloudpayments
gzbender 7 years ago
parent fca1d9c220
commit 63699581c8
  1. 30
      apps/payment/views.py
  2. 4
      project/urls.py
  3. 1
      requirements.txt

@ -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)

@ -35,7 +35,7 @@ from apps.payment.views import (
CourseBuySuccessView, CourseBuyView,
PaymentwallCallbackView, SchoolBuySuccessView,
SchoolBuyView, GiftCertificatesView, GiftCertificateBuyView,
GiftCertificateBuySuccessView, GiftCertificateGetView)
GiftCertificateBuySuccessView, GiftCertificateGetView, CloudPaymentsTestView, CloudPaymentsCallbackTestView)
from .views import AboutView, IndexView, SchoolSchedulesView
@ -98,6 +98,8 @@ urlpatterns = [
name='gift-certificate-payment-success'),
path('gift-certificate/<str:slug>/get', GiftCertificateGetView.as_view(), name='gift-certificate-get'),
path('faq', FAQView.as_view(), name='faq'),
path('cloud_payments_callback_test', CloudPaymentsCallbackTestView.as_view(), name='cloud_payments_callback_test'),
path('cloud_payments_test', CloudPaymentsTestView.as_view(), name='cloud_payments_test'),
]

@ -37,3 +37,4 @@ sendgrid
drf_dynamic_fields
flower==0.9.2
unidecode
cloudpayments

Loading…
Cancel
Save