Commits

Andres Vargas  committed 5d02b31

generate url on shop

  • Participants
  • Parent commits 49a81f0

Comments (0)

Files changed (2)

File dineromail/dineromail_settings.py

 )
 
 DINEROMAIL_URL = "https://checkout.dineromail.com/CheckOut"
+DINEROMAIL_URL_PROXY = "https://mexico.dineromail.com/Shop/Shop_Ingreso.asp"
 
 DINEROMAIL_PARAMS = {
+    "usr_nombre":  "Andres",
+    "usr_apellido":    "Vargas",
+    "usr_tel_numero":"",#  52 9992019253
+    "usr_email":"",  # zodman@gmail.com
+    "NombreItem":"",#  SuEmpresa.com - Compra no. 327746
+    "TipoMoneda":  1,
+    "PrecioItem":0.0,  #149.64
+    "E_Comercio": DINEROMAIL_ACCOUNT_NUMBER,  #  142966
+    "NroItem":"-",# 327746
+    "image_url":"https://",#   https://www.suempresa.com/imagenes/dineroMail/minilogo-Suempresa.gif
+    "DireccionExito":"http://",  #http://www.suempresa.com/pagos/dineromail.php?trx_id=327746
+    "DireccionFracaso":"http://",#    http://suempresa.com/pagos/dineromail_pago_no_acreditado.php?trx_id=327746
+    "DireccionEnvio":0,
+    "Mensaje": 0,
+    "MediosPago":"4,19,13,14,2",
+    "trx_id":0 #  327746
+}
+
+DINEROMAIL_PARAMS_old = {
     "merchant":DINEROMAIL_ACCOUNT_NUMBER, # required
     "country_id":MEXICO, #requried
     "payment_method_available":"all",

File dineromail/lfs/utils.py

 # dineromail modules
 from dineromail.dineromail_settings import DINEROMAIL_URL,DINEROMAIL_PARAMS
+from dineromail.dineromail_settings import DINEROMAIL_PARAMS
+from dineromail.dineromail_settings import DINEROMAIL_URL_PROXY
 from dineromail.models import Transaction
 
 # lfs modules
 import urllib
 
 
-def lfs_generate_url(request = None, order = None):
+def lfs_generate_url( order = None, request = None):
     """ Generate url from request or from order """
-    if request and order:
+    if  order:
+        p = DINEROMAIL_PARAMS
+        total_price = order.price
+        shop = get_default_shop()
+        current_site = Site.objects.get(id=settings.SITE_ID)
+        last_index = 1
+        str_item =""
+        price  = 0
+        # adding items to dineromail cart
+        for index, item in enumerate(order.items.all()):
+            str_item += " " + item.product_name
+            price =  item.product_price_net + item.product_tax
+        #dineromail commision and shipping cost
+        price += order.payment_price + order.payment_tax  + order.shipping_price
+
+        #buyer info
+        p["usr_nombre"] = order.customer_firstname
+        p["usr_apellido"] = order.customer_lastname
+        p["usr_email"] = order.customer_email
+        p["usr_tel_numero"] = order.invoice_phone
+        p["NombreItem"] = str_item
+        p["PrecioItem"] ="%.2f" % price
+        # configuration
+  #      if shop.image:
+  #         p["image_url"]= "http://"+ current_site.domain + settings.MEDIA_URL + shop.image.url
+#        p["DireccionExito"] ="http://"+ current_site.domain + reverse("lfs_thank_you")
+ #       p["DireccionFracaso"] = "http://"+ current_site.domain + reverse("lfs_checkout_dispatcher")
+        t = Transaction.objects.create(content_object=order)
+        p["trx_id"] = "t-%s-%s" % (t.id,order.id)
+        #uri = urllib.urlencode(p)
+        uri= (
+            '?usr_nombre=%(usr_nombre)s&usr_apellido=%(usr_apellido)s'
+            '&usr_tel_numero=%(usr_tel_numero)s&usr_email=%(usr_email)s'
+            '&NombreItem=%(NombreItem)s&TipoMoneda=%(TipoMoneda)s'
+            '&PrecioItem=%(PrecioItem)s'
+            '&E_Comercio=%(E_Comercio)s&NroItem=%(NroItem)s'
+            '&image_url=%(image_url)s&DireccionExito=%(DireccionExito)s'
+            '&DireccionFracaso=%(DireccionFracaso)s&DireccionEnvio=%(DireccionEnvio)s'
+            '&Mensaje=%(Mensaje)s&MediosPago=%(MediosPago)s&trx_id=%(trx_id)s'
+        ) 
+
+        return  DINEROMAIL_URL_PROXY+ uri%p
+    return None
+
+
+def __lfs_generate_url(request = None, order = None):
+    """ Generate url from request or from order """
+    if  order:
         p = DINEROMAIL_PARAMS
         total_price = order.price
         shop = get_default_shop()