source: main/waeup.uniben/trunk/src/waeup/uniben/remita/browser.py @ 14768

Last change on this file since 14768 was 14768, checked in by Henrik Bettermann, 7 years ago

Update bank data.

  • Property svn:keywords set to Id
File size: 5.9 KB
Line 
1## $Id: browser.py 14768 2017-08-04 13:10:28Z 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    RemitaPageStudent)
23from kofacustom.nigeria.remita.applicantsbrowser import (
24    RemitaRequestPaymentStatusPageApplicant,
25    RemitaPageApplicant)
26
27class CustomRemitaRequestPaymentStatusPageStudent(
28    RemitaRequestPaymentStatusPageStudent):
29    """ Request webservice view for the Remita gateway.
30    """
31
32    # Here we use Remita test portal data
33    merchantId = '2547916'
34    host = 'www.remitademo.net'
35    https = True
36    api_key = '1946'
37
38class CustomRemitaPageStudent(RemitaPageStudent):
39    """ View which sends a POST request to the Remita payment gateway.
40    """
41
42    # Here we use Remita test portal data
43    merchantId = '2547916'
44    serviceTypeId = '4430731'
45    api_key = '1946'
46    #orderId = '3456346346'
47    host = 'www.remitademo.net'
48    init_url = '/remita/ecomm/split/init.reg'
49    #amount='1000'
50    https = True
51
52    action = 'http://www.remitademo.net/remita/ecomm/finalize.reg'
53
54    @property
55    def lineitems(self):
56        ba1 = self.context.amount_auth / 2
57        ba2 = self.context.amount_auth / 2
58        lineitems = (
59                      {"lineItemsId":"itemid1","beneficiaryName":"Klaus Mueller",
60                      "beneficiaryAccount":"6020067886","bankCode":"011",
61                      "beneficiaryAmount":str(ba1),"deductFeeFrom":"1"},
62                      {"lineItemsId":"itemid2","beneficiaryName":"Werner Rumm",
63                      "beneficiaryAccount":"0360883515","bankCode":"050",
64                      "beneficiaryAmount":str(ba2),"deductFeeFrom":"0"}
65                    )
66        return lineitems
67
68    def dynamic_provider_amt(self, student):
69        if student.entry_session >= 2016:
70            return 2500.0
71        return 1500.0
72
73    @property
74    def xxx_lineitems(self):
75        provider_amt = 0.0
76        if self.context.p_category == 'schoolfee' and \
77            not self.context.p_item == 'Balance':
78            provider_amt = self.dynamic_provider_amt(self.student)
79        elif self.context.p_category == 'clearance':
80            provider_amt = self.dynamic_provider_amt(self.student)
81        inst_amt = self.context.amount_auth - provider_amt
82        if provider_amt:
83            lineitems = (
84                          {"lineItemsId":"itemid1","beneficiaryName":"Uniben",
85                          "beneficiaryAccount":"0040217361011","bankCode":"000",
86                          "beneficiaryAmount":inst_amt,"deductFeeFrom":"1"},
87                          {"lineItemsId":"itemid2","beneficiaryName":"WAeAC",
88                          "beneficiaryAccount":"1014261520","bankCode":"057",
89                          "beneficiaryAmount":provider_amt,"deductFeeFrom":"0"}
90                        )
91        else:
92            lineitems = (
93                          {"lineItemsId":"itemid1","beneficiaryName":"Uniben",
94                          "beneficiaryAccount":"0040217361011","bankCode":"000",
95                          "beneficiaryAmount":inst_amt,"deductFeeFrom":"1"},
96                        )
97        return lineitems
98
99    def update(self):
100        if not module_activated(self.context.student.current_session):
101            return
102        self.orderId = self.context.p_id
103        self.amount = str(self.context.amount_auth)
104        error = self.init_update()
105        if error:
106            self.flash(error, type='danger')
107            self.redirect(self.url(self.context, '@@index'))
108            return
109        return
110
111class CustomRemitaRequestPaymentStatusPageApplicant(
112    RemitaRequestPaymentStatusPageApplicant):
113    """ Request webservice view for the Remita gateway.
114    """
115
116    # Here we use Remita test portal data
117    merchantId = '2547916'
118    host = 'www.remitademo.net'
119    https = True
120    api_key = '1946'
121
122class CustomRemitaPageApplicant(RemitaPageApplicant):
123    """ View which sends a POST request to the Remita payment gateway.
124    """
125
126    # Here we use Remita test portal data
127    merchantId = '2547916'
128    serviceTypeId = '4430731'
129    api_key = '1946'
130    #orderId = '3456346346'
131    host = 'www.remitademo.net'
132    init_url = '/remita/ecomm/split/init.reg'
133    #amount='1000'
134    https = True
135
136    action = 'http://www.remitademo.net/remita/ecomm/finalize.reg'
137
138    @property
139    def lineitems(self):
140
141        lineitems = (
142                      {"lineItemsId":"itemid1","beneficiaryName":"Klaus Mueller",
143                      "beneficiaryAccount":"6020067886","bankCode":"011",
144                      "beneficiaryAmount":self.context.amount_auth/2,"deductFeeFrom":"1"},
145                      {"lineItemsId":"itemid2","beneficiaryName":"Werner Rumm",
146                      "beneficiaryAccount":"0360883515","bankCode":"050",
147                      "beneficiaryAmount":self.context.amount_auth/2,"deductFeeFrom":"0"}
148                    )
149        return lineitems
150
151    def update(self):
152        if not module_activated(self.context.__parent__.__parent__.year):
153            return
154        self.orderId = self.context.p_id
155        self.amount = str(self.context.amount_auth)
156        error = self.init_update()
157        if error:
158            self.flash(error, type='danger')
159            self.redirect(self.url(self.context, '@@index'))
160            return
161        return
Note: See TracBrowser for help on using the repository browser.