Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add request object to signal from result view #10

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions robokassa/forms.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
#coding: utf-8

from hashlib import md5
from urllib import urlencode
try:
from urllib import urlencode
except ImportError:
from urllib.parse import urlencode
from django import forms

from robokassa.conf import LOGIN, PASSWORD1, PASSWORD2, TEST_MODE
from robokassa.conf import STRICT_CHECK, FORM_TARGET, EXTRA_PARAMS
from robokassa.models import SuccessNotification


# python3
try:
unicode
except NameError:
unicode = str


class BaseRobokassaForm(forms.Form):

def __init__(self, *args, **kwargs):
Expand All @@ -32,7 +43,10 @@ def extra_params(self):
return extra

def _get_signature(self):
return md5(self._get_signature_string()).hexdigest().upper()
try:
return md5(self._get_signature_string()).hexdigest().upper()
except TypeError:
return md5(self._get_signature_string().encode('utf8')).hexdigest().upper()

def _get_signature_string(self):
raise NotImplementedError
Expand Down Expand Up @@ -162,5 +176,4 @@ class FailRedirectForm(BaseRobokassaForm):
OutSum = forms.CharField(max_length=15)
InvId = forms.IntegerField(min_value=0)
Culture = forms.CharField(max_length=10)


49 changes: 22 additions & 27 deletions robokassa/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,29 @@
# -*- coding: utf-8 -*-
import datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
# Generated by Django 1.9.5 on 2016-05-25 14:56
from __future__ import unicode_literals

from django.db import migrations, models

class Migration(SchemaMigration):

def forwards(self, orm):
# Adding model 'SuccessNotification'
db.create_table('robokassa_successnotification', (
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('InvId', self.gf('django.db.models.fields.IntegerField')(db_index=True)),
('OutSum', self.gf('django.db.models.fields.CharField')(max_length=15)),
('created_at', self.gf('django.db.models.fields.DateTimeField')(default=datetime.datetime.now)),
))
db.send_create_signal('robokassa', ['SuccessNotification'])
class Migration(migrations.Migration):

def backwards(self, orm):
# Deleting model 'SuccessNotification'
db.delete_table('robokassa_successnotification')
initial = True

models = {
'robokassa.successnotification': {
'InvId': ('django.db.models.fields.IntegerField', [], {'db_index': 'True'}),
'Meta': {'object_name': 'SuccessNotification'},
'OutSum': ('django.db.models.fields.CharField', [], {'max_length': '15'}),
'created_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'})
}
}
dependencies = [
]

complete_apps = ['robokassa']
operations = [
migrations.CreateModel(
name='SuccessNotification',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('InvId', models.IntegerField(db_index=True, verbose_name='\u041d\u043e\u043c\u0435\u0440 \u0437\u0430\u043a\u0430\u0437\u0430')),
('OutSum', models.CharField(max_length=15, verbose_name='\u0421\u0443\u043c\u043c\u0430')),
('created_at', models.DateTimeField(auto_now_add=True, verbose_name='\u0414\u0430\u0442\u0430 \u0438 \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f')),
],
options={
'verbose_name': '\u0423\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435 \u043e\u0431 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u043c \u043f\u043b\u0430\u0442\u0435\u0436\u0435',
'verbose_name_plural': '\u0423\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u043e\u0431 \u0443\u0441\u043f\u0435\u0448\u043d\u044b\u0445 \u043f\u043b\u0430\u0442\u0435\u0436\u0430\u0445 (ROBOKASSA)',
},
),
]
28 changes: 0 additions & 28 deletions robokassa/migrations/0002_update_to_14.py

This file was deleted.

31 changes: 9 additions & 22 deletions robokassa/urls.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,11 @@
#coding: utf-8
try:
from django.conf.urls.defaults import patterns, url
except ImportError:
from django.conf.urls import patterns, url

from django.conf.urls import url

urlpatterns = patterns('robokassa.views',
url(
r'^result/$',
'receive_result',
name='robokassa_result'
),
url(
r'^success/$',
'success',
name='robokassa_success'
),
url(
r'^fail/$',
'fail',
name='robokassa_fail'
),
)
from robokassa.views import receive_result, success, fail


urlpatterns = [
url(r'^result/$', receive_result, name='robokassa_result'),
url(r'^success/$', success, name='robokassa_success'),
url(r'^fail/$', fail, name='robokassa_fail'),
]
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#!/usr/bin/env python
#coding: utf-8
from setuptools import setup
from importlib import reload

import sys
reload(sys).setdefaultencoding("UTF-8")
# reload(sys).setdefaultencoding("UTF-8")

setup(
name='django-robokassa',
Expand All @@ -16,7 +17,7 @@
url='https://bitbucket.org/kmike/django-robokassa/',
license = 'MIT license',
description = u'Приложение для интеграции платежной системы ROBOKASSA в проекты на Django.'.encode('utf8'),
long_description = open('README.rst').read().decode('utf8') + u"\n\n" + open('CHANGES.rst').read().decode('utf8'),
long_description = open('README.rst').read() + u"\n\n" + open('CHANGES.rst').read(),

requires=['django (>= 1.3)'],

Expand Down