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.payWay.webinterface import urlHandlers as localUrlHandlers
26 from MaKaC.plugins.EPayment.payWay import MODULE_ID
31 class PayWayMod(BaseEPayMod):
33 def __init__(self, data=None):
34 BaseEPayMod.__init__(self)
35 self._title = "payway"
37 self._url="https://pgwtest.ht.hr/services/payment/api/authorize-form"
38 self._business="please fill in private key here"
39 self._shopid="please fill in shop id here"
47 def clone(self, newSessions):
49 sesf.setTitle(self.getTitle())
50 sesf.setUrl(self.getUrl())
51 sesf.setBusiness(self.getBusiness())
55 def setValues(self, data):
56 self.setTitle(data.get("title", "epayment"))
57 self.setUrl(data.get("url", ""))
58 self.setBusiness(data["business"])
59 self.setShopID(data["shopid"])
66 def getBusiness(self):
68 def setBusiness(self,business):
69 self._business= business
72 if hasattr(self, '_shopid'):
75 self._shopid = "please fill in shop id"
77 def setShopID(self,shopid):
80 def strip_accents(self,text):
82 Strip accents from input String.
84 :param text: The input string.
87 :returns: The processed String.
91 text = unicode(text, 'utf-8')
92 except NameError: # unicode is a default on python 3
94 text = unicodedata.normalize('NFD', text)
95 text = text.encode('ascii', 'ignore')
96 text = text.decode("utf-8")
99 def getFormHTML(self,prix,Currency,conf,registrant,lang = "en_GB", secure=False):
101 pgw_shop_id=str(self._shopid)
102 pgw_order_id=str(registrant.getId())
103 pgw_amount=str(int(prix * 100))
105 pgw_success_url=str(localUrlHandlers.UHPayConfirmPayWay.getURL(registrant))
106 pgw_failure_url=str(localUrlHandlers.UHPayCancelPayWay.getURL(registrant))
107 url_notify=localUrlHandlers.UHPayParamsPayWay.getURL(registrant)
109 pgw_first_name=self.strip_accents(registrant.getFirstName())
110 pgw_last_name=self.strip_accents(registrant.getSurName())
112 pgw_telephone=registrant.getPhone()
113 pgw_email=registrant.getEmail()
115 secret_key=self.getBusiness()
117 'authorize-form' + secret_key + \
118 pgw_shop_id + secret_key + \
119 pgw_order_id + secret_key + \
120 pgw_amount + secret_key + \
122 'en' + secret_key + \
123 pgw_success_url + secret_key + \
124 pgw_failure_url + secret_key + \
125 pgw_first_name + secret_key + \
126 pgw_last_name + secret_key + \
127 pgw_telephone + secret_key + \
128 pgw_email + secret_key
132 naziv_metode + secret_key +
133 pgw_shop_id + secret_key +
134 pgw_order_id + secret_key +
135 pgw_amount + secret_key +
136 #pgw_installments + secret_key +
137 pgw_authorization_type + secret_key +
138 #pgw_authorization_token + secret_key +
139 pgw_language + secret_key +
140 #pgw_return_method + secret_key +
141 pgw_success_url + secret_key +
142 pgw_failure_url + secret_key +
143 #pgw_card_number + secret_key +
144 #pgw_card_expiration_date + secret_key +
145 #pgw_card_verification_data + secret_key +
146 pgw_first_name + secret_key +
147 pgw_last_name + secret_key +
148 #pgw_street + secret_key +
149 #pgw_city + secret_key +
150 #pgw_post_code + secret_key +
151 #pgw_country + secret_key +
152 pgw_telephone + secret_key +
153 pgw_email + secret_key +
154 #pgw_merchant_data + secret_key
157 pgw_signature=hashlib.sha512(pgw_signature).hexdigest()
159 s="""<form name="Button" action="%s" method="post" id="%s">
160 <input type="hidden" name="pgw_shop_id" value="%s" />
161 <input type="hidden" name="pgw_order_id" value="%s" />
162 <input type="hidden" name="pgw_amount" value="%s" />
164 <input type="hidden" name="pgw_authorization_type" value="0" />
165 <input type="hidden" name="pgw_language" value="en" />
167 <input type="hidden" name="pgw_success_url" value="%s" />
168 <input type="hidden" name="pgw_failure_url" value="%s" />
170 <input type="hidden" name="pgw_first_name" value="%s" />
171 <input type="hidden" name="pgw_last_name" value="%s" />
173 <input type="hidden" name="pgw_telephone" value="%s" />
174 <input type="hidden" name="pgw_email" value="%s" />
176 <input type="hidden" name="pgw_signature" value="%s" />
178 </form>""" % (self.getUrl(), self.getId(), \
179 pgw_shop_id, pgw_order_id, pgw_amount, \
180 pgw_success_url, pgw_failure_url, \
181 pgw_first_name, pgw_last_name, pgw_telephone, pgw_email, \
186 def getConfModifEPaymentURL(self, conf):
187 return localUrlHandlers.UHConfModifEPaymentPayWay.getURL(conf)
191 class TransactionPayWay(BaseTransaction):
193 def __init__(self,parms):
194 BaseTransaction.__init__(self)
202 except AttributeError, e:
206 def getTransactionHTML(self):
209 <td align="right"><b>Payment with:</b></td>
210 <td align="left">PayWay</td>
213 <td align="right"><b>Payment Date:</b></td>
214 <td align="left">%s</td>
217 <td align="right"><b>Payment ID:</b></td>
218 <td align="left">%s</td>
221 <td align="right"><b>Order Total:</b></td>
222 <td align="left">%s %s</td>
225 <td align="right"><b>verify sign:</b></td>
226 <td align="left">%s</td>
228 </table>"""%(self._Data["payment_date"],self._Data["payer_id"], self._Data["mc_gross"], \
229 self._Data["mc_currency"], self._Data["verify_sign"])
230 def getTransactionTxt(self):
232 \tPayment with:PayWay\n
235 \tOrder Total:%s %s\n
237 """%(self._Data["payment_date"],self._Data["payer_id"], self._Data["mc_gross"], \
238 self._Data["mc_currency"], self._Data["verify_sign"])
245 def getPayModClass():