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

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

Setup live gateway configuration.

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