This commit is contained in:
2024-05-16 14:36:52 -04:00
parent 7164e41aa1
commit 52a02c7595
34 changed files with 771 additions and 2342 deletions

View File

@@ -1,171 +0,0 @@
<template>
<Header />
<div class="flex">
<div class="">
<SideBar />
</div>
<div class=" w-full px-10">
<div class="text-sm breadcrumbs">
<ul>
<li>
<router-link :to="{ name: 'home' }">
Home
</router-link>
</li>
<li>
<router-link :to="{ name: 'deliveryEdit', params: { id: oil['id'] } }">
Edit Delivery
</router-link>
</li>
</ul>
</div>
<div class="grid grid-cols-1 rounded-md p-6 ">
<div class="text-[24px]">Create Oil Delivery {{ customer_id }}
</div>
<form class="rounded-md px-8 pt-6 pb-8 mb-4 w-full" enctype="multipart/form-data" @submit.prevent="checkoutOil">
<div class="col-span-12 md:col-span-4 mb-5 md:mb-0 gap-10">
<label class="block text-white text-sm font-bold cursor-pointer label">Order </label>
<div class=""></div>
<div class=""></div>
<div class=""></div>
</div>
<div class="col-span-12 md:col-span-12 flex mt-5 mb-5">
<button class="btn">
Create Oil Order
</button>
</div>
</form>
</div>
</div>
</div>
<Footer />
</template>
<script lang="ts">
import {defineComponent} from 'vue'
import axios from 'axios'
import authHeader from '../../services/auth.header'
import Header from '../../layouts/headers/headerauth.vue'
import SideBar from '../../layouts/sidebar/sidebar.vue'
import Footer from '../../layouts/footers/footer.vue'
import useValidate from "@vuelidate/core";
import {notify} from "@kyvg/vue3-notification"
import {minLength, required} from "@vuelidate/validators";
export default defineComponent({
name: 'PayCancel',
components: {
Header,
SideBar,
Footer,
},
data() {
return {
v$: useValidate(),
user: null,
customer: null,
customer_id: null,
stripe: null,
}
},
validations() {
return {
CreateOilOrderForm: {
basicInfo: {
gallons_ordered: {required, minLength: minLength(1)},
expected_delivery_date: {required},
},
},
};
},
created() {
this.userStatus()
},
watch: {
$route() {
this.getCustomer(this.$route.params.id);
},
},
mounted() {
this.getCustomer(this.$route.params.id)
this.getStripePublishableKey();
},
methods: {
userStatus() {
let path = import.meta.env.VITE_BASE_URL + '/auth/whoami';
axios({
method: 'get',
url: path,
withCredentials: true,
headers: authHeader(),
})
.then((response: any) => {
if (response.data.ok) {
this.user = response.data.user;
}
})
.catch(() => {
this.user = null
})
},
getCustomer(user_id: any) {
let path = import.meta.env.VITE_BASE_URL + "/customer/" + user_id;
axios({
method: "get",
url: path,
withCredentials: true,
})
.then((response: any) => {
this.customer = response.data;
this.customer_id = response.datauser_id
})
.catch(() => {
notify({
title: "Error",
text: "Could not find customer",
type: "error",
});
});
},
checkoutOil() {
// Get Checkout Session ID
fetch('http://localhost:5001/create-checkout-session', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ book_id: book.id }),
})
.then((result) => result.json())
.then((data) => {
// Redirect to Stripe Checkout
return this.stripe.redirectToCheckout({ sessionId: data.sessionId });
})
.then((res) => {
console.log(res);
});
},
getStripePublishableKey() {
fetch('http://localhost:5001/config')
.then((result) => result.json())
.then((data) => {
// Initialize Stripe.js
this.stripe = Stripe(data.publicKey);
});
},
},
})
</script>
<style scoped></style>

View File

@@ -17,171 +17,204 @@
</ul>
</div>
<div class="grid grid-cols-1 rounded-md p-6 mb-5" v-if="loaded">
<div class=" col-span-12 text-[24px]">
<div class="grid grid-cols-1 rounded-md p-6 mb-5">
<div class=" col-span-12 text-2xl">
Confirm Payment Oil Delivery {{ delivery.id }}
</div>
<div class="grid grid-cols-12 bg-neutral mb-5">
<div class="col-span-12 font-bold flex pb-5 text-lg">
{{ customer.account_number }}
</div>
<div class="col-span-12 font-bold flex">
{{ customer.customer_first_name }}
{{ customer.customer_last_name }}
</div>
<div class="col-span-12 font-bold flex">
{{ customer.customer_address }}
<div v-if="customer.customer_apt != 'None'">
<div class="grid grid-cols-12 mb-5 gap-5">
<div class="col-span-12 xl:col-span-6 ">
<div class="col-span-12 font-bold flex pb-5 text-lg">
{{ customer.account_number }}
</div>
<div class="col-span-12 font-bold flex">
{{ customer.customer_first_name }}
{{ customer.customer_last_name }}
</div>
<div class="col-span-12 font-bold flex">
{{ customer.customer_address }}
<div v-if="customer.customer_apt != 'None'">
{{ customer.customer_apt }}
</div>
</div>
<div class="col-span-12 font-bold flex">
<div class="pr-2">
{{ customer.customer_town }},
</div>
<div class="pr-2">
<div v-if="customer.customer_state == 0">Massachusetts</div>
<div v-else-if="customer.customer_state == 1">Rhode Island</div>
<div v-else-if="customer.customer_state == 2">New Hampshire</div>
<div v-else-if="customer.customer_state == 3">Maine</div>
<div v-else-if="customer.customer_state == 4">Vermont</div>
<div v-else-if="customer.customer_state == 5">Maine</div>
<div v-else-if="customer.customer_state == 6">New York</div>
<div v-else>Unknown state</div>
</div>
<div class="pr-2">
{{ customer.customer_zip }}
</div>
</div>
<div class="col-span-12 font-bold flex" v-if="customer.customer_apt !== 'None'">
{{ customer.customer_apt }}
</div>
</div>
<div class="col-span-12 font-bold flex">
<div class="pr-2">
{{ customer.customer_town }},
<div class="col-span-12 font-bold flex">
<div v-if="customer.customer_home_type == 0">Residential</div>
<div v-else-if="customer.customer_home_type == 1">apartment</div>
<div v-else-if="customer.customer_home_type == 2">condo</div>
<div v-else-if="customer.customer_home_type == 3">commercial</div>
<div v-else-if="customer.customer_home_type == 4">business</div>
<div v-else-if="customer.customer_home_type == 5">construction</div>
<div v-else-if="customer.customer_home_type == 6">container</div>
</div>
<div class="pr-2">
<div v-if="customer.customer_state == 0">Massachusetts</div>
<div v-else-if="customer.customer_state == 1">Rhode Island</div>
<div v-else-if="customer.customer_state == 2">New Hampshire</div>
<div v-else-if="customer.customer_state == 3">Maine</div>
<div v-else-if="customer.customer_state == 4">Vermont</div>
<div v-else-if="customer.customer_state == 5">Maine</div>
<div v-else-if="customer.customer_state == 6">New York</div>
<div v-else>Unknown state</div>
</div>
<div class="pr-2">
{{ customer.customer_zip }}
</div>
</div>
<div class="col-span-12 font-bold flex" v-if="customer.customer_apt !== 'None'">
{{ customer.customer_apt }}
</div>
<div class="col-span-12 font-bold flex">
<div v-if="customer.customer_home_type == 0">Residential</div>
<div v-else-if="customer.customer_home_type == 1">apartment</div>
<div v-else-if="customer.customer_home_type == 2">condo</div>
<div v-else-if="customer.customer_home_type == 3">commercial</div>
<div v-else-if="customer.customer_home_type == 4">business</div>
<div v-else-if="customer.customer_home_type == 5">construction</div>
<div v-else-if="customer.customer_home_type == 6">container</div>
</div>
<div class="col-span-12 font-bold flex">
{{ customer.customer_phone_number }}
</div>
</div>
<div class="col-span-12 ">
<div class="grid grid-cols-12 mb-5 bg-neutral">
<div class="col-span-12 py-3">
<div v-if="delivery.delivery_status == 0"> Delivery Status: Waiting</div>
<div v-else-if="delivery.delivery_status == 1">Delivery Status: delivered</div>
<div v-else-if="delivery.delivery_status == 2">Delivery Status: Out for Delivery</div>
<div v-else-if="delivery.delivery_status == 3">Delivery Status: Cancelled</div>
<div v-else-if="delivery.delivery_status == 4">Delivery Status: Partial Delivery</div>
<div v-else-if="delivery.delivery_status == 5">Delivery Status: Issue</div>
<div v-else></div>
<div class="col-span-12 font-bold flex">
{{ customer.customer_phone_number }}
</div>
<div class="col-span-12 py-3">Expected Delivery: {{ delivery.expected_delivery_date }}</div>
<div class="col-span-12 ">
<div class="grid grid-cols-12 mb-5">
<div class="col-span-12 pt-10 font-bold">Delivery Status</div>
<div class="col-span-12 text-gray-500">
<div v-if="delivery.delivery_status == 0"> Waiting</div>
<div v-else-if="delivery.delivery_status == 1"> delivered</div>
<div v-else-if="delivery.delivery_status == 2"> Out for Delivery</div>
<div v-else-if="delivery.delivery_status == 3">Cancelled</div>
<div v-else-if="delivery.delivery_status == 4"> Partial Delivery</div>
<div v-else-if="delivery.delivery_status == 5">Issue</div>
<div v-else></div>
</div>
<div class="col-span-12 pt-3 font-bold">
Expected Delivery:
</div>
<div class="col-span-12 text-gray-500">
{{ delivery.expected_delivery_date }}
</div>
</div>
</div>
</div>
<div class="grid grid-cols-12 mb-5 bg-neutral">
<div v-for="card in credit_cards" class="col-span-12">
<div class="flex flex-row ">
<div v-if="card.main_card" class="basis-1/3 p-2">
<div class="bg-accent rounded-md border-2 ">
<div class="flex p-3">
{{ card.type_of_card }}
</div>
<div class="flex p-1 pl-4">
{{ card.name_on_card }}
</div>
<div class="flex p-1 pl-4">
{{ card.card_number }}
</div>
<div class="flex p-1 pl-4">
{{ card.expiration_month }}/ {{ card.expiration_year }}
</div>
<div class="flex p-1 pl-4">
{{ card.security_number }}
<div class="col-span-12 xl:col-span-6">
<div class="grid grid-cols-12 mb-5 ">
<div v-for="card in credit_cards" class="col-span-12">
<div class="col-span-12 ">
<div v-if="card.main_card" class="basis-1/3 p-2">
<div class="bg-secondary rounded-md border-2 ">
<div class="flex p-3">
{{ card.type_of_card }}
</div>
<div class="flex p-1 pl-4">
{{ card.name_on_card }}
</div>
<div class="flex p-1 pl-4">
{{ card.card_number }}
</div>
<div class="flex p-1 pl-4">
{{ card.expiration_month }}/ {{ card.expiration_year }}
</div>
<div class="flex p-1 pl-4">
{{ card.security_number }}
</div>
</div>
</div>
</div>
<div v-else class="basis-1/3 p-2">
<div class="bg-neutral rounded-md border-2 ">
<div class="flex p-3">
{{ card.type_of_card }}
</div>
<div class="flex p-1 pl-4">
{{ card.name_on_card }}
</div>
<div class="flex p-1 pl-4">
{{ card.card_number }}
</div>
<div class="flex p-1 pl-4">
{{ card.expiration_month }}/ {{ card.expiration_year }}
</div>
<div class="flex p-1 pl-4">
{{ card.security_number }}
<div v-else class="basis-1/3 p-2">
<div class=" rounded-md border-2 ">
<div class="flex p-3">
{{ card.type_of_card }}
</div>
<div class="flex p-1 pl-4">
{{ card.name_on_card }}
</div>
<div class="flex p-1 pl-4">
{{ card.card_number }}
</div>
<div class="flex p-1 pl-4">
{{ card.expiration_month }}/ {{ card.expiration_year }}
</div>
<div class="flex p-1 pl-4">
{{ card.security_number }}
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="grid grid-cols-12 mb-5 bg-neutral">
<div class="col-span-12 py-3">Price / Gallon: {{ delivery.customer_price }}</div>
<div class="col-span-12 py-3">
<div v-if="delivery.customer_asked_for_fill == 1"> Gallons Ordered: FILL (250)</div>
<div v-else> Gallons Ordered: {{ delivery.gallons_ordered }}</div>
</div>
<div class="col-span-12 py-3" v-if="delivery.prime == 1">
Prime Fee: {{ pricing.price_prime }}
</div>
<div class="col-span-12 py-3" v-if="delivery.same_day == 1">
Same Day: {{ pricing.price_same_day }}
</div>
<div class="col-span-12 font-bold py-5 text-lg" v-if="delivery.payment_type == 0">
<div class="">
CASH Total: ${{ total_amount }}
<div class="grid grid-cols-12 mb-5">
<div class="col-span-12 pt-3 font-bold">
Price / Gallon:
</div>
<div class="col-span-12 text-gray-500">
{{ delivery.customer_price }}
</div>
<div class="col-span-12 pt-3 font-bold">
Gallons Ordered:
</div>
<div class="col-span-12 text-gray-500">
<div v-if="delivery.customer_asked_for_fill == 1"> FILL (250)</div>
<div v-else> Gallons Ordered: {{ delivery.gallons_ordered }}</div>
</div>
<div class="col-span-12 py-3" v-if="delivery.prime == 1">
Prime Fee: {{ pricing.price_prime }}
</div>
<div class="col-span-12 py-3" v-if="delivery.same_day == 1">
Same Day: {{ pricing.price_same_day }}
</div>
<div class="col-span-12 font-bold py-5 " v-if="delivery.payment_type == 0">
<div class="">
CASH Total: ${{ total_amount }}
</div>
</div>
<div class="col-span-12 font-bold py-5 text-accent" v-if="delivery.payment_type == 1">
<div class="">
Pre Charge Credit Card Total: ${{ total_amount }}
</div>
</div>
<div class="col-span-12 font-bold py-5 text-accent" v-if="delivery.payment_type == 2">
<div class="">
Pre Charge Credit Card Total: ${{ total_amount }}
</div>
</div>
<div class="col-span-12 font-bold py-5 text-accent" v-if="delivery.payment_type == 3">
<div class="">
Pre Charge Credit Card Total: ${{ total_amount }}
</div>
</div>
</div>
<div class="col-span-12 font-bold py-5 text-lg text-primary" v-if="delivery.payment_type == 1">
<div class="">
Pre Charge Credit Card Total: ${{ total_amount }}
<div class="flex justify-between">
<!-- <button class="btn" @click="checkoutOilCreditStripe()">-->
<!-- Pay Credit Card (Stripe)-->
<!-- </button>-->
<div class="" v-if="delivery.payment_type == 0">
<button class="btn btn-accent btn-sm" @click="checkoutOilUpdatePayment(0)">
Confirm Cash Payment
</button>
</div>
<div class="" v-if="delivery.payment_type == 1">
<button class="btn btn-accent btn-sm" @click="checkoutOilUpdatePayment(1)">
Pay Credit Terminal
</button>
</div>
<div class="" v-if="delivery.payment_type == 2">
<button class="btn btn-accent btn-sm" @click="checkoutOilUpdatePayment(2)">
Cash + Pay Credit Terminal
</button>
</div>
<div class="" v-if="delivery.payment_type == 3">
<button class="btn btn-accent btn-sm" @click="checkoutOilUpdatePayment(3)">
Error
</button>
</div>
</div>
<div class="col-span-12 font-bold py-5 text-lg text-primary" v-if="delivery.payment_type == 2">
<div class="">
Pre Charge Credit Card Total: ${{ total_amount }}
</div>
</div>
</div>
</div>
<div class="flex justify-between">
<!-- <button class="btn" @click="checkoutOilCreditStripe()">-->
<!-- Pay Credit Card (Stripe)-->
<!-- </button>-->
<div class="" v-if="delivery.payment_type == 0">
<button class="btn btn-primary" @click="checkoutOilUpdatePayment(0)">
Cash Payment
</button>
</div>
<div class="" v-if="delivery.payment_type == 1">
<button class="btn btn-accent" @click="checkoutOilUpdatePayment(1)">
Pay Credit Terminal
</button>
</div>
<div class="" v-if="delivery.payment_type == 2">
Cash +
<button class="btn btn-accent" @click="checkoutOilUpdatePayment(3)">
Pay Credit Terminal
</button>
</div>
</div>
</div>
@@ -291,7 +324,8 @@ export default defineComponent({
},
priceprime: 0,
pricesameday: 0,
total_amount: 0
total_amount: 0,
total_precharge_amount: 0
}
},
validations() {
@@ -315,24 +349,36 @@ export default defineComponent({
},
mounted() {
this.getOilOrder(this.$route.params.id)
this.sumdelivery(this.$route.params.id);
this.getOilPricing()
// this.getStripePublishableKey();
},
methods: {
sumdelivery() {
if (this.delivery.same_day == 1)
this.pricesameday = this.pricing.price_same_day
else { this.pricesameday = 0 };
sumdelivery(delivery_id: any) {
let path = import.meta.env.VITE_BASE_URL + "/delivery/total/" + delivery_id;
axios({
method: "get",
url: path,
withCredentials: true,
})
.then((response: any) => {
if (response.data.ok) {
this.priceprime = response.data.priceprime;
this.pricesameday = response.data.pricesameday;
this.total_amount = response.data.total_amount;
if (this.delivery.prime == 1)
this.priceprime = this.pricing.price_prime
else { this.priceprime = 0 };
this.total_amount = Number(this.delivery.total_price) + Number(this.priceprime) + Number(this.pricesameday)
}
this.loaded = true
})
.catch(() => {
notify({
title: "Error",
text: "Could not get oil pricing",
type: "error",
});
});
},
@@ -361,8 +407,8 @@ export default defineComponent({
})
.then((response: any) => {
this.pricing = response.data;
this.sumdelivery();
})
.catch(() => {
@@ -448,6 +494,13 @@ export default defineComponent({
})
.then((response: any) => {
if (response.data.ok) {
if (payment_type == 0) {
notify({
title: "Success",
text: "marked payment as cash (COD)",
type: "success",
});
}
if (payment_type == 1) {
notify({
title: "Success",
@@ -455,7 +508,15 @@ export default defineComponent({
type: "success",
});
}
if (payment_type == 0) {
if (payment_type == 2) {
notify({
title: "Success",
text: "marked payment as cash (COD)",
type: "success",
});
}
if (payment_type == 3) {
notify({
title: "Success",
text: "marked payment as cash (COD)",

View File

@@ -1,465 +0,0 @@
<template>
<Header/>
<div class="flex">
<div class="">
<SideBar/>
</div>
<div class=" w-full px-10">
<div class="text-sm breadcrumbs">
<ul>
<li>
<router-link :to="{ name: 'home' }">
Home
</router-link>
</li>
<li>
</li>
</ul>
</div>
<div class="grid grid-cols-1 rounded-md p-6 mb-5">
<div class=" col-span-12 text-[24px]">
Confirm Payment Service Call {{ service_id }}
</div>
<div class="grid grid-cols-12 bg-neutral mb-5">
<div class="col-span-12 font-bold flex pb-5 text-lg">{{ customer.account_number }}</div>
<div class="col-span-12 font-bold flex">
{{ customer.customer_first_name }}
{{ customer.customer_last_name }}
</div>
<div class="col-span-12 font-bold flex">
{{ customer.customer_address }}
<div v-if="customer.customer_apt != 'None'">
{{ customer.customer_apt }}
</div>
</div>
<div class="col-span-12 font-bold flex">
<div class="pr-2">
{{ customer.customer_town }},
</div>
<div class="pr-2">
<div v-if="customer.customer_state == 0">Massachusetts</div>
<div v-else-if="customer.customer_state == 1">Rhode Island</div>
<div v-else-if="customer.customer_state == 2">New Hampshire</div>
<div v-else-if="customer.customer_state == 3">Maine</div>
<div v-else-if="customer.customer_state == 4">Vermont</div>
<div v-else-if="customer.customer_state == 5">Maine</div>
<div v-else-if="customer.customer_state == 6">New York</div>
<div v-else>Unknown state</div>
</div>
<div class="pr-2">
{{ customer.customer_zip }}
</div>
</div>
<div class="col-span-12 font-bold flex" v-if="customer.customer_apt !== 'None'">
{{ customer.customer_apt }}
</div>
<div class="col-span-12 font-bold flex">
<div v-if="customer.customer_home_type == 0">Residential</div>
<div v-else-if="customer.customer_home_type == 1">apartment</div>
<div v-else-if="customer.customer_home_type == 2">condo</div>
<div v-else-if="customer.customer_home_type == 3">commercial</div>
<div v-else-if="customer.customer_home_type == 4">business</div>
<div v-else-if="customer.customer_home_type == 5">construction</div>
<div v-else-if="customer.customer_home_type == 6">container</div>
</div>
<div class="col-span-12 font-bold flex">
{{ customer.customer_phone_number }}
</div>
</div>
<div class="col-span-12 ">
<div class="grid grid-cols-12 mb-5 bg-neutral">
<div class="col-span-12 py-3">
<div v-if="service.service_type == '0'">Service Type: General</div>
<div v-else-if="service.service_type == '1'">Service Type: Cleaning / Tuneup</div>
<div v-else-if="service.service_type == '2'">Service Type: No Heat</div>
<div v-else-if="service.service_type == '3'">Service Type: Install</div>
<div v-else-if="service.service_type == '4'">Service Type: Call Back</div>
<div v-else-if="service.service_type == '5'">Service Type: Quote</div>
<div v-else-if="service.service_type == '6'">Service Type: Emergency</div>
<div v-else></div>
</div>
<div class="col-span-12 py-3">Tech: {{ service.tech_first_name }} {{ service.tech_last_name }}</div>
<div class="col-span-12 py-3">Expected Service Date: {{ service.scheduled_date }}</div>
</div>
<div class="grid grid-cols-12 mb-5 bg-neutral">
<div v-for="card in credit_cards" class="col-span-12">
<div class="flex flex-row ">
<div v-if="card.main_card" class="basis-1/3 p-2">
<div class="bg-accent rounded-md border-2 ">
<div class="flex p-3">
{{ card.type_of_card }}
</div>
<div class="flex p-1 pl-4">
{{ card.name_on_card }}
</div>
<div class="flex p-1 pl-4">
{{ card.card_number }}
</div>
<div class="flex p-1 pl-4">
{{ card.expiration_month }}/ {{ card.expiration_year }}
</div>
<div class="flex p-1 pl-4">
{{ card.security_number }}
</div>
</div>
</div>
<div v-else class="basis-1/3 p-2">
<div class="bg-neutral rounded-md border-2 ">
<div class="flex p-3">
{{ card.type_of_card }}
</div>
<div class="flex p-1 pl-4">
{{ card.name_on_card }}
</div>
<div class="flex p-1 pl-4">
{{ card.card_number }}
</div>
<div class="flex p-1 pl-4">
{{ card.expiration_month }}/ {{ card.expiration_year }}
</div>
<div class="flex p-1 pl-4">
{{ card.security_number }}
</div>
</div>
</div>
</div>
</div>
</div>
<div class="grid grid-cols-12 mb-5 bg-neutral">
<div class="col-span-12 py-3">Price / hour: {{ service_prices.price_service_hour }}</div>
<div class="col-span-12 py-3" v-if="service.payment_type == 0">Pay Method: Cash (COD)</div>
<div class="col-span-12 py-3" v-if="service.payment_type == 1">Pay Method: Credit Card</div>
<div class="col-span-12 py-3" v-if="service.payment_type == 2">Pay Method: Stripe</div>
<div class="col-span-12 py-3" v-if="service.payment_type == 2">Pay Method: Cash/Credit Mix</div>
<div class="col-span-12 font-bold py-5 text-lg">Pre-Charge: 300$</div>
</div>
</div>
<div class="flex justify-between">
<!-- <button class="btn" @click="checkoutServiceCreditStripe()">-->
<!-- Pay Credit Card (Stripe)-->
<!-- </button>-->
<button class="btn" @click="checkoutServiceUpdatePayment(0)">
Cash Payment
</button>
<button class="btn" @click="checkoutServiceUpdatePayment(1)">
Pay Credit Terminal
</button>
</div>
</div>
</div>
</div>
<Footer/>
</template>
<script lang="ts">
import {defineComponent} from 'vue'
import axios from 'axios'
import authHeader from '../../services/auth.header'
import Header from '../../layouts/headers/headerauth.vue'
import SideBar from '../../layouts/sidebar/sidebar.vue'
import Footer from '../../layouts/footers/footer.vue'
import useValidate from "@vuelidate/core";
import {notify} from "@kyvg/vue3-notification"
import {minLength, required} from "@vuelidate/validators";
export default defineComponent({
name: 'PayOil',
components: {
Header,
SideBar,
Footer,
},
data() {
return {
v$: useValidate(),
user: {
user_id: 0,
},
service_id: null,
service: {
id: 0,
customer_id: 0,
customer_last_name: '',
customer_first_name: '',
customer_town: '',
customer_state: '',
customer_zip: '',
customer_apt: '',
customer_address: '',
status: 0,
service_type: '',
when_called: '',
scheduled_date: '',
scheduled_time: '',
when_serviced: '',
completed: 0,
tech_id: 0,
tech_first_name: '',
tech_last_name: '',
payment_type: 0,
payment_card_id: 0,
},
service_notes: {
service_call_id: 0,
dispatcher_notes: '',
dispatcher_subject: '',
time_added: '',
dispatcher_id: 0,
dispatcher_name: '',
},
service_prices: {
id: 0,
price_service_hour: 0,
price_emergency_service_hour: 0,
price_emergency_call: 0,
price_out_of_oil: 0,
price_prime: 0,
price_same_day: 0,
price_cleaning: 0,
date: '',
},
credit_cards: [
{
id: 0,
name_on_card: '',
main_card: false,
card_number: '',
expiration_month: '',
type_of_card: '',
last_four_digits: '',
expiration_year: '',
security_number: 0,
}
],
stripe: null,
customer: {
id: 0,
user_id: 0,
customer_first_name: '',
customer_last_name: '',
customer_town: '',
customer_address: '',
customer_state: 0,
customer_zip: '',
customer_apt: '',
customer_home_type: 0,
customer_phone_number: '',
account_number: '',
},
}
},
validations() {
return {
CreateOilOrderForm: {
basicInfo: {
gallons_ordered: {required, minLength: minLength(1)},
expected_delivery_date: {required},
},
},
};
},
created() {
this.userStatus();
this.getServiceOrder(this.$route.params.id);
},
watch: {
$route() {
},
},
mounted() {
// this.getStripePublishableKey();
},
methods: {
userStatus() {
let path = import.meta.env.VITE_BASE_URL + '/auth/whoami';
axios({
method: 'get',
url: path,
withCredentials: true,
headers: authHeader(),
})
.then((response: any) => {
if (response.data.ok) {
this.user = response.data.user;
}
})
},
getServiceOrder(service_id: any) {
let path = import.meta.env.VITE_BASE_URL + "/service/" + service_id;
axios({
method: "get",
url: path,
withCredentials: true,
headers: authHeader(),
})
.then((response: any) => {
this.service = response.data;
this.getCustomer(this.service.customer_id)
this.getCreditCards(this.service.customer_id)
})
.catch(() => {
notify({
title: "Error",
text: "Could not get service order",
type: "error",
});
});
},
getServiceOrderNotes(service_id: any) {
let path = import.meta.env.VITE_BASE_URL + "/service/call/notes" + service_id;
axios({
method: "get",
url: path,
withCredentials: true,
})
.then((response: any) => {
this.service = response.data;
})
.catch(() => {
notify({
title: "Error",
text: "Could not get service order",
type: "error",
});
});
},
getCreditCards(user_id: any) {
let path = import.meta.env.VITE_BASE_URL + '/payment/cards/' + user_id;
axios({
method: 'get',
url: path,
headers: authHeader(),
}).then((response: any) => {
this.credit_cards = response.data
})
},
getCustomer(userid: any) {
let path = import.meta.env.VITE_BASE_URL + '/customer/' + userid;
axios({
method: 'get',
url: path,
headers: authHeader(),
}).then((response: any) => {
this.customer = response.data
})
},
checkoutServiceUpdateCreditStripe() {
let path = import.meta.env.VITE_BASE_URL + "/service/cash/" + this.service.id + '/2';
axios({
method: "PUT",
url: path,
})
.then((response: any) => {
if (response.data.ok) {
notify({
title: "Success",
text: "marked payment as STRIPE credit card",
type: "success",
});
}
})
.catch(() => {
notify({
title: "Error",
text: "Could not update with credit card Stripe",
type: "error",
});
});
},
checkoutServiceUpdatePayment(payment_type: number) {
let path = import.meta.env.VITE_BASE_URL + "/service/paymenttype/" + this.service.id + '/' + payment_type;
axios({
method: "PUT",
url: path,
})
.then((response: any) => {
if (response.data.ok) {
if (payment_type == 1) {
notify({
title: "Success",
text: "marked payment as credit (bank terminal)",
type: "success",
});
}
if (payment_type == 0) {
notify({
title: "Success",
text: "marked payment as cash (COD)",
type: "success",
});
}
this.$router.push({name: "customerProfile", params: {id: this.customer.id}});
}
})
.catch(() => {
notify({
title: "Error",
text: "Could not update wth cash",
type: "error",
});
});
},
// checkoutServiceCreditStripe() {
//
// let path = import.meta.env.VITE_PAY_URL + "/pay/charge";
// axios({
// method: "get",
// url: path,
// })
// .then((response: any) => {
// this.checkoutServiceUpdateCreditStripe();
// // Redirect to Stripe Checkout
// return this.stripe.redirectToCheckout({sessionId: response.data.sessionId});
// })
// .catch(() => {
// notify({
// title: "Error",
// text: "Could not find customer",
// type: "error",
// });
// });
// },
//
// getStripePublishableKey() {
// let path = import.meta.env.VITE_PAY_URL + "/pay/config";
// axios({
// method: "get",
// url: path,
// })
// .then((response: any) => {
// this.stripe = Stripe(response.data.publicKey);
// })
//
// },
},
})
</script>
<style scoped></style>

View File

@@ -1,32 +1,19 @@
import PayOil from '../pay/pay_oil.vue';
import PayService from "../pay/pay_service.vue";
import PaySuccess from "../pay/success.vue";
import PayCancel from "../pay/cancel.vue";
const payRoutes = [
{
path: '/pay/service/:id',
name: 'payService',
component: PayService,
},
{
path: '/pay/oil/:id',
name: 'payOil',
component: PayOil,
},
{
path: '/pay/success',
name: 'paySuccess',
component: PaySuccess,
},
{
path: '/pay/cancel',
name: 'payCancel',
component: PayCancel,
},
]
export default payRoutes

View File

@@ -1,176 +0,0 @@
<template>
<Header />
<div class="flex">
<div class="">
<SideBar />
</div>
<div class=" w-full px-10">
<div class="text-sm breadcrumbs">
<ul>
<li>
<router-link :to="{ name: 'home' }">
Home
</router-link>
</li>
<li>
<router-link :to="{ name: 'deliveryEdit', params: { id: oil['id'] } }">
Edit Delivery
</router-link>
</li>
</ul>
</div>
<div class="grid grid-cols-1 rounded-md p-6 ">
<div class="text-[24px]">Create Oil Delivery {{ customer_id }}
</div>
<form class="rounded-md px-8 pt-6 pb-8 mb-4 w-full" enctype="multipart/form-data" @submit.prevent="checkoutOil">
<div class="col-span-12 md:col-span-4 mb-5 md:mb-0 gap-10">
<label class="block text-white text-sm font-bold cursor-pointer label">Order </label>
<div class=""></div>
<div class=""></div>
<div class=""></div>
</div>
<div class="col-span-12 md:col-span-12 flex mt-5 mb-5">
<button class="btn">
Create Oil Order
</button>
</div>
</form>
</div>
</div>
</div>
<Footer />
</template>
<script lang="ts">
import {defineComponent} from 'vue'
import axios from 'axios'
import authHeader from '../../services/auth.header'
import Header from '../../layouts/headers/headerauth.vue'
import SideBar from '../../layouts/sidebar/sidebar.vue'
import Footer from '../../layouts/footers/footer.vue'
import useValidate from "@vuelidate/core";
import {notify} from "@kyvg/vue3-notification"
import {minLength, required} from "@vuelidate/validators";
export default defineComponent({
name: 'PaySuccess',
components: {
Header,
SideBar,
Footer,
},
data() {
return {
v$: useValidate(),
user: null,
customer: null,
customer_id: null,
stripe: null,
}
},
validations() {
return {
CreateOilOrderForm: {
basicInfo: {
gallons_ordered: {required, minLength: minLength(1)},
expected_delivery_date: {required},
},
},
};
},
created() {
this.userStatus()
},
watch: {
$route() {
this.getCustomer(this.$route.params.id);
},
},
mounted() {
this.getCustomer(this.$route.params.id)
this.getStripePublishableKey();
},
methods: {
userStatus() {
let path = import.meta.env.VITE_BASE_URL + '/auth/whoami';
axios({
method: 'get',
url: path,
withCredentials: true,
headers: authHeader(),
})
.then((response: any) => {
if (response.data.ok) {
this.user = response.data.user;
}
})
.catch(() => {
this.user = null
})
},
getCustomer(user_id: any) {
let path = import.meta.env.VITE_BASE_URL + "/customer/" + user_id;
axios({
method: "get",
url: path,
withCredentials: true,
})
.then((response: any) => {
this.customer = response.data;
this.customer_id = response.data.user_id;
})
.catch(() => {
notify({
title: "Error",
text: "Could not find customer",
type: "error",
});
});
},
checkoutOil() {
// Get Checkout Session ID
fetch('http://localhost:5001/create-checkout-session', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ book_id: book.id }),
})
.then((result) => result.json())
.then((data) => {
console.log(data);
// Redirect to Stripe Checkout
return this.stripe.redirectToCheckout({ sessionId: data.sessionId });
})
.then((res) => {
console.log(res);
});
},
getStripePublishableKey() {
fetch('http://localhost:5001/config')
.then((result) => result.json())
.then((data) => {
// Initialize Stripe.js
this.stripe = Stripe(data.publicKey);
});
},
},
})
</script>
<style scoped></style>