I am doing a purchase process in which I want the user to follow the following steps:
For them, the first function they enter is this:
def proceso_compra(request, slug, talla):
producto = get_object_or_404(Producto, slug = slug)
foto = Foto.objects.filter(producto = producto)
perfil = Perfil.objects.get(usuario = request.user)
comision = Comision.objects.get(id = 1)
stock = Stock.objects.get(producto = producto, id = talla)
promocion = Promocion.objects.get(id = 1)
if request.POST:
form = PayerForm(request.POST)
if form.is_valid():
return redirect('confirmacion-pedido', pedido.slug, {'form':form})
form = PayerForm()
tarjeta_pri = False
if perfil.pri_card != None:
tarjeta = consultar_tarjeta(perfil.pri_card,perfil.id)
if tarjeta['code'] == 'SUCCESS':
if tarjeta['creditCardTokenList'][0]['payerId'] == str(perfil.id):
tarjeta_pri = tarjeta['creditCardTokenList'][0]
tarjeta_alt = False
if perfil.alt_card != None:
tarjeta = consultar_tarjeta(perfil.alt_card,perfil.id)
if tarjeta['code'] == 'SUCCESS':
if tarjeta['creditCardTokenList'][0]['payerId'] == str(perfil.id):
tarjeta_alt = tarjeta['creditCardTokenList'][0]
if promocion.activo:
total = producto.p_venta + promocion.precio_oferta
gastos_envio = promocion.precio_oferta
else:
total = producto.p_venta + comision.gastos_envio
gastos_envio = comision.gastos_envio
try:
vacaciones = Vacaciones.objects.get(perfil=perfil)
except:
vacaciones = None
return render(request, 'intranet/comprar_producto.html',{'form':form, 'producto':producto,
'perfil': perfil,'foto':foto[0],'gastos_envio':comision.gastos_envio,'total':total,
'stock':stock, 'count_productos' : contador_productos(perfil),'vacaciones':vacaciones,
'promocion':promocion,'tarjeta_pri':tarjeta_pri,'tarjeta_alt':tarjeta_alt,'stock':stock})
After that, you should enter another function in which the order was generated and once the data was confirmed, it would send the data to the platform and send it back to a third function where the response template would be displayed.
My problem is that I do not know how to retain the card data to pass it to the second function.