feat: added tpv form view
This commit is contained in:
@@ -0,0 +1,20 @@
|
|||||||
|
<div>
|
||||||
|
{% if order.status == 'PEN' %}
|
||||||
|
<form name="from" action="{{ redsys_target_url }}" method="POST">
|
||||||
|
{% csrf_token %}
|
||||||
|
<input type="hidden" name="Ds_SignatureVersion" value="{{ signature_version }}"/>
|
||||||
|
<input type="hidden" name="Ds_MerchantParameters" value="{{ merchant_parameters }}"/>
|
||||||
|
<input type="hidden" name="Ds_Signature" value="{{ signature }}"/>
|
||||||
|
|
||||||
|
{% if order.contact_email != '' %}
|
||||||
|
<input
|
||||||
|
class="mt-6 w-full rounded-md bg-primary-500 py-1.5 font-medium text-primary-50 hover:bg-primary-600 cursor-pointer"
|
||||||
|
type="submit" value="Ir a pagar">
|
||||||
|
{% else %}
|
||||||
|
<input
|
||||||
|
class="mt-6 w-full rounded-md bg-primary-500 py-1.5 font-medium text-primary-50 hover:bg-primary-600 cursor-pointer"
|
||||||
|
type="submit" value="Ir a pagar" disabled>
|
||||||
|
{% endif %}
|
||||||
|
</form>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
+2
-1
@@ -1,5 +1,5 @@
|
|||||||
from django.urls import path
|
from django.urls import path
|
||||||
from tpv.views import transaction_created, webhook, payment_accepted, payment_rejected
|
from tpv.views import transaction_created, webhook, payment_accepted, payment_rejected, payment_form
|
||||||
|
|
||||||
app_name = "tpv"
|
app_name = "tpv"
|
||||||
|
|
||||||
@@ -9,4 +9,5 @@ urlpatterns = [
|
|||||||
path("transaction/<str:transaction>/webhook/", webhook, name="webhook"),
|
path("transaction/<str:transaction>/webhook/", webhook, name="webhook"),
|
||||||
path("transaction/<str:transaction>/ok/", payment_accepted, name="ok"),
|
path("transaction/<str:transaction>/ok/", payment_accepted, name="ok"),
|
||||||
path("transaction/<str:transaction>/ko/", payment_rejected, name="ko"),
|
path("transaction/<str:transaction>/ko/", payment_rejected, name="ko"),
|
||||||
|
path("transaction/<str:transaction>/form/", payment_form, name="payment_form"),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ from django.urls import reverse
|
|||||||
from django.views.decorators.csrf import csrf_exempt
|
from django.views.decorators.csrf import csrf_exempt
|
||||||
from django.shortcuts import render, get_object_or_404, redirect
|
from django.shortcuts import render, get_object_or_404, redirect
|
||||||
from django.http.response import HttpResponse
|
from django.http.response import HttpResponse
|
||||||
|
from django.views.generic import TemplateView
|
||||||
|
|
||||||
from tpv.forms import UpdateEmailForm
|
from tpv.forms import UpdateEmailForm
|
||||||
from tpv.models import PaymentTransaction
|
from tpv.models import PaymentTransaction
|
||||||
@@ -75,3 +76,24 @@ def transaction_created(request, transaction):
|
|||||||
"redsys_target_url": client.get_target_url(),
|
"redsys_target_url": client.get_target_url(),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class PaymentFormView(TemplateView):
|
||||||
|
template_name = "tpv/form.html"
|
||||||
|
|
||||||
|
def get_context_data(self, transaction):
|
||||||
|
transaction = get_object_or_404(PaymentTransaction, hash=transaction)
|
||||||
|
client = RedsysClient()
|
||||||
|
parameters = client.get_body_for_transaction(transaction)
|
||||||
|
target_url = client.get_target_url()
|
||||||
|
|
||||||
|
return {
|
||||||
|
"order": transaction,
|
||||||
|
"signature_version": parameters.get("Ds_SignatureVersion"),
|
||||||
|
"merchant_parameters": parameters.get("Ds_MerchantParameters"),
|
||||||
|
"signature": parameters.get("Ds_Signature"),
|
||||||
|
"redsys_target_url": target_url,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
payment_form = PaymentFormView.as_view()
|
||||||
|
|||||||
Reference in New Issue
Block a user