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

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

Adjust skeleton. Remove XMLRPC test user.

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):
[15847]90        if not module_activated(
91            self.context.student.current_session, self.context):
[15614]92            return
93        self.orderId = self.context.p_id
94        error = self.init_update()
95        if error:
96            self.flash(error, type='danger')
97            self.redirect(self.url(self.context, '@@index'))
98            return
[15756]99        # Already now it becomes a Remita payment. We set the net amount
100        # and add the gateway amount.
101        if not self.context.r_company:
102            self.context.net_amt = self.context.amount_auth
103            self.context.amount_auth += self.gateway_amt
104            self.context.gateway_amt = self.gateway_amt
105            self.context.r_company = u'remita'
106        self.amount_auth = int(100 * self.context.amount_auth)
[15614]107        return
108
109class CustomRemitaRequestPaymentStatusPageApplicant(
110    RemitaRequestPaymentStatusPageApplicant):
111    """ Request webservice view for the Remita gateway.
112    """
113
114    merchantId = MERCHANTID
115    host = HOST
116    https = HTTPS
117    api_key = API_KEY
118
119class CustomRemitaVerifyPaymentStatusPageApplicant(
120    RemitaVerifyPaymentStatusPageApplicant):
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 CustomRemitaPageApplicant(RemitaPageApplicant):
130    """ View which sends a POST request to the Remita payment gateway.
131    """
132
133    merchantId = MERCHANTID
134    host = HOST
135    https = HTTPS
136    api_key = API_KEY
137
138    init_url = '/remita/ecomm/split/init.reg'
139
140    @property
141    def serviceTypeId(self):
142        return SERVICETYPEID
143
144    @property
145    def lineitems(self):
146        lineitems = (
147                      {"lineItemsId":"itemid1","beneficiaryName":"Klaus Mueller",
148                      "beneficiaryAccount":"6020067886","bankCode":"011",
149                      "beneficiaryAmount":self.context.amount_auth/2,"deductFeeFrom":"1"},
150                      {"lineItemsId":"itemid2","beneficiaryName":"Werner Rumm",
151                      "beneficiaryAccount":"0360883515","bankCode":"050",
152                      "beneficiaryAmount":self.context.amount_auth/2,"deductFeeFrom":"0"}
153                    )
154        return lineitems
155
156    def update(self):
[15847]157        if not module_activated(
158            self.context.__parent__.__parent__.year, self.context):
[15614]159            return
160        self.orderId = self.context.p_id
161        error = self.init_update()
162        if error:
163            self.flash(error, type='danger')
164            self.redirect(self.url(self.context, '@@index'))
165            return
[15756]166        # Already now it becomes a Remita payment. We set the net amount
167        # and add the gateway amount.
168        if not self.context.r_company:
169            self.context.net_amt = self.context.amount_auth
170            self.context.amount_auth += self.gateway_amt
171            self.context.gateway_amt = self.gateway_amt
172            self.context.r_company = u'remita'
173        self.amount_auth = int(100 * self.context.amount_auth)
[15614]174        return
Note: See TracBrowser for help on using the repository browser.