Skip to content

BAI-17 Add/invoice checkout #211

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,14 @@ module.exports = {
},
],
"vue/multi-word-component-names": "off",
"new-cap": [
"error",
{
newIsCap: true,
capIsNew: false,
properties: true,
newIsCapExceptions: ["jsPDF"],
},
],
},
}
119 changes: 119 additions & 0 deletions components/ReceiptComponent.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
<template>
<v-row class="justify-center">
<v-col>
<v-img
class="mt-8"
max-height="80"
max-width="80"
contain
:src="`${STATIC_PATH}/icon.svg`"
/>
<v-card-title
v-icon="`${STATIC_PATH}/icon.svg`"
class="subheading font-weight-bold"
>
Bitcart AI
</v-card-title>

<v-divider></v-divider>

<v-list dense>
<v-list-item>
<v-list-item-content class="grey--text text--darken"
><strong>Invoice ID</strong></v-list-item-content
>
<v-list-item-content class="align-end">
{{ invoice.id }}
</v-list-item-content>
</v-list-item>

<v-list-item>
<v-list-item-content class="grey--text text--darken"
><strong>Order ID</strong></v-list-item-content
>
<v-list-item-content class="align-end">
{{ invoice.order_id }}
</v-list-item-content>
</v-list-item>

<v-list-item>
<v-list-item-content class="grey--text text--darken"
><strong>Store ID</strong></v-list-item-content
>
<v-list-item-content class="align-end">
{{ invoice.store_id }}
</v-list-item-content>
</v-list-item>

<v-list-item>
<v-list-item-content class="grey--text text--darken"
><strong>Total Amount</strong></v-list-item-content
>
<v-list-item-content class="align-end">
{{ invoice.price }}
{{ invoice.currency }}
</v-list-item-content>
</v-list-item>
<v-list-item>
<v-list-item-content class="grey--text text--darken"
><strong>Sent Amount</strong></v-list-item-content
>
<v-list-item-content class="align-end">
{{ invoice.sent_amount + " " + invoice.currency }}
</v-list-item-content>
</v-list-item>
<v-list-item>
<v-list-item-content class="grey--text text--darken"
><strong>Total Fiat</strong></v-list-item-content
>
<v-list-item-content class="align-end">
{{ payment.amount + " " + payment.currency.toUpperCase() }}
</v-list-item-content>
</v-list-item>
<v-list-item>
<v-list-item-content class="grey--text text--darken"
><strong>Exchange Rate</strong></v-list-item-content
>
<v-list-item-content class="align-end">
{{ payment.rate_str }}
</v-list-item-content>
</v-list-item>
<v-list-item>
<v-list-item-content class="grey--text text--darken"
><strong>Amount Due</strong></v-list-item-content
>
<v-list-item-content class="align-end">
{{ invoice.sent_amount }} {{ invoice.currency }}
</v-list-item-content>
</v-list-item>

<v-list-item>
<v-list-item-content class="grey--text text--darken"
><strong>Date</strong></v-list-item-content
>
<v-list-item-content class="align-end">
{{ invoice.paid_date.substring(0, 19).replace("T", " ") }}
</v-list-item-content>
</v-list-item>
</v-list>
</v-col>
</v-row>
</template>

<script>
export default {
props: {
invoice: {
type: Object,
required: true,
},
},
computed: {
payment() {
return this.invoice.payments.find(
(obj) => obj.id === this.invoice.payment_id
)
},
},
}
</script>
1 change: 1 addition & 0 deletions nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export default {
"~/plugins/eventbus.js",
{ src: "~/plugins/imageinput.js", mode: "client" },
{ src: "~/plugins/datetimepicker.js", mode: "client" },
{ src: "~/plugins/vue-html2pdf.js", mode: "client" },
"~/plugins/vueQR.js",
],
/*
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"js-cookie": "^3.0.5",
"nuxt-start": "^2.15.1",
"socks-proxy-agent": "^8.0.0",
"vuex-persistedstate": "^4.1.0"
"vuex-persistedstate": "^4.1.0",
"vue-html2pdf": "^1.8.0"
},
"devDependencies": {
"@babel/eslint-parser": "^7.16.5",
Expand Down
32 changes: 31 additions & 1 deletion pages/i/_id.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,32 @@
{{ texts[status].text }}
</div>
</div>
<ReceiptComponent :invoice="invoice" />
<client-only>
<vue-html2pdf
ref="transactionReceipt"
:show-layout="false"
:float-layout="true"
:pdf-quality="2"
:manual-pagination="true"
:pdf-format="pdfFormat"
:pdf-orientation="'portrait'"
filename="document.pdf"
>
<div slot="pdf-content">
<style>
@import "~assets/styles/main.css";
</style>
<ReceiptComponent :invoice="invoice" />
</div>
</vue-html2pdf>
<v-btn
class="mt-8"
color="primary"
@click="$refs.transactionReceipt.generatePdf()"
>Print</v-btn
>
</client-only>
</v-card-text>
</div>
</v-card>
Expand All @@ -63,13 +89,16 @@
</template>

<script>
import TabbedCheckout from "@/components/TabbedCheckout"
import CloseButton from "@/components/CloseButton"
import ReceiptComponent from "@/components/ReceiptComponent"
import TabbedCheckout from "@/components/TabbedCheckout"

export default {
auth: false,
components: {
TabbedCheckout,
CloseButton,
ReceiptComponent,
},
layout: "checkout",
data() {
Expand Down Expand Up @@ -137,6 +166,7 @@ export default {
.catch((err) => (this.errorText = err))
})
.catch((err) => this.setError(err))
console.log(document.styleSheets)
},
beforeDestroy() {
if (this.websocket) {
Expand Down
6 changes: 6 additions & 0 deletions plugins/vue-html2pdf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Vue from "vue"

if (process.browser) {
const VueHtml2pdf = require("vue-html2pdf").default
Vue.component("VueHtml2pdf", VueHtml2pdf)
}
Loading