PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 1.2.20
Booking for Appointments and Events Calendar – Amelia v1.2.20
2.4.4 2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / v3 / src / assets / js / common / integrationStripe.js
ameliabooking / v3 / src / assets / js / common Last commit date
appointments.js 1 year ago attendees.js 1 year ago colorManipulation.js 3 years ago customer.js 1 year ago date.js 1 year ago defaultCustomize.js 1 year ago employee.js 1 year ago events.js 1 year ago formFieldsTemplates.js 3 years ago formatting.js 1 year ago helper.js 1 year ago image.js 1 year ago integrationApple.js 1 year ago integrationGoogle.js 1 year ago integrationOutlook.js 1 year ago integrationStripe.js 1 year ago integrationZoom.js 1 year ago licence.js 2 years ago objectAndArrayManipulation.js 3 years ago pricing.js 1 year ago recurring.js 1 year ago responsive.js 1 year ago scrollElements.js 4 years ago settings.js 1 year ago translationsElementPlus.js 1 year ago
integrationStripe.js
108 lines
1 import httpClient from "../../../plugins/axios";
2 import {useAuthorizationHeaderObject} from "../public/panel";
3
4 function useStripeSync (store) {
5 store.commit('auth/setStripeLoading', true)
6
7 httpClient.get(
8 '/stripe/accounts/' + store.getters['employee/getId'],
9 Object.assign(
10 {
11 },
12 useAuthorizationHeaderObject(store)
13 )
14 ).then((response) => {
15 if (response.data.data.account) {
16 store.commit('auth/setStripeProvider', response.data.data.account)
17
18 if (!store.getters['employee/getStripeConnect']) {
19 store.commit('employee/setStripeConnect', {
20 id: response.data.data.account.id,
21 amount: null,
22 })
23 }
24 }
25 }).catch((error) => {
26 console.log(error)
27 }).finally(() => {
28 store.commit('auth/setStripeLoading', false)
29 })
30 }
31
32 function useStripeConnect (store, accountType) {
33 store.commit('auth/setStripeLoading', true)
34
35 httpClient.post(
36 '/stripe/onboard/' + store.getters['auth/getProfile'].id,
37 Object.assign(
38 {
39 returnUrl: window.location.href,
40 accountType: accountType,
41 },
42 useAuthorizationHeaderObject(store)
43 )
44 ).then((response) => {
45 window.location.href = response.data.data.url
46 }).catch((error) => {
47 store.commit('auth/setStripeLoading', false)
48 console.log('response' in error && 'data' in error.response && 'message' in error.response.data ? error.response.data.message : error.message)
49 })
50 }
51
52 function useStripeDisconnect (store) {
53 store.commit('auth/setStripeLoading', true)
54
55 httpClient.post(
56 '/stripe/disconnect/' + store.getters['auth/getProfile'].id,
57 useAuthorizationHeaderObject(store)
58 ).then(() => {
59 store.commit(
60 'auth/setStripeProvider',
61 {
62 id: '',
63 email: '',
64 type: '',
65 completed: false,
66 }
67 )
68
69 store.commit('employee/setStripeConnect', null)
70 }).catch((error) => {
71 console.log(error)
72 }).finally(() => {
73 store.commit('auth/setStripeLoading', false)
74 })
75 }
76
77 function useStripePreview (store) {
78 let stripeProvider = store.getters['auth/getStripeProvider']
79
80 store.commit('auth/setStripeLoading', true)
81
82 if (stripeProvider.type === 'standard') {
83 window.open('https://dashboard.stripe.com/' + stripeProvider.id, '_blank')
84
85 store.commit('auth/setStripeLoading', false)
86 } else if (stripeProvider.type === 'express') {
87 httpClient.post(
88 '/stripe/dashboard/' + store.getters['auth/getProfile'].id,
89 useAuthorizationHeaderObject(store)
90 ).then((response) => {
91 if (response.data.data.url) {
92 window.open(response.data.data.url, '_blank')
93 }
94 }).catch((error) => {
95 console.log(error)
96 }).finally(() => {
97 store.commit('auth/setStripeLoading', false)
98 })
99 }
100 }
101
102 export {
103 useStripeSync,
104 useStripeConnect,
105 useStripeDisconnect,
106 useStripePreview,
107 }
108