source: main/kofacustom.unidel/trunk/src/kofacustom/unidel/remita/browser.py @ 17891

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

Add Id keyword

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