|
|
|
|
@ -5,6 +5,9 @@ import logging |
|
|
|
|
from datetime import timedelta |
|
|
|
|
from urllib.parse import urlsplit |
|
|
|
|
|
|
|
|
|
import datetime |
|
|
|
|
import calendar |
|
|
|
|
|
|
|
|
|
from django.contrib import messages |
|
|
|
|
from django.contrib.auth.decorators import login_required |
|
|
|
|
from django.http import HttpResponse |
|
|
|
|
@ -148,6 +151,15 @@ class SchoolBuyView(TemplateView): |
|
|
|
|
@method_decorator(csrf_exempt, name='dispatch') |
|
|
|
|
class PaymentwallCallbackView(View): |
|
|
|
|
|
|
|
|
|
>> > |
|
|
|
|
|
|
|
|
|
def add_months(self, sourcedate, months): |
|
|
|
|
month = sourcedate.month - 1 + months |
|
|
|
|
year = sourcedate.year + month // 12 |
|
|
|
|
month = month % 12 + 1 |
|
|
|
|
day = min(sourcedate.day, calendar.monthrange(year, month)[1]) |
|
|
|
|
return datetime.date(year, month, day) |
|
|
|
|
|
|
|
|
|
def get_request_ip(self): |
|
|
|
|
x_forwarded_for = self.request.META.get('HTTP_X_FORWARDED_FOR') |
|
|
|
|
if x_forwarded_for: |
|
|
|
|
@ -201,13 +213,13 @@ class PaymentwallCallbackView(View): |
|
|
|
|
).last() |
|
|
|
|
if school_payment: |
|
|
|
|
if payment.add_days: |
|
|
|
|
date_start = now().shift(months=1).replace(hour=0, minute=0, day=1) |
|
|
|
|
date_start = self.add_months(sourcedate=now(), months=1).replace(hour=0, minute=0, day=1) |
|
|
|
|
date_end = school_payment.date_end |
|
|
|
|
else: |
|
|
|
|
date_start = arrow.get(school_payment.date_end).shift(days=1).datetime |
|
|
|
|
date_end = arrow.get(date_start).shift(months=1).datetime |
|
|
|
|
else: |
|
|
|
|
date_start = now().shift(months=1).replace(hour=0, minute=0, day=1) |
|
|
|
|
date_start = self.add_months(sourcedate=now(), months=1).replace(hour=0, minute=0, day=1) |
|
|
|
|
date_end = arrow.get(date_start).shift(months=1).datetime |
|
|
|
|
payment.date_start = date_start |
|
|
|
|
payment.date_end = date_end |
|
|
|
|
|