first payment nastrel
This commit is contained in:
parent
9e531d4fa2
commit
2818eb7f38
@ -83,6 +83,11 @@ DATABASES = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
COMGATE_MERCHANT = 484757
|
||||||
|
COMGATE_TEST = True
|
||||||
|
COMGATE_SECRET = '2c07bfabd1a5e4a312dc49929de60aa2'
|
||||||
|
|
||||||
|
|
||||||
# Email
|
# Email
|
||||||
DEFAULT_FROM_EMAIL = 'info@alkator.cz'
|
DEFAULT_FROM_EMAIL = 'info@alkator.cz'
|
||||||
EMAIL_HOST = 'smtp.seznam.cz'
|
EMAIL_HOST = 'smtp.seznam.cz'
|
||||||
|
23
alkatorapi/migrations/0012_user_paid_user_trans_id.py
Normal file
23
alkatorapi/migrations/0012_user_paid_user_trans_id.py
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# Generated by Django 4.2.12 on 2024-08-05 12:47
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('alkatorapi', '0011_alter_user_alkator_class'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='user',
|
||||||
|
name='paid',
|
||||||
|
field=models.BooleanField(default=False),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='user',
|
||||||
|
name='trans_id',
|
||||||
|
field=models.CharField(blank=True, max_length=120, null=True),
|
||||||
|
),
|
||||||
|
]
|
@ -32,6 +32,8 @@ class User(models.Model):
|
|||||||
starting_number = models.IntegerField(null=True, blank=True)
|
starting_number = models.IntegerField(null=True, blank=True)
|
||||||
alkator_category = models.IntegerField(choices=ALKATOR_CHOICES, default=1)
|
alkator_category = models.IntegerField(choices=ALKATOR_CHOICES, default=1)
|
||||||
alkator_class = models.IntegerField(choices=ALKATOR_CLASSES)
|
alkator_class = models.IntegerField(choices=ALKATOR_CLASSES)
|
||||||
|
trans_id = models.CharField(null=True, blank=True, max_length=120)
|
||||||
|
paid = models.BooleanField(default=False)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"<User {self.starting_number} {self.first_name} {self.last_name} {self.email} {self.duration} {self.alkator_category} {ALKATOR_CLASSES_DICT[self.alkator_class]}>"
|
return f"<User {self.starting_number} {self.first_name} {self.last_name} {self.email} {self.duration} {self.alkator_category} {ALKATOR_CLASSES_DICT[self.alkator_class]}>"
|
||||||
|
@ -2,12 +2,14 @@ from django.shortcuts import render
|
|||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
from django.views.decorators.csrf import csrf_exempt
|
from django.views.decorators.csrf import csrf_exempt
|
||||||
from datetime import date, datetime
|
from datetime import date, datetime
|
||||||
|
import requests
|
||||||
import json
|
import json
|
||||||
import glob
|
import glob
|
||||||
import PIL.Image
|
import PIL.Image
|
||||||
import random
|
import random
|
||||||
|
|
||||||
from .models import User, ALKATOR_CHOICES_DICT
|
from .models import User, ALKATOR_CHOICES_DICT
|
||||||
|
from alkator.settings import COMGATE_MERCHANT, COMGATE_TEST, COMGATE_SECRET
|
||||||
|
|
||||||
|
|
||||||
@csrf_exempt
|
@csrf_exempt
|
||||||
@ -46,6 +48,20 @@ def register(request):
|
|||||||
alkator_class=ALKATOR_CLASS,
|
alkator_class=ALKATOR_CLASS,
|
||||||
)
|
)
|
||||||
user.save()
|
user.save()
|
||||||
|
|
||||||
|
payment_data = {
|
||||||
|
'merchant': COMGATE_MERCHANT,
|
||||||
|
'test': COMGATE_TEST,
|
||||||
|
'price': 69000,
|
||||||
|
'curr': 'CZK',
|
||||||
|
'label': 'Startovné',
|
||||||
|
'refId': f'{user.id}',
|
||||||
|
'secret': COMGATE_SECRET,
|
||||||
|
}
|
||||||
|
result = requests.post('https://payments.comgate.cz/v1.0/create', data=payment_data)
|
||||||
|
|
||||||
|
raise Exception(result)
|
||||||
|
|
||||||
return HttpResponse('{"success":"Úspěšná registrace."}', content_type='application/json')
|
return HttpResponse('{"success":"Úspěšná registrace."}', content_type='application/json')
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user