appointments.js
1 month ago
attendees.js
1 month ago
colorManipulation.js
1 month ago
customer.js
1 month ago
date.js
3 weeks ago
defaultCustomize.js
3 weeks ago
employee.js
5 days ago
events.js
1 month ago
formFieldsTemplates.js
1 month ago
formatting.js
1 month ago
helper.js
5 days ago
image.js
1 month ago
integrationApple.js
1 month ago
integrationGoogle.js
1 month ago
integrationOutlook.js
1 month ago
integrationStripe.js
1 month ago
integrationZoom.js
1 month ago
licence.js
1 month ago
liveAnnouncer.js
3 weeks ago
phone.js
3 weeks ago
pricing.js
1 month ago
recurring.js
5 days ago
responsive.js
1 month ago
scrollElements.js
1 month ago
settings.js
1 month ago
translationsElementPlus.js
1 month ago
utilHeaderHeight.js
1 month ago
integrationStripe.js
99 lines
| 1 | import httpClient from '../../../plugins/axios' |
| 2 | |
| 3 | function useStripeSync(store) { |
| 4 | store.commit('auth/setStripeLoading', true) |
| 5 | |
| 6 | httpClient |
| 7 | .get('/stripe/accounts/' + store.getters['employee/getId']) |
| 8 | .then((response) => { |
| 9 | if (response.data.data.account) { |
| 10 | store.commit('auth/setStripeProvider', response.data.data.account) |
| 11 | |
| 12 | if (!store.getters['employee/getStripeConnect']) { |
| 13 | store.commit('employee/setStripeConnect', { |
| 14 | id: response.data.data.account.id, |
| 15 | amount: null, |
| 16 | }) |
| 17 | } |
| 18 | } |
| 19 | }) |
| 20 | .catch((error) => { |
| 21 | console.log(error) |
| 22 | }) |
| 23 | .finally(() => { |
| 24 | store.commit('auth/setStripeLoading', false) |
| 25 | }) |
| 26 | } |
| 27 | |
| 28 | function useStripeConnect(store, accountType) { |
| 29 | store.commit('auth/setStripeLoading', true) |
| 30 | |
| 31 | httpClient |
| 32 | .post('/stripe/onboard/' + store.getters['auth/getProfile'].id, { |
| 33 | returnUrl: window.location.href, |
| 34 | accountType: accountType, |
| 35 | }) |
| 36 | .then((response) => { |
| 37 | window.location.href = response.data.data.url |
| 38 | }) |
| 39 | .catch((error) => { |
| 40 | store.commit('auth/setStripeLoading', false) |
| 41 | console.log( |
| 42 | 'response' in error && 'data' in error.response && 'message' in error.response.data |
| 43 | ? error.response.data.message |
| 44 | : error.message, |
| 45 | ) |
| 46 | }) |
| 47 | } |
| 48 | |
| 49 | function useStripeDisconnect(store) { |
| 50 | store.commit('auth/setStripeLoading', true) |
| 51 | |
| 52 | httpClient |
| 53 | .post('/stripe/disconnect/' + store.getters['auth/getProfile'].id) |
| 54 | .then(() => { |
| 55 | store.commit('auth/setStripeProvider', { |
| 56 | id: '', |
| 57 | email: '', |
| 58 | type: '', |
| 59 | completed: false, |
| 60 | }) |
| 61 | |
| 62 | store.commit('employee/setStripeConnect', null) |
| 63 | }) |
| 64 | .catch((error) => { |
| 65 | console.log(error) |
| 66 | }) |
| 67 | .finally(() => { |
| 68 | store.commit('auth/setStripeLoading', false) |
| 69 | }) |
| 70 | } |
| 71 | |
| 72 | function useStripePreview(store) { |
| 73 | let stripeProvider = store.getters['auth/getStripeProvider'] |
| 74 | |
| 75 | store.commit('auth/setStripeLoading', true) |
| 76 | |
| 77 | if (stripeProvider.type === 'standard') { |
| 78 | window.open('https://dashboard.stripe.com/' + stripeProvider.id, '_blank') |
| 79 | |
| 80 | store.commit('auth/setStripeLoading', false) |
| 81 | } else if (stripeProvider.type === 'express') { |
| 82 | httpClient |
| 83 | .post('/stripe/dashboard/' + store.getters['auth/getProfile'].id) |
| 84 | .then((response) => { |
| 85 | if (response.data.data.url) { |
| 86 | window.open(response.data.data.url, '_blank') |
| 87 | } |
| 88 | }) |
| 89 | .catch((error) => { |
| 90 | console.log(error) |
| 91 | }) |
| 92 | .finally(() => { |
| 93 | store.commit('auth/setStripeLoading', false) |
| 94 | }) |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | export { useStripeSync, useStripeConnect, useStripeDisconnect, useStripePreview } |
| 99 |