Browse Source

Validate comnpay payments on another host

portal
Yohann D'ANELLO 5 years ago
parent
commit
e28ad0ab2d
No known key found for this signature in database GPG Key ID: 3A75C55819C8CF85
  1. 8
      cotisations/payment_methods/comnpay/models.py
  2. 5
      portail/views.py

8
cotisations/payment_methods/comnpay/models.py

@ -73,7 +73,7 @@ class ComnpayPayment(PaymentMethodMixin, models.Model):
else: else:
return "https://secure.homologation.comnpay.com" return "https://secure.homologation.comnpay.com"
def end_payment(self, invoice, request): def end_payment(self, invoice, request, accept_host=None, refuse_host=None, ipn_host=None):
""" """
Build a request to start the negociation with Comnpay by using Build a request to start the negociation with Comnpay by using
a facture id, the price and the secret transaction data stored in a facture id, the price and the secret transaction data stored in
@ -84,12 +84,12 @@ class ComnpayPayment(PaymentMethodMixin, models.Model):
str(self.payment_credential), str(self.payment_credential),
str(self.payment_pass), str(self.payment_pass),
"https://" "https://"
+ host + (accept_host or host)
+ reverse( + reverse(
"cotisations:comnpay:accept_payment", kwargs={"factureid": invoice.id} "cotisations:comnpay:accept_payment", kwargs={"factureid": invoice.id}
), ),
"https://" + host + reverse("cotisations:comnpay:refuse_payment"), "https://" + (refuse_host or host) + reverse("cotisations:comnpay:refuse_payment"),
"https://" + host + reverse("cotisations:comnpay:ipn"), "https://" + (ipn_host or host) + reverse("cotisations:comnpay:ipn"),
"", "",
"D", "D",
) )

5
portail/views.py

@ -30,6 +30,7 @@ to redirect all requests to /portail/.
The app provides new views to sign in and buy articles, to avoid The app provides new views to sign in and buy articles, to avoid
accessing to the full Re2o. accessing to the full Re2o.
""" """
from django.conf import settings
from cotisations.models import Facture, Vente from cotisations.models import Facture, Vente
from cotisations.utils import find_payment_method from cotisations.utils import find_payment_method
@ -103,7 +104,9 @@ class SignUpView(CreateView):
# POOP CODE, pliz Re2o # POOP CODE, pliz Re2o
# End the payment process, it mays redirect to ComNPay # End the payment process, it mays redirect to ComNPay
return payment_method.end_payment(invoice, self.request) # We don't assume that the captive portal can be accessed from the whole web,
# then we provide to ComNPay another domain to validate the invoice
return payment_method.end_payment(invoice, self.request, settings.ALLOWED_HOSTS[0])
def get_success_url(self): def get_success_url(self):
return reverse_lazy("users:profil", args=(self.object.pk,)) return reverse_lazy("users:profil", args=(self.object.pk,))

Loading…
Cancel
Save