[15271] | 1 | ## $Id: browser.py 16919 2022-04-13 08:43:11Z 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 | |
---|
| 19 | from kofacustom.nigeria.remita.studentsbrowser import ( |
---|
| 20 | module_activated, |
---|
| 21 | RemitaRequestPaymentStatusPageStudent, |
---|
| 22 | RemitaVerifyPaymentStatusPageStudent, |
---|
| 23 | RemitaPageStudent) |
---|
| 24 | from 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 | |
---|
[15281] | 31 | #from kofacustom.nigeria.remita.tests import ( |
---|
| 32 | # MERCHANTID, HOST, HTTPS, API_KEY, SERVICETYPEID) |
---|
[15271] | 33 | |
---|
[15281] | 34 | MERCHANTID = '3534555222' |
---|
| 35 | HOST = 'login.remita.net' |
---|
| 36 | HTTPS = True |
---|
| 37 | API_KEY = '756843' |
---|
| 38 | SERVICETYPEID = '365039884' |
---|
[15271] | 39 | |
---|
[15281] | 40 | PROVIDER_ACCT = '0773411069' |
---|
| 41 | PROVIDER_BANKCODE = '044' |
---|
| 42 | INSTITUTION_ACCT = '0270100161017' |
---|
| 43 | INSTITUTION_BANKCODE = '000' |
---|
| 44 | |
---|
[15271] | 45 | class 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 | |
---|
| 55 | class 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 | |
---|
| 65 | class 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): |
---|
[15281] | 82 | provider_amt = 1600.0 |
---|
[16912] | 83 | if self.context.p_item == 'Balance' or self.context.p_category in ( |
---|
[16919] | 84 | 'clearance', 'hostel_maintenance', 'third_semester', |
---|
| 85 | 'schoolfee_third'): |
---|
[15281] | 86 | provider_amt = 0.0 |
---|
| 87 | inst_amt = self.context.amount_auth - provider_amt |
---|
| 88 | if provider_amt: |
---|
| 89 | lineitems = ( |
---|
| 90 | {"lineItemsId":"itemid1","beneficiaryName":"FCEOkene", |
---|
| 91 | "beneficiaryAccount":INSTITUTION_ACCT, |
---|
| 92 | "bankCode":INSTITUTION_BANKCODE, |
---|
| 93 | "beneficiaryAmount":inst_amt,"deductFeeFrom":"1"}, |
---|
| 94 | {"lineItemsId":"itemid2","beneficiaryName":"WAEAC", |
---|
| 95 | "beneficiaryAccount":PROVIDER_ACCT, |
---|
| 96 | "bankCode":PROVIDER_BANKCODE, |
---|
| 97 | "beneficiaryAmount":provider_amt,"deductFeeFrom":"0"} |
---|
| 98 | ) |
---|
| 99 | else: |
---|
| 100 | lineitems = ( |
---|
| 101 | {"lineItemsId":"itemid1","beneficiaryName":"FCEOkene", |
---|
[15296] | 102 | "beneficiaryAccount":INSTITUTION_ACCT, |
---|
| 103 | "bankCode":INSTITUTION_BANKCODE, |
---|
[15281] | 104 | "beneficiaryAmount":inst_amt,"deductFeeFrom":"1"}, |
---|
| 105 | ) |
---|
| 106 | self.context.provider_amt = provider_amt |
---|
[15271] | 107 | return lineitems |
---|
| 108 | |
---|
| 109 | def update(self): |
---|
[15827] | 110 | if not module_activated( |
---|
| 111 | self.context.student.current_session, self.context): |
---|
[15271] | 112 | return |
---|
| 113 | self.orderId = self.context.p_id |
---|
| 114 | self.amount = str(self.context.amount_auth) |
---|
| 115 | error = self.init_update() |
---|
| 116 | if error: |
---|
| 117 | self.flash(error, type='danger') |
---|
| 118 | self.redirect(self.url(self.context, '@@index')) |
---|
| 119 | return |
---|
[15827] | 120 | self.context.r_company = u'remita' |
---|
[15271] | 121 | return |
---|
| 122 | |
---|
| 123 | class CustomRemitaRequestPaymentStatusPageApplicant( |
---|
| 124 | RemitaRequestPaymentStatusPageApplicant): |
---|
| 125 | """ Request webservice view for the Remita gateway. |
---|
| 126 | """ |
---|
| 127 | |
---|
| 128 | merchantId = MERCHANTID |
---|
| 129 | host = HOST |
---|
| 130 | https = HTTPS |
---|
| 131 | api_key = API_KEY |
---|
| 132 | |
---|
| 133 | class CustomRemitaVerifyPaymentStatusPageApplicant( |
---|
| 134 | RemitaVerifyPaymentStatusPageApplicant): |
---|
| 135 | """ Request webservice view for the Remita gateway. |
---|
| 136 | """ |
---|
| 137 | |
---|
| 138 | merchantId = MERCHANTID |
---|
| 139 | host = HOST |
---|
| 140 | https = HTTPS |
---|
| 141 | api_key = API_KEY |
---|
| 142 | |
---|
| 143 | class CustomRemitaPageApplicant(RemitaPageApplicant): |
---|
| 144 | """ View which sends a POST request to the Remita payment gateway. |
---|
| 145 | """ |
---|
| 146 | |
---|
| 147 | merchantId = MERCHANTID |
---|
| 148 | host = HOST |
---|
| 149 | https = HTTPS |
---|
| 150 | api_key = API_KEY |
---|
| 151 | |
---|
| 152 | init_url = '/remita/ecomm/split/init.reg' |
---|
| 153 | |
---|
| 154 | @property |
---|
| 155 | def serviceTypeId(self): |
---|
| 156 | return SERVICETYPEID |
---|
| 157 | |
---|
| 158 | @property |
---|
| 159 | def lineitems(self): |
---|
[15281] | 160 | provider_amt = 500.0 |
---|
| 161 | inst_amt = self.context.amount_auth - provider_amt |
---|
[15271] | 162 | lineitems = ( |
---|
[15281] | 163 | {"lineItemsId":"itemid1","beneficiaryName":"FCEOkene", |
---|
| 164 | "beneficiaryAccount":INSTITUTION_ACCT, |
---|
| 165 | "bankCode":INSTITUTION_BANKCODE, |
---|
| 166 | "beneficiaryAmount":inst_amt,"deductFeeFrom":"1"}, |
---|
| 167 | {"lineItemsId":"itemid2","beneficiaryName":"WAEAC", |
---|
| 168 | "beneficiaryAccount":PROVIDER_ACCT, |
---|
| 169 | "bankCode":PROVIDER_BANKCODE, |
---|
| 170 | "beneficiaryAmount":provider_amt,"deductFeeFrom":"0"} |
---|
[15271] | 171 | ) |
---|
[15281] | 172 | self.context.provider_amt = provider_amt |
---|
[15271] | 173 | return lineitems |
---|
| 174 | |
---|
| 175 | def update(self): |
---|
[15827] | 176 | if not module_activated( |
---|
| 177 | self.context.__parent__.__parent__.year, self.context): |
---|
[15271] | 178 | return |
---|
| 179 | self.orderId = self.context.p_id |
---|
| 180 | self.amount = str(self.context.amount_auth) |
---|
| 181 | error = self.init_update() |
---|
| 182 | if error: |
---|
| 183 | self.flash(error, type='danger') |
---|
| 184 | self.redirect(self.url(self.context, '@@index')) |
---|
| 185 | return |
---|
[15827] | 186 | self.context.r_company = u'remita' |
---|
[15271] | 187 | return |
---|