Conversion_Kitchen_Code/kitchen_counter/payment/templates/payments/checkoutold.html

210 lines
9.0 KiB
HTML
Raw Normal View History

2024-04-27 09:33:09 +00:00
{% extends "mnfapp/base.html" %}
{% load static %}
{% block content %}
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Checkout</title>
<script src="https://js.stripe.com/v3/"></script>
<!-- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"> -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<!-- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script> -->
<style>
.checkout-container{
display: grid;
grid-template-columns: 50% 50%;
}
.checkout-content{
margin: 10px;
padding: 10px;
}
</style>
</head>
<button style="color: blue;background-color: transparent; border: 0; text-decoration: underline;" onclick="window.history.back()"> Back To Payment</button>
<h1 style="background-color: black; color: white; padding:0.2em 0em 0.3em 0.3em ; width: 100vw;">Chut</h1>
<div class="checkout-container">
<div>
<div class="checkout-content" style="border: solid black 1px;">
<form action="{% url 'pcard'%}" method="post" id='payment-form'>
<h2 style="background-color: black; color: white; padding:0.2em 0em 0.3em 0.3em ;">Payment</h2>
{%csrf_token%}
<div style="padding-left: 0.3em;">
<h3>Pay Using Card</h3>
<input type="hidden" name="payment_intent_id" value='{{pid}}'>
{% if desc %}
<input type="hidden" name="type" value='subscription'>
<input type="hidden" name="giftId" value=''>
{%endif%}
{% if giftId %}
<input type="hidden" name="type" value='gift'>
<input type="hidden" name="giftId" value='{{giftId}}'>
{%endif%}
<input type="hidden" name="subPlan" value='{{subPlan}}'>
<div id="card-element" style="margin-top: 4vh; display: grid; grid-template-columns: auto;">
</div>
<div id="card-errors" role="alert"></div>
<button id="submit-button" style="width: 10vw; margin-top: 2em; background-color: blue; color: white;padding: 0.3em;border: solid blue 1px">PAY NOW</button>
</div>
</form>
</div>
</div>
<div class="checkout-content" style="border: solid black 1px;">
<h2 style="background-color: black; color: white; padding:0.2em 0em 0.3em 0.3em ;">Order Summary</h2>
<div style="display: grid; grid-template-columns: auto auto; margin-left: 0.5em;font-size: 1.4em;">
<span style="text-align: left;">Amount To Be Paid</span>
<span style="text-align: left;">$ {{amount}} USD = ₹ {{amtINR}} INR</span>
{% if desc %}
<span style="text-align: left;">Subscription</span>
<span style="text-align: left;">{{subPlan}}</span>
{%endif%}
<div><span style="font-size: 13px;">Have a promo code? Enter Here</span><br>
<form action="{% url 'promo'%}" onsubmit="return false;" method="post">
{%csrf_token%}
<input type="hidden" name="subPlan" value='{{subPlan}}'>
<input type="hidden" name="pid" id="pid" value="{{pid}}">
<input type="hidden" name="amount" value='{{amount}}'>
<input type="hidden" name="amtINR" id="pid" value="{{amtINR}}">
<input type="hidden" name="desc" id="pid" value="{{desc}}">
<!-- <input type="hidden" name="secret_key" id="pid" value="{{secret_key}}"> -->
{%if green%}
{%else%}
<input type="text" name="code" id="code" style="border-radius: 8px; padding-left: 3px;" placeholder="Promo Code" required>
<button type="submit" onclick="alert('Promo code invalid');" class="btn btn-primary">Submit</button>
{%endif%}
</form>
{% if promo_message%}
{% if green %}
<span style="font-size: 13px;color: green;">{{promo_message}}</span>
{%else%}
<span style="font-size: 13px;color: red;">{{promo_message}}</span>
{%endif%}
{%endif%}
</div>
{% if giftId %}
<span style="text-align: left;">Gift</span>
<span style="text-align: left;">One Month Subscription</span>
{% endif %}
</div>
</div>
</div>
</div>
</div>
<script>
function cardstripe(stripe_publishable_key, customer_email){
document.addEventListener('DOMContentLoaded', function(event){
var stripe = Stripe(stripe_publishable_key);
var elements = stripe.elements();
var style = {
base: {
color: "#32325d",
fontFamily: '"Helvetica Neue", Helvetica, sans-serif',
fontSmoothing: "antialiased",
fontSize: "16px",
"::placeholder": {
color: "#aab7c4"
}
},
invalid: {
color: "#fa755a",
iconColor: "#fa755a"
}
};
var card = elements.create("card", { style: style });
card.mount("#card-element");
card.addEventListener('change', function(event){
var displayError = document.getElementById('card-errors');
if(event.error){
displayError.textContent = event.error.message;
}else{
displayError.textContent = '';
}
})
var form = document.getElementById('payment-form');
form.addEventListener('submit', function(event){
event.preventDefault();
stripe.createToken(card).then(function(result){
if(result.error){
var errorElement = document.getElementById('card-errors');
errorElement.textContent = result.error.message;
}else{
stripe.createPaymentMethod({
type:'card',
card:card,
billing_details:{
email:'{{user.email}}',
},
}).then(function(payment_method_result){
if(payment_method_result.error){
var errorElement = document.getElementById('card-errors');
errorElement.textContent = payment_method_result.error.message;
}else{
//var form = document.getElementById('payment-form');
var hiddenInput = document.createElement('input');
// var hiddenInput2 = document.createElement('input');
// hiddenInput2.setAttribute('type','hidden');
// hiddenInput2.setAttribute('name','payment_intent_id');
// hiddenInput2.setAttribute('value',payment_intent_result.paymentIntent.id);
// form.appendChild(hiddenInput2);
hiddenInput.setAttribute('type','hidden');
hiddenInput.setAttribute('name','payment_method_id');
hiddenInput.setAttribute('value',payment_method_result.paymentMethod.id);
// alert(payment_method_result.paymentMethod.id)
form.appendChild(hiddenInput);
form.submit();
}
})
}
})
})
})
}
</script>
<script>
cardstripe('{{pk}}', '{{user.email}}')
// card('pk_test_51JT8ahSF9vzGWngg9ik0jueTIilHhCQomixBFOiNzCuo4Wwc5oRm73d05vdcboMgNwhyNcNTa2si8idqbB5msvwe006q3S96tM', '{{user.email}}')
//card('pk_live_51JT8ahSF9vzGWngg4N8fwhTPk5jq8fqBFdokqSMe7AVaOvH6BdyTwAfAoY79qkeJTFA0OdT5qkAk2FCNWCu6W9l000STNnHa7H', '{{user.email}}')
</script>
<script>
document.addEventListener('keypress',function(){
//alert("hello");
document.getElementsByName('cvc')[0].setAttribute('type','password')
})
</script>
{%endblock%}