added shopid
[indico-PayWay] / MaKaC / plugins / EPayment / payWay / epayment.py
index 0fd4a75..5748bd0 100644 (file)
@@ -35,7 +35,8 @@ class PayWayMod(BaseEPayMod):
         self._title = "payway"
 
         self._url="https://pgwtest.ht.hr/services/payment/api/authorize-form"
-        self._business= "please fill in private key here"
+        self._business="please fill in private key here"
+        self._shopid="please fill in shop id here"
 
         if data is not None:
             setValue(data)
@@ -55,6 +56,7 @@ class PayWayMod(BaseEPayMod):
         self.setTitle(data.get("title", "epayment"))
         self.setUrl(data.get("url", ""))
         self.setBusiness(data["business"])
+        self.setShopID(data["shopid"])
 
     def getUrl(self):
         return self._url
@@ -66,6 +68,15 @@ class PayWayMod(BaseEPayMod):
     def setBusiness(self,business):
         self._business= business
 
+    def getShopID(self):
+        if hasattr(self, '_shopid'):
+            return self._shopid
+        else:
+            self._shopid = "please fill in shop id"
+            return self._shopid
+    def setShopID(self,shopid):
+        self._shopid= shopid
+
     def strip_accents(self,text):
         """
         Strip accents from input String.
@@ -87,9 +98,9 @@ class PayWayMod(BaseEPayMod):
 
     def getFormHTML(self,prix,Currency,conf,registrant,lang = "en_GB", secure=False):
 
-       pgw_shop_id=str(20000573)
-       pgw_order_id=str(registrant.getId())
-       pgw_amount=str(int(prix * 100))
+        pgw_shop_id=str(self._shopid)
+        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))
@@ -98,11 +109,11 @@ class PayWayMod(BaseEPayMod):
         pgw_first_name=self.strip_accents(registrant.getFirstName())
         pgw_last_name=self.strip_accents(registrant.getSurName())
 
-       pgw_telephone=registrant.getPhone()
-       pgw_email=registrant.getEmail()
+        pgw_telephone=registrant.getPhone()
+        pgw_email=registrant.getEmail()
 
-       secret_key=self.getBusiness()
-       pgw_signature= \
+        secret_key=self.getBusiness()
+        pgw_signature= \
 'authorize-form' + secret_key + \
 pgw_shop_id + secret_key + \
 pgw_order_id + secret_key + \
@@ -116,7 +127,7 @@ pgw_last_name + secret_key + \
 pgw_telephone + secret_key + \
 pgw_email + secret_key
 
-       """
+        """
 gnature = SHA512 (
 naziv_metode + secret_key +
 pgw_shop_id + secret_key +
@@ -143,7 +154,7 @@ pgw_email + secret_key +
 #pgw_merchant_data + secret_key
 """
 
-       pgw_signature=hashlib.sha512(pgw_signature).hexdigest()
+        pgw_signature=hashlib.sha512(pgw_signature).hexdigest()
 
         s="""<form name="Button" action="%s" method="post" id="%s">
              <input type="hidden" name="pgw_shop_id" value="%s" />
@@ -165,10 +176,10 @@ pgw_email + secret_key +
              <input type="hidden" name="pgw_signature" value="%s" />
 
              </form>""" % (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)
+                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