55: Method not allowed
This commit is contained in:
parent
d02814bf43
commit
f4d40edf40
5 changed files with 84 additions and 40 deletions
20
SWSCloudCore/templates/default/payment/fail.html
Normal file
20
SWSCloudCore/templates/default/payment/fail.html
Normal file
|
@ -0,0 +1,20 @@
|
|||
<html>
|
||||
<head></head>
|
||||
<body>
|
||||
<h1>Что-то пошло не так</h1>
|
||||
<p>
|
||||
Во время оплаты произошла ошибка, попробуйте ещё раз.
|
||||
В случае повторения ошибки обратитесь в <a href="mailto:support@procdn.ru">поддержку</a>.
|
||||
</p>
|
||||
|
||||
<ul>
|
||||
<li><a href="{{ url_for('account.billing') }}">Биллинг</a></li>
|
||||
{% if g.settings.get('SERVICE_CONTAINERS_ENABLE', "0") == "1" %}
|
||||
<li><a href="{{ url_for('containers.index') }}">Контейнеры</a></li>
|
||||
{% endif %}
|
||||
{% if g.settings.get('SERVICE_VMS_ENABLE', '0') == '1' %}
|
||||
<li><a href="{{ url_for('vms.index') }}">Виртуальные машины</a></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
|
@ -1,11 +0,0 @@
|
|||
<html>
|
||||
<head></head>
|
||||
<body>
|
||||
<h1>Что-то пошло не так</h1>
|
||||
<p>
|
||||
Во время оплаты произошла ошибка, попробуйте ещё раз.
|
||||
В случае повторения ошибки обратитесь в <a href="mailto:support@procdn.ru">поддержку</a>.
|
||||
</p>
|
||||
<p><a href="{{ url_for("account.billing") }}">В личный кабинет</a></p>
|
||||
</body>
|
||||
</html>
|
21
SWSCloudCore/templates/default/payment/success.html
Normal file
21
SWSCloudCore/templates/default/payment/success.html
Normal file
|
@ -0,0 +1,21 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Успешное пополнение счёта</title>
|
||||
</head>
|
||||
<body>
|
||||
Спасибо!
|
||||
|
||||
Личный счёт успешно пополнен.
|
||||
<ul>
|
||||
<li><a href="{{ url_for('account.billing') }}">Биллинг</a></li>
|
||||
{% if g.settings.get('SERVICE_CONTAINERS_ENABLE', "0") == "1" %}
|
||||
<li><a href="{{ url_for('containers.index') }}">Контейнеры</a></li>
|
||||
{% endif %}
|
||||
{% if g.settings.get('SERVICE_VMS_ENABLE', '0') == '1' %}
|
||||
<li><a href="{{ url_for('vms.index') }}">Виртуальные машины</a></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
|
@ -9,7 +9,7 @@ from flask import redirect
|
|||
from flask import render_template
|
||||
from flask import request
|
||||
from flask import session
|
||||
from flask import url_for
|
||||
from flask import url_for, jsonify
|
||||
|
||||
from SWSCloudCore import models
|
||||
from SWSCloudCore.controllers.users import ControllerUsers
|
||||
|
@ -17,6 +17,16 @@ from SWSCloudCore.controllers.users import ControllerUsers
|
|||
viewPayments = Blueprint('payments', __name__, url_prefix='/payments')
|
||||
|
||||
|
||||
@viewPayments.route('/fail.html')
|
||||
def fail():
|
||||
return render_template('default/payment/fail.html')
|
||||
|
||||
|
||||
@viewPayments.route('/success.html')
|
||||
def success():
|
||||
return render_template('default/payment/success.html')
|
||||
|
||||
|
||||
@viewPayments.route('/robokassa/<action>', methods=['GET', 'POST'])
|
||||
def robokassa(action):
|
||||
controller_robokassa = ControllerPaymentsRobokassa(
|
||||
|
@ -51,25 +61,31 @@ def robokassa(action):
|
|||
payment_details["signature"] = md5(
|
||||
"%(login)s:%(amount)s:%(payment_id)s:%(password)s" % payment_details
|
||||
).hexdigest()
|
||||
print payment_details
|
||||
# print payment_details
|
||||
return render_template('default/payment/robokassa/process.html', payment=payment_details)
|
||||
|
||||
if action == 'result':
|
||||
transaction_id = request.form['InvId']
|
||||
signature = request.form['SignatureValue']
|
||||
amount = request.form['OutSum']
|
||||
if request.method == 'POST':
|
||||
transaction_id = request.form['InvId']
|
||||
signature = request.form['SignatureValue']
|
||||
amount = request.form['OutSum']
|
||||
|
||||
transaction_hash = md5("%s:%s:%s" % (amount, transaction_id, controller_robokassa.args['PAY_ROBOKASSA_PASSWORD2'])).hexdigest()
|
||||
# print transaction_hash
|
||||
# print signature.lower()
|
||||
if signature.lower() == transaction_hash.lower():
|
||||
# update transaction signature
|
||||
controller_robokassa.transaction_set_notified(transaction_id, 1)
|
||||
# update user balance
|
||||
controller_robokassa.balance_update(transaction_id, amount)
|
||||
else:
|
||||
print "ERR: invalid signature"
|
||||
return render_template('default/payment/robokassa/result.html')
|
||||
transaction_hash = md5("%s:%s:%s" % (amount, transaction_id, controller_robokassa.args['PAY_ROBOKASSA_PASSWORD2'])).hexdigest()
|
||||
# print transaction_hash
|
||||
# print signature.lower()
|
||||
if signature.lower() == transaction_hash.lower():
|
||||
# update transaction signature
|
||||
controller_robokassa.transaction_set_notified(transaction_id, 1)
|
||||
# update user balance
|
||||
controller_robokassa.balance_update(transaction_id, amount)
|
||||
|
||||
# update transaction signature
|
||||
transaction = models.UsersBalanceTransactions.get(models.UsersBalanceTransactions.id == transaction_id)
|
||||
transaction.status = 'success'
|
||||
transaction.save()
|
||||
else:
|
||||
return jsonify(error="invalid signature")
|
||||
return render_template('default/payment/robokassa/result.html')
|
||||
|
||||
if action == 'success':
|
||||
# check session
|
||||
|
@ -80,19 +96,18 @@ def robokassa(action):
|
|||
return redirect(url_for("account.logout"))
|
||||
|
||||
if request.method == "POST":
|
||||
print request.form
|
||||
# print request.form
|
||||
# culture = request.form['Culture']
|
||||
transaction_id = request.form['InvId']
|
||||
# transaction_id = request.form.get('InvId')
|
||||
|
||||
# TODO: если эта часть делается на шаге `results`, то можно убрать его
|
||||
# update transaction signature
|
||||
transaction = models.UsersBalanceTransactions.get(models.UsersBalanceTransactions.id == transaction_id)
|
||||
transaction.status = 'success'
|
||||
transaction.save()
|
||||
# transaction = models.UsersBalanceTransactions.get(models.UsersBalanceTransactions.id == transaction_id)
|
||||
# transaction.status = 'success'
|
||||
# transaction.save()
|
||||
|
||||
return redirect(url_for('payments.robokassa', action='success'))
|
||||
# else:
|
||||
# print "ERR: invalid signature"
|
||||
return render_template('payment/robokassa/success.html')
|
||||
return redirect(url_for('payments.success'))
|
||||
return redirect(url_for('payments.success'))
|
||||
|
||||
if action == 'fail':
|
||||
# check session
|
||||
|
@ -104,7 +119,7 @@ def robokassa(action):
|
|||
return redirect(url_for("account.logout"))
|
||||
|
||||
if request.method == "POST":
|
||||
print request.form
|
||||
# print request.form
|
||||
|
||||
transaction_id = request.form['InvId']
|
||||
|
||||
|
@ -113,5 +128,4 @@ def robokassa(action):
|
|||
transaction.status = 'fail'
|
||||
transaction.save()
|
||||
|
||||
return redirect(url_for('payments.robokassa', action='fail'))
|
||||
return render_template('default/payment/robokassa/fail.html')
|
||||
return redirect(url_for('payments.fail'))
|
||||
|
|
2
setup.py
2
setup.py
|
@ -4,7 +4,7 @@ from setuptools import setup
|
|||
|
||||
setup(
|
||||
name='SWSCloudCore',
|
||||
version='2.4.5',
|
||||
version='2.4.6',
|
||||
author='Vyacheslav Anzhiganov',
|
||||
author_email='hello@anzhiganov.com',
|
||||
packages=[
|
||||
|
|
Loading…
Add table
Reference in a new issue