From 62cadba7d7112af9de5cffd7191cc8e2d2411f8e Mon Sep 17 00:00:00 2001 From: Arsenije Savic Date: Wed, 20 Sep 2023 16:59:31 -0600 Subject: [PATCH] feat: add stripe --- src/components/dao/settings-plans-billing.vue | 51 +++++++-- src/layouts/DhoSelector.vue | 26 +++-- src/layouts/MultiDhoLayout.vue | 51 ++++----- src/store/dao/getters.js | 21 +--- src/store/dao/mutations.js | 105 +++++++++--------- 5 files changed, 143 insertions(+), 111 deletions(-) diff --git a/src/components/dao/settings-plans-billing.vue b/src/components/dao/settings-plans-billing.vue index bbf54fadf..47fac8af7 100644 --- a/src/components/dao/settings-plans-billing.vue +++ b/src/components/dao/settings-plans-billing.vue @@ -65,14 +65,31 @@ export default { async checkout (id) { this.state = STATES.CREATING_SESSION + console.log(JSON.stringify( + { + daoId: this.selectedDao.docId, + daoName: this.selectedDao.title, + daoType: this.planType, + priceId: id, + redirectDomain: ORIGIN, + successUrl: `/${this.selectedDao.url}/configuration?tab=PLANS_AND_BILLING` + } + )) + const res = await this.$apollo.mutate({ mutation: gql` mutation createSession( + $daoId: String! + $daoName: String! + $daoType: String! $priceId: String! $redirectDomain: String! $successUrl: String! ) { createCheckoutSession( + daoId: $daoId + daoName: $daoName + daoType: $daoType priceId: $priceId redirectDomain: $redirectDomain successUrl: $successUrl @@ -83,10 +100,12 @@ export default { } `, variables: { + daoId: this.selectedDao.docId, + daoName: this.selectedDao.title, + daoType: this.planType, priceId: id, redirectDomain: ORIGIN, - - successUrl: `/${this.daoSettings.url}/configuration?tab=PLANS_AND_BILLING` + successUrl: `/${this.selectedDao.url}/configuration?tab=PLANS_AND_BILLING` } }) @@ -95,11 +114,27 @@ export default { } }, + onPlanDialogClose () { + // this.state = STATES.WAITING + // this.planType = PLAN_TYPE.SAAS + // this.paymentInterval = 'year' + }, + + switchPlanType () { + // if (this.planType === PLAN_TYPE.SAAS) { + // this.planType = PLAN_TYPE.EAAS + // this.paymentInterval = null + // } else { + // this.planType = PLAN_TYPE.SAAS + // this.paymentInterval = 'year' + // } + }, + formatMoney (amount) { return amount ? new Intl.NumberFormat().format(parseInt(amount), { style: 'currency' }) : 0 } }, computed: { - ...mapGetters('dao', ['daoSettings', 'selectedDaoPlan']), + ...mapGetters('dao', ['daoSettings', 'selectedDao', 'selectedDaoPlan']), isPlanModalOpen () { return [STATES.UPDATING_PLAIN, STATES.CREATING_SESSION].includes(this.state) }, @@ -124,7 +159,7 @@ export default {