Basic Stripe integration. new pages for stripe handshake and new Account page. use query instead of useQuery for trpc fetches from store

This commit is contained in:
Michael Dausmann
2023-03-18 20:37:51 +11:00
parent 2ef98d0d98
commit 7311c13db2
21 changed files with 503 additions and 34 deletions

23
pages/success.vue Normal file
View File

@@ -0,0 +1,23 @@
<script setup lang="ts">
import Stripe from 'stripe';
const config = useRuntimeConfig();
const stripe = new Stripe(config.stripeSecretKey, { apiVersion: '2022-11-15' });
const route = useRoute();
let customer: Stripe.Response<Stripe.Customer | Stripe.DeletedCustomer>
try{
const session = await stripe.checkout.sessions.retrieve(route?.query?.session_id as string);
customer = await stripe.customers.retrieve(session?.customer as string);
} catch(e) {
console.log(`Error ${e}`)
}
</script>
<template>
<div>
<p>
<span v-if="!customer.deleted">We appreciate your business {{customer.name}}!</span>
<span v-if="customer.deleted">It appears your stripe customer information has been deleted!</span>
</p>
<p><NuxtLink to="/dashboard">To Your Dashboard</NuxtLink></p>
</div>
</template>