[14993] | 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 | |
---|
| 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 | |
---|
| 31 | from 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 | |
---|
| 40 | class 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 | |
---|
| 50 | class 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 | |
---|
| 60 | class 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 | self.amount = str(self.context.amount_auth) |
---|
| 94 | error = self.init_update() |
---|
| 95 | if error: |
---|
| 96 | self.flash(error, type='danger') |
---|
| 97 | self.redirect(self.url(self.context, '@@index')) |
---|
| 98 | return |
---|
| 99 | return |
---|
| 100 | |
---|
| 101 | class CustomRemitaRequestPaymentStatusPageApplicant( |
---|
| 102 | RemitaRequestPaymentStatusPageApplicant): |
---|
| 103 | """ Request webservice view for the Remita gateway. |
---|
| 104 | """ |
---|
| 105 | |
---|
| 106 | merchantId = MERCHANTID |
---|
| 107 | host = HOST |
---|
| 108 | https = HTTPS |
---|
| 109 | api_key = API_KEY |
---|
| 110 | |
---|
| 111 | class CustomRemitaVerifyPaymentStatusPageApplicant( |
---|
| 112 | RemitaVerifyPaymentStatusPageApplicant): |
---|
| 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 | |
---|
| 121 | class CustomRemitaPageApplicant(RemitaPageApplicant): |
---|
| 122 | """ View which sends a POST request to the Remita payment gateway. |
---|
| 123 | """ |
---|
| 124 | |
---|
| 125 | merchantId = MERCHANTID |
---|
| 126 | host = HOST |
---|
| 127 | https = HTTPS |
---|
| 128 | api_key = API_KEY |
---|
| 129 | |
---|
| 130 | init_url = '/remita/ecomm/split/init.reg' |
---|
| 131 | |
---|
| 132 | @property |
---|
| 133 | def serviceTypeId(self): |
---|
| 134 | return SERVICETYPEID |
---|
| 135 | |
---|
| 136 | @property |
---|
| 137 | def lineitems(self): |
---|
| 138 | lineitems = ( |
---|
| 139 | {"lineItemsId":"itemid1","beneficiaryName":"Klaus Mueller", |
---|
| 140 | "beneficiaryAccount":"6020067886","bankCode":"011", |
---|
| 141 | "beneficiaryAmount":self.context.amount_auth/2,"deductFeeFrom":"1"}, |
---|
| 142 | {"lineItemsId":"itemid2","beneficiaryName":"Werner Rumm", |
---|
| 143 | "beneficiaryAccount":"0360883515","bankCode":"050", |
---|
| 144 | "beneficiaryAmount":self.context.amount_auth/2,"deductFeeFrom":"0"} |
---|
| 145 | ) |
---|
| 146 | return lineitems |
---|
| 147 | |
---|
| 148 | def update(self): |
---|
| 149 | if not module_activated(self.context.__parent__.__parent__.year): |
---|
| 150 | return |
---|
| 151 | self.orderId = self.context.p_id |
---|
| 152 | self.amount = str(self.context.amount_auth) |
---|
| 153 | error = self.init_update() |
---|
| 154 | if error: |
---|
| 155 | self.flash(error, type='danger') |
---|
| 156 | self.redirect(self.url(self.context, '@@index')) |
---|
| 157 | return |
---|
| 158 | return |
---|