Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
re2o
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nounous
re2o
Commits
0fe430d7
Commit
0fe430d7
authored
Jul 02, 2018
by
Hugo LEVY-FALK
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ajout de comnpay + fix de l'utilisation des paiements personnalisés
parent
cc4815c8
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
32 additions
and
32 deletions
+32
-32
cotisations/models.py
cotisations/models.py
+5
-2
cotisations/payment_methods/__init__.py
cotisations/payment_methods/__init__.py
+1
-20
cotisations/payment_methods/comnpay/models.py
cotisations/payment_methods/comnpay/models.py
+1
-1
cotisations/payment_methods/comnpay/views.py
cotisations/payment_methods/comnpay/views.py
+6
-6
cotisations/payment_methods/forms.py
cotisations/payment_methods/forms.py
+2
-2
cotisations/payment_methods/urls.py
cotisations/payment_methods/urls.py
+7
-0
cotisations/urls.py
cotisations/urls.py
+1
-1
cotisations/utils.py
cotisations/utils.py
+9
-0
No files found.
cotisations/models.py
View file @
0fe430d7
...
@@ -51,6 +51,8 @@ from re2o.field_permissions import FieldPermissionModelMixin
...
@@ -51,6 +51,8 @@ from re2o.field_permissions import FieldPermissionModelMixin
from
re2o.mixins
import
AclMixin
,
RevMixin
from
re2o.mixins
import
AclMixin
,
RevMixin
from
preferences.models
import
OptionalUser
from
preferences.models
import
OptionalUser
from
cotisations.utils
import
find_payment_method
# TODO : change facture to invoice
# TODO : change facture to invoice
class
Facture
(
RevMixin
,
AclMixin
,
FieldPermissionModelMixin
,
models
.
Model
):
class
Facture
(
RevMixin
,
AclMixin
,
FieldPermissionModelMixin
,
models
.
Model
):
...
@@ -643,8 +645,9 @@ class Paiement(RevMixin, AclMixin, models.Model):
...
@@ -643,8 +645,9 @@ class Paiement(RevMixin, AclMixin, models.Model):
:returns: An `HttpResponse`-like object.
:returns: An `HttpResponse`-like object.
"""
"""
if
hasattr
(
self
,
'payment_method'
)
and
use_payment_method
:
payment_method
=
find_payment_method
(
self
)
return
self
.
payment_method
.
end_payment
(
invoice
,
request
)
if
payment_method
is
not
None
and
use_payment_method
:
return
payment_method
.
end_payment
(
invoice
,
request
)
# In case a cotisation was bought, inform the user, the
# In case a cotisation was bought, inform the user, the
# cotisation time has been extended too
# cotisation time has been extended too
...
...
cotisations/payment_methods/__init__.py
View file @
0fe430d7
from
django.conf.urls
import
include
,
url
from
.
import
comnpay
,
cheque
,
urls
from
django.utils.translation
import
ugettext_lazy
as
_l
from
.
import
comnpay
,
cheque
urlpatterns
=
[
url
(
r
'^comnpay/'
,
include
(
comnpay
.
urls
,
namespace
=
'comnpay'
)),
url
(
r
'^cheque/'
,
include
(
cheque
.
urls
,
namespace
=
'cheque'
)),
]
PAYMENT_METHODS
=
[
PAYMENT_METHODS
=
[
comnpay
,
comnpay
,
cheque
,
cheque
,
]
]
def
find_payment_method
(
payment
):
for
method
in
PAYMENT_METHODS
:
try
:
o
=
method
.
PaymentMethod
.
objects
.
get
(
payment
=
payment
)
return
o
except
method
.
PaymentMethod
.
DoesNotExist
:
pass
return
None
cotisations/payment_methods/comnpay/models.py
View file @
0fe430d7
...
@@ -31,5 +31,5 @@ class ComnpayPayment(PaymentMethodMixin, models.Model):
...
@@ -31,5 +31,5 @@ class ComnpayPayment(PaymentMethodMixin, models.Model):
def
end_payment
(
self
,
invoice
,
request
):
def
end_payment
(
self
,
invoice
,
request
):
invoice
.
valid
=
False
invoice
.
valid
=
False
invoice
.
save
()
invoice
.
save
()
content
=
comnpay
(
invoice
,
request
)
content
=
comnpay
(
invoice
,
request
,
self
)
return
render
(
request
,
'cotisations/payment.html'
,
content
)
return
render
(
request
,
'cotisations/payment.html'
,
content
)
cotisations/payment_methods/comnpay/views.py
View file @
0fe430d7
...
@@ -114,7 +114,7 @@ def ipn(request):
...
@@ -114,7 +114,7 @@ def ipn(request):
return
HttpResponse
(
"HTTP/1.0 200 OK"
)
return
HttpResponse
(
"HTTP/1.0 200 OK"
)
def
comnpay
(
facture
,
request
):
def
comnpay
(
facture
,
request
,
payment
):
"""
"""
Build a request to start the negociation with Comnpay by using
Build a request to start the negociation with Comnpay by using
a facture id, the price and the secret transaction data stored in
a facture id, the price and the secret transaction data stored in
...
@@ -122,14 +122,14 @@ def comnpay(facture, request):
...
@@ -122,14 +122,14 @@ def comnpay(facture, request):
"""
"""
host
=
request
.
get_host
()
host
=
request
.
get_host
()
p
=
Transaction
(
p
=
Transaction
(
str
(
AssoOption
.
get_cached_value
(
'payment_id'
)
),
str
(
payment
.
payment_credential
),
str
(
AssoOption
.
get_cached_value
(
'payment_pass'
)
),
str
(
payment
.
payment_pass
),
'https://'
+
host
+
reverse
(
'https://'
+
host
+
reverse
(
'cotisations:comnpay
_
accept_payment'
,
'cotisations:comnpay
:
accept_payment'
,
kwargs
=
{
'factureid'
:
facture
.
id
}
kwargs
=
{
'factureid'
:
facture
.
id
}
),
),
'https://'
+
host
+
reverse
(
'cotisations:comnpay
_
refuse_payment'
),
'https://'
+
host
+
reverse
(
'cotisations:comnpay
:
refuse_payment'
),
'https://'
+
host
+
reverse
(
'cotisations:comnpay
_
ipn'
),
'https://'
+
host
+
reverse
(
'cotisations:comnpay
:
ipn'
),
""
,
""
,
"D"
"D"
)
)
...
...
cotisations/payment_methods/forms.py
View file @
0fe430d7
...
@@ -2,8 +2,8 @@ from django import forms
...
@@ -2,8 +2,8 @@ from django import forms
from
django.utils.translation
import
ugettext
as
_
from
django.utils.translation
import
ugettext
as
_
from
django.utils.translation
import
ugettext_lazy
as
_l
from
django.utils.translation
import
ugettext_lazy
as
_l
from
.
import
PAYMENT_METHODS
,
find_payment_method
from
.
import
PAYMENT_METHODS
from
cotisations.utils
import
find_payment_method
def
payment_method_factory
(
payment
,
*
args
,
**
kwargs
):
def
payment_method_factory
(
payment
,
*
args
,
**
kwargs
):
payment_method
=
kwargs
.
pop
(
'instance'
,
find_payment_method
(
payment
))
payment_method
=
kwargs
.
pop
(
'instance'
,
find_payment_method
(
payment
))
...
...
cotisations/payment_methods/urls.py
0 → 100644
View file @
0fe430d7
from
django.conf.urls
import
include
,
url
from
.
import
comnpay
,
cheque
urlpatterns
=
[
url
(
r
'^comnpay/'
,
include
(
comnpay
.
urls
,
namespace
=
'comnpay'
)),
url
(
r
'^cheque/'
,
include
(
cheque
.
urls
,
namespace
=
'cheque'
)),
]
cotisations/urls.py
View file @
0fe430d7
...
@@ -144,5 +144,5 @@ urlpatterns = [
...
@@ -144,5 +144,5 @@ urlpatterns = [
name
=
'recharge'
name
=
'recharge'
),
),
url
(
r
'^$'
,
views
.
index
,
name
=
'index'
),
url
(
r
'^$'
,
views
.
index
,
name
=
'index'
),
]
+
payment_methods
.
urlpatterns
]
+
payment_methods
.
url
s
.
url
patterns
cotisations/utils.py
0 → 100644
View file @
0fe430d7
def
find_payment_method
(
payment
):
from
cotisations.payment_methods
import
PAYMENT_METHODS
for
method
in
PAYMENT_METHODS
:
try
:
o
=
method
.
PaymentMethod
.
objects
.
get
(
payment
=
payment
)
return
o
except
method
.
PaymentMethod
.
DoesNotExist
:
pass
return
None
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment