1 # -*- coding: utf-8 -*-
4 ## This file is part of Indico.
5 ## Copyright (C) 2002 - 2014 European Organization for Nuclear Research (CERN).
7 ## Indico is free software; you can redistribute it and/or
8 ## modify it under the terms of the GNU General Public License as
9 ## published by the Free Software Foundation; either version 3 of the
10 ## License, or (at your option) any later version.
12 ## Indico is distributed in the hope that it will be useful, but
13 ## WITHOUT ANY WARRANTY; without even the implied warranty of
14 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 ## General Public License for more details.
17 ## You should have received a copy of the GNU General Public License
18 ## along with Indico;if not, see <http://www.gnu.org/licenses/>.
20 from MaKaC.epayment import BaseEPayMod, BaseTransaction
21 import MaKaC.webinterface.urlHandlers as urlHandlers
22 from MaKaC.webinterface.common.tools import strip_ml_tags
25 from MaKaC.plugins.EPayment.payPal.webinterface import urlHandlers as localUrlHandlers
26 from MaKaC.plugins.EPayment.payPal import MODULE_ID
28 class PayPalMod(BaseEPayMod):
30 def __init__(self, data=None):
31 BaseEPayMod.__init__(self)
32 self._title = "paypal"
34 self._url="https://www.paypal.com/cgi-bin/webscr"
43 def clone(self, newSessions):
45 sesf.setTitle(self.getTitle())
46 sesf.setUrl(self.getUrl())
47 sesf.setBusiness(self.getBusiness())
51 def setValues(self, data):
52 self.setTitle(data.get("title", "epayment"))
53 self.setUrl(data.get("url", ""))
54 self.setBusiness(data["business"])
61 def getBusiness(self):
63 def setBusiness(self,business):
64 self._business= business
66 def getFormHTML(self,prix,Currency,conf,registrant,lang = "en_GB", secure=False):
67 url_return=localUrlHandlers.UHPayConfirmPayPal.getURL(registrant)
68 url_cancel_return=localUrlHandlers.UHPayCancelPayPal.getURL(registrant)
69 url_notify=localUrlHandlers.UHPayParamsPayPal.getURL(registrant)
70 s=""" <form action="%s" method="POST" id="%s">
71 <input type="hidden" name="cmd" value="_xclick">
72 <input type="hidden" name="business" value="%s">
73 <input type="hidden" name="item_name" value="%s">
74 <input type="hidden" name="amount" value="%s">
75 <INPUT TYPE="hidden" NAME="currency_code" value="%s">
76 <input type="hidden" name="charset" value="utf-8">
77 <input type="hidden" name="return" value="%s">
78 <input type="hidden" name="cancel_return" value="%s">
79 <input type="hidden" name="notify_url" value="%s">
81 """%(self.getUrl(),self.getId(),self.getBusiness(), "%s: registration for %s"%(registrant.getFullName(),strip_ml_tags(conf.getTitle())),prix,Currency,\
82 url_return,url_cancel_return,url_notify)
86 def getConfModifEPaymentURL(self, conf):
87 return localUrlHandlers.UHConfModifEPaymentPayPal.getURL(conf)
91 class TransactionPayPal(BaseTransaction):
93 def __init__(self,parms):
94 BaseTransaction.__init__(self)
102 except AttributeError, e:
106 def getTransactionHTML(self):
109 <td align="right"><b>Payment with:</b></td>
110 <td align="left">PayPal</td>
113 <td align="right"><b>Payment Date:</b></td>
114 <td align="left">%s</td>
117 <td align="right"><b>Payment ID:</b></td>
118 <td align="left">%s</td>
121 <td align="right"><b>Order Total:</b></td>
122 <td align="left">%s %s</td>
125 <td align="right"><b>verify sign:</b></td>
126 <td align="left">%s</td>
128 </table>"""%(self._Data["payment_date"],self._Data["payer_id"], self._Data["mc_gross"], \
129 self._Data["mc_currency"], self._Data["verify_sign"])
130 def getTransactionTxt(self):
132 \tPayment with:PayPal\n
135 \tOrder Total:%s %s\n
137 """%(self._Data["payment_date"],self._Data["payer_id"], self._Data["mc_gross"], \
138 self._Data["mc_currency"], self._Data["verify_sign"])
145 def getPayModClass():