From a7a0fbb20bc83b243bb5f99ee219a1be2c0fbeed Mon Sep 17 00:00:00 2001 From: Jonathan Cobb Date: Tue, 17 Dec 2019 16:38:32 -0500 Subject: [PATCH] WIP. getting payment views to work --- src/_helpers/router.js | 28 ++++++++++++--- src/_store/paymentMethods.module.js | 27 +++++++++++++-- src/account/NewNetworkPage.vue | 30 +++++++++++----- src/account/payment/InviteCodePayment.vue | 42 +++++++++++++++++++++++ src/account/payment/StripePayment.vue | 22 ++++++++++++ src/account/payment/UnknownPayment.vue | 13 +++++++ 6 files changed, 146 insertions(+), 16 deletions(-) create mode 100644 src/account/payment/InviteCodePayment.vue create mode 100644 src/account/payment/StripePayment.vue create mode 100644 src/account/payment/UnknownPayment.vue diff --git a/src/_helpers/router.js b/src/_helpers/router.js index 88d1cfe..7dad770 100644 --- a/src/_helpers/router.js +++ b/src/_helpers/router.js @@ -9,10 +9,25 @@ import NetworksPage from '../account/NetworksPage' import NewNetworkPage from '../account/NewNetworkPage' import NetworkPage from '../account/NetworkPage' import AccountsPage from '../admin/AccountsPage' +import StripePayment from "../account/payment/StripePayment"; +import InviteCodePayment from "../account/payment/InviteCodePayment"; +import UnknownPayment from "../account/payment/UnknownPayment"; import { currentUser } from '../_helpers' Vue.use(Router); +const newNetworkChildren = [ + { path: '', component: NewNetworkPage, + children: [{ + 'path': '', components: { + 'stripe': StripePayment, + 'invite': InviteCodePayment, + 'unknown': UnknownPayment + } + }] + }, +]; + export const router = new Router({ mode: 'history', routes: [ @@ -21,18 +36,21 @@ export const router = new Router({ children: [ { path: '', component: NetworksPage, - children: [ - { path: '', component: NewNetworkPage }, - ] + children: newNetworkChildren }, { path: '/profile', component: ProfilePage }, { path: '/networks', component: NetworksPage , children: [ - { path: '', component: NewNetworkPage }, + { + path: '', component: NewNetworkPage, + children: newNetworkChildren + }, ] }, - { path: '/networks/new', component: NewNetworkPage }, + { path: '/networks/new', component: NewNetworkPage, + children: newNetworkChildren + }, { path: '/networks/:uuid', component: NetworkPage } ] }, diff --git a/src/_store/paymentMethods.module.js b/src/_store/paymentMethods.module.js index e4eed88..b671bd6 100644 --- a/src/_store/paymentMethods.module.js +++ b/src/_store/paymentMethods.module.js @@ -4,7 +4,8 @@ const state = { loading: null, error: null, paymentMethods: null, - paymentMethod: null + paymentMethod: null, + paymentInfo: null }; const actions = { @@ -17,13 +18,24 @@ const actions = { ); }, - getByUuid({ commit }, uuid) { + getById({ commit }, uuid) { commit('getByUuidRequest'); paymentMethodService.getById(uuid) .then( paymentMethod => commit('getByUuidSuccess', paymentMethod), error => commit('getByUuidFailure', error) ); + }, + + setPaymentMethod({ commit }, pm) { + console.log('setPaymentMethod: setting: '+JSON.stringify(pm)); + commit('setPaymentMethodSuccess', pm); + }, + setPaymentInfo({ commit }, info) { + commit('setPaymentInfoSuccess', info); + }, + clearPaymentInfo({ commit }) { + commit('clearPaymentInfoSuccess'); } }; @@ -49,6 +61,15 @@ const mutations = { getByUuidFailure(state, error) { state.loading = false; state.error = { error }; + }, + setPaymentMethodSuccess(state, pm) { + state.paymentMethod = pm; + }, + setPaymentInfoSuccess(state, info) { + state.paymentInfo = info; + }, + clearPaymentInfoSuccess(state) { + state.paymentInfo = null; } }; @@ -57,4 +78,4 @@ export const paymentMethods = { state, actions, mutations -}; +}; \ No newline at end of file diff --git a/src/account/NewNetworkPage.vue b/src/account/NewNetworkPage.vue index 3aa5a44..ee11379 100644 --- a/src/account/NewNetworkPage.vue +++ b/src/account/NewNetworkPage.vue @@ -42,14 +42,17 @@
{{ errors.first('paymentMethodService') }}
{{ errors.first('paymentInfo') }}
- + -
- credit selected + +
+ +
-
- invite code selected +
+ +
@@ -90,7 +93,7 @@ ...mapState('domains', ['domains']), ...mapState('plans', ['plans']), ...mapState('footprints', ['footprints']), - ...mapState('paymentMethods', ['paymentMethods']), + ...mapState('paymentMethods', ['paymentMethods', 'paymentMethod', 'paymentInfo']), ...mapState('networks', { creating: state => state.loading, error: state => state.error @@ -146,13 +149,24 @@ loadFootprints: 'getAll' }), ...mapActions('paymentMethods', { - loadPaymentMethods: 'getAll' + loadPaymentMethods: 'getAll', + setPaymentMethod: 'setPaymentMethod' }), handleSubmit(e) { this.submitted = true; this.$validator.validate().then(valid => { if (valid) { - this.createNewNetwork(this.network); + if (this.paymentInfo) { + this.network.paymentMethodObject = { + paymentMethodType: this.paymentMethod.paymentMethodType, + paymentInfo: this.paymentInfo + }; + this.createNewNetwork(this.network); + } + } else { + console.log('handleSubmit: no payment info found'); + // console.log('handleSubmit: paymentMethod='+JSON.stringify(this.paymentMethod)); + if (this.paymentMethod) console.log('handleSubmit: paymentMethod.driverClass='+JSON.stringify(this.paymentMethod.driverClass)); } }); } diff --git a/src/account/payment/InviteCodePayment.vue b/src/account/payment/InviteCodePayment.vue new file mode 100644 index 0000000..4dfec18 --- /dev/null +++ b/src/account/payment/InviteCodePayment.vue @@ -0,0 +1,42 @@ + + + \ No newline at end of file diff --git a/src/account/payment/StripePayment.vue b/src/account/payment/StripePayment.vue new file mode 100644 index 0000000..1a94e94 --- /dev/null +++ b/src/account/payment/StripePayment.vue @@ -0,0 +1,22 @@ + + + \ No newline at end of file diff --git a/src/account/payment/UnknownPayment.vue b/src/account/payment/UnknownPayment.vue new file mode 100644 index 0000000..1410d87 --- /dev/null +++ b/src/account/payment/UnknownPayment.vue @@ -0,0 +1,13 @@ + + + \ No newline at end of file