This commit is contained in:
Martin Quarda 2024-08-16 14:35:27 +02:00
parent 2c84576e63
commit b0ecfc00bb
3 changed files with 19 additions and 9 deletions

View File

@ -88,7 +88,10 @@ COMGATE_TEST = True
COMGATE_SECRET = '2c07bfabd1a5e4a312dc49929de60aa2' COMGATE_SECRET = '2c07bfabd1a5e4a312dc49929de60aa2'
ADMINS = [('Martin Quarda', 'martin@quarda.cz')]
# Email # Email
SERVER_EMAIL = 'info@alkator.cz'
DEFAULT_FROM_EMAIL = 'info@alkator.cz' DEFAULT_FROM_EMAIL = 'info@alkator.cz'
EMAIL_HOST = 'smtp.seznam.cz' EMAIL_HOST = 'smtp.seznam.cz'
EMAIL_PORT = 465 EMAIL_PORT = 465

View File

@ -88,7 +88,7 @@ def register(request):
if result['code'][0] != '0': if result['code'][0] != '0':
user.delete() user.delete()
return HttpResponse('{"reason":"Chyba na straně platební brány: ' + result['message'][0] + '"}', status=400, content_type='application/json') return HttpResponse('{"reason":"Chyba na straně platební brány: ' + result['message'][0] + ', zkuste prosím registraci později."}', status=400, content_type='application/json')
user.trans_id = result['transId'][0] user.trans_id = result['transId'][0]
user.save() user.save()
@ -114,7 +114,6 @@ def payment_result(request):
f"body", f"body",
"info@alkator.cz", "info@alkator.cz",
[user.email], [user.email],
fail_silently=True,
) )
elif paid == 'CANCELLED' and not user.paid: elif paid == 'CANCELLED' and not user.paid:
user.delete() user.delete()
@ -123,10 +122,13 @@ def payment_result(request):
def payment_state(request): def payment_state(request):
invoice_id = request.GET['refId'] invoice_id = request.GET['refId']
try:
if User.objects.get(invoice_id=invoice_id).paid: if User.objects.get(invoice_id=invoice_id).paid:
return HttpResponse('{"status":"success", "reason":"Úspěšná platba"}', content_type='application/json') return HttpResponse('{"status":"success", "reason":"Úspěšná platba"}', content_type='application/json')
else: else:
return HttpResponse('{"status":"failed", "reason":"Zatím nemáme informace o provedené platbě. Zkuste reload nebo zkontrolujte email."}', content_type='application/json') return HttpResponse('{"status":"failed", "reason":"Zatím nemáme informace o provedené platbě. Zkuste reload nebo zkontrolujte email."}', content_type='application/json')
except User.DoesNotExist as e:
return HttpResponse('{"status":"failed", "reason":"Uživatel neexistuje, prosím registraci opakujte."}', content_type='application/json')
def results(request): def results(request):

View File

@ -31,10 +31,15 @@ class Main extends Component {
this.setState({photos: json}) this.setState({photos: json})
}) })
if(window.location.search){ if(window.location.search){
fetch(addr_prefix + "/api/payment_state" + window.location.search).then(resp => resp.json()).then(json =>{ let searchParams = new URLSearchParams(window.location.search);
for(const [key, value] of searchParams){
if (key == "refId"){
fetch(addr_prefix + "/api/payment_state?refId=" + value).then(resp => resp.json()).then(json =>{
this.setState({status: json.status, text: json.reason}) this.setState({status: json.status, text: json.reason})
}) })
} }
}
}
window.addEventListener("hashchange", (e) => {this.onHashChange(e)}) window.addEventListener("hashchange", (e) => {this.onHashChange(e)})
} }
closePhoto = () => { closePhoto = () => {