Payment.vue
413 lines
| 1 | <template> |
| 2 | <div class="am-payments" :class="[props.componentClass, props.globalClass]" :style="cssVars"> |
| 3 | <div class="am-payments__heading"> |
| 4 | <span class="am-payments__heading-main"> |
| 5 | {{ props.customizedLabels.summary }} |
| 6 | </span> |
| 7 | </div> |
| 8 | |
| 9 | <component |
| 10 | :is="componentTypes[bookableType]" |
| 11 | :payment-gateway="paymentGateway" |
| 12 | :selected-item="props.selectedItem" |
| 13 | :customized-labels="props.customizedLabels" |
| 14 | ></component> |
| 15 | |
| 16 | <AmCheckbox |
| 17 | v-if="paymentGateway !== 'onSite' && features.depositPayment" |
| 18 | v-model="paymentDeposit" |
| 19 | class="am-payments__full" |
| 20 | :label="props.customizedLabels.full_amount_consent" |
| 21 | :class="{ 'am-payments__full-checked': paymentDeposit }" |
| 22 | > |
| 23 | </AmCheckbox> |
| 24 | |
| 25 | <div v-if="!licence.isLite && !licence.isStarter" class="am-payments__method"> |
| 26 | <p class="am-payments__method-heading"> |
| 27 | {{ props.customizedLabels.payment_method }} |
| 28 | </p> |
| 29 | <div |
| 30 | class="am-payments__method-cards" |
| 31 | :class="{ 'am-payments__method-cards-wrap': wrapCards }" |
| 32 | > |
| 33 | <div |
| 34 | v-for="(available, gateway) in availablePayments" |
| 35 | :key="gateway" |
| 36 | class="am-payments__method-button" |
| 37 | :class="[ |
| 38 | { 'am-payments__method-button__selected': paymentGateway === gateway }, |
| 39 | responsiveClass, |
| 40 | `am-payments__method-button-${paymentList.length}`, |
| 41 | ]" |
| 42 | @click="setPaymentGateway(gateway)" |
| 43 | > |
| 44 | <img |
| 45 | :src="`${baseUrls.wpAmeliaPluginURL}/v3/src/assets/img/icons/${gateway === 'mollie' ? 'stripe' : gateway}.svg`" |
| 46 | :class="gateway" |
| 47 | /> |
| 48 | <div> |
| 49 | <p> |
| 50 | {{ |
| 51 | gateway === 'onSite' |
| 52 | ? props.customizedLabels.on_site |
| 53 | : paymentsBtnText.filter((item) => item.key === gateway)[0].text |
| 54 | }} |
| 55 | </p> |
| 56 | </div> |
| 57 | </div> |
| 58 | </div> |
| 59 | </div> |
| 60 | <div class="am-payments__sentence"> |
| 61 | <p> |
| 62 | {{ paymentSentence }} |
| 63 | </p> |
| 64 | </div> |
| 65 | </div> |
| 66 | </template> |
| 67 | |
| 68 | <script setup> |
| 69 | // * _components |
| 70 | import AmCheckbox from '../../../../_components/checkbox/AmCheckbox.vue' |
| 71 | |
| 72 | // * Parts |
| 73 | import EventPaymentInfo from '../Events/common/EventPayment/parts/EventPaymentInfo.vue' |
| 74 | |
| 75 | // * Import from Vue |
| 76 | import { computed, inject, markRaw, ref } from 'vue' |
| 77 | |
| 78 | // * Composables |
| 79 | import { useColorTransparency } from '../../../../../assets/js/common/colorManipulation' |
| 80 | import { useResponsiveClass } from '../../../../../assets/js/common/responsive' |
| 81 | |
| 82 | // * Components Properties |
| 83 | let props = defineProps({ |
| 84 | globalClass: { |
| 85 | type: String, |
| 86 | default: '', |
| 87 | }, |
| 88 | componentClass: { |
| 89 | type: String, |
| 90 | default: '', |
| 91 | }, |
| 92 | selectedItem: { |
| 93 | type: Object, |
| 94 | required: true, |
| 95 | }, |
| 96 | customizedLabels: { |
| 97 | type: Object, |
| 98 | required: true, |
| 99 | }, |
| 100 | }) |
| 101 | |
| 102 | // * Base Urls |
| 103 | const baseUrls = inject('baseUrls') |
| 104 | |
| 105 | // * Plugin Licence |
| 106 | let licence = inject('licence') |
| 107 | |
| 108 | // * Features |
| 109 | let features = inject('features') |
| 110 | |
| 111 | // * Bookable type |
| 112 | let bookableType = inject('bookableType') |
| 113 | |
| 114 | // * Payment Part |
| 115 | const componentTypes = { |
| 116 | event: markRaw(EventPaymentInfo), |
| 117 | } |
| 118 | |
| 119 | let paymentDeposit = ref(false) |
| 120 | |
| 121 | const availablePayments = { |
| 122 | onSite: true, |
| 123 | stripe: true, |
| 124 | payPal: true, |
| 125 | razorpay: true, |
| 126 | } |
| 127 | |
| 128 | let paymentList = computed(() => { |
| 129 | let arr = [] |
| 130 | Object.keys(availablePayments).forEach((a) => { |
| 131 | if (availablePayments[a]) { |
| 132 | arr.push(a) |
| 133 | } |
| 134 | }) |
| 135 | |
| 136 | return arr |
| 137 | }) |
| 138 | |
| 139 | let paymentGateway = ref('onSite') |
| 140 | |
| 141 | function setPaymentGateway(gateway) { |
| 142 | paymentGateway.value = gateway |
| 143 | } |
| 144 | |
| 145 | let paymentsBtnText = [] |
| 146 | |
| 147 | Object.keys(availablePayments).forEach((key) => { |
| 148 | paymentsBtnText.push({ key, text: getPaymentBtnString(key) }) |
| 149 | }) |
| 150 | |
| 151 | function getPaymentBtnString(key) { |
| 152 | switch (key) { |
| 153 | case 'onSite': |
| 154 | return props.customizedLabels['on_site'] |
| 155 | case 'payPal': |
| 156 | return props.customizedLabels['payment_paypal'] |
| 157 | case 'stripe': |
| 158 | return props.customizedLabels['stripe'] |
| 159 | case 'razorpay': |
| 160 | return props.customizedLabels['razorpay'] |
| 161 | case 'mollie': |
| 162 | return props.customizedLabels['on_line'] |
| 163 | default: |
| 164 | return '' |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | let paymentSentence = computed(() => { |
| 169 | if (paymentGateway.value === 'onSite') { |
| 170 | return props.customizedLabels.payment_onsite_sentence |
| 171 | } |
| 172 | |
| 173 | if (paymentGateway.value === 'mollie' || paymentGateway.value === 'wc') { |
| 174 | return props.customizedLabels.payment_wc_mollie_sentence |
| 175 | } |
| 176 | |
| 177 | return '' |
| 178 | }) |
| 179 | |
| 180 | // * Responsive |
| 181 | let cWidth = inject('containerWidth') |
| 182 | let responsiveClass = computed(() => { |
| 183 | return useResponsiveClass(cWidth.value) |
| 184 | }) |
| 185 | |
| 186 | let wrapCards = computed( |
| 187 | () => cWidth.value < 450 || (cWidth.value > 560 && cWidth.value - 240 < 450), |
| 188 | ) |
| 189 | |
| 190 | // * Fonts |
| 191 | let amFonts = inject('amFonts') |
| 192 | |
| 193 | // * Colors |
| 194 | let amColors = inject('amColors') |
| 195 | |
| 196 | // * Css Variables |
| 197 | const cssVars = computed(() => { |
| 198 | return { |
| 199 | '--am-font-family': amFonts.value.fontFamily, |
| 200 | '--am-c-ps-price-bgr': useColorTransparency(amColors.value.colorBtnPrim, 0.05), |
| 201 | '--am-c-ps-total-price': amColors.value.colorBtnPrim, |
| 202 | '--am-c-ps-text': amColors.value.colorMainText, |
| 203 | '--am-c-ps-border': amColors.value.colorInpBorder, |
| 204 | '--am-c-ps-text-op06': useColorTransparency(amColors.value.colorMainText, 0.06), |
| 205 | '--am-c-ps-text-op20': useColorTransparency(amColors.value.colorMainText, 0.2), |
| 206 | '--am-c-ps-text-op25': useColorTransparency(amColors.value.colorMainText, 0.25), |
| 207 | '--am-c-ps-text-op50': useColorTransparency(amColors.value.colorMainText, 0.5), |
| 208 | '--am-c-ps-text-op60': useColorTransparency(amColors.value.colorMainText, 0.6), |
| 209 | '--am-c-ps-primary': amColors.value.colorPrimary, |
| 210 | '--am-c-ps-primary-op10': useColorTransparency(amColors.value.colorPrimary, 0.1), |
| 211 | '--am-c-ps-primary-op06': useColorTransparency(amColors.value.colorPrimary, 0.06), |
| 212 | } |
| 213 | }) |
| 214 | </script> |
| 215 | |
| 216 | <style lang="scss"> |
| 217 | #amelia-app-backend-new #amelia-container { |
| 218 | .am-payments { |
| 219 | & > * { |
| 220 | $count: 6; |
| 221 | @for $i from 0 through $count { |
| 222 | &:nth-child(#{$i + 1}) { |
| 223 | animation: 600ms cubic-bezier(0.45, 1, 0.4, 1.2) #{$i * 100}ms am-animation-slide-up; |
| 224 | animation-fill-mode: both; |
| 225 | } |
| 226 | } |
| 227 | } |
| 228 | |
| 229 | &__heading { |
| 230 | font-size: 15px; |
| 231 | font-style: normal; |
| 232 | font-weight: 500; |
| 233 | line-height: 1.6; |
| 234 | color: var(--am-c-ps-text); |
| 235 | margin-bottom: 4px; |
| 236 | animation: 600ms cubic-bezier(0.45, 1, 0.4, 1.2) #{100}ms am-animation-slide-up; |
| 237 | animation-fill-mode: both; |
| 238 | } |
| 239 | |
| 240 | &__price { |
| 241 | } |
| 242 | |
| 243 | &__sentence { |
| 244 | display: flex; |
| 245 | justify-content: center; |
| 246 | margin-top: 2px; |
| 247 | |
| 248 | p { |
| 249 | display: inline-flex; |
| 250 | font-size: 14px; |
| 251 | font-weight: 500; |
| 252 | line-height: 1.42857; |
| 253 | color: var(--am-c-ps-text-op60); |
| 254 | } |
| 255 | } |
| 256 | |
| 257 | &__full { |
| 258 | color: var(--am-c-ps-text); |
| 259 | border: 1px solid var(--am-c-ps-text-op25); |
| 260 | border-radius: 8px; |
| 261 | box-shadow: 0 1px 1px var(--am-c-ps-text-op06); |
| 262 | box-sizing: border-box; |
| 263 | padding: 12px; |
| 264 | margin: 16px 0 0; |
| 265 | |
| 266 | &-checked { |
| 267 | border: 1px solid var(--am-c-ps-primary); |
| 268 | background: var(--am-c-ps-primary-op10); |
| 269 | |
| 270 | &:after { |
| 271 | transform: rotate(45deg) scaleY(1); |
| 272 | } |
| 273 | } |
| 274 | |
| 275 | .el-checkbox { |
| 276 | display: flex; |
| 277 | align-items: center; |
| 278 | |
| 279 | &__input { |
| 280 | height: 32px !important; |
| 281 | line-height: 32px; |
| 282 | align-items: center; |
| 283 | } |
| 284 | |
| 285 | &__label { |
| 286 | line-height: 32px; |
| 287 | align-items: center; |
| 288 | } |
| 289 | } |
| 290 | } |
| 291 | |
| 292 | &__error { |
| 293 | animation: 600ms cubic-bezier(0.45, 1, 0.4, 1.2) #{100}ms am-animation-slide-up; |
| 294 | animation-fill-mode: both; |
| 295 | margin-bottom: 10px; |
| 296 | } |
| 297 | |
| 298 | &__method { |
| 299 | margin-top: 16px; |
| 300 | |
| 301 | &-heading { |
| 302 | font-size: 18px; |
| 303 | font-weight: 500; |
| 304 | line-height: 1.55555; |
| 305 | color: var(--am-c-ps-text); |
| 306 | margin-bottom: 8px; |
| 307 | } |
| 308 | |
| 309 | &-cards { |
| 310 | display: flex; |
| 311 | justify-items: center; |
| 312 | |
| 313 | & > div { |
| 314 | margin: 0 6px 6px 0; |
| 315 | } |
| 316 | |
| 317 | &-wrap { |
| 318 | flex-wrap: wrap; |
| 319 | } |
| 320 | } |
| 321 | |
| 322 | &-button { |
| 323 | display: flex; |
| 324 | align-items: center; |
| 325 | gap: 2px; |
| 326 | width: 108px; |
| 327 | border: 1px solid var(--am-c-ps-text-op25); |
| 328 | border-radius: 8px; |
| 329 | box-shadow: 0 1px 1px var(--am-c-ps-text-op06); |
| 330 | box-sizing: border-box; |
| 331 | padding: 12px; |
| 332 | cursor: pointer; |
| 333 | flex-direction: column; |
| 334 | justify-items: center; |
| 335 | height: fit-content; |
| 336 | |
| 337 | img { |
| 338 | height: 24px; |
| 339 | width: 24px; |
| 340 | } |
| 341 | |
| 342 | .barion { |
| 343 | width: 50px; |
| 344 | } |
| 345 | |
| 346 | div { |
| 347 | p { |
| 348 | font-weight: 500; |
| 349 | font-size: 15px; |
| 350 | line-height: 24px; |
| 351 | color: var(--am-c-ps-text); |
| 352 | margin: 0; |
| 353 | text-align: center; |
| 354 | word-break: break-all; |
| 355 | } |
| 356 | span { |
| 357 | font-size: 12px; |
| 358 | font-weight: 400; |
| 359 | line-height: 1.66666; |
| 360 | color: var(--am-c-ps-text-op50); |
| 361 | } |
| 362 | } |
| 363 | |
| 364 | &__selected { |
| 365 | background: var(--am-c-ps-primary-op10); |
| 366 | border: 1px solid var(--am-c-ps-primary); |
| 367 | box-sizing: border-box; |
| 368 | box-shadow: 0 1px 1px var(--am-c-ps-primary-op06); |
| 369 | } |
| 370 | |
| 371 | &-4 { |
| 372 | width: calc(25% - 6px); |
| 373 | |
| 374 | &.am-rw { |
| 375 | &-480 { |
| 376 | width: calc(50% - 6px); |
| 377 | } |
| 378 | } |
| 379 | } |
| 380 | |
| 381 | &-3 { |
| 382 | width: calc(33.333333% - 6px); |
| 383 | |
| 384 | &.am-rw { |
| 385 | &-420 { |
| 386 | width: calc(50% - 6px); |
| 387 | } |
| 388 | } |
| 389 | } |
| 390 | |
| 391 | &-2 { |
| 392 | width: calc(50% - 6px); |
| 393 | |
| 394 | &.am-rw { |
| 395 | &-420 { |
| 396 | width: calc(50% - 6px); |
| 397 | } |
| 398 | } |
| 399 | } |
| 400 | } |
| 401 | } |
| 402 | // pm - payment method |
| 403 | &__pm { |
| 404 | margin-top: 24px; |
| 405 | } |
| 406 | |
| 407 | .el-checkbox__label { |
| 408 | font-size: 15px; |
| 409 | } |
| 410 | } |
| 411 | } |
| 412 | </style> |
| 413 |