@designcrowd/library.brand-page 5.17.3 → 5.17.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/src/{CreatedOnBrandCrowd-de-de-yFg0wq_8.js → CreatedOnBrandCrowd-de-de-C_NzyXvG.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-en-us-D4sUyR-U.js → CreatedOnBrandCrowd-en-us-DSmpdByg.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-es-es-CjXHshc0.js → CreatedOnBrandCrowd-es-es-4O9ttd4y.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-fr-fr-CtsyncLl.js → CreatedOnBrandCrowd-fr-ca-DDr8rQHb.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-fr-ca-CtsyncLl.js → CreatedOnBrandCrowd-fr-fr-DDr8rQHb.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-pt-pt-D8Z-gS4q.js → CreatedOnBrandCrowd-pt-br-BUTVQ17i.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-pt-br-D8Z-gS4q.js → CreatedOnBrandCrowd-pt-pt-BUTVQ17i.js} +1 -1
- package/lib/src/{CreatedOnDcom-de-de-k7a8-Akd.js → CreatedOnDcom-de-de-thkGl7gg.js} +1 -1
- package/lib/src/{CreatedOnDcom-en-us-Bh5mbVcr.js → CreatedOnDcom-en-us-DOgnHkVR.js} +1 -1
- package/lib/src/{CreatedOnDcom-es-es-DkEBWtQn.js → CreatedOnDcom-es-es-NyEB16vO.js} +1 -1
- package/lib/src/{CreatedOnDcom-fr-ca-DcarvQ1r.js → CreatedOnDcom-fr-ca-Cd6WjWcu.js} +1 -1
- package/lib/src/{CreatedOnDcom-fr-fr-Cbe-yOPu.js → CreatedOnDcom-fr-fr-CDKX35U7.js} +1 -1
- package/lib/src/{CreatedOnDcom-pt-br-DlWu_Kwc.js → CreatedOnDcom-pt-br-PbJzyRNp.js} +1 -1
- package/lib/src/{CreatedOnDcom-pt-pt-DZp9RWfH.js → CreatedOnDcom-pt-pt-tja7jglY.js} +1 -1
- package/lib/src/brand-page/clients/brand-page.client.d.ts +2 -1
- package/lib/src/brand-page/clients/brand-page.client.js +1 -0
- package/lib/src/brand-page/models/payment.model.d.ts +42 -0
- package/lib/src/brand-page/models/payment.model.js +9 -0
- package/lib/src/brand-page/utils/view-model.util.js +1 -0
- package/lib/src/brand-page/view-models.d.ts +1 -0
- package/lib/src/brand-page-maker/components/brand-page-maker/BrandPageMaker.mixin.d.ts +1 -1
- package/lib/src/brand-page-maker/components/brandpage-maker-page/BrandPageMakerPage.mixin.d.ts +1 -0
- package/lib/src/brand-page-maker/composables/useEventTracker.d.ts +2 -0
- package/lib/src/brand-page-maker/composables/useEventTracker.js +6 -0
- package/lib/src/brand-page-maker/constants/config-settings-constant.d.ts +1 -0
- package/lib/src/brand-page-maker/constants/config-settings-constant.js +7 -0
- package/lib/src/brand-page-maker/models/content-settings.js +1 -0
- package/lib/src/bundled-translations-D5A4swr0.js +173 -0
- package/lib/src/bundled-translations.de-DE-Bq6H28Hz.js +173 -0
- package/lib/src/bundled-translations.es-ES-Bo-UGy51.js +173 -0
- package/lib/src/bundled-translations.fr-CA-7GXawEcN.js +173 -0
- package/lib/src/bundled-translations.fr-FR-DzVwt2U-.js +173 -0
- package/lib/src/bundled-translations.pt-BR-DSZZ-i-B.js +173 -0
- package/lib/src/bundled-translations.pt-PT-SNbEX0GM.js +173 -0
- package/lib/src/bundles/bundled-translations.de-DE.json +965 -1
- package/lib/src/bundles/bundled-translations.es-ES.json +965 -1
- package/lib/src/bundles/bundled-translations.fr-CA.json +965 -1
- package/lib/src/bundles/bundled-translations.fr-FR.json +965 -1
- package/lib/src/bundles/bundled-translations.json +965 -1
- package/lib/src/bundles/bundled-translations.pt-BR.json +965 -1
- package/lib/src/bundles/bundled-translations.pt-PT.json +965 -1
- package/lib/src/composables/useTranslate.d.ts +7 -1
- package/lib/src/composables/useTranslate.js +9 -1
- package/lib/src/css/library.brand-page-brandCrowd.min.css +33 -14
- package/lib/src/css/library.brand-page-brandPage.min.css +33 -14
- package/lib/src/css/library.brand-page-designCom.min.css +33 -14
- package/lib/src/css/library.brand-page-preview.min.css +33 -14
- package/lib/src/index.mjs +88 -87
- package/lib/src/{lib-DOfGX3z2.js → lib-DL-13itP.js} +21136 -20938
- package/lib/src/shared/content-settings/components/content-settings/ContentSettings.mixin.d.ts +1 -0
- package/lib/src/shared/content-settings/components/content-settings/ReplaceImageSettingsForContent.mixin.d.ts +1 -0
- package/lib/src/shared/content-settings/components/content-settings-item/ContentSettingsItem.mixin.d.ts +1 -0
- package/lib/src/shared/content-settings/components/payment-config-field/payment-toggle-field/PaymentToggleField.mixin.d.ts +13 -1
- package/lib/src/shared/content-settings/components/payment-config-field/payment-toggle-field/PaymentToggleField.mixin.js +10 -0
- package/lib/src/shared/logo-settings/components/EditLogoSettings.mixin.d.ts +2 -1
- package/lib/src/shared/page-settings/components/page-settings/PageSettings.mixin.d.ts +1 -0
- package/lib/src/shared/publish-brand-page-with-state/PublishBrandPageModalWithState.mixin.d.ts +1 -0
- package/lib/src/shared/side-bar/components/SideBarTabButton.mixin.d.ts +1 -0
- package/lib/src/shared/style-settings/components/StyleSettings.mixin.d.ts +1 -0
- package/lib/src/shared/template-settings/components/TemplatesSettings.mixin.d.ts +2 -1
- package/package.json +1 -1
- package/src/brand-page/clients/brand-page.client.ts +3 -0
- package/src/brand-page/components/payment/RequestPaymentStripe.vue +381 -44
- package/src/brand-page/components/shop/PaymentModal.vue +7 -1
- package/src/brand-page/components/shop/PaymentShippingAddress.vue +297 -0
- package/src/brand-page/components/shop/Shop.vue +1 -0
- package/src/brand-page/components/shop/i18n/countries.de-DE.json +240 -0
- package/src/brand-page/components/shop/i18n/countries.es-ES.json +240 -0
- package/src/brand-page/components/shop/i18n/countries.fr-CA.json +240 -0
- package/src/brand-page/components/shop/i18n/countries.fr-FR.json +240 -0
- package/src/brand-page/components/shop/i18n/countries.json +240 -0
- package/src/brand-page/components/shop/i18n/countries.pt-BR.json +240 -0
- package/src/brand-page/components/shop/i18n/countries.pt-PT.json +240 -0
- package/src/brand-page/components/shop/i18n/payment-shipping-address.de-DE.json +18 -0
- package/src/brand-page/components/shop/i18n/payment-shipping-address.es-ES.json +18 -0
- package/src/brand-page/components/shop/i18n/payment-shipping-address.fr-CA.json +18 -0
- package/src/brand-page/components/shop/i18n/payment-shipping-address.fr-FR.json +18 -0
- package/src/brand-page/components/shop/i18n/payment-shipping-address.json +18 -0
- package/src/brand-page/components/shop/i18n/payment-shipping-address.pt-BR.json +18 -0
- package/src/brand-page/components/shop/i18n/payment-shipping-address.pt-PT.json +18 -0
- package/src/brand-page/models/payment.model.ts +24 -0
- package/src/brand-page/utils/view-model.util.ts +1 -0
- package/src/brand-page/view-models.ts +1 -0
- package/src/brand-page-maker/composables/useEventTracker.ts +6 -0
- package/src/brand-page-maker/constants/config-settings-constant.ts +8 -0
- package/src/brand-page-maker/models/content-settings.ts +1 -0
- package/src/bundles/bundled-translations.de-DE.json +965 -1
- package/src/bundles/bundled-translations.es-ES.json +965 -1
- package/src/bundles/bundled-translations.fr-CA.json +965 -1
- package/src/bundles/bundled-translations.fr-FR.json +965 -1
- package/src/bundles/bundled-translations.json +965 -1
- package/src/bundles/bundled-translations.pt-BR.json +965 -1
- package/src/bundles/bundled-translations.pt-PT.json +965 -1
- package/src/composables/useTranslate.ts +15 -0
- package/src/shared/content-settings/components/content-settings/i18n/content-settings.de-DE.json +3 -1
- package/src/shared/content-settings/components/content-settings/i18n/content-settings.es-ES.json +3 -1
- package/src/shared/content-settings/components/content-settings/i18n/content-settings.fr-CA.json +3 -1
- package/src/shared/content-settings/components/content-settings/i18n/content-settings.fr-FR.json +3 -1
- package/src/shared/content-settings/components/content-settings/i18n/content-settings.json +3 -1
- package/src/shared/content-settings/components/content-settings/i18n/content-settings.pt-BR.json +3 -1
- package/src/shared/content-settings/components/content-settings/i18n/content-settings.pt-PT.json +3 -1
- package/src/shared/content-settings/components/payment-config-field/payment-toggle-field/PaymentToggleField.mixin.ts +12 -0
- package/src/shared/content-settings/components/payment-config-field/payment-toggle-field/PaymentToggleField.vue +9 -1
- package/lib/src/brand-page/components/payment/RequestPaymentStripe.mixin.d.ts +0 -106
- package/lib/src/brand-page/components/payment/RequestPaymentStripe.mixin.js +0 -253
- package/lib/src/bundled-translations-B6qZE8LU.js +0 -169
- package/lib/src/bundled-translations.de-DE-CsU6YsZb.js +0 -169
- package/lib/src/bundled-translations.es-ES-unPBdcJx.js +0 -169
- package/lib/src/bundled-translations.fr-CA-Dpa2wEtC.js +0 -169
- package/lib/src/bundled-translations.fr-FR-BPloaUjN.js +0 -169
- package/lib/src/bundled-translations.pt-BR-CFRGdaDO.js +0 -169
- package/lib/src/bundled-translations.pt-PT-BHVYCE0K.js +0 -169
- package/src/brand-page/components/payment/RequestPaymentStripe.mixin.ts +0 -364
|
@@ -15,6 +15,8 @@ export type LocaleTypes =
|
|
|
15
15
|
| 'fr-CA'
|
|
16
16
|
| 'pt-BR';
|
|
17
17
|
|
|
18
|
+
type Country = { code: string; name: string };
|
|
19
|
+
|
|
18
20
|
export const supportedLocales: LocaleTypes[] = [
|
|
19
21
|
'en-US',
|
|
20
22
|
'de-DE',
|
|
@@ -215,6 +217,17 @@ const generateAiModalTr = (key, valuesToInterpolate = {}) =>
|
|
|
215
217
|
tr(`aiModal.${key}`, valuesToInterpolate);
|
|
216
218
|
const saveContactWidgetTr = (key, valuesToInterpolate = {}) =>
|
|
217
219
|
tr(`saveContactWidget.${key}`, valuesToInterpolate);
|
|
220
|
+
const paymentShippingAddressTr = (key, valuesToInterpolate = {}) =>
|
|
221
|
+
tr(`paymentShippingAddress.${key}`, valuesToInterpolate);
|
|
222
|
+
|
|
223
|
+
const countriesTr = (): Country[] => {
|
|
224
|
+
const instance = getI18NextInstance();
|
|
225
|
+
|
|
226
|
+
return instance.t('countries', {
|
|
227
|
+
ns: nameSpace,
|
|
228
|
+
returnObjects: true,
|
|
229
|
+
}) as Country[];
|
|
230
|
+
};
|
|
218
231
|
|
|
219
232
|
const currentLocale = (): LocaleTypes => {
|
|
220
233
|
const i18 = getI18NextInstance();
|
|
@@ -316,4 +329,6 @@ export {
|
|
|
316
329
|
logoTemplateSearchModalTr,
|
|
317
330
|
generateAiModalTr,
|
|
318
331
|
saveContactWidgetTr,
|
|
332
|
+
paymentShippingAddressTr,
|
|
333
|
+
countriesTr,
|
|
319
334
|
};
|
package/src/shared/content-settings/components/content-settings/i18n/content-settings.de-DE.json
CHANGED
|
@@ -202,6 +202,8 @@
|
|
|
202
202
|
"addLinkButtonText": "Link hinzufügen",
|
|
203
203
|
"enterValidUrlError": "Bitte geben Sie eine gültige URL ein",
|
|
204
204
|
"enterTextHerePlaceholder": "Text hier eingeben ...",
|
|
205
|
-
"bookNowLabel": "Jetzt buchen"
|
|
205
|
+
"bookNowLabel": "Jetzt buchen",
|
|
206
|
+
"shippingLabel": "Lieferadresse aktivieren",
|
|
207
|
+
"shippingPlaceholder": "Fordern Sie Kunden auf, während des Bezahlvorgangs eine Lieferadresse einzugeben."
|
|
206
208
|
}
|
|
207
209
|
}
|
package/src/shared/content-settings/components/content-settings/i18n/content-settings.es-ES.json
CHANGED
|
@@ -202,6 +202,8 @@
|
|
|
202
202
|
"addLinkButtonText": "Añadir enlace",
|
|
203
203
|
"enterValidUrlError": "Introduce una URL válida",
|
|
204
204
|
"enterTextHerePlaceholder": "Introduce el texto aquí...",
|
|
205
|
-
"bookNowLabel": "Reserva ahora"
|
|
205
|
+
"bookNowLabel": "Reserva ahora",
|
|
206
|
+
"shippingLabel": "Habilitar dirección de envío",
|
|
207
|
+
"shippingPlaceholder": "Exigir a los clientes que introduzcan una dirección de envío al finalizar la compra."
|
|
206
208
|
}
|
|
207
209
|
}
|
package/src/shared/content-settings/components/content-settings/i18n/content-settings.fr-CA.json
CHANGED
|
@@ -202,6 +202,8 @@
|
|
|
202
202
|
"addLinkButtonText": "Ajouter un lien",
|
|
203
203
|
"enterValidUrlError": "Veuillez entrer une URL valide",
|
|
204
204
|
"enterTextHerePlaceholder": "Saisir le texte ici...",
|
|
205
|
-
"bookNowLabel": "Prendre RDV"
|
|
205
|
+
"bookNowLabel": "Prendre RDV",
|
|
206
|
+
"shippingLabel": "Activer l'adresse de livraison",
|
|
207
|
+
"shippingPlaceholder": "Exigez des clients qu'ils saisissent une adresse de livraison lors de la validation de leur commande."
|
|
206
208
|
}
|
|
207
209
|
}
|
package/src/shared/content-settings/components/content-settings/i18n/content-settings.fr-FR.json
CHANGED
|
@@ -202,6 +202,8 @@
|
|
|
202
202
|
"addLinkButtonText": "Ajouter un lien",
|
|
203
203
|
"enterValidUrlError": "Veuillez entrer une URL valide",
|
|
204
204
|
"enterTextHerePlaceholder": "Saisir le texte ici...",
|
|
205
|
-
"bookNowLabel": "Prendre RDV"
|
|
205
|
+
"bookNowLabel": "Prendre RDV",
|
|
206
|
+
"shippingLabel": "Activer l'adresse de livraison",
|
|
207
|
+
"shippingPlaceholder": "Exigez des clients qu'ils saisissent une adresse de livraison lors de la validation de leur commande."
|
|
206
208
|
}
|
|
207
209
|
}
|
|
@@ -202,6 +202,8 @@
|
|
|
202
202
|
"addLinkButtonText": "Add Link",
|
|
203
203
|
"enterValidUrlError": "Please enter a valid URL",
|
|
204
204
|
"enterTextHerePlaceholder": "Enter text here...",
|
|
205
|
-
"bookNowLabel": "Book Now"
|
|
205
|
+
"bookNowLabel": "Book Now",
|
|
206
|
+
"shippingLabel": "Enable Shipping Address",
|
|
207
|
+
"shippingPlaceholder": "Require customers to enter a shipping address during checkout."
|
|
206
208
|
}
|
|
207
209
|
}
|
package/src/shared/content-settings/components/content-settings/i18n/content-settings.pt-BR.json
CHANGED
|
@@ -202,6 +202,8 @@
|
|
|
202
202
|
"addLinkButtonText": "Adicionar link",
|
|
203
203
|
"enterValidUrlError": "Insira um URL válido",
|
|
204
204
|
"enterTextHerePlaceholder": "Insira o texto aqui...",
|
|
205
|
-
"bookNowLabel": "Reserve agora"
|
|
205
|
+
"bookNowLabel": "Reserve agora",
|
|
206
|
+
"shippingLabel": "Ativar endereço para envio",
|
|
207
|
+
"shippingPlaceholder": "Exija que os clientes informem um endereço para envio na finalização da compra."
|
|
206
208
|
}
|
|
207
209
|
}
|
package/src/shared/content-settings/components/content-settings/i18n/content-settings.pt-PT.json
CHANGED
|
@@ -202,6 +202,8 @@
|
|
|
202
202
|
"addLinkButtonText": "Adicionar link",
|
|
203
203
|
"enterValidUrlError": "Por favor, introduza um URL válido",
|
|
204
204
|
"enterTextHerePlaceholder": "Introduza o texto aqui...",
|
|
205
|
-
"bookNowLabel": "Reservar já"
|
|
205
|
+
"bookNowLabel": "Reservar já",
|
|
206
|
+
"shippingLabel": "Ativar morada de envio",
|
|
207
|
+
"shippingPlaceholder": "Exija que os clientes introduzam uma morada de envio durante o processo de finalização da compra."
|
|
206
208
|
}
|
|
207
209
|
}
|
|
@@ -2,6 +2,7 @@ import { defineComponent } from 'vue';
|
|
|
2
2
|
import type { PropType } from 'vue';
|
|
3
3
|
import type { RequestPaymentConfig } from '@brand-page';
|
|
4
4
|
import type { UpdateItemValuePayload } from '../../../models';
|
|
5
|
+
import { useEventTracker } from '../../../../../brand-page-maker/composables/useEventTracker';
|
|
5
6
|
|
|
6
7
|
export default defineComponent({
|
|
7
8
|
props: {
|
|
@@ -25,6 +26,11 @@ export default defineComponent({
|
|
|
25
26
|
type: Object as PropType<RequestPaymentConfig>,
|
|
26
27
|
required: true,
|
|
27
28
|
},
|
|
29
|
+
placeholder: {
|
|
30
|
+
type: String,
|
|
31
|
+
required: false,
|
|
32
|
+
default: '',
|
|
33
|
+
},
|
|
28
34
|
},
|
|
29
35
|
emits: ['update:modelValue'],
|
|
30
36
|
computed: {
|
|
@@ -44,6 +50,12 @@ export default defineComponent({
|
|
|
44
50
|
value,
|
|
45
51
|
};
|
|
46
52
|
|
|
53
|
+
if (this.settingsName === 'isShippingEnabled') {
|
|
54
|
+
const eventTracker = useEventTracker();
|
|
55
|
+
|
|
56
|
+
eventTracker.sendShippingToggleEvent(newVal);
|
|
57
|
+
}
|
|
58
|
+
|
|
47
59
|
this.$emit('update:modelValue', payload);
|
|
48
60
|
},
|
|
49
61
|
},
|
|
@@ -3,7 +3,10 @@
|
|
|
3
3
|
data-component="payment-toggle-field"
|
|
4
4
|
class="tw-flex tw-flex-row tw-mt-2"
|
|
5
5
|
>
|
|
6
|
-
<span class="tw-flex-grow tw-text-sm">
|
|
6
|
+
<span v-if="placeholder" class="tw-flex-grow tw-text-sm tw-font-bold">
|
|
7
|
+
{{ label }}
|
|
8
|
+
</span>
|
|
9
|
+
<span v-else class="tw-flex-grow tw-text-sm">
|
|
7
10
|
{{ label }}
|
|
8
11
|
</span>
|
|
9
12
|
<Toggle
|
|
@@ -12,6 +15,11 @@
|
|
|
12
15
|
color="primary"
|
|
13
16
|
/>
|
|
14
17
|
</div>
|
|
18
|
+
<p v-if="placeholder">
|
|
19
|
+
<span class="tw-flex-grow tw-text-sm tw-text-grayscale-600">
|
|
20
|
+
{{ placeholder }}
|
|
21
|
+
</span>
|
|
22
|
+
</p>
|
|
15
23
|
</template>
|
|
16
24
|
<script>
|
|
17
25
|
import { Toggle } from '@designcrowd/fe-shared-lib';
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import type { PropType } from 'vue';
|
|
2
|
-
import type { BrandPagePaymentConfig, ButtonStyles, CheckoutInformation, CreateCartResult, StripePaymentIntent } from '@brand-page/models';
|
|
3
|
-
declare global {
|
|
4
|
-
interface Window {
|
|
5
|
-
Stripe?: stripe.StripeStatic;
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
interface RequestPaymentStripeData {
|
|
9
|
-
cardCvcElement: stripe.elements.Element | undefined;
|
|
10
|
-
cardCvcElementError: stripe.Error | undefined;
|
|
11
|
-
cardExpiryElement: stripe.elements.Element | undefined;
|
|
12
|
-
cardExpiryElementError: stripe.Error | undefined;
|
|
13
|
-
cardNumberElement: stripe.elements.Element | undefined;
|
|
14
|
-
cardNumberElementError: stripe.Error | undefined;
|
|
15
|
-
emailAddress: string | undefined;
|
|
16
|
-
emailAddressError: Error | undefined;
|
|
17
|
-
isBusy: boolean;
|
|
18
|
-
isCardCvcValid: boolean;
|
|
19
|
-
isCardExpiryValid: boolean;
|
|
20
|
-
isCardNumberValid: boolean;
|
|
21
|
-
isInitialised: boolean;
|
|
22
|
-
stripe: stripe.Stripe | undefined;
|
|
23
|
-
submitButtonMessage: string;
|
|
24
|
-
submitError: Error | stripe.Error | undefined;
|
|
25
|
-
}
|
|
26
|
-
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
27
|
-
cart: {
|
|
28
|
-
type: PropType<CreateCartResult<StripePaymentIntent>>;
|
|
29
|
-
required: true;
|
|
30
|
-
};
|
|
31
|
-
checkoutInformation: {
|
|
32
|
-
type: PropType<CheckoutInformation>;
|
|
33
|
-
required: true;
|
|
34
|
-
};
|
|
35
|
-
buttonStyles: {
|
|
36
|
-
type: PropType<ButtonStyles>;
|
|
37
|
-
required: true;
|
|
38
|
-
};
|
|
39
|
-
paymentConfig: {
|
|
40
|
-
type: PropType<BrandPagePaymentConfig>;
|
|
41
|
-
required: true;
|
|
42
|
-
};
|
|
43
|
-
stripePublishableKey: {
|
|
44
|
-
type: StringConstructor;
|
|
45
|
-
required: true;
|
|
46
|
-
};
|
|
47
|
-
productName: {
|
|
48
|
-
type: StringConstructor;
|
|
49
|
-
required: false;
|
|
50
|
-
};
|
|
51
|
-
isShop: {
|
|
52
|
-
type: BooleanConstructor;
|
|
53
|
-
required: false;
|
|
54
|
-
default: boolean;
|
|
55
|
-
};
|
|
56
|
-
}>, {}, RequestPaymentStripeData, {
|
|
57
|
-
amount(): string;
|
|
58
|
-
currencyCode(): string;
|
|
59
|
-
currencySymbol(): string;
|
|
60
|
-
isStripeElementFormComplete(): boolean;
|
|
61
|
-
isSubmitButtonEnabled(): boolean;
|
|
62
|
-
arrowStyle(): BrandPageCssStyle;
|
|
63
|
-
payButtonStyle(): BrandPageCssStyle;
|
|
64
|
-
containerStyle(): BrandPageCssStyle;
|
|
65
|
-
}, {
|
|
66
|
-
initialiseStripeScript(): void;
|
|
67
|
-
initStripeElements(): void;
|
|
68
|
-
onBackClick(): void;
|
|
69
|
-
onEmailAddressEvent(): void;
|
|
70
|
-
onStripeElementChange(response?: stripe.elements.ElementChangeResponse): void;
|
|
71
|
-
onSubmitPaymentClick(): Promise<void>;
|
|
72
|
-
validateEmailAddress(): void;
|
|
73
|
-
}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
74
|
-
cart: {
|
|
75
|
-
type: PropType<CreateCartResult<StripePaymentIntent>>;
|
|
76
|
-
required: true;
|
|
77
|
-
};
|
|
78
|
-
checkoutInformation: {
|
|
79
|
-
type: PropType<CheckoutInformation>;
|
|
80
|
-
required: true;
|
|
81
|
-
};
|
|
82
|
-
buttonStyles: {
|
|
83
|
-
type: PropType<ButtonStyles>;
|
|
84
|
-
required: true;
|
|
85
|
-
};
|
|
86
|
-
paymentConfig: {
|
|
87
|
-
type: PropType<BrandPagePaymentConfig>;
|
|
88
|
-
required: true;
|
|
89
|
-
};
|
|
90
|
-
stripePublishableKey: {
|
|
91
|
-
type: StringConstructor;
|
|
92
|
-
required: true;
|
|
93
|
-
};
|
|
94
|
-
productName: {
|
|
95
|
-
type: StringConstructor;
|
|
96
|
-
required: false;
|
|
97
|
-
};
|
|
98
|
-
isShop: {
|
|
99
|
-
type: BooleanConstructor;
|
|
100
|
-
required: false;
|
|
101
|
-
default: boolean;
|
|
102
|
-
};
|
|
103
|
-
}>> & Readonly<{}>, {
|
|
104
|
-
isShop: boolean;
|
|
105
|
-
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
106
|
-
export default _default;
|
|
@@ -1,253 +0,0 @@
|
|
|
1
|
-
import { defineComponent } from 'vue';
|
|
2
|
-
import validator from 'validator';
|
|
3
|
-
import { debug, debugError } from '../../../utils/debug.util';
|
|
4
|
-
import * as constants from '../../constants';
|
|
5
|
-
import { requestPaymentStripeTr } from '@src/composables/useTranslate';
|
|
6
|
-
import brandPageClient from '../../clients/brand-page.client';
|
|
7
|
-
const INVALID_EMAIL_MESSAGE = () => requestPaymentStripeTr('invalidEmailMessage');
|
|
8
|
-
const STRIPE_SCRIPT_URL = 'https://js.stripe.com/v3/';
|
|
9
|
-
const SCRIPT_TAG_NAME = 'SCRIPT';
|
|
10
|
-
const centsToDollars = (cents) => {
|
|
11
|
-
return cents / 100;
|
|
12
|
-
};
|
|
13
|
-
export default defineComponent({
|
|
14
|
-
props: {
|
|
15
|
-
cart: {
|
|
16
|
-
type: Object,
|
|
17
|
-
required: true,
|
|
18
|
-
},
|
|
19
|
-
checkoutInformation: {
|
|
20
|
-
type: Object,
|
|
21
|
-
required: true,
|
|
22
|
-
},
|
|
23
|
-
buttonStyles: {
|
|
24
|
-
type: Object,
|
|
25
|
-
required: true,
|
|
26
|
-
},
|
|
27
|
-
paymentConfig: {
|
|
28
|
-
type: Object,
|
|
29
|
-
required: true,
|
|
30
|
-
},
|
|
31
|
-
stripePublishableKey: {
|
|
32
|
-
type: String,
|
|
33
|
-
required: true,
|
|
34
|
-
},
|
|
35
|
-
productName: {
|
|
36
|
-
type: String,
|
|
37
|
-
required: false,
|
|
38
|
-
},
|
|
39
|
-
isShop: {
|
|
40
|
-
type: Boolean,
|
|
41
|
-
required: false,
|
|
42
|
-
default: false,
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
data() {
|
|
46
|
-
return {
|
|
47
|
-
cardCvcElement: undefined,
|
|
48
|
-
cardCvcElementError: undefined,
|
|
49
|
-
cardExpiryElement: undefined,
|
|
50
|
-
cardExpiryElementError: undefined,
|
|
51
|
-
cardNumberElement: undefined,
|
|
52
|
-
cardNumberElementError: undefined,
|
|
53
|
-
emailAddress: undefined,
|
|
54
|
-
emailAddressError: undefined,
|
|
55
|
-
isBusy: false,
|
|
56
|
-
isCardCvcValid: false,
|
|
57
|
-
isCardExpiryValid: false,
|
|
58
|
-
isCardNumberValid: false,
|
|
59
|
-
isInitialised: false,
|
|
60
|
-
stripe: undefined,
|
|
61
|
-
submitButtonMessage: 'Pay',
|
|
62
|
-
submitError: undefined,
|
|
63
|
-
};
|
|
64
|
-
},
|
|
65
|
-
computed: {
|
|
66
|
-
amount() {
|
|
67
|
-
return centsToDollars(this.cart.totalAmount).toFixed(2) || '';
|
|
68
|
-
},
|
|
69
|
-
currencyCode() {
|
|
70
|
-
return this.paymentConfig?.defaultCurrency || '';
|
|
71
|
-
},
|
|
72
|
-
currencySymbol() {
|
|
73
|
-
return this.paymentConfig?.defaultCurrencySymbol || '$';
|
|
74
|
-
},
|
|
75
|
-
isStripeElementFormComplete() {
|
|
76
|
-
return (this.isCardCvcValid && this.isCardExpiryValid && this.isCardNumberValid);
|
|
77
|
-
},
|
|
78
|
-
isSubmitButtonEnabled() {
|
|
79
|
-
return (this.isInitialised &&
|
|
80
|
-
this.isStripeElementFormComplete &&
|
|
81
|
-
Boolean(this.emailAddress) &&
|
|
82
|
-
!this.emailAddressError &&
|
|
83
|
-
!this.isBusy);
|
|
84
|
-
},
|
|
85
|
-
arrowStyle() {
|
|
86
|
-
return {
|
|
87
|
-
color: this.buttonStyles.style?.color,
|
|
88
|
-
};
|
|
89
|
-
},
|
|
90
|
-
payButtonStyle() {
|
|
91
|
-
if (!this.buttonStyles || !this.buttonStyles.style) {
|
|
92
|
-
return { ...this.buttonStyles };
|
|
93
|
-
}
|
|
94
|
-
return {
|
|
95
|
-
...this.buttonStyles.style,
|
|
96
|
-
color: this.buttonStyles.style.backgroundColor,
|
|
97
|
-
backgroundColor: this.buttonStyles.style.color,
|
|
98
|
-
};
|
|
99
|
-
},
|
|
100
|
-
containerStyle() {
|
|
101
|
-
const buttonStyle = { ...this.buttonStyles?.style };
|
|
102
|
-
return {
|
|
103
|
-
color: buttonStyle.color,
|
|
104
|
-
};
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
mounted() {
|
|
108
|
-
this.initialiseStripeScript();
|
|
109
|
-
this.initStripeElements();
|
|
110
|
-
},
|
|
111
|
-
methods: {
|
|
112
|
-
initialiseStripeScript() {
|
|
113
|
-
debug('initialiseStripeScript: start');
|
|
114
|
-
const stripeScript = Array.from(document.head.children).find((c) => {
|
|
115
|
-
return (c.tagName.toUpperCase() === SCRIPT_TAG_NAME &&
|
|
116
|
-
c.hasAttribute('src') &&
|
|
117
|
-
c.getAttribute('src') === STRIPE_SCRIPT_URL);
|
|
118
|
-
});
|
|
119
|
-
if (stripeScript) {
|
|
120
|
-
debug('initialiseStripeScript: script exists');
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
const scriptElement = document.createElement(SCRIPT_TAG_NAME);
|
|
124
|
-
scriptElement.setAttribute('src', STRIPE_SCRIPT_URL);
|
|
125
|
-
scriptElement.setAttribute('async', '');
|
|
126
|
-
scriptElement.setAttribute('defer', '');
|
|
127
|
-
document.head.appendChild(scriptElement);
|
|
128
|
-
debug('initialiseStripeScript: script injected');
|
|
129
|
-
},
|
|
130
|
-
initStripeElements() {
|
|
131
|
-
if (!this.stripePublishableKey) {
|
|
132
|
-
debugError('initStripeElements: stripe publishable key undefined');
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
if (typeof window.Stripe !== 'function') {
|
|
136
|
-
setTimeout(() => {
|
|
137
|
-
debug('initStripeElements: waiting for stripe script');
|
|
138
|
-
this.initStripeElements();
|
|
139
|
-
}, 250);
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
debug('initStripeElements: start');
|
|
143
|
-
try {
|
|
144
|
-
this.stripe = window.Stripe(this.stripePublishableKey, {
|
|
145
|
-
stripeAccount: this.cart.paymentProviderExternalId,
|
|
146
|
-
});
|
|
147
|
-
const stripeElements = this.stripe.elements();
|
|
148
|
-
// card number
|
|
149
|
-
this.cardNumberElement = stripeElements.create('cardNumber', {
|
|
150
|
-
style: constants.stripeDefaultStyle,
|
|
151
|
-
placeholder: 'Credit Card Number',
|
|
152
|
-
});
|
|
153
|
-
this.cardNumberElement.mount(this.$refs.cardNumber);
|
|
154
|
-
this.cardNumberElement.addEventListener('change', this.onStripeElementChange);
|
|
155
|
-
// cart expiry
|
|
156
|
-
this.cardExpiryElement = stripeElements.create('cardExpiry', {
|
|
157
|
-
style: constants.stripeDefaultStyle,
|
|
158
|
-
placeholder: 'Expiry',
|
|
159
|
-
});
|
|
160
|
-
this.cardExpiryElement.mount(this.$refs.cardExpiry);
|
|
161
|
-
this.cardExpiryElement.addEventListener('change', this.onStripeElementChange);
|
|
162
|
-
// cart cvc
|
|
163
|
-
this.cardCvcElement = stripeElements.create('cardCvc', {
|
|
164
|
-
style: constants.stripeDefaultStyle,
|
|
165
|
-
placeholder: 'CVV',
|
|
166
|
-
});
|
|
167
|
-
this.cardCvcElement.mount(this.$refs.cardCvc);
|
|
168
|
-
this.cardCvcElement.addEventListener('change', this.onStripeElementChange);
|
|
169
|
-
this.isInitialised = true;
|
|
170
|
-
}
|
|
171
|
-
catch (err) {
|
|
172
|
-
console.error(err);
|
|
173
|
-
}
|
|
174
|
-
debug('initStripeElements: end');
|
|
175
|
-
},
|
|
176
|
-
onBackClick() {
|
|
177
|
-
this.$emit('go-to-payment-option-selection');
|
|
178
|
-
},
|
|
179
|
-
onEmailAddressEvent() {
|
|
180
|
-
this.validateEmailAddress();
|
|
181
|
-
},
|
|
182
|
-
onStripeElementChange(response) {
|
|
183
|
-
if (!response) {
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
switch (response.elementType) {
|
|
187
|
-
case 'cardCvc':
|
|
188
|
-
this.isCardCvcValid = response.complete;
|
|
189
|
-
this.cardCvcElementError = response.error;
|
|
190
|
-
break;
|
|
191
|
-
case 'cardExpiry':
|
|
192
|
-
this.isCardExpiryValid = response.complete;
|
|
193
|
-
this.cardExpiryElementError = response.error;
|
|
194
|
-
break;
|
|
195
|
-
case 'cardNumber':
|
|
196
|
-
this.isCardNumberValid = response.complete;
|
|
197
|
-
this.cardNumberElementError = response.error;
|
|
198
|
-
break;
|
|
199
|
-
}
|
|
200
|
-
},
|
|
201
|
-
async onSubmitPaymentClick() {
|
|
202
|
-
if (!this.cardNumberElement ||
|
|
203
|
-
!this.isSubmitButtonEnabled ||
|
|
204
|
-
!this.stripe ||
|
|
205
|
-
!this.stripePublishableKey ||
|
|
206
|
-
!this.emailAddress) {
|
|
207
|
-
debugError('onSubmitPaymentClick: invalid operation');
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
|
-
this.isBusy = true;
|
|
211
|
-
try {
|
|
212
|
-
const paymentIntentResponse = await brandPageClient.createStripePaymentIntent({
|
|
213
|
-
cartId: this.cart.cartId,
|
|
214
|
-
customerEmail: this.emailAddress,
|
|
215
|
-
customerRequestDetails: this.checkoutInformation.customerRequestDetails,
|
|
216
|
-
customerMessage: this.checkoutInformation.customerMessage,
|
|
217
|
-
});
|
|
218
|
-
if (!paymentIntentResponse) {
|
|
219
|
-
this.submitError =
|
|
220
|
-
'Unable to create payment intent. Please try again.';
|
|
221
|
-
return;
|
|
222
|
-
}
|
|
223
|
-
const confirmCardPaymentResult = await this.stripe.confirmCardPayment(paymentIntentResponse.paymentIntent.client_secret, {
|
|
224
|
-
payment_method: {
|
|
225
|
-
card: this.cardNumberElement,
|
|
226
|
-
},
|
|
227
|
-
});
|
|
228
|
-
if (confirmCardPaymentResult.error) {
|
|
229
|
-
debugError(confirmCardPaymentResult.error);
|
|
230
|
-
this.submitError = confirmCardPaymentResult.error;
|
|
231
|
-
}
|
|
232
|
-
else {
|
|
233
|
-
debug('onSubmitPaymentClick: payment intent success');
|
|
234
|
-
this.$emit('success', { result: confirmCardPaymentResult });
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
finally {
|
|
238
|
-
this.isBusy = false;
|
|
239
|
-
}
|
|
240
|
-
},
|
|
241
|
-
validateEmailAddress() {
|
|
242
|
-
if (!this.emailAddress) {
|
|
243
|
-
this.emailAddressError = new Error(INVALID_EMAIL_MESSAGE());
|
|
244
|
-
return;
|
|
245
|
-
}
|
|
246
|
-
if (!validator.isEmail(this.emailAddress)) {
|
|
247
|
-
this.emailAddressError = new Error(INVALID_EMAIL_MESSAGE());
|
|
248
|
-
return;
|
|
249
|
-
}
|
|
250
|
-
this.emailAddressError = undefined;
|
|
251
|
-
},
|
|
252
|
-
},
|
|
253
|
-
});
|