-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathmanual.py
80 lines (65 loc) · 1.96 KB
/
manual.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# -*- coding: utf-8 -*-
'''
Manual payment gateway
Often payment modes are offline like cash, external credit card terminals
etc. This gateway implements that
:copyright: (c) 2013-2014 by Openlabs Technologies & Consulting (P) Ltd.
:license: BSD, see LICENSE for more details
'''
from trytond.pool import PoolMeta
__metaclass__ = PoolMeta
class PaymentGatewaySelf:
"COD, Cheque and Bank Transfer Implementation"
__name__ = 'payment_gateway.gateway'
@classmethod
def get_providers(cls, values=None):
"""
Downstream modules can add to the list
"""
rv = super(PaymentGatewaySelf, cls).get_providers()
self_record = ('self', 'Self')
if self_record not in rv:
rv.append(self_record)
return rv
def get_methods(self):
if self.provider == 'self':
return [
('manual', 'Manual/Offline'),
]
return super(PaymentGatewaySelf, self).get_methods()
class ManualSelfTransaction:
"""
Implement the authorize and capture methods
"""
__name__ = 'payment_gateway.transaction'
def authorize_self(self, card_info=None):
"""
Authorize a manual payment
"""
self.state = 'authorized'
self.save()
def settle_self(self):
"""
Capture a manual payment.
All that needs to be done is post the transaction.
"""
self.state = 'completed'
self.save()
self.safe_post()
def capture_self(self):
"""
Capture a manual payment.
All that needs to be done is post the transaction.
"""
self.state = 'completed'
self.save()
self.safe_post()
def cancel_dummy(self):
"""
Cancel a dummy transaction
"""
if self.state != 'authorized':
self.raise_user_error('cancel_only_authorized')
else:
self.state = 'cancel'
self.save()