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

Last change on this file since 18240 was 18240, checked in by Henrik Bettermann, 10 months ago

Change account.

  • Property svn:keywords set to Id
File size: 6.4 KB
Line 
1## $Id: browser.py 18240 2026-02-04 13:17:07Z 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 self.context.student.faccode == 'SUP':
84            provider_amt = 7000.0
85        if self.context.p_category == 'clearance':
86            provider_amt = 1500.0
87        if self.context.p_item == 'Balance' or self.context.p_category in (
88           'hostel_maintenance', 'third_semester', 'reg2sandwich',
89            'schoolfee_third'):
90            provider_amt = 0.0
91        inst_amt = self.context.amount_auth - provider_amt
92        if provider_amt:
93            lineitems = (
94                          {"lineItemsId":"itemid1","beneficiaryName":"FCEOkene",
95                          "beneficiaryAccount":INSTITUTION_ACCT,
96                          "bankCode":INSTITUTION_BANKCODE,
97                          "beneficiaryAmount":inst_amt,"deductFeeFrom":"1"},
98                          {"lineItemsId":"itemid2","beneficiaryName":"WAEAC",
99                          "beneficiaryAccount":PROVIDER_ACCT,
100                          "bankCode":PROVIDER_BANKCODE,
101                          "beneficiaryAmount":provider_amt,"deductFeeFrom":"0"}
102                        )
103        else:
104            lineitems = (
105                          {"lineItemsId":"itemid1","beneficiaryName":"FCEOkene",
106                          "beneficiaryAccount":INSTITUTION_ACCT,
107                          "bankCode":INSTITUTION_BANKCODE,
108                          "beneficiaryAmount":inst_amt,"deductFeeFrom":"1"},
109                        )
110        self.context.provider_amt = provider_amt
111        return lineitems
112
113    def update(self):
114        if not module_activated(
115            self.context.student.current_session, self.context):
116            return
117        self.orderId = self.context.p_id
118        self.amount = str(self.context.amount_auth)
119        error = self.init_update()
120        if error:
121            self.flash(error, type='danger')
122            self.redirect(self.url(self.context, '@@index'))
123            return
124        self.context.r_company = u'remita'
125        return
126
127class CustomRemitaRequestPaymentStatusPageApplicant(
128    RemitaRequestPaymentStatusPageApplicant):
129    """ Request webservice view for the Remita gateway.
130    """
131
132    merchantId = MERCHANTID
133    host = HOST
134    https = HTTPS
135    api_key = API_KEY
136
137class CustomRemitaVerifyPaymentStatusPageApplicant(
138    RemitaVerifyPaymentStatusPageApplicant):
139    """ Request webservice view for the Remita gateway.
140    """
141
142    merchantId = MERCHANTID
143    host = HOST
144    https = HTTPS
145    api_key = API_KEY
146
147class CustomRemitaPageApplicant(RemitaPageApplicant):
148    """ View which sends a POST request to the Remita payment gateway.
149    """
150
151    merchantId = MERCHANTID
152    host = HOST
153    https = HTTPS
154    api_key = API_KEY
155
156    init_url = '/remita/ecomm/split/init.reg'
157
158    @property
159    def serviceTypeId(self):
160        return SERVICETYPEID
161
162    @property
163    def lineitems(self):
164        provider_amt = 500.0
165        inst_amt = self.context.amount_auth - provider_amt
166        lineitems = (
167                          {"lineItemsId":"itemid1","beneficiaryName":"FCEOkene",
168                          "beneficiaryAccount":INSTITUTION_ACCT,
169                          "bankCode":INSTITUTION_BANKCODE,
170                          "beneficiaryAmount":inst_amt,"deductFeeFrom":"1"},
171                          {"lineItemsId":"itemid2","beneficiaryName":"WAEAC",
172                          "beneficiaryAccount":PROVIDER_ACCT,
173                          "bankCode":PROVIDER_BANKCODE,
174                          "beneficiaryAmount":provider_amt,"deductFeeFrom":"0"}
175                    )
176        self.context.provider_amt = provider_amt
177        return lineitems
178
179    def update(self):
180        if not module_activated(
181            self.context.__parent__.__parent__.year, self.context):
182            return
183        self.orderId = self.context.p_id
184        self.amount = str(self.context.amount_auth)
185        error = self.init_update()
186        if error:
187            self.flash(error, type='danger')
188            self.redirect(self.url(self.context, '@@index'))
189            return
190        self.context.r_company = u'remita'
191        return
Note: See TracBrowser for help on using the repository browser.