feat: added tpv form view
This commit is contained in:
@@ -2,6 +2,7 @@ from django.urls import reverse
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
from django.shortcuts import render, get_object_or_404, redirect
|
||||
from django.http.response import HttpResponse
|
||||
from django.views.generic import TemplateView
|
||||
|
||||
from tpv.forms import UpdateEmailForm
|
||||
from tpv.models import PaymentTransaction
|
||||
@@ -75,3 +76,24 @@ def transaction_created(request, transaction):
|
||||
"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