Skip to content
Merged
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
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,9 @@
helm upgrade --install frontend-service ./helm/frontend-service \
-n cloudshopt \
-f helm/frontend-service/values.yaml
```
```

## Test stripe checkout locally
```
stripe listen --forward-to http://app.localhost/api/payments/webhooks/strip
```
1 change: 0 additions & 1 deletion src/lib/api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// src/lib/api.ts
const API_BASE = import.meta.env.VITE_API_BASE ?? "/api";
const TOKEN_KEY = "cloudshopt_token";

Expand Down
3 changes: 3 additions & 0 deletions src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ const router = createRouter({
{ path: "/cart", component: CartView, meta: { auth: true } },
{ path: "/orders", component: OrdersView, meta: { auth: true } },
{ path: "/orders/:id", component: OrderDetailView, meta: { auth: true } },

{ path: "/checkout/success", component: CheckoutSuccessView, meta: { auth: true } },
{ path: "/checkout/cancel", component: CheckoutCancelView, meta: { auth: true } },
],
});

Expand Down
1 change: 0 additions & 1 deletion src/stores/auth.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// src/stores/auth.ts
import { defineStore } from "pinia";
import { apiGet, apiPost, getToken, setToken } from "@/lib/api";

Expand Down
1 change: 0 additions & 1 deletion src/stores/cart.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// src/stores/cart.ts
import { defineStore } from "pinia";
import { apiDel, apiGet, apiPatch, apiPost } from "@/lib/api";

Expand Down
4 changes: 4 additions & 0 deletions src/style.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
@import "tailwindcss";

button:hover {
cursor: pointer;
}

/*:root {*/
/* font-family: system-ui, Avenir, Helvetica, Arial, sans-serif;*/
/* line-height: 1.5;*/
Expand Down
14 changes: 11 additions & 3 deletions src/views/CartView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import { onMounted, ref } from "vue";
import { useRouter } from "vue-router";
import { useCartStore } from "@/stores/cart";
import { apiPost } from "@/lib/api";

const cart = useCartStore();
const router = useRouter();
Expand Down Expand Up @@ -77,12 +78,19 @@ async function remove(itemId: number) {
async function createOrder() {
error.value = "";
msg.value = "";

try {
const order = await cart.createOrderFromCart();
msg.value = `Order created (#${order.id}).`;
router.push(`/orders/${order.id}`);

const r = await apiPost<{ url: string }>(
"/payments/checkout-session",
{ order_id: order.id },
true
);

window.location.href = r.url;
} catch (e: any) {
error.value = e?.message ?? "Failed to create order";
error.value = e?.message ?? "Failed to create order / start payment";
}
}
</script>
21 changes: 21 additions & 0 deletions src/views/CheckoutCancelView.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<template>
<div>
<h1 class="text-2xl font-semibold">Payment cancelled</h1>
<p class="text-zinc-400 mt-2">You cancelled the payment.</p>

<RouterLink
class="inline-block mt-4 px-4 py-2 rounded bg-zinc-800 hover:bg-zinc-700"
:to="`/orders/${orderId}`"
>
Back to order
</RouterLink>
</div>
</template>

<script setup lang="ts">
import { computed } from "vue";
import { RouterLink, useRoute } from "vue-router";

const route = useRoute();
const orderId = computed(() => route.query.order_id ?? "");
</script>
21 changes: 21 additions & 0 deletions src/views/CheckoutSuccessView.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<template>
<div>
<h1 class="text-2xl font-semibold">Payment success</h1>
<p class="text-zinc-400 mt-2">Your payment was successful. You can open the order.</p>

<RouterLink
class="inline-block mt-4 px-4 py-2 rounded bg-indigo-600 hover:bg-indigo-500"
:to="`/orders/${orderId}`"
>
Go to order
</RouterLink>
</div>
</template>

<script setup lang="ts">
import { computed } from "vue";
import { RouterLink, useRoute } from "vue-router";

const route = useRoute();
const orderId = computed(() => route.query.order_id ?? "");
</script>