source: main/kofacustom.skeleton/trunk/src/kofacustom/skeleton/remita/browser.py @ 15800

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

Adjust to changes in nigeria package.

File size: 5.8 KB
RevLine 
[15614]1## $Id: browser.py 14993 2018-04-26 11:58: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
31from kofacustom.nigeria.remita.tests import (
32    MERCHANTID, HOST, HTTPS, API_KEY, SERVICETYPEID)
33
34#MERCHANTID = ''
35#HOST = 'login.remita.net'
36#HTTPS = True
37#API_KEY = ''
38#SERVICETYPEID = ''
39
40class CustomRemitaRequestPaymentStatusPageStudent(
41    RemitaRequestPaymentStatusPageStudent):
42    """ Request webservice view for the Remita gateway.
43    """
44
45    merchantId = MERCHANTID
46    host = HOST
47    https = HTTPS
48    api_key = API_KEY
49
50class CustomRemitaVerifyPaymentStatusPageStudent(
51    RemitaVerifyPaymentStatusPageStudent):
52    """ Request webservice view for the Remita gateway.
53    """
54
55    merchantId = MERCHANTID
56    host = HOST
57    https = HTTPS
58    api_key = API_KEY
59
60class CustomRemitaPageStudent(RemitaPageStudent):
61    """ View which sends a POST request to the Remita payment gateway.
62    """
63
64    merchantId = MERCHANTID
65    host = HOST
66    https = HTTPS
67    api_key = API_KEY
68
69    init_url = '/remita/ecomm/split/init.reg'
70
71    @property
72    def serviceTypeId(self):
73        return SERVICETYPEID
74
75    @property
76    def lineitems(self):
77        ba1 = self.context.amount_auth / 2
78        ba2 = self.context.amount_auth / 2
79        lineitems = (
80                      {"lineItemsId":"itemid1","beneficiaryName":"Klaus Mueller",
81                      "beneficiaryAccount":"6020067886","bankCode":"011",
82                      "beneficiaryAmount":str(ba1),"deductFeeFrom":"1"},
83                      {"lineItemsId":"itemid2","beneficiaryName":"Werner Rumm",
84                      "beneficiaryAccount":"0360883515","bankCode":"050",
85                      "beneficiaryAmount":str(ba2),"deductFeeFrom":"0"}
86                    )
87        return lineitems
88
89    def update(self):
90        if not module_activated(self.context.student.current_session):
91            return
92        self.orderId = self.context.p_id
93        error = self.init_update()
94        if error:
95            self.flash(error, type='danger')
96            self.redirect(self.url(self.context, '@@index'))
97            return
[15756]98        # Already now it becomes a Remita payment. We set the net amount
99        # and add the gateway amount.
100        if not self.context.r_company:
101            self.context.net_amt = self.context.amount_auth
102            self.context.amount_auth += self.gateway_amt
103            self.context.gateway_amt = self.gateway_amt
104            self.context.r_company = u'remita'
105        self.amount_auth = int(100 * self.context.amount_auth)
[15614]106        return
107
108class CustomRemitaRequestPaymentStatusPageApplicant(
109    RemitaRequestPaymentStatusPageApplicant):
110    """ Request webservice view for the Remita gateway.
111    """
112
113    merchantId = MERCHANTID
114    host = HOST
115    https = HTTPS
116    api_key = API_KEY
117
118class CustomRemitaVerifyPaymentStatusPageApplicant(
119    RemitaVerifyPaymentStatusPageApplicant):
120    """ Request webservice view for the Remita gateway.
121    """
122
123    merchantId = MERCHANTID
124    host = HOST
125    https = HTTPS
126    api_key = API_KEY
127
128class CustomRemitaPageApplicant(RemitaPageApplicant):
129    """ View which sends a POST request to the Remita payment gateway.
130    """
131
132    merchantId = MERCHANTID
133    host = HOST
134    https = HTTPS
135    api_key = API_KEY
136
137    init_url = '/remita/ecomm/split/init.reg'
138
139    @property
140    def serviceTypeId(self):
141        return SERVICETYPEID
142
143    @property
144    def lineitems(self):
145        lineitems = (
146                      {"lineItemsId":"itemid1","beneficiaryName":"Klaus Mueller",
147                      "beneficiaryAccount":"6020067886","bankCode":"011",
148                      "beneficiaryAmount":self.context.amount_auth/2,"deductFeeFrom":"1"},
149                      {"lineItemsId":"itemid2","beneficiaryName":"Werner Rumm",
150                      "beneficiaryAccount":"0360883515","bankCode":"050",
151                      "beneficiaryAmount":self.context.amount_auth/2,"deductFeeFrom":"0"}
152                    )
153        return lineitems
154
155    def update(self):
156        if not module_activated(self.context.__parent__.__parent__.year):
157            return
158        self.orderId = self.context.p_id
159        error = self.init_update()
160        if error:
161            self.flash(error, type='danger')
162            self.redirect(self.url(self.context, '@@index'))
163            return
[15756]164        # Already now it becomes a Remita payment. We set the net amount
165        # and add the gateway amount.
166        if not self.context.r_company:
167            self.context.net_amt = self.context.amount_auth
168            self.context.amount_auth += self.gateway_amt
169            self.context.gateway_amt = self.gateway_amt
170            self.context.r_company = u'remita'
171        self.amount_auth = int(100 * self.context.amount_auth)
[15614]172        return
Note: See TracBrowser for help on using the repository browser.