[7195] | 1 | ## $Id: interfaces.py 16526 2021-07-05 15:42:14Z henrik $ |
---|
[6861] | 2 | ## |
---|
[7195] | 3 | ## Copyright (C) 2011 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 | ## |
---|
[6969] | 18 | from zope.interface import Attribute |
---|
[6864] | 19 | from zope import schema |
---|
[8245] | 20 | from waeup.kofa.interfaces import ( |
---|
[11450] | 21 | IKofaObject, SimpleKofaVocabulary, academic_sessions_vocab, |
---|
| 22 | ContextualDictSourceFactoryBase) |
---|
[7811] | 23 | from waeup.kofa.interfaces import MessageFactory as _ |
---|
[6861] | 24 | |
---|
[7819] | 25 | payment_states = SimpleKofaVocabulary( |
---|
[7717] | 26 | (_('Not yet paid'),'unpaid'), |
---|
| 27 | (_('Paid'),'paid'), |
---|
| 28 | (_('Failed'),'failed'), |
---|
[12568] | 29 | (_('Fees waived'),'waived'), |
---|
[15792] | 30 | (_('Scholarship'),'scholarship'), |
---|
[7627] | 31 | ) |
---|
| 32 | |
---|
[9405] | 33 | class PaymentCategorySource(ContextualDictSourceFactoryBase): |
---|
[9864] | 34 | """A payment category source delivers all categories of payments. |
---|
| 35 | |
---|
[9405] | 36 | """ |
---|
| 37 | #: name of dict to deliver from kofa utils. |
---|
| 38 | DICT_NAME = 'PAYMENT_CATEGORIES' |
---|
[7627] | 39 | |
---|
[16431] | 40 | class PaymentOptionSource(ContextualDictSourceFactoryBase): |
---|
| 41 | """A payment option source delivers all options of a payment. |
---|
| 42 | |
---|
| 43 | """ |
---|
| 44 | #: name of dict to deliver from kofa utils. |
---|
| 45 | DICT_NAME = 'PAYMENT_OPTIONS' |
---|
| 46 | |
---|
[15664] | 47 | class CombiPaymentCategorySource(ContextualDictSourceFactoryBase): |
---|
| 48 | """A payment category source delivers all categories of payments. |
---|
| 49 | |
---|
| 50 | """ |
---|
| 51 | #: name of dict to deliver from kofa utils. |
---|
| 52 | DICT_NAME = 'COMBI_PAYMENT_CATEGORIES' |
---|
| 53 | |
---|
[7819] | 54 | class IPaymentsContainer(IKofaObject): |
---|
[6861] | 55 | """A container for all kind of payment objects. |
---|
| 56 | |
---|
| 57 | """ |
---|
[6864] | 58 | |
---|
[7819] | 59 | class IPayment(IKofaObject): |
---|
[6864] | 60 | """A base representation of payments. |
---|
| 61 | |
---|
| 62 | """ |
---|
[9533] | 63 | p_id = Attribute('Payment identifier') |
---|
[6864] | 64 | |
---|
| 65 | p_category = schema.Choice( |
---|
[7717] | 66 | title = _(u'Payment Category'), |
---|
[10842] | 67 | #default = u'schoolfee', |
---|
[9405] | 68 | source = PaymentCategorySource(), |
---|
[6864] | 69 | required = True, |
---|
| 70 | ) |
---|
| 71 | |
---|
[16431] | 72 | p_option = schema.Choice( |
---|
| 73 | title = _(u'Payment Option'), |
---|
| 74 | source = PaymentOptionSource(), |
---|
| 75 | required = False, |
---|
| 76 | ) |
---|
| 77 | |
---|
[6864] | 78 | p_item = schema.TextLine( |
---|
[9984] | 79 | title = u'', |
---|
[6869] | 80 | default = None, |
---|
[6864] | 81 | required = False, |
---|
| 82 | ) |
---|
| 83 | |
---|
[15664] | 84 | p_combi = schema.List( |
---|
| 85 | title = _(u'Combi Payment'), |
---|
| 86 | value_type = schema.Choice( |
---|
| 87 | source = CombiPaymentCategorySource(), |
---|
| 88 | ), |
---|
| 89 | required = False, |
---|
| 90 | defaultFactory=list, |
---|
| 91 | ) |
---|
| 92 | |
---|
[9984] | 93 | display_item = schema.TextLine( |
---|
| 94 | title = _(u'Payment Item'), |
---|
| 95 | required = False, |
---|
| 96 | readonly = True, |
---|
| 97 | ) |
---|
| 98 | |
---|
[8245] | 99 | p_session = schema.Choice( |
---|
| 100 | title = _(u'Payment Session'), |
---|
| 101 | source = academic_sessions_vocab, |
---|
[9512] | 102 | required = True, |
---|
[8245] | 103 | ) |
---|
| 104 | |
---|
[7020] | 105 | p_state = schema.Choice( |
---|
[7717] | 106 | title = _(u'Payment State'), |
---|
[7020] | 107 | default = u'unpaid', |
---|
| 108 | vocabulary = payment_states, |
---|
| 109 | required = True, |
---|
| 110 | ) |
---|
| 111 | |
---|
[8170] | 112 | creation_date = schema.Datetime( |
---|
[7717] | 113 | title = _(u'Ticket Creation Date'), |
---|
[7623] | 114 | readonly = False, |
---|
[8944] | 115 | required = False, |
---|
[6864] | 116 | ) |
---|
| 117 | |
---|
[8170] | 118 | payment_date = schema.Datetime( |
---|
[7717] | 119 | title = _(u'Payment Date'), |
---|
[6869] | 120 | required = False, |
---|
[6934] | 121 | readonly = False, |
---|
[6864] | 122 | ) |
---|
| 123 | |
---|
[7927] | 124 | amount_auth = schema.Float( |
---|
[7717] | 125 | title = _(u'Amount Authorized'), |
---|
[7927] | 126 | default = 0.0, |
---|
[6864] | 127 | required = True, |
---|
[7931] | 128 | readonly = False, |
---|
[6864] | 129 | ) |
---|
| 130 | |
---|
| 131 | class IOnlinePayment(IPayment): |
---|
| 132 | """A payment via payment gateways. |
---|
| 133 | |
---|
| 134 | """ |
---|
| 135 | |
---|
[6930] | 136 | ac = schema.TextLine( |
---|
[7717] | 137 | title = _(u'Activation Code'), |
---|
[6930] | 138 | default = None, |
---|
| 139 | required = False, |
---|
| 140 | readonly = False, |
---|
| 141 | ) |
---|
| 142 | |
---|
[7927] | 143 | r_amount_approved = schema.Float( |
---|
[7717] | 144 | title = _(u'Response Amount Approved'), |
---|
[7927] | 145 | default = 0.0, |
---|
[6864] | 146 | required = False, |
---|
[6930] | 147 | readonly = False, |
---|
[6864] | 148 | ) |
---|
| 149 | |
---|
| 150 | r_code = schema.TextLine( |
---|
[7717] | 151 | title = _(u'Response Code'), |
---|
[6864] | 152 | default = None, |
---|
[6869] | 153 | required = False, |
---|
[6930] | 154 | readonly = False, |
---|
[6864] | 155 | ) |
---|
[8420] | 156 | |
---|
[8429] | 157 | r_desc = schema.TextLine( |
---|
| 158 | title = _(u'Response Description'), |
---|
| 159 | default = None, |
---|
| 160 | required = False, |
---|
| 161 | readonly = False, |
---|
| 162 | ) |
---|
| 163 | |
---|
[8420] | 164 | def approve(): |
---|
| 165 | "Approve an online payment and set to paid." |
---|
[8703] | 166 | |
---|
[10030] | 167 | class IPayer(IKofaObject): |
---|
| 168 | """An interface for an adapter to publish student and applicant data |
---|
[16526] | 169 | through a simple webservice. Also used in payment modules. |
---|
[8703] | 170 | |
---|
[9533] | 171 | """ |
---|
[16526] | 172 | payer = Attribute("The payer object") |
---|
[16500] | 173 | display_fullname = Attribute('Name of payer') |
---|
[10030] | 174 | id = Attribute('Id of payer') |
---|
| 175 | reg_number = Attribute('Reg number of payer') |
---|
| 176 | matric_number = Attribute('Matric number of payer') |
---|
| 177 | faculty = Attribute('Faculty of payer') |
---|
| 178 | department = Attribute('Department of payer') |
---|
[10914] | 179 | email= Attribute('Email of payer') |
---|
| 180 | phone= Attribute('Phone number of payer') |
---|
| 181 | current_mode= Attribute('Current study mode of payer') |
---|
| 182 | current_level= Attribute('Current level of payer') |
---|
[16526] | 183 | |
---|
| 184 | def doAfterPayment(): |
---|
| 185 | "Do after payment was made." |
---|