From 9bd5ffa253631bc23dcf508ea49df2ad82c700af Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Wed, 9 Dec 2015 11:52:24 +0100 Subject: [PATCH] first succesfull transfer of form to PayWay --- EGG-INFO/SOURCES.txt | 15 ++- EGG-INFO/entry_points.txt | 3 +- MaKaC/plugins/EPayment/payWay/epayment.py | 125 +++++++++++++++--- .../payWay/tpls/ConfModifEPaymentPayWay.tpl | 2 +- .../tpls/ConfModifEPaymentPayWayDataModif.tpl | 2 +- 5 files changed, 125 insertions(+), 22 deletions(-) diff --git a/EGG-INFO/SOURCES.txt b/EGG-INFO/SOURCES.txt index 9228b2d..52efd2f 100644 --- a/EGG-INFO/SOURCES.txt +++ b/EGG-INFO/SOURCES.txt @@ -412,6 +412,19 @@ indico/MaKaC/plugins/EPayment/payPal/webinterface/pages/__init__.py indico/MaKaC/plugins/EPayment/payPal/webinterface/pages/ePayments.py indico/MaKaC/plugins/EPayment/payPal/webinterface/rh/__init__.py indico/MaKaC/plugins/EPayment/payPal/webinterface/rh/ePaymentModif.py +indico/MaKaC/plugins/EPayment/peyWay/__init__.py +indico/MaKaC/plugins/EPayment/peyWay/epayment.py +indico/MaKaC/plugins/EPayment/peyWay/tpls/CancelEPaymentPayPal.tpl +indico/MaKaC/plugins/EPayment/peyWay/tpls/ConfModifEPaymentPayPal.tpl +indico/MaKaC/plugins/EPayment/peyWay/tpls/ConfModifEPaymentPayPalDataModif.tpl +indico/MaKaC/plugins/EPayment/peyWay/tpls/confirmEPaymentPayPal.tpl +indico/MaKaC/plugins/EPayment/peyWay/webinterface/__init__.py +indico/MaKaC/plugins/EPayment/peyWay/webinterface/urlHandlers.py +indico/MaKaC/plugins/EPayment/peyWay/webinterface/wcomponents.py +indico/MaKaC/plugins/EPayment/peyWay/webinterface/pages/__init__.py +indico/MaKaC/plugins/EPayment/peyWay/webinterface/pages/ePayments.py +indico/MaKaC/plugins/EPayment/peyWay/webinterface/rh/__init__.py +indico/MaKaC/plugins/EPayment/peyWay/webinterface/rh/ePaymentModif.py indico/MaKaC/plugins/EPayment/skipjack/__init__.py indico/MaKaC/plugins/EPayment/skipjack/epayment.py indico/MaKaC/plugins/EPayment/skipjack/tpls/CancelEPaymentSkipjack.tpl @@ -5276,4 +5289,4 @@ indico/web/http_api/metadata/xml.py indico/web/templates/alarm_email.txt indico/web/templates/alarm_email_agenda.txt indico/web/views/__init__.py -indico/web/views/etickets.py \ No newline at end of file +indico/web/views/etickets.py diff --git a/EGG-INFO/entry_points.txt b/EGG-INFO/entry_points.txt index 939b8ba..d2bbc6e 100644 --- a/EGG-INFO/entry_points.txt +++ b/EGG-INFO/entry_points.txt @@ -36,6 +36,7 @@ RoomBooking.default = MaKaC.plugins.RoomBooking.default EPayment.payPal = MaKaC.plugins.EPayment.payPal + EPayment.payWay = MaKaC.plugins.EPayment.payWay EPayment.worldPay = MaKaC.plugins.EPayment.worldPay EPayment.yellowPay = MaKaC.plugins.EPayment.yellowPay EPayment.skipjack = MaKaC.plugins.EPayment.skipjack @@ -52,4 +53,4 @@ search.invenio = indico.ext.search.invenio - \ No newline at end of file + diff --git a/MaKaC/plugins/EPayment/payWay/epayment.py b/MaKaC/plugins/EPayment/payWay/epayment.py index 435c20e..0fd4a75 100644 --- a/MaKaC/plugins/EPayment/payWay/epayment.py +++ b/MaKaC/plugins/EPayment/payWay/epayment.py @@ -25,14 +25,17 @@ from MaKaC.webinterface.common.tools import strip_ml_tags from MaKaC.plugins.EPayment.payWay.webinterface import urlHandlers as localUrlHandlers from MaKaC.plugins.EPayment.payWay import MODULE_ID +import unicodedata +import hashlib + class PayWayMod(BaseEPayMod): def __init__(self, data=None): BaseEPayMod.__init__(self) self._title = "payway" - self._url="https://www.payway.com/cgi-bin/webscr" - self._business= "" + self._url="https://pgwtest.ht.hr/services/payment/api/authorize-form" + self._business= "please fill in private key here" if data is not None: setValue(data) @@ -63,24 +66,110 @@ class PayWayMod(BaseEPayMod): def setBusiness(self,business): self._business= business + def strip_accents(self,text): + """ + Strip accents from input String. + + :param text: The input string. + :type text: String. + + :returns: The processed String. + :rtype: String. + """ + try: + text = unicode(text, 'utf-8') + except NameError: # unicode is a default on python 3 + pass + text = unicodedata.normalize('NFD', text) + text = text.encode('ascii', 'ignore') + text = text.decode("utf-8") + return str(text) + def getFormHTML(self,prix,Currency,conf,registrant,lang = "en_GB", secure=False): - url_return=localUrlHandlers.UHPayConfirmPayWay.getURL(registrant) - url_cancel_return=localUrlHandlers.UHPayCancelPayWay.getURL(registrant) + + pgw_shop_id=str(20000573) + pgw_order_id=str(registrant.getId()) + pgw_amount=str(int(prix * 100)) + + pgw_success_url=str(localUrlHandlers.UHPayConfirmPayWay.getURL(registrant)) + pgw_failure_url=str(localUrlHandlers.UHPayCancelPayWay.getURL(registrant)) url_notify=localUrlHandlers.UHPayParamsPayWay.getURL(registrant) - s="""
- - - - - - - - - -
- """%(self.getUrl(),self.getId(),self.getBusiness(), "%s: registration for %s"%(registrant.getFullName(),strip_ml_tags(conf.getTitle())),prix,Currency,\ - url_return,url_cancel_return,url_notify) - #s=cgi.escape(s) + + pgw_first_name=self.strip_accents(registrant.getFirstName()) + pgw_last_name=self.strip_accents(registrant.getSurName()) + + pgw_telephone=registrant.getPhone() + pgw_email=registrant.getEmail() + + secret_key=self.getBusiness() + pgw_signature= \ +'authorize-form' + secret_key + \ +pgw_shop_id + secret_key + \ +pgw_order_id + secret_key + \ +pgw_amount + secret_key + \ +'0' + secret_key + \ +'en' + secret_key + \ +pgw_success_url + secret_key + \ +pgw_failure_url + secret_key + \ +pgw_first_name + secret_key + \ +pgw_last_name + secret_key + \ +pgw_telephone + secret_key + \ +pgw_email + secret_key + + """ +gnature = SHA512 ( +naziv_metode + secret_key + +pgw_shop_id + secret_key + +pgw_order_id + secret_key + +pgw_amount + secret_key + +#pgw_installments + secret_key + +pgw_authorization_type + secret_key + +#pgw_authorization_token + secret_key + +pgw_language + secret_key + +#pgw_return_method + secret_key + +pgw_success_url + secret_key + +pgw_failure_url + secret_key + +#pgw_card_number + secret_key + +#pgw_card_expiration_date + secret_key + +#pgw_card_verification_data + secret_key + +pgw_first_name + secret_key + +pgw_last_name + secret_key + +#pgw_street + secret_key + +#pgw_city + secret_key + +#pgw_post_code + secret_key + +#pgw_country + secret_key + +pgw_telephone + secret_key + +pgw_email + secret_key + +#pgw_merchant_data + secret_key +""" + + pgw_signature=hashlib.sha512(pgw_signature).hexdigest() + + s="""
+ + + + + + + + + + + + + + + + + + +
""" % (self.getUrl(), self.getId(), \ + pgw_shop_id, pgw_order_id, pgw_amount, \ + pgw_success_url, pgw_failure_url, \ + pgw_first_name, pgw_last_name, pgw_telephone, pgw_email, \ + pgw_signature) + return s def getConfModifEPaymentURL(self, conf): diff --git a/MaKaC/plugins/EPayment/payWay/tpls/ConfModifEPaymentPayWay.tpl b/MaKaC/plugins/EPayment/payWay/tpls/ConfModifEPaymentPayWay.tpl index f4ab65d..42828cc 100644 --- a/MaKaC/plugins/EPayment/payWay/tpls/ConfModifEPaymentPayWay.tpl +++ b/MaKaC/plugins/EPayment/payWay/tpls/ConfModifEPaymentPayWay.tpl @@ -13,7 +13,7 @@
${ url }
- business + Private key
${ business }
  diff --git a/MaKaC/plugins/EPayment/payWay/tpls/ConfModifEPaymentPayWayDataModif.tpl b/MaKaC/plugins/EPayment/payWay/tpls/ConfModifEPaymentPayWayDataModif.tpl index d0fa00a..889d6e6 100644 --- a/MaKaC/plugins/EPayment/payWay/tpls/ConfModifEPaymentPayWayDataModif.tpl +++ b/MaKaC/plugins/EPayment/payWay/tpls/ConfModifEPaymentPayWayDataModif.tpl @@ -12,7 +12,7 @@ - business + Private key   -- 2.20.1