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

Last change on this file since 15420 was 15296, checked in by Henrik Bettermann, 6 years ago

Remove bug.

  • Property svn:keywords set to Id
File size: 6.0 KB
Line 
1## $Id: browser.py 15296 2019-01-14 13:04:14Z 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(self.context.student.current_session):
110            return
111        self.orderId = self.context.p_id
112        self.amount = str(self.context.amount_auth)
113        error = self.init_update()
114        if error:
115            self.flash(error, type='danger')
116            self.redirect(self.url(self.context, '@@index'))
117            return
118        return
119
120class CustomRemitaRequestPaymentStatusPageApplicant(
121    RemitaRequestPaymentStatusPageApplicant):
122    """ Request webservice view for the Remita gateway.
123    """
124
125    merchantId = MERCHANTID
126    host = HOST
127    https = HTTPS
128    api_key = API_KEY
129
130class CustomRemitaVerifyPaymentStatusPageApplicant(
131    RemitaVerifyPaymentStatusPageApplicant):
132    """ Request webservice view for the Remita gateway.
133    """
134
135    merchantId = MERCHANTID
136    host = HOST
137    https = HTTPS
138    api_key = API_KEY
139
140class CustomRemitaPageApplicant(RemitaPageApplicant):
141    """ View which sends a POST request to the Remita payment gateway.
142    """
143
144    merchantId = MERCHANTID
145    host = HOST
146    https = HTTPS
147    api_key = API_KEY
148
149    init_url = '/remita/ecomm/split/init.reg'
150
151    @property
152    def serviceTypeId(self):
153        return SERVICETYPEID
154
155    @property
156    def lineitems(self):
157        provider_amt = 500.0
158        inst_amt = self.context.amount_auth - provider_amt
159        lineitems = (
160                          {"lineItemsId":"itemid1","beneficiaryName":"FCEOkene",
161                          "beneficiaryAccount":INSTITUTION_ACCT,
162                          "bankCode":INSTITUTION_BANKCODE,
163                          "beneficiaryAmount":inst_amt,"deductFeeFrom":"1"},
164                          {"lineItemsId":"itemid2","beneficiaryName":"WAEAC",
165                          "beneficiaryAccount":PROVIDER_ACCT,
166                          "bankCode":PROVIDER_BANKCODE,
167                          "beneficiaryAmount":provider_amt,"deductFeeFrom":"0"}
168                    )
169        self.context.provider_amt = provider_amt
170        return lineitems
171
172    def update(self):
173        if not module_activated(self.context.__parent__.__parent__.year):
174            return
175        self.orderId = self.context.p_id
176        self.amount = str(self.context.amount_auth)
177        error = self.init_update()
178        if error:
179            self.flash(error, type='danger')
180            self.redirect(self.url(self.context, '@@index'))
181            return
182        return
Note: See TracBrowser for help on using the repository browser.