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

Last change on this file since 17101 was 16919, checked in by Henrik Bettermann, 3 years ago

No provider fee for schoolfee_third payments.

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