source: main/waeup.fceokene/trunk/src/waeup/fceokene/remita/browser.py @ 16593

Last change on this file since 16593 was 15827, checked in by Henrik Bettermann, 5 years ago

Fix module_activated.

  • Property svn:keywords set to Id
File size: 6.1 KB
Line 
1## $Id: browser.py 15827 2019-11-19 13:08:27Z henrik $
2##
3## Copyright (C) 2017 Uli Fouquet & Henrik Bettermann
4## This program is free software; you can redistribute it and/or modify
5## it under the terms of the GNU General Public License as published by
6## the Free Software Foundation; either version 2 of the License, or
7## (at your option) any later version.
8##
9## This program is distributed in the hope that it will be useful,
10## but WITHOUT ANY WARRANTY; without even the implied warranty of
11## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12## GNU General Public License for more details.
13##
14## You should have received a copy of the GNU General Public License
15## along with this program; if not, write to the Free Software
16## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17##
18
19from kofacustom.nigeria.remita.studentsbrowser import (
20    module_activated,
21    RemitaRequestPaymentStatusPageStudent,
22    RemitaVerifyPaymentStatusPageStudent,
23    RemitaPageStudent)
24from kofacustom.nigeria.remita.applicantsbrowser import (
25    RemitaRequestPaymentStatusPageApplicant,
26    RemitaVerifyPaymentStatusPageApplicant,
27    RemitaPageApplicant)
28
29# Temporarily we can use the test portal like in kofacustom.nigeria
30
31#from kofacustom.nigeria.remita.tests import (
32#    MERCHANTID, HOST, HTTPS, API_KEY, SERVICETYPEID)
33
34MERCHANTID = '3534555222'
35HOST = 'login.remita.net'
36HTTPS = True
37API_KEY = '756843'
38SERVICETYPEID = '365039884'
39
40PROVIDER_ACCT = '0773411069'
41PROVIDER_BANKCODE = '044'
42INSTITUTION_ACCT = '0270100161017'
43INSTITUTION_BANKCODE = '000'
44
45class CustomRemitaRequestPaymentStatusPageStudent(
46    RemitaRequestPaymentStatusPageStudent):
47    """ Request webservice view for the Remita gateway.
48    """
49
50    merchantId = MERCHANTID
51    host = HOST
52    https = HTTPS
53    api_key = API_KEY
54
55class CustomRemitaVerifyPaymentStatusPageStudent(
56    RemitaVerifyPaymentStatusPageStudent):
57    """ Request webservice view for the Remita gateway.
58    """
59
60    merchantId = MERCHANTID
61    host = HOST
62    https = HTTPS
63    api_key = API_KEY
64
65class CustomRemitaPageStudent(RemitaPageStudent):
66    """ View which sends a POST request to the Remita payment gateway.
67    """
68
69    merchantId = MERCHANTID
70    host = HOST
71    https = HTTPS
72    api_key = API_KEY
73
74    init_url = '/remita/ecomm/split/init.reg'
75
76    @property
77    def serviceTypeId(self):
78        return SERVICETYPEID
79
80    @property
81    def lineitems(self):
82        provider_amt = 1600.0
83        if 'maintenance' in self.context.p_category or \
84            self.context.p_category == 'clearance':
85            provider_amt = 0.0
86        inst_amt = self.context.amount_auth - provider_amt
87        if provider_amt:
88            lineitems = (
89                          {"lineItemsId":"itemid1","beneficiaryName":"FCEOkene",
90                          "beneficiaryAccount":INSTITUTION_ACCT,
91                          "bankCode":INSTITUTION_BANKCODE,
92                          "beneficiaryAmount":inst_amt,"deductFeeFrom":"1"},
93                          {"lineItemsId":"itemid2","beneficiaryName":"WAEAC",
94                          "beneficiaryAccount":PROVIDER_ACCT,
95                          "bankCode":PROVIDER_BANKCODE,
96                          "beneficiaryAmount":provider_amt,"deductFeeFrom":"0"}
97                        )
98        else:
99            lineitems = (
100                          {"lineItemsId":"itemid1","beneficiaryName":"FCEOkene",
101                          "beneficiaryAccount":INSTITUTION_ACCT,
102                          "bankCode":INSTITUTION_BANKCODE,
103                          "beneficiaryAmount":inst_amt,"deductFeeFrom":"1"},
104                        )
105        self.context.provider_amt = provider_amt
106        return lineitems
107
108    def update(self):
109        if not module_activated(
110            self.context.student.current_session, self.context):
111            return
112        self.orderId = self.context.p_id
113        self.amount = str(self.context.amount_auth)
114        error = self.init_update()
115        if error:
116            self.flash(error, type='danger')
117            self.redirect(self.url(self.context, '@@index'))
118            return
119        self.context.r_company = u'remita'
120        return
121
122class CustomRemitaRequestPaymentStatusPageApplicant(
123    RemitaRequestPaymentStatusPageApplicant):
124    """ Request webservice view for the Remita gateway.
125    """
126
127    merchantId = MERCHANTID
128    host = HOST
129    https = HTTPS
130    api_key = API_KEY
131
132class CustomRemitaVerifyPaymentStatusPageApplicant(
133    RemitaVerifyPaymentStatusPageApplicant):
134    """ Request webservice view for the Remita gateway.
135    """
136
137    merchantId = MERCHANTID
138    host = HOST
139    https = HTTPS
140    api_key = API_KEY
141
142class CustomRemitaPageApplicant(RemitaPageApplicant):
143    """ View which sends a POST request to the Remita payment gateway.
144    """
145
146    merchantId = MERCHANTID
147    host = HOST
148    https = HTTPS
149    api_key = API_KEY
150
151    init_url = '/remita/ecomm/split/init.reg'
152
153    @property
154    def serviceTypeId(self):
155        return SERVICETYPEID
156
157    @property
158    def lineitems(self):
159        provider_amt = 500.0
160        inst_amt = self.context.amount_auth - provider_amt
161        lineitems = (
162                          {"lineItemsId":"itemid1","beneficiaryName":"FCEOkene",
163                          "beneficiaryAccount":INSTITUTION_ACCT,
164                          "bankCode":INSTITUTION_BANKCODE,
165                          "beneficiaryAmount":inst_amt,"deductFeeFrom":"1"},
166                          {"lineItemsId":"itemid2","beneficiaryName":"WAEAC",
167                          "beneficiaryAccount":PROVIDER_ACCT,
168                          "bankCode":PROVIDER_BANKCODE,
169                          "beneficiaryAmount":provider_amt,"deductFeeFrom":"0"}
170                    )
171        self.context.provider_amt = provider_amt
172        return lineitems
173
174    def update(self):
175        if not module_activated(
176            self.context.__parent__.__parent__.year, self.context):
177            return
178        self.orderId = self.context.p_id
179        self.amount = str(self.context.amount_auth)
180        error = self.init_update()
181        if error:
182            self.flash(error, type='danger')
183            self.redirect(self.url(self.context, '@@index'))
184            return
185        self.context.r_company = u'remita'
186        return
Note: See TracBrowser for help on using the repository browser.