Commits

eloici  committed dd0372b

Support for extended signature calculation (tipo de clave SHA1 completo ampliado) in payment.modules.sermepa

  • Participants
  • Parent commits 2a5cd69

Comments (0)

Files changed (2)

File satchmo/apps/payment/modules/sermepa/config.py

         help_text=_('Your secret code used to sign transaction data in test payments'),
         ordering=200,
         ),
+    BooleanValue(
+        PAYMENT_GROUP,
+        'EXTENDED_SIGNATURE',
+        description=_("Extended signature calculation"),
+        help_text=_("Consult your Sermepa documentation to know the differences between normal and extended signature calculation, and ask your provider which type of signature expects you to use. If possible, use extended signature."),
+        default=False,
+        ordering=105,
+        ),
+#    BooleanValue(
+#        PAYMENT_GROUP,
+#        'EXTENDED_SIGNATURE',
+#        description=_("Extended signature calculation"),
+#        ordering=110,
+#        default=False)
+#    ),
     # terminal
     IntegerValue(
         PAYMENT_GROUP,

File satchmo/apps/payment/modules/sermepa/views.py

     xchg_order_id = "%07dT%02d%02d" % (order.id, now.minute, now.second)
 
     amount = "%d" % (order.balance * 100,)    # in cents
-    signature_data = ''.join(
-            map(str, (
-                    amount,
-                    xchg_order_id,
-                    payment_module.MERCHANT_FUC.value,
-                    payment_module.MERCHANT_CURRENCY.value,
-                    signature_code,
-                    )
-               )
-            )
-
-    signature = sha1(signature_data).hexdigest()
 
     template = lookup_template(payment_module, 'shop/checkout/sermepa/confirm.html')
 
     url_ok = _resolve_local_url(payment_module, payment_module.MERCHANT_URL_OK)
     url_ko = _resolve_local_url(payment_module, payment_module.MERCHANT_URL_KO)
 
+    if payment_module.EXTENDED_SIGNATURE.value:
+        signature_data = ''.join(
+                map(str, (
+                        amount,
+                        xchg_order_id,
+                        payment_module.MERCHANT_FUC.value,
+                        payment_module.MERCHANT_CURRENCY.value,
+                        "0", #TransactionType
+                        url_callback,
+                        signature_code,
+                        )
+                   )
+                )
+    else:
+        signature_data = ''.join(
+                map(str, (
+                        amount,
+                        xchg_order_id,
+                        payment_module.MERCHANT_FUC.value,
+                        payment_module.MERCHANT_CURRENCY.value,
+                        signature_code,
+                        )
+                   )
+                )
+
+    signature = sha1(signature_data).hexdigest()
     ctx = {
         'live': live,
         'post_url': post_url,