diff --git a/batiskaf/settings.py b/batiskaf/settings.py index 7d21c83..9e75c34 100644 --- a/batiskaf/settings.py +++ b/batiskaf/settings.py @@ -133,7 +133,7 @@ TIME_ZONE = 'Asia/Almaty' USE_I18N = True -USE_L10N = True +USE_L10N = False USE_TZ = False @@ -264,12 +264,11 @@ PROFILE_TEMP_PASSWORD = 'dE6Hyo9heWck5yiM2dIs' MERCHANT_CERTIFICATE_ID = "c183d5b8" # ; Серийный номер сертификата Cert Serial Number MERCHANT_NAME = "BATISKAF-KZ.KZ" # ; Название магазина (продавца) Shop/merchant Name -PRIVATE_KEY_FN = os.path.join(BASE_DIR, 'kkb_keys', - 'cert.prv') # "../paysys/cert.prv" # ; Путь к закрытому ключу Private cert path +PRIVATE_KEY_FN = os.path.join(BASE_DIR, 'kkb_keys', 'cert.prv') # "../paysys/cert.prv" # ; Путь к закрытому ключу Private cert path PRIVATE_KEY_PASS = "1q2w3e4r" # ; Пароль к закрытому ключу Private cert password # XML_TEMPLATE_FN = "../paysys/template.xml" # ; Путь к XML шаблону XML template path # XML_COMMAND_TEMPLATE_FN = "../paysys/command_template.xml" # ; Путь к XML шаблону для команд (возврат/подтверждение) PUBLIC_KEY_FN = os.path.join(BASE_DIR, 'kkb_keys', - 'kkbca.cer') # "../paysys/kkbca.pem" # ; Путь к открытому ключу Public cert path + 'cert.pub') # "../paysys/kkbca.pem" # ; Путь к открытому ключу Public cert path MERCHANT_ID = "92210431" # ; Терминал ИД в банковской Системе diff --git a/batiskaf/templates/jinja2/cart_detail.jinja b/batiskaf/templates/jinja2/cart_detail.jinja index f6f5176..e5ab884 100644 --- a/batiskaf/templates/jinja2/cart_detail.jinja +++ b/batiskaf/templates/jinja2/cart_detail.jinja @@ -107,6 +107,19 @@ Итого к оплате: {{ cart.total }}
+
+ +
+
+ +
+
- +{% extends 'base.jinja' %} +{% block title %} + Перенаправление на платежный шлюз +{% endblock %} +{% block content %} + + + +

+
Нажмите, чтобы перейти на сайт платежного шлюза и продолжить оплату...
+ +
+ + + + + + +
+ +
+

+ +
+ {#
#} + {# #} + {# #} + {# #} + {# #} + {# #} + {# #} + {# #} + {# #} + {# #} + {#
#} + {# Платеж#} + {# #} + {# ИИК: KZ809261001507363000
#} + {# РНН/БИН бенефециара: 760419302190
#} + {# Бенефециар: ИП Полинкин Матвей Владимирович
#} + {# Банк бенефециара: АО "Казкоммерцбанк"
#} + {# БИК: KZKOKZKX
#} + {# Платеж: Заказ №{{ order.pk }} от {{ date.strftime('%d.%m.%Y') }}
#} + {# Плательщик: {{ order.first_name }} {{ order.last_name }}
#} + {# Адрес плательщика: {{ order.address }}
#} + {# Сумма: {{ order.amount }} тенге

#} + {# Подпись:_____________________ Дата: {{ date.strftime('%d.%m.%Y') }}
#} + {##} + {#
#} + {# Квитанция
#} + {# Кассир#} + {#
#} + {# ИИК: KZ809261001507363000
#} + {# РНН/БИН бенефециара: 760419302190
#} + {# Бенефециар: ИП Полинкин Матвей Владимирович
#} + {# Банк бенефециара: АО "Казкоммерцбанк"
#} + {# БИК: KZKOKZKX
#} + {# Платеж: Заказ №{{ order.pk }} от {{ date.strftime('%d.%m.%Y') }}
#} + {# Плательщик: {{ order.first_name }} {{ order.last_name }}
#} + {# Адрес плательщика: {{ order.address }}
#} + {# Сумма: {{ order.amount }} тенге

#} + {# Подпись:_____________________ Дата: {{ date.strftime('%d.%m.%Y') }}
#} + {##} + {#
#} + {#
#} + {##} + {#

Версия для печати#} + {#

#} + {#
#} + +{% endblock %} + + + + diff --git a/batiskaf/templates/jinja2/kkb_ok.jinja b/batiskaf/templates/jinja2/kkb_ok.jinja new file mode 100644 index 0000000..a0aba93 --- /dev/null +++ b/batiskaf/templates/jinja2/kkb_ok.jinja @@ -0,0 +1 @@ +OK \ No newline at end of file diff --git a/batiskaf/templates/jinja2/order_ok.jinja b/batiskaf/templates/jinja2/order_ok.jinja index 1c2ac46..ed60cc8 100644 --- a/batiskaf/templates/jinja2/order_ok.jinja +++ b/batiskaf/templates/jinja2/order_ok.jinja @@ -1,67 +1,86 @@ {% extends 'base.jinja' %} {% block title %} -Заказ успешно оформлен + Заказ успешно оформлен {% endblock %} {% block content %} -
- -

Спасибо!

-

Ваш заказ успешно принят и поступит в обработку сразу после оплаты.

-

Распечатать квитанцию для оплаты

-
-
-
Вы можете отправить прямой платеж на карту:
-

- Банк: Казкоммерцбанк
- ИИН: 760419302190
- Номер карты: 4405 6452 0912 2014

- ...либо воспользуйтесь квитанцией для оплаты банковским платежом -

-
-
- - - - - - - - - -
- Платеж - - ИИК: KZ809261001507363000
- РНН/БИН бенефециара: 760419302190
- Бенефециар: ИП Полинкин Матвей Владимирович
- Банк бенефециара: АО "Казкоммерцбанк"
- БИК: KZKOKZKX
- Платеж: Заказ №{{ order.pk }} от {{ date.strftime('%d.%m.%Y') }}
- Плательщик: {{ order.first_name }} {{ order.last_name }}
- Адрес плательщика: {{ order.address }}
- Сумма: {{ order.amount }} тенге

- Подпись:_____________________ Дата: {{ date.strftime('%d.%m.%Y') }}
+
+ +

Спасибо!

-
- Квитанция
- Кассир -
- ИИК: KZ809261001507363000
- РНН/БИН бенефециара: 760419302190
- Бенефециар: ИП Полинкин Матвей Владимирович
- Банк бенефециара: АО "Казкоммерцбанк"
- БИК: KZKOKZKX
- Платеж: Заказ №{{ order.pk }} от {{ date.strftime('%d.%m.%Y') }}
- Плательщик: {{ order.first_name }} {{ order.last_name }}
- Адрес плательщика: {{ order.address }}
- Сумма: {{ order.amount }} тенге

- Подпись:_____________________ Дата: {{ date.strftime('%d.%m.%Y') }}
+

Ваш заказ успешно принят и поступит в обработку сразу после оплаты.

-
-
-

Версия для печати

+{#

Распечатать квитанцию для#} +{# оплаты

#} +
+
+
+
+ +
+ +{#
#} +{#
Вы можете отправить прямой платеж на карту:
#} +{##} +{#

#} +{# Банк: Казкоммерцбанк
#} +{# ИИН: 760419302190
#} +{# Номер карты: 4405 6452 0912 2014

#} +{# ...либо воспользуйтесь квитанцией для оплаты банковским платежом#} +{#

#} +{#
#} +{#
#} +{# #} +{# #} +{# #} +{# #} +{# #} +{# #} +{# #} +{# #} +{# #} +{#
#} +{# Платеж#} +{# #} +{# ИИК: KZ809261001507363000
#} +{# РНН/БИН бенефециара: 760419302190
#} +{# Бенефециар: ИП Полинкин Матвей Владимирович
#} +{# Банк бенефециара: АО "Казкоммерцбанк"
#} +{# БИК: KZKOKZKX
#} +{# Платеж: Заказ №{{ order.pk }} от {{ date.strftime('%d.%m.%Y') }}
#} +{# Плательщик: {{ order.first_name }} {{ order.last_name }}
#} +{# Адрес плательщика: {{ order.address }}
#} +{# Сумма: {{ order.amount }} тенге

#} +{# Подпись:_____________________ Дата: {{ date.strftime('%d.%m.%Y') }}
#} +{##} +{#
#} +{# Квитанция
#} +{# Кассир#} +{#
#} +{# ИИК: KZ809261001507363000
#} +{# РНН/БИН бенефециара: 760419302190
#} +{# Бенефециар: ИП Полинкин Матвей Владимирович
#} +{# Банк бенефециара: АО "Казкоммерцбанк"
#} +{# БИК: KZKOKZKX
#} +{# Платеж: Заказ №{{ order.pk }} от {{ date.strftime('%d.%m.%Y') }}
#} +{# Плательщик: {{ order.first_name }} {{ order.last_name }}
#} +{# Адрес плательщика: {{ order.address }}
#} +{# Сумма: {{ order.amount }} тенге

#} +{# Подпись:_____________________ Дата: {{ date.strftime('%d.%m.%Y') }}
#} +{##} +{#
#} +{#
#} +{##} +{#

Версия для печати#} +{#

#} +{#
#} {% endblock %} diff --git a/batiskaf/urls.py b/batiskaf/urls.py index 28ca8d1..5b92b1e 100644 --- a/batiskaf/urls.py +++ b/batiskaf/urls.py @@ -3,7 +3,7 @@ from django.contrib import admin from django.http import HttpResponse from api.views import call_order from news.views import NewsSitemap -from store.views import order_view, order_print, ProductSitemap, CategorySitemap, order_kkb +from store.views import order_view, order_print, ProductSitemap, CategorySitemap, order_kkb, kkb_result from main.views import * from rest_framework import routers # from api.urls import router @@ -90,6 +90,8 @@ urlpatterns = patterns( name='store_order_print'), url(r'^order/(?P.+)/kkb/$', order_kkb, name='store_order_kkb'), + url(r'^kkb_result/$', kkb_result, + name='kkb_result'), url(r'^order/(?P.+)/$', order_view, name='store_order_view'), diff --git a/kkb/__init__.py b/kkb/__init__.py new file mode 100644 index 0000000..43e2d87 --- /dev/null +++ b/kkb/__init__.py @@ -0,0 +1,31 @@ +from django.conf import settings +from django.core.exceptions import ImproperlyConfigured +from kkb.process import get_context, postlink_process as postlink + +version_info = (0, 3, 0) + +__version__ = version = '.'.join(map(str, version_info)) +__project__ = PROJECT = 'kkb' +__author__ = AUTHOR = "sofaku " + +if not hasattr(settings, 'MERCHANT_ID'): + raise ImproperlyConfigured('MERCHANT_ID is required') + +if not hasattr(settings, 'MERCHANT_CERTIFICATE_ID'): + raise ImproperlyConfigured('MERCHANT_CERTIFICATE_ID is required') + +if not hasattr(settings, 'MERCHANT_NAME'): + raise ImproperlyConfigured('MERCHANT_NAME is required') + +if not hasattr(settings, 'PRIVATE_KEY_FN'): + raise ImproperlyConfigured('PRIVATE_KEY_FN is required') + +if not hasattr(settings, 'PRIVATE_KEY_PASS'): + raise ImproperlyConfigured('PRIVATE_KEY_PASS is required') + +if not hasattr(settings, 'PUBLIC_KEY_FN'): + raise ImproperlyConfigured('PUBLIC_KEY_FN is required') + +settings.XML_TEMPLATE_FN = getattr(settings, 'XML_TEMPLATE_FN', 'kkb/template.xml') + +settings.XML_COMMAND_TEMPLATE_FN = getattr(settings, 'XML_COMMAND_TEMPLATE_FN', 'kkb/command_template.xml') diff --git a/kkb/kkb_sign.py b/kkb/kkb_sign.py new file mode 100644 index 0000000..a64e0c8 --- /dev/null +++ b/kkb/kkb_sign.py @@ -0,0 +1,70 @@ +import os +from django.conf import settings +import tempfile +import subprocess +import shlex +import base64 + + +class KKBSign(object): + """docstring for KBBSign""" + + def check(self, rawsign, data): + tempSignature = tempfile.NamedTemporaryFile(mode="wb", delete=False) + tempData = tempfile.NamedTemporaryFile(mode="wb", delete=False) + tempPubKey = tempfile.NamedTemporaryFile(mode="wb", delete=False) + rawsign = base64.b64decode(rawsign)[::-1] + try: + tempSignature.write(bytes(rawsign, 'UTF-8')) + except Exception as e: + tempSignature.write(rawsign) + tempSignature.seek(0) + + try: + tempData.write(bytes(data, 'UTF-8')) + except Exception as e: + tempData.write(data) + tempData.seek(0) + + cmd = "".join(["openssl x509 -pubkey -noout -in ", settings.PUBLIC_KEY_FN]) + pubkey = \ + subprocess.Popen(shlex.split(cmd), shell=False, stdin=subprocess.PIPE, stdout=subprocess.PIPE).communicate()[0] + try: + tempPubKey.write(bytes(pubkey, 'UTF-8')) + except Exception as e: + tempPubKey.write(pubkey) + + tempPubKey.seek(0) + + cmd = "".join( + ["openssl dgst -sha1 -verify ", tempPubKey.name, " -signature ", tempSignature.name, " ", tempData.name]) + result = \ + subprocess.Popen(shlex.split(cmd), shell=False, stdin=subprocess.PIPE, stdout=subprocess.PIPE).communicate()[0] + + tempPubKey.close() + tempData.close() + tempSignature.close() + os.unlink(tempPubKey.name) + os.unlink(tempData.name) + os.unlink(tempSignature.name) + return result.decode('utf-8') + + def sign64(self, text): + tempData = tempfile.NamedTemporaryFile(delete=False) + try: + tempData.write(bytes(text, 'UTF-8')) + except Exception as e: + tempData.write(text) + tempData.seek(0) + + tempSignature = tempfile.NamedTemporaryFile(mode="rb", delete=False) + cmd = "".join(["openssl dgst -sha1 -sign ", settings.PRIVATE_KEY_FN, " -passin ", + "".join(['pass:', settings.PRIVATE_KEY_PASS]), " -out ", tempSignature.name, " ", tempData.name]) + p = subprocess.Popen(shlex.split(cmd), shell=False, stdin=subprocess.PIPE) + p.communicate() + signature = tempSignature.read()[::-1] + tempData.close() + tempSignature.close() + os.unlink(tempData.name) + os.unlink(tempSignature.name) + return base64.b64encode(signature) diff --git a/kkb/process.py b/kkb/process.py new file mode 100644 index 0000000..2435a21 --- /dev/null +++ b/kkb/process.py @@ -0,0 +1,104 @@ +from django.conf import settings +import xml.etree.ElementTree as ET +from kkb.kkb_sign import KKBSign +from django.template.loader import render_to_string +import base64 + + +class Result: + def __init__(self, **entries): + self.__dict__.update(entries) + + +def xml2dict(xml): + root = ET.fromstring(xml) + bank = root.find('bank') + customer = bank.find('customer') + merchant = customer.find('merchant') + order = merchant.find('order') + department = order.find('department') + merchant_sign = customer.find('merchant_sign') + customer_sign = bank.find('customer_sign') + results = bank.find('results') + payment = results.find('payment') + bank_sign = root.find('bank_sign') + result = { + 'BANK_NAME': bank.get('name'), + 'CUSTOMER_NAME': customer.get('name'), + 'CUSTOMER_MAIL': customer.get('mail'), + 'CUSTOMER_PHONE': customer.get('phone'), + 'MERCHANT_CERT_ID': merchant.get('cert_id'), + 'MERCHANT_NAME': merchant.get('name'), + 'ORDER_ID': order.get('order_id'), + 'ORDER_AMOUNT': order.get('amount'), + 'ORDER_CURRENCY': order.get('currency'), + 'DEPARTMENT_MERCHANT_ID': department.get('merchant_id'), + 'DEPARTMENT_AMOUNT': department.get('amount'), + 'MERCHANT_SIGN_TYPE': merchant_sign.get('type'), + 'CUSTOMER_SIGN_TYPE': customer_sign.get('type'), + 'RESULTS_TIMESTAMP': results.get('timestamp'), + 'PAYMENT_MERCHANT_ID': payment.get('merchant_id'), + 'PAYMENT_AMOUNT': payment.get('amount'), + 'PAYMENT_REFERENCE': payment.get('reference'), + 'PAYMENT_APPROVAL_CODE': payment.get('approval_code'), + 'PAYMENT_RESPONSE_CODE': payment.get('response_code'), + 'BANK_SIGN_CERT_ID': bank_sign.get('cert_id'), + 'BANK_SIGN_TYPE': bank_sign.get('type'), + } + result['LETTER'] = letter = '')[0] + '' + result['SIGN'] = ET.tostring(bank_sign) + result['RAWSIGN'] = bank_sign.text + return result + + +def postlink_process(response=""): + args = { + 'status': False, + 'message': "", + } + result = Result(**args) + try: + root = ET.fromstring(response) + except Exception as e: + result.message = "xml file not parsable" + return result + if root.find('error'): + result.message = root.find('error').text + return result + if root.tag == 'document': + kkbSign = KKBSign() + data = xml2dict(response) + check = kkbSign.check(data['RAWSIGN'], data['LETTER']) + if "Verified OK" in check: + result.status = True + result.data = data + result.message = check + else: + result.message = check + else: + result.message = "[XML_DOCUMENT_UNKNOWN_TYPE]" + return result + + +def get_context(order_id, amount='0', currency_id='398', b64=True): + context = { + 'ORDER_ID': int(order_id), + 'CURRENCY': currency_id, + 'AMOUNT': float(amount), + 'MERCHANT_CERTIFICATE_ID': settings.MERCHANT_CERTIFICATE_ID, + 'MERCHANT_NAME': settings.MERCHANT_NAME, + 'MERCHANT_ID': settings.MERCHANT_ID, + } + kkbSign = KKBSign() + try: + rendered = render_to_string(settings.XML_TEMPLATE_FN, context) + except Exception as e: + return "Error reading XML template." + result_sign = "".join(['', + kkbSign.sign64(rendered).decode('utf-8'), '']) + xml = "".join(["", rendered, result_sign, ""]) + if b64: + return base64.b64encode(xml.encode('ascii')).decode('utf-8') + # return "".join(base64.b64encode(xml.encode('utf-8')).split("\n")) + else: + return xml diff --git a/kkb/templates/kkb/appendix.xml b/kkb/templates/kkb/appendix.xml new file mode 100644 index 0000000..2d54dce --- /dev/null +++ b/kkb/templates/kkb/appendix.xml @@ -0,0 +1,7 @@ + + + {% for item in items %} + + {% endfor %} + \ No newline at end of file diff --git a/kkb/templates/kkb/command_template.xml b/kkb/templates/kkb/command_template.xml new file mode 100644 index 0000000..1c0a437 --- /dev/null +++ b/kkb/templates/kkb/command_template.xml @@ -0,0 +1,6 @@ + + + + [REASON] + \ No newline at end of file diff --git a/kkb/templates/kkb/template.xml b/kkb/templates/kkb/template.xml new file mode 100644 index 0000000..befb675 --- /dev/null +++ b/kkb/templates/kkb/template.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/static/img/bank.png b/static/img/bank.png new file mode 100644 index 0000000..f828a99 Binary files /dev/null and b/static/img/bank.png differ diff --git a/static/img/cards.png b/static/img/cards.png new file mode 100644 index 0000000..b97e384 Binary files /dev/null and b/static/img/cards.png differ diff --git a/static/less/_.css b/static/less/_.css index 5f8c86d..fd1be00 100644 --- a/static/less/_.css +++ b/static/less/_.css @@ -965,3 +965,15 @@ ul.messages { font-size: 20px; line-height: 50px; } +.radio img { + margin-top: 10px; + margin-bottom: 10px; +} +.radio label { + margin-left: 0px !important; + padding-left: 0px !important; +} +.radio label input { + margin-left: 0 !important; + position: relative !important; +} diff --git a/static/less/_.less b/static/less/_.less index 72857ff..68ec31e 100644 --- a/static/less/_.less +++ b/static/less/_.less @@ -8,8 +8,8 @@ @brand-gray: #434a54; @brand-white: @white; -body{ - font-family: 'Trebuchet MS', 'PT Sans', Helvetica, Arial, sans-serif; +body { + font-family: 'Trebuchet MS', 'PT Sans', Helvetica, Arial, sans-serif; } /* Account for fixed navbar */ @@ -122,11 +122,11 @@ span.yellow { * with disabling the responsiveness. */ - /* Account for fixed navbar */ +/* Account for fixed navbar */ - body, - .navbar-static-top, - .navbar-fixed-bottom { +body, +.navbar-static-top, +.navbar-fixed-bottom { min-width: 970px; } @@ -150,8 +150,8 @@ span.yellow { * grid system, and navbar. */ - /* Reset the container */ - .container { +/* Reset the container */ +.container { width: 970px; max-width: none !important; } @@ -235,7 +235,7 @@ span.yellow { font-weight: normal; font-size: 11px; &.title { - color: @brand-yellow !important;//lighten(@blue, 30%) !important; + color: @brand-yellow !important; //lighten(@blue, 30%) !important; font-weight: bold; font-size: 12px; @@ -252,10 +252,12 @@ span.yellow { -webkit-box-shadow: 0 6px 12px rgba(0, 0, 0, .175); box-shadow: 0 6px 12px rgba(0, 0, 0, .175); } -a#order-call-link{ + +a#order-call-link { color: #FC6E51; //font-size: 14px; } + .navbar-default .navbar-nav .open .dropdown-menu > li > a { color: #333; } @@ -608,8 +610,8 @@ hr.dashed { height: 20px; padding: 0 10px; } - select{ - color:black; + select { + color: black; } } @@ -730,25 +732,27 @@ table.table-cart { text-align: left; float: right; } - tbody{ - td{ + tbody { + td { padding-top: 45px; - &.table-cart-image{ + &.table-cart-image { padding-top: 8px; } - .form-control{ + .form-control { margin-top: -8px; } } } } -.breadcrumbs{ + +.breadcrumbs { overflow: hidden !important; } -ol.breadcrumb.breadcrumb-arrow{ +ol.breadcrumb.breadcrumb-arrow { overflow: hidden !important; } + .table { thead { tr { @@ -793,42 +797,45 @@ ul.messages { display: none; } -.product-description{ +.product-description { margin-top: 40px; padding-top: 20px; border-top: 1px #ddd solid; } -.order-data .radio{ + +.order-data .radio { margin-left: 15px; } #order-itogo-amount, #order-itogo-delivery, #cart-itogo, -#order-itogo-amount-up, #order-itogo-delivery-up, #cart-itogo-up -{ +#order-itogo-amount-up, #order-itogo-delivery-up, #cart-itogo-up { font-size: 20px; } -.well-large{ + +.well-large { padding: 40px; } -.news-container{ - .comment{ + +.news-container { + .comment { overflow: auto; } - .media{ + .media { background: #F5F7FA; padding: 15px; } } + .call-form, .order-form { - background: #FFF; - padding: 20px 30px; - text-align: left; - max-width: 500px; - margin: 40px auto; - position: relative + background: #FFF; + padding: 20px 30px; + text-align: left; + max-width: 500px; + margin: 40px auto; + position: relative } -.sale-percent-block{ +.sale-percent-block { background: #E9573F; width: 50px; height: 50px; @@ -837,4 +844,19 @@ ul.messages { top: 0; font-size: 20px; line-height: 50px; -} \ No newline at end of file +} + +.radio { + img { + margin-top: 10px; + margin-bottom: 10px; + } + label { + margin-left: 0px !important; + padding-left: 0px !important; + input { + margin-left: 0 !important; + position: relative !important; + } + } +} diff --git a/static/less/style.less b/static/less/style.less index d60575c..dac6957 100644 --- a/static/less/style.less +++ b/static/less/style.less @@ -45,3 +45,6 @@ .form-group.required .control-label:after{ content: '*'; } +.radio{ + +} \ No newline at end of file diff --git a/store/views.py b/store/views.py index 7dc43ca..61801d4 100644 --- a/store/views.py +++ b/store/views.py @@ -1,7 +1,9 @@ +import base64 from django.contrib.auth import authenticate, login from django.core.mail import mail_managers from django.core.paginator import Paginator, PageNotAnInteger, EmptyPage from django.shortcuts import get_object_or_404, redirect, render +from django.template.loader import render_to_string from django.views.generic import * from accounts.models import Profile from accounts.utils import normalize_phone, send_email @@ -15,7 +17,7 @@ from django.http import JsonResponse from datetime import datetime from django.conf import settings from django.contrib.sitemaps import Sitemap - +import kkb class CategoryBaseView(object): category = None @@ -267,8 +269,12 @@ class CartDetailView(TemplateView): order.save() mail_managers('Оформили заказ', 'Смотреть в админке') + payment_type = request.POST.get('payment_type', 'card') + if payment_type == 'card': + return redirect('/order/{}/kkb/'.format(order.pk)) + return redirect('/order/{}/print/'.format(order.pk)) + - return redirect('/order/{}/'.format(order.pk)) else: return self.render_to_response(self.get_context_data()) @@ -303,12 +309,31 @@ def order_print(request, order): def order_kkb(request, order): order = get_object_or_404(OrderData, pk=order) - import kkb - context = kkb.get_context(order_id='333', amount="666", currency_id="398") - c = dict(order=order, context=context) + cart = Cart(request) + context = kkb.get_context(order.pk, amount=order.amount, b64=True) + + c_appendix = dict(items=cart.items, deliv_price=order.amount - cart.total) + render_appendix = render_to_string('kkb/appendix.xml', c_appendix) + appendix = base64.b64encode( + bytes(render_appendix, 'utf-8') + ).decode('utf-8') + + c = dict(order=order, context=context, appendix=appendix) return render(request, 'kkb.jinja', c) +def kkb_result(request): + response = request.POST['response'] + result = kkb.postlink(response) + if result.status: + order = OrderData.objects.get(pk=int(result.data['ORDER_ID'])) + order.status = 1 + order.save() + mail_managers('Оплатили заказ картой', 'Заказ №{}'.format(order.pk)) + else: + print(result.message) + return render(request, 'kkb_ok.jinja') + class ProductSitemap(Sitemap): changefreq = "daily" diff --git a/tmp/eml/20150728-003520-4463280256.eml b/tmp/eml/20150728-003520-4463280256.eml new file mode 100644 index 0000000..b66b505 --- /dev/null +++ b/tmp/eml/20150728-003520-4463280256.eml @@ -0,0 +1,37 @@ +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Subject: =?utf-8?b?0KDQvtCx0L7RgiBCYXRpc2thZi1rei5reg==?= +From: admin@batiskaf-kz.kz +To: asdfasdf@sadf.com +Date: Mon, 27 Jul 2015 18:35:20 -0000 +Message-ID: <20150727183520.60869.33366@macbook-pro.local> + +Привет, gre! + +Поздравляем, вы успешно оформили заказ. + +Для того, чтобы его было удобнее отслеживать, войдите в свой личный кабинет, используя свой номер телефона +7: + +http://batiskaf-kz.kz/account/ + + +Это автоматическое сообщение. Отвечать на него не нужно! + +С Уважением, +Администрация Batiskaf-kz.kz +-- +Skype: batiskaf_kz +Тел: +7 (777) 163-14-34 или +7 (775) 859-12-17 +------------------------------------------------------------------------------- +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Subject: =?utf-8?b?W0RqYW5nb10g0J7RhNC+0YDQvNC40LvQuCDQt9Cw0LrQsNC3?= +From: admin@batiskaf-kz.kz +To: spacenergy@me.com, admin@batiskaf-kz.kz +Date: Mon, 27 Jul 2015 18:35:20 -0000 +Message-ID: <20150727183520.60869.15005@macbook-pro.local> + +Смотреть в админке +------------------------------------------------------------------------------- diff --git a/tmp/eml/20150728-010913-4461213232.eml b/tmp/eml/20150728-010913-4461213232.eml new file mode 100644 index 0000000..db2202b --- /dev/null +++ b/tmp/eml/20150728-010913-4461213232.eml @@ -0,0 +1,37 @@ +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Subject: =?utf-8?b?0KDQvtCx0L7RgiBCYXRpc2thZi1rei5reg==?= +From: admin@batiskaf-kz.kz +To: asdfasdf@sadf.com +Date: Mon, 27 Jul 2015 19:09:13 -0000 +Message-ID: <20150727190913.62010.2321@macbook-pro.local> + +Привет, gre! + +Поздравляем, вы успешно оформили заказ. + +Для того, чтобы его было удобнее отслеживать, войдите в свой личный кабинет, используя свой номер телефона +7: + +http://batiskaf-kz.kz/account/ + + +Это автоматическое сообщение. Отвечать на него не нужно! + +С Уважением, +Администрация Batiskaf-kz.kz +-- +Skype: batiskaf_kz +Тел: +7 (777) 163-14-34 или +7 (775) 859-12-17 +------------------------------------------------------------------------------- +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Subject: =?utf-8?b?W0RqYW5nb10g0J7RhNC+0YDQvNC40LvQuCDQt9Cw0LrQsNC3?= +From: admin@batiskaf-kz.kz +To: spacenergy@me.com, admin@batiskaf-kz.kz +Date: Mon, 27 Jul 2015 19:09:13 -0000 +Message-ID: <20150727190913.62010.34998@macbook-pro.local> + +Смотреть в админке +------------------------------------------------------------------------------- diff --git a/tmp/eml/20150728-010925-4463159840.eml b/tmp/eml/20150728-010925-4463159840.eml new file mode 100644 index 0000000..c912061 --- /dev/null +++ b/tmp/eml/20150728-010925-4463159840.eml @@ -0,0 +1,37 @@ +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Subject: =?utf-8?b?0KDQvtCx0L7RgiBCYXRpc2thZi1rei5reg==?= +From: admin@batiskaf-kz.kz +To: asdfasdf@sadf.com +Date: Mon, 27 Jul 2015 19:09:25 -0000 +Message-ID: <20150727190925.62010.23670@macbook-pro.local> + +Привет, gre! + +Поздравляем, вы успешно оформили заказ. + +Для того, чтобы его было удобнее отслеживать, войдите в свой личный кабинет, используя свой номер телефона +7: + +http://batiskaf-kz.kz/account/ + + +Это автоматическое сообщение. Отвечать на него не нужно! + +С Уважением, +Администрация Batiskaf-kz.kz +-- +Skype: batiskaf_kz +Тел: +7 (777) 163-14-34 или +7 (775) 859-12-17 +------------------------------------------------------------------------------- +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Subject: =?utf-8?b?W0RqYW5nb10g0J7RhNC+0YDQvNC40LvQuCDQt9Cw0LrQsNC3?= +From: admin@batiskaf-kz.kz +To: spacenergy@me.com, admin@batiskaf-kz.kz +Date: Mon, 27 Jul 2015 19:09:25 -0000 +Message-ID: <20150727190925.62010.21647@macbook-pro.local> + +Смотреть в админке +------------------------------------------------------------------------------- diff --git a/tmp/eml/20150728-011421-4462853816.eml b/tmp/eml/20150728-011421-4462853816.eml new file mode 100644 index 0000000..d6dd419 --- /dev/null +++ b/tmp/eml/20150728-011421-4462853816.eml @@ -0,0 +1,37 @@ +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Subject: =?utf-8?b?0KDQvtCx0L7RgiBCYXRpc2thZi1rei5reg==?= +From: admin@batiskaf-kz.kz +To: asdfasdf@sadf.com +Date: Mon, 27 Jul 2015 19:14:21 -0000 +Message-ID: <20150727191421.62010.24196@macbook-pro.local> + +Привет, gre! + +Поздравляем, вы успешно оформили заказ. + +Для того, чтобы его было удобнее отслеживать, войдите в свой личный кабинет, используя свой номер телефона +7: + +http://batiskaf-kz.kz/account/ + + +Это автоматическое сообщение. Отвечать на него не нужно! + +С Уважением, +Администрация Batiskaf-kz.kz +-- +Skype: batiskaf_kz +Тел: +7 (777) 163-14-34 или +7 (775) 859-12-17 +------------------------------------------------------------------------------- +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Subject: =?utf-8?b?W0RqYW5nb10g0J7RhNC+0YDQvNC40LvQuCDQt9Cw0LrQsNC3?= +From: admin@batiskaf-kz.kz +To: spacenergy@me.com, admin@batiskaf-kz.kz +Date: Mon, 27 Jul 2015 19:14:21 -0000 +Message-ID: <20150727191421.62010.4569@macbook-pro.local> + +Смотреть в админке +------------------------------------------------------------------------------- diff --git a/tmp/eml/20150728-222412-4460787808.eml b/tmp/eml/20150728-222412-4460787808.eml new file mode 100644 index 0000000..4afc2ff --- /dev/null +++ b/tmp/eml/20150728-222412-4460787808.eml @@ -0,0 +1,26 @@ +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Subject: =?utf-8?b?0KDQvtCx0L7RgiBCYXRpc2thZi1rei5reg==?= +From: admin@batiskaf-kz.kz +To: asdfasdf@sadf.com +Date: Tue, 28 Jul 2015 16:24:12 -0000 +Message-ID: <20150728162412.68057.81489@macbook-pro.local> + +Привет, gre! + +Поздравляем, вы успешно оформили заказ. + +Для того, чтобы его было удобнее отслеживать, войдите в свой личный кабинет, используя свой номер телефона +7: + +http://batiskaf-kz.kz/account/ + + +Это автоматическое сообщение. Отвечать на него не нужно! + +С Уважением, +Администрация Batiskaf-kz.kz +-- +Skype: batiskaf_kz +Тел: +7 (777) 163-14-34 или +7 (775) 859-12-17 +------------------------------------------------------------------------------- diff --git a/tmp/eml/20150728-222412-4460820968.eml b/tmp/eml/20150728-222412-4460820968.eml new file mode 100644 index 0000000..b3b2c56 --- /dev/null +++ b/tmp/eml/20150728-222412-4460820968.eml @@ -0,0 +1,11 @@ +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Subject: =?utf-8?b?W0RqYW5nb10g0J7RhNC+0YDQvNC40LvQuCDQt9Cw0LrQsNC3?= +From: admin@batiskaf-kz.kz +To: spacenergy@me.com, admin@batiskaf-kz.kz +Date: Tue, 28 Jul 2015 16:24:12 -0000 +Message-ID: <20150728162412.68057.17322@macbook-pro.local> + +Смотреть в админке +------------------------------------------------------------------------------- diff --git a/tmp/eml/20150728-224018-4465087488.eml b/tmp/eml/20150728-224018-4465087488.eml new file mode 100644 index 0000000..106bb03 --- /dev/null +++ b/tmp/eml/20150728-224018-4465087488.eml @@ -0,0 +1,26 @@ +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Subject: =?utf-8?b?0KDQvtCx0L7RgiBCYXRpc2thZi1rei5reg==?= +From: admin@batiskaf-kz.kz +To: asdfasdf@sadf.com +Date: Tue, 28 Jul 2015 16:40:18 -0000 +Message-ID: <20150728164018.68341.81056@macbook-pro.local> + +Привет, gre! + +Поздравляем, вы успешно оформили заказ. + +Для того, чтобы его было удобнее отслеживать, войдите в свой личный кабинет, используя свой номер телефона +7: + +http://batiskaf-kz.kz/account/ + + +Это автоматическое сообщение. Отвечать на него не нужно! + +С Уважением, +Администрация Batiskaf-kz.kz +-- +Skype: batiskaf_kz +Тел: +7 (777) 163-14-34 или +7 (775) 859-12-17 +------------------------------------------------------------------------------- diff --git a/tmp/eml/20150728-224018-4465536528.eml b/tmp/eml/20150728-224018-4465536528.eml new file mode 100644 index 0000000..46c9248 --- /dev/null +++ b/tmp/eml/20150728-224018-4465536528.eml @@ -0,0 +1,11 @@ +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Subject: =?utf-8?b?W0RqYW5nb10g0J7RhNC+0YDQvNC40LvQuCDQt9Cw0LrQsNC3?= +From: admin@batiskaf-kz.kz +To: spacenergy@me.com, admin@batiskaf-kz.kz +Date: Tue, 28 Jul 2015 16:40:18 -0000 +Message-ID: <20150728164018.68341.64244@macbook-pro.local> + +Смотреть в админке +------------------------------------------------------------------------------- diff --git a/tmp/eml/20150728-224147-4462188696.eml b/tmp/eml/20150728-224147-4462188696.eml new file mode 100644 index 0000000..b9c40da --- /dev/null +++ b/tmp/eml/20150728-224147-4462188696.eml @@ -0,0 +1,26 @@ +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Subject: =?utf-8?b?0KDQvtCx0L7RgiBCYXRpc2thZi1rei5reg==?= +From: admin@batiskaf-kz.kz +To: asdfasdf@sadf.com +Date: Tue, 28 Jul 2015 16:41:47 -0000 +Message-ID: <20150728164147.68341.19068@macbook-pro.local> + +Привет, gre! + +Поздравляем, вы успешно оформили заказ. + +Для того, чтобы его было удобнее отслеживать, войдите в свой личный кабинет, используя свой номер телефона +7: + +http://batiskaf-kz.kz/account/ + + +Это автоматическое сообщение. Отвечать на него не нужно! + +С Уважением, +Администрация Batiskaf-kz.kz +-- +Skype: batiskaf_kz +Тел: +7 (777) 163-14-34 или +7 (775) 859-12-17 +------------------------------------------------------------------------------- diff --git a/tmp/eml/20150728-224147-4462410160.eml b/tmp/eml/20150728-224147-4462410160.eml new file mode 100644 index 0000000..b9cf818 --- /dev/null +++ b/tmp/eml/20150728-224147-4462410160.eml @@ -0,0 +1,11 @@ +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Subject: =?utf-8?b?W0RqYW5nb10g0J7RhNC+0YDQvNC40LvQuCDQt9Cw0LrQsNC3?= +From: admin@batiskaf-kz.kz +To: spacenergy@me.com, admin@batiskaf-kz.kz +Date: Tue, 28 Jul 2015 16:41:47 -0000 +Message-ID: <20150728164147.68341.15616@macbook-pro.local> + +Смотреть в админке +------------------------------------------------------------------------------- diff --git a/tmp/eml/20150728-224504-4460315928.eml b/tmp/eml/20150728-224504-4460315928.eml new file mode 100644 index 0000000..f594c93 --- /dev/null +++ b/tmp/eml/20150728-224504-4460315928.eml @@ -0,0 +1,11 @@ +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Subject: =?utf-8?b?W0RqYW5nb10g0J7RhNC+0YDQvNC40LvQuCDQt9Cw0LrQsNC3?= +From: admin@batiskaf-kz.kz +To: spacenergy@me.com, admin@batiskaf-kz.kz +Date: Tue, 28 Jul 2015 16:45:04 -0000 +Message-ID: <20150728164504.68482.44783@macbook-pro.local> + +Смотреть в админке +------------------------------------------------------------------------------- diff --git a/tmp/eml/20150728-224504-4460735232.eml b/tmp/eml/20150728-224504-4460735232.eml new file mode 100644 index 0000000..5d56fea --- /dev/null +++ b/tmp/eml/20150728-224504-4460735232.eml @@ -0,0 +1,26 @@ +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Subject: =?utf-8?b?0KDQvtCx0L7RgiBCYXRpc2thZi1rei5reg==?= +From: admin@batiskaf-kz.kz +To: asdfasdf@sadf.com +Date: Tue, 28 Jul 2015 16:45:04 -0000 +Message-ID: <20150728164504.68482.57283@macbook-pro.local> + +Привет, gre! + +Поздравляем, вы успешно оформили заказ. + +Для того, чтобы его было удобнее отслеживать, войдите в свой личный кабинет, используя свой номер телефона +7: + +http://batiskaf-kz.kz/account/ + + +Это автоматическое сообщение. Отвечать на него не нужно! + +С Уважением, +Администрация Batiskaf-kz.kz +-- +Skype: batiskaf_kz +Тел: +7 (777) 163-14-34 или +7 (775) 859-12-17 +------------------------------------------------------------------------------- diff --git a/tmp/eml/20150728-225843-4463828832.eml b/tmp/eml/20150728-225843-4463828832.eml new file mode 100644 index 0000000..9f917a5 --- /dev/null +++ b/tmp/eml/20150728-225843-4463828832.eml @@ -0,0 +1,26 @@ +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Subject: =?utf-8?b?0KDQvtCx0L7RgiBCYXRpc2thZi1rei5reg==?= +From: admin@batiskaf-kz.kz +To: spacenergy@asd.com +Date: Tue, 28 Jul 2015 16:58:43 -0000 +Message-ID: <20150728165843.68923.61730@macbook-pro.local> + +Привет, Виталий1! + +Поздравляем, вы успешно оформили заказ. + +Для того, чтобы его было удобнее отслеживать, войдите в свой личный кабинет, используя свой номер телефона +77083044916: + +http://batiskaf-kz.kz/account/ + + +Это автоматическое сообщение. Отвечать на него не нужно! + +С Уважением, +Администрация Batiskaf-kz.kz +-- +Skype: batiskaf_kz +Тел: +7 (777) 163-14-34 или +7 (775) 859-12-17 +------------------------------------------------------------------------------- diff --git a/tmp/eml/20150728-225844-4463827040.eml b/tmp/eml/20150728-225844-4463827040.eml new file mode 100644 index 0000000..d72333e --- /dev/null +++ b/tmp/eml/20150728-225844-4463827040.eml @@ -0,0 +1,11 @@ +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Subject: =?utf-8?b?W0RqYW5nb10g0J7RhNC+0YDQvNC40LvQuCDQt9Cw0LrQsNC3?= +From: admin@batiskaf-kz.kz +To: spacenergy@me.com, admin@batiskaf-kz.kz +Date: Tue, 28 Jul 2015 16:58:44 -0000 +Message-ID: <20150728165844.68923.14083@macbook-pro.local> + +Смотреть в админке +-------------------------------------------------------------------------------