PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 2.4.8
Booking for Appointments and Events Calendar – Amelia v2.4.8
2.4.8 2.4.7 2.4.6 2.4.5 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 / views / public / Parts / Payment / PaymentCommon.vue
ameliabooking / v3 / src / views / public / Parts / Payment Last commit date
Coupon 5 days ago Info 1 month ago Methods 5 days ago Page 5 days ago Coupon.vue 1 month ago PaymentCommon.vue 5 days ago PaymentOnSite.vue 1 month ago PaymentPayPal.vue 1 month ago PaymentSquare.vue 5 days ago PaymentStripe.vue 1 month ago PaymentWc.vue 1 month ago
PaymentCommon.vue
175 lines
1 <template>
2 <div class="am-fs__payment_default"></div>
3 </template>
4
5 <script setup>
6 import { useStore } from 'vuex'
7 import { inject, watchEffect } from 'vue'
8 import httpClient from '../../../../plugins/axios'
9 import {
10 useBookingData,
11 useCreateBookingError,
12 getErrorMessage,
13 } from '../../../../assets/js/public/booking.js'
14 import {
15 storeDeferredGatewayCache,
16 storeRazorpayCache,
17 deletePendingRazorpayBookings,
18 razorpayVerify,
19 } from '@/assets/js/common/integrationRazorpay.js'
20
21 const store = useStore()
22
23 const emits = defineEmits(['payment-error', 'payment-abandoned'])
24
25 const shortcodeData = inject('shortcodeData')
26
27 let stepsArray = inject('stepsArray')
28
29 let sidebarSteps = inject('sidebarSteps')
30
31 /**************
32 * Navigation *
33 *************/
34
35 const { nextStep, footerButtonReset, footerButtonClicked } = inject('changingStepsFunctions', {
36 nextStep: () => {},
37 footerButtonReset: () => {},
38 footerButtonClicked: {
39 value: false,
40 },
41 })
42
43 // * Labels
44 const amLabels = inject('amLabels')
45
46 watchEffect(() => {
47 if (footerButtonClicked.value) {
48 if (!store.getters['booking/getCouponValidated']) {
49 footerButtonReset()
50 emits('payment-error', amLabels.value.coupon_mandatory)
51 } else {
52 continueWithBooking()
53 }
54 }
55 })
56
57 /***********
58 * Payment *
59 **********/
60
61 function continueWithBooking() {
62 footerButtonReset()
63
64 let gateway = store.getters['booking/getPaymentGateway']
65
66 let bookingData = useBookingData(
67 store,
68 gateway === 'mollie' || gateway === 'barion' || gateway === 'razorpay'
69 ? {
70 shortcode: shortcodeData.value,
71 steps: stepsArray.value.map((i) => i.key),
72 sidebar: sidebarSteps.value.map((i) =>
73 Object.assign({ key: i.key, data: i.stepSelectedData }),
74 ),
75 }
76 : null,
77 false,
78 {},
79 null,
80 )
81
82 store.commit('booking/setLoading', true)
83
84 switch (gateway) {
85 case 'mollie':
86 payment('/payment/mollie', bookingData, function (response) {
87 storeDeferredGatewayCache(response)
88 window.location = response.data.data.redirectUrl
89 })
90
91 break
92
93 case 'razorpay':
94 payment('/payment/razorpay', bookingData, function (response) {
95 storeRazorpayCache(response)
96
97 let options = response.data.data.data
98 let cacheName = response.data.data.name
99 let razorpayCheckoutFinalizing = false
100
101 options.handler = function (razorpayResponse) {
102 razorpayCheckoutFinalizing = true
103 razorpayVerify(
104 store,
105 razorpayResponse.razorpay_payment_id,
106 razorpayResponse.razorpay_signature,
107 options.order_id,
108 cacheName,
109 {
110 onSuccess: () => nextStep(),
111 onError: (message) => emits('payment-error', message),
112 },
113 )
114 }
115
116 options.modal = {
117 ondismiss: async function () {
118 if (razorpayCheckoutFinalizing) {
119 return
120 }
121
122 const deleted = await deletePendingRazorpayBookings()
123
124 if (deleted) {
125 emits('payment-abandoned')
126 }
127 },
128 }
129
130 let razorpay = new Razorpay(options)
131
132 razorpay.open()
133 })
134
135 break
136
137 case 'barion':
138 payment('/payment/barion', bookingData, function (response) {
139 storeDeferredGatewayCache(response)
140 window.location = response.data.data.redirectUrl
141 })
142
143 break
144 }
145 }
146
147 function payment(endpoint, bookingData, success) {
148 httpClient
149 .post(endpoint, bookingData.data, bookingData.options)
150 .then(success)
151 .catch((error) => {
152 useCreateBookingError(store, error.response.data, () => {
153 emits('payment-error', getErrorMessage())
154 })
155 })
156 }
157 </script>
158
159 <script>
160 export default {
161 name: 'PaymentCommon',
162 }
163 </script>
164
165 <style lang="scss">
166 .amelia-v2-booking {
167 #amelia-container {
168 .am-fs__payment_default {
169 &-btn {
170 }
171 }
172 }
173 }
174 </style>
175