[7195] | 1 | ## $Id: interfaces.py 9864 2013-01-11 17:19:38Z 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 |
---|
[9405] | 20 | from waeup.kofa.university.vocabularies import ContextualDictSourceFactoryBase |
---|
[8245] | 21 | from waeup.kofa.interfaces import ( |
---|
| 22 | IKofaObject, SimpleKofaVocabulary, academic_sessions_vocab) |
---|
[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'), |
---|
[7627] | 29 | ) |
---|
| 30 | |
---|
[9405] | 31 | class PaymentCategorySource(ContextualDictSourceFactoryBase): |
---|
[9864] | 32 | """A payment category source delivers all categories of payments. |
---|
| 33 | |
---|
[9405] | 34 | """ |
---|
| 35 | #: name of dict to deliver from kofa utils. |
---|
| 36 | DICT_NAME = 'PAYMENT_CATEGORIES' |
---|
[7627] | 37 | |
---|
[7819] | 38 | class IPaymentsContainer(IKofaObject): |
---|
[6861] | 39 | """A container for all kind of payment objects. |
---|
| 40 | |
---|
| 41 | """ |
---|
[6864] | 42 | |
---|
[7819] | 43 | class IPayment(IKofaObject): |
---|
[6864] | 44 | """A base representation of payments. |
---|
| 45 | |
---|
| 46 | """ |
---|
[9533] | 47 | p_id = Attribute('Payment identifier') |
---|
[6864] | 48 | |
---|
| 49 | p_category = schema.Choice( |
---|
[7717] | 50 | title = _(u'Payment Category'), |
---|
[6865] | 51 | default = u'schoolfee', |
---|
[9405] | 52 | source = PaymentCategorySource(), |
---|
[6864] | 53 | required = True, |
---|
| 54 | ) |
---|
| 55 | |
---|
| 56 | p_item = schema.TextLine( |
---|
[7717] | 57 | title = _(u'Payment Item'), |
---|
[6869] | 58 | default = None, |
---|
[6864] | 59 | required = False, |
---|
| 60 | ) |
---|
| 61 | |
---|
[8245] | 62 | p_session = schema.Choice( |
---|
| 63 | title = _(u'Payment Session'), |
---|
| 64 | source = academic_sessions_vocab, |
---|
[9512] | 65 | required = True, |
---|
[8245] | 66 | ) |
---|
| 67 | |
---|
[7020] | 68 | p_state = schema.Choice( |
---|
[7717] | 69 | title = _(u'Payment State'), |
---|
[7020] | 70 | default = u'unpaid', |
---|
| 71 | vocabulary = payment_states, |
---|
| 72 | required = True, |
---|
| 73 | ) |
---|
| 74 | |
---|
[8170] | 75 | creation_date = schema.Datetime( |
---|
[7717] | 76 | title = _(u'Ticket Creation Date'), |
---|
[7623] | 77 | readonly = False, |
---|
[8944] | 78 | required = False, |
---|
[6864] | 79 | ) |
---|
| 80 | |
---|
[8170] | 81 | payment_date = schema.Datetime( |
---|
[7717] | 82 | title = _(u'Payment Date'), |
---|
[6869] | 83 | required = False, |
---|
[6934] | 84 | readonly = False, |
---|
[6864] | 85 | ) |
---|
| 86 | |
---|
[7927] | 87 | amount_auth = schema.Float( |
---|
[7717] | 88 | title = _(u'Amount Authorized'), |
---|
[7927] | 89 | default = 0.0, |
---|
[6864] | 90 | required = True, |
---|
[7931] | 91 | readonly = False, |
---|
[6864] | 92 | ) |
---|
| 93 | |
---|
| 94 | class IOnlinePayment(IPayment): |
---|
| 95 | """A payment via payment gateways. |
---|
| 96 | |
---|
| 97 | """ |
---|
| 98 | |
---|
[6930] | 99 | ac = schema.TextLine( |
---|
[7717] | 100 | title = _(u'Activation Code'), |
---|
[6930] | 101 | default = None, |
---|
| 102 | required = False, |
---|
| 103 | readonly = False, |
---|
| 104 | ) |
---|
| 105 | |
---|
[7927] | 106 | r_amount_approved = schema.Float( |
---|
[7717] | 107 | title = _(u'Response Amount Approved'), |
---|
[7927] | 108 | default = 0.0, |
---|
[6864] | 109 | required = False, |
---|
[6930] | 110 | readonly = False, |
---|
[6864] | 111 | ) |
---|
| 112 | |
---|
| 113 | r_code = schema.TextLine( |
---|
[7717] | 114 | title = _(u'Response Code'), |
---|
[6864] | 115 | default = None, |
---|
[6869] | 116 | required = False, |
---|
[6930] | 117 | readonly = False, |
---|
[6864] | 118 | ) |
---|
[8420] | 119 | |
---|
[8429] | 120 | r_desc = schema.TextLine( |
---|
| 121 | title = _(u'Response Description'), |
---|
| 122 | default = None, |
---|
| 123 | required = False, |
---|
| 124 | readonly = False, |
---|
| 125 | ) |
---|
| 126 | |
---|
[8420] | 127 | def approve(): |
---|
| 128 | "Approve an online payment and set to paid." |
---|
[8703] | 129 | |
---|
| 130 | class IPaymentWebservice(IKofaObject): |
---|
| 131 | """An interface for a webservice. |
---|
| 132 | |
---|
[9533] | 133 | """ |
---|
| 134 | display_fullname = Attribute('Name of payee') |
---|
| 135 | id = Attribute('Id of payee') |
---|
[9733] | 136 | reg_number = Attribute('Reg number of payee') |
---|
| 137 | matric_number = Attribute('Matric number of payee') |
---|
[9533] | 138 | faculty = Attribute('Faculty of payee') |
---|
| 139 | department = Attribute('Department of payee') |
---|