@revenexx/cover 0.23.0 → 0.24.2
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/app/components/account/orders/AccountOrderPay.vue +5 -1
- package/app/components/auth/AuthRegisterPanel.vue +10 -1
- package/app/components/checkout/onepage/CheckoutAddressSection.vue +2 -2
- package/app/components/checkout/onepage/CheckoutGuestDetailsSection.vue +6 -0
- package/app/components/checkout/onepage/CheckoutNotesSection.vue +2 -0
- package/app/components/checkout/onepage/CheckoutPaymentSection.vue +2 -0
- package/app/components/ui/forms/FormKitDatePicker.vue +1 -1
- package/app/composables/useAuthStore.ts +4 -0
- package/app/composables/useCheckoutOnePage.ts +7 -0
- package/app/shared/signInLink.ts +86 -0
- package/i18n/locales/de/account.json +2 -1
- package/i18n/locales/de/auth.json +2 -0
- package/i18n/locales/de/checkout.json +1 -0
- package/i18n/locales/en/account.json +2 -1
- package/i18n/locales/en/auth.json +2 -0
- package/i18n/locales/en/checkout.json +1 -0
- package/nuxt.config.ts +13 -0
- package/package.json +23 -21
- package/server/api/account/orders/[id]/pay.post.ts +7 -0
- package/server/api/auth/register.post.ts +15 -41
- package/server/api/campaigns/touches.post.ts +1 -1
- package/server/api/orders/index.post.ts +7 -0
- package/server/api/payment/methods.post.ts +11 -4
- package/server/middleware/market-scope.ts +24 -0
- package/server/services/ApiAuthService.ts +14 -3
- package/server/utils/appSettings.ts +1 -1
- package/server/utils/buyerIdentity.ts +28 -1
- package/server/utils/country.ts +71 -12
- package/server/utils/eligiblePaymentMethods.ts +37 -0
- package/server/utils/locale.ts +2 -2
- package/server/utils/market.ts +131 -7
- package/server/utils/orderAttribution.ts +1 -17
- package/server/utils/orderPayment.ts +26 -1
- package/server/utils/registration.ts +149 -0
- package/server/utils/revenexxSdk.ts +33 -6
- package/server/utils/sdkClientAdding.ts +25 -0
|
@@ -136,9 +136,13 @@ async function pay(): Promise<void> {
|
|
|
136
136
|
if (statusCode === 402 || statusCode === 422) {
|
|
137
137
|
attempt.value = crypto.randomUUID();
|
|
138
138
|
}
|
|
139
|
+
const failure = err as { data?: { message?: string; data?: { type?: string } } };
|
|
139
140
|
toast.add({
|
|
140
141
|
title: t("orders.pay.failed"),
|
|
141
|
-
|
|
142
|
+
// A method the merchant does not allow the buyer's company (RAD-513).
|
|
143
|
+
description: failure?.data?.data?.type === "method_not_allowed_for_organization"
|
|
144
|
+
? t("orders.pay.methodNotAllowedForOrganization")
|
|
145
|
+
: failure?.data?.message ?? (err instanceof Error ? err.message : undefined),
|
|
142
146
|
color: "error",
|
|
143
147
|
icon: icon("error"),
|
|
144
148
|
});
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
import { setErrors } from "@formkit/core";
|
|
3
|
+
|
|
2
4
|
import { COUNTRIES } from "../../config/countries";
|
|
3
5
|
import { REQUIRED_MARK, REQUIRED_MARK_LEADING } from "../../config/forms";
|
|
4
6
|
import type { RegisterFormState, RegistrationMode, RegistrationProfile } from "../../interfaces/auth";
|
|
@@ -36,6 +38,8 @@ const vatRequired = computed(() => registration.value?.vatRequired === true);
|
|
|
36
38
|
const needsApproval = computed(() => registration.value?.mode === "approval_required");
|
|
37
39
|
const applied = ref(false);
|
|
38
40
|
|
|
41
|
+
const FORM_ID = "cover-register";
|
|
42
|
+
|
|
39
43
|
/**
|
|
40
44
|
* How far the customers app checks a VAT id.
|
|
41
45
|
*
|
|
@@ -147,7 +151,11 @@ async function onSubmit(): Promise<void> {
|
|
|
147
151
|
emit("success");
|
|
148
152
|
}
|
|
149
153
|
catch {
|
|
150
|
-
// error is set on the store and rendered by UAlert
|
|
154
|
+
// error is set on the store and rendered by UAlert. A VAT id the
|
|
155
|
+
// customers app refused is also marked at its field.
|
|
156
|
+
if (error.value === "auth.register.errors.vatIdInvalid") {
|
|
157
|
+
setErrors(FORM_ID, [], { vatId: t(error.value) });
|
|
158
|
+
}
|
|
151
159
|
}
|
|
152
160
|
}
|
|
153
161
|
</script>
|
|
@@ -223,6 +231,7 @@ async function onSubmit(): Promise<void> {
|
|
|
223
231
|
|
|
224
232
|
<FormKit
|
|
225
233
|
v-if="registrationEnabled && !applied"
|
|
234
|
+
:id="FORM_ID"
|
|
226
235
|
type="form"
|
|
227
236
|
:actions="false"
|
|
228
237
|
@submit="onSubmit"
|
|
@@ -80,7 +80,7 @@ function changeBilling() {
|
|
|
80
80
|
v-if="!profileLoading"
|
|
81
81
|
variant="ghost"
|
|
82
82
|
size="sm"
|
|
83
|
-
class="shrink-0"
|
|
83
|
+
class="shrink-0 min-h-11 lg:min-h-0"
|
|
84
84
|
tabindex="0"
|
|
85
85
|
@click="showShippingPicker = true"
|
|
86
86
|
>
|
|
@@ -155,7 +155,7 @@ function changeBilling() {
|
|
|
155
155
|
v-if="!profileLoading"
|
|
156
156
|
variant="ghost"
|
|
157
157
|
size="sm"
|
|
158
|
-
class="shrink-0"
|
|
158
|
+
class="shrink-0 min-h-11 lg:min-h-0"
|
|
159
159
|
tabindex="0"
|
|
160
160
|
@click="changeBilling"
|
|
161
161
|
>
|
|
@@ -65,6 +65,7 @@ const addressFields: AddressFieldRow[] = [
|
|
|
65
65
|
type="email"
|
|
66
66
|
autocomplete="email"
|
|
67
67
|
class="w-full"
|
|
68
|
+
:ui="{ base: 'min-h-11 lg:min-h-0' }"
|
|
68
69
|
@blur="validateField('guestEmail')"
|
|
69
70
|
/>
|
|
70
71
|
</UFormField>
|
|
@@ -74,6 +75,7 @@ const addressFields: AddressFieldRow[] = [
|
|
|
74
75
|
type="tel"
|
|
75
76
|
autocomplete="tel"
|
|
76
77
|
class="w-full"
|
|
78
|
+
:ui="{ base: 'min-h-11 lg:min-h-0' }"
|
|
77
79
|
/>
|
|
78
80
|
</UFormField>
|
|
79
81
|
</div>
|
|
@@ -98,6 +100,7 @@ const addressFields: AddressFieldRow[] = [
|
|
|
98
100
|
<UInput
|
|
99
101
|
v-model="guestShipping[field.key]"
|
|
100
102
|
class="w-full"
|
|
103
|
+
:ui="{ base: 'min-h-11 lg:min-h-0' }"
|
|
101
104
|
@update:model-value="clearFieldError(`guestShipping.${field.key}`)"
|
|
102
105
|
/>
|
|
103
106
|
</UFormField>
|
|
@@ -111,6 +114,7 @@ const addressFields: AddressFieldRow[] = [
|
|
|
111
114
|
v-model="guestShipping.country"
|
|
112
115
|
:items="countryItems"
|
|
113
116
|
class="w-full"
|
|
117
|
+
:ui="{ base: 'min-h-11 lg:min-h-0' }"
|
|
114
118
|
@update:model-value="clearFieldError('guestShipping.country')"
|
|
115
119
|
/>
|
|
116
120
|
</UFormField>
|
|
@@ -141,6 +145,7 @@ const addressFields: AddressFieldRow[] = [
|
|
|
141
145
|
<UInput
|
|
142
146
|
v-model="guestBilling[field.key]"
|
|
143
147
|
class="w-full"
|
|
148
|
+
:ui="{ base: 'min-h-11 lg:min-h-0' }"
|
|
144
149
|
@update:model-value="clearFieldError(`guestBilling.${field.key}`)"
|
|
145
150
|
/>
|
|
146
151
|
</UFormField>
|
|
@@ -154,6 +159,7 @@ const addressFields: AddressFieldRow[] = [
|
|
|
154
159
|
v-model="guestBilling.country"
|
|
155
160
|
:items="countryItems"
|
|
156
161
|
class="w-full"
|
|
162
|
+
:ui="{ base: 'min-h-11 lg:min-h-0' }"
|
|
157
163
|
@update:model-value="clearFieldError('guestBilling.country')"
|
|
158
164
|
/>
|
|
159
165
|
</UFormField>
|
|
@@ -26,6 +26,7 @@ const { form, isGuest, orderNumberRequired, fieldErrors, validateField } = useCh
|
|
|
26
26
|
v-model="form.orderNumber"
|
|
27
27
|
maxlength="20"
|
|
28
28
|
class="w-full"
|
|
29
|
+
:ui="{ base: 'min-h-11 lg:min-h-0' }"
|
|
29
30
|
:placeholder="t('onepage.orderInfo.orderNumberPlaceholder')"
|
|
30
31
|
@blur="validateField('orderNumber')"
|
|
31
32
|
/>
|
|
@@ -38,6 +39,7 @@ const { form, isGuest, orderNumberRequired, fieldErrors, validateField } = useCh
|
|
|
38
39
|
v-model="form.quoteNumber"
|
|
39
40
|
maxlength="20"
|
|
40
41
|
class="w-full"
|
|
42
|
+
:ui="{ base: 'min-h-11 lg:min-h-0' }"
|
|
41
43
|
:placeholder="t('onepage.orderInfo.quoteNumberPlaceholder')"
|
|
42
44
|
/>
|
|
43
45
|
</UFormField>
|
|
@@ -249,6 +249,7 @@ if (import.meta.client) {
|
|
|
249
249
|
<UInput
|
|
250
250
|
v-model="form.poNumber"
|
|
251
251
|
class="w-full sm:max-w-sm"
|
|
252
|
+
:ui="{ base: 'min-h-11 lg:min-h-0' }"
|
|
252
253
|
:placeholder="t('onepage.payment.poNumberPlaceholder')"
|
|
253
254
|
/>
|
|
254
255
|
</div>
|
|
@@ -263,6 +264,7 @@ if (import.meta.client) {
|
|
|
263
264
|
<USelect
|
|
264
265
|
v-model="form.costCenterId"
|
|
265
266
|
class="w-full sm:max-w-sm"
|
|
267
|
+
:ui="{ base: 'min-h-11 lg:min-h-0' }"
|
|
266
268
|
:items="costCenterOptions"
|
|
267
269
|
/>
|
|
268
270
|
</div>
|
|
@@ -82,7 +82,7 @@ function clear(): void {
|
|
|
82
82
|
type="button"
|
|
83
83
|
tabindex="0"
|
|
84
84
|
:disabled="Boolean(context.disabled)"
|
|
85
|
-
class="w-full flex items-center justify-between gap-2 px-3 py-2 text-sm border rounded-md
|
|
85
|
+
class="w-full min-h-11 lg:min-h-0 flex items-center justify-between gap-2 px-3 py-2 text-sm border rounded-md
|
|
86
86
|
bg-transparent border-(--ui-border) text-left cursor-pointer
|
|
87
87
|
focus:outline-none focus:ring-2 focus:ring-(--ui-primary)"
|
|
88
88
|
:class="calendarValue ? 'text-highlighted' : 'text-muted'"
|
|
@@ -23,6 +23,10 @@ function mapAuthError(err: unknown, context: "login" | "recovery" | "register" =
|
|
|
23
23
|
return "auth.register.errors.emailExists";
|
|
24
24
|
case "registration_disabled":
|
|
25
25
|
return "auth.register.errors.registrationDisabled";
|
|
26
|
+
case "vat_id_invalid":
|
|
27
|
+
return "auth.register.errors.vatIdInvalid";
|
|
28
|
+
case "address_invalid":
|
|
29
|
+
return "auth.register.errors.addressInvalid";
|
|
26
30
|
case "service_unavailable":
|
|
27
31
|
return "auth.errors.serviceUnavailable";
|
|
28
32
|
case "general_rate_limit_exceeded":
|
|
@@ -474,6 +474,13 @@ export function useCheckoutOnePage() {
|
|
|
474
474
|
submitError.value = refusal.message;
|
|
475
475
|
return null;
|
|
476
476
|
}
|
|
477
|
+
// A method the merchant does not allow the buyer's company (RAD-513).
|
|
478
|
+
// The checkout no longer offers one, so this is a page that was open
|
|
479
|
+
// before the merchant changed the list: say so in the buyer's words.
|
|
480
|
+
if ((err as { data?: { data?: { type?: string } } })?.data?.data?.type === "method_not_allowed_for_organization") {
|
|
481
|
+
submitError.value = t("onepage.payment.methodNotAllowedForOrganization");
|
|
482
|
+
return null;
|
|
483
|
+
}
|
|
477
484
|
submitError.value = err instanceof Error
|
|
478
485
|
? err.message
|
|
479
486
|
: t("onepage.errors.submitError");
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a sign-in link carries beside the secret (RAD-472).
|
|
3
|
+
*
|
|
4
|
+
* A mailed link carries `userId` and `secret` only. The link a sales rep opens
|
|
5
|
+
* when acting for a buyer carries more: where the shop should open
|
|
6
|
+
* (`landing`), the handover entry (`acting`), and the buyer's `market`,
|
|
7
|
+
* `locale` and `currency`. The link's values are a suggestion for where the
|
|
8
|
+
* buyer starts, never a grant: each is checked for its form here, and the shop
|
|
9
|
+
* then treats it exactly like the same choice made in the locale selector.
|
|
10
|
+
*
|
|
11
|
+
* Pure functions, shared by the link page and the server redirect in front of
|
|
12
|
+
* it, so both read a link the same way.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { localeLanguage, normalizeLocaleCode } from "./locale";
|
|
16
|
+
|
|
17
|
+
/** Where a handed-over buyer lands, as the sales-reps app names it. */
|
|
18
|
+
export type SignInLanding = "home" | "quick_order";
|
|
19
|
+
|
|
20
|
+
export interface SignInLinkPreferences {
|
|
21
|
+
readonly landing?: SignInLanding;
|
|
22
|
+
readonly market?: string;
|
|
23
|
+
/** The full locale code, `de-DE`, or a bare language, `de`. */
|
|
24
|
+
readonly locale?: string;
|
|
25
|
+
/** The locale's language, `de`. */
|
|
26
|
+
readonly language?: string;
|
|
27
|
+
readonly currency?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const LANDINGS: readonly SignInLanding[] = ["home", "quick_order"];
|
|
31
|
+
const MARKET_CODE = /^[a-z][a-z0-9_]{0,62}$/;
|
|
32
|
+
const LOCALE_CODE = /^[a-z]{2,3}(?:-[A-Z]{2})?$/;
|
|
33
|
+
const CURRENCY_CODE = /^[A-Z]{3}$/;
|
|
34
|
+
|
|
35
|
+
const text = (value: unknown): string => (typeof value === "string" ? value.trim() : "");
|
|
36
|
+
|
|
37
|
+
/** The values of a link's query the shop may follow; anything malformed is left out. */
|
|
38
|
+
export function signInLinkPreferences(query: Readonly<Record<string, unknown>>): SignInLinkPreferences {
|
|
39
|
+
const landing = text(query.landing);
|
|
40
|
+
const market = text(query.market).toLowerCase();
|
|
41
|
+
const locale = normalizeLocaleCode(text(query.locale));
|
|
42
|
+
const currency = text(query.currency).toUpperCase();
|
|
43
|
+
return {
|
|
44
|
+
...(LANDINGS.includes(landing as SignInLanding) ? { landing: landing as SignInLanding } : {}),
|
|
45
|
+
...(MARKET_CODE.test(market) ? { market } : {}),
|
|
46
|
+
...(LOCALE_CODE.test(locale) ? { locale, language: localeLanguage(locale) } : {}),
|
|
47
|
+
...(CURRENCY_CODE.test(currency) ? { currency } : {}),
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* The page a signed-in link opens: the home page or the cart, whose quick entry
|
|
53
|
+
* is the shop's fast product entry, where the link names a landing; the
|
|
54
|
+
* account, as before, where it names none.
|
|
55
|
+
*/
|
|
56
|
+
export function signInLinkDestination(preferences: SignInLinkPreferences): string {
|
|
57
|
+
switch (preferences.landing) {
|
|
58
|
+
case "home": return "/";
|
|
59
|
+
case "quick_order": return "/cart";
|
|
60
|
+
default: return "/account";
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The language-prefixed address of the link page for a link that arrived
|
|
66
|
+
* without a prefix, or null when it needs none.
|
|
67
|
+
*
|
|
68
|
+
* Links are minted as `/login/link`, which a shop that prefixes every page with
|
|
69
|
+
* its language does not serve. The link's own `locale` decides the language
|
|
70
|
+
* where the shop speaks it, so a handed-over English buyer lands in English;
|
|
71
|
+
* otherwise the shop's default language.
|
|
72
|
+
*/
|
|
73
|
+
export function prefixedSignInLinkPath(
|
|
74
|
+
path: string,
|
|
75
|
+
query: Readonly<Record<string, unknown>>,
|
|
76
|
+
languages: readonly string[],
|
|
77
|
+
defaultLanguage: string,
|
|
78
|
+
): string | null {
|
|
79
|
+
const [pathname = "", search = ""] = path.split("?");
|
|
80
|
+
if (pathname.replace(/\/+$/, "") !== "/login/link") {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
const wanted = signInLinkPreferences(query).language;
|
|
84
|
+
const language = wanted && languages.includes(wanted) ? wanted : defaultLanguage;
|
|
85
|
+
return `/${language}/login/link${search ? `?${search}` : ""}`;
|
|
86
|
+
}
|
|
@@ -174,7 +174,8 @@
|
|
|
174
174
|
"failed": "Die Zahlung ist nicht durchgegangen",
|
|
175
175
|
"due": "Diese Bestellung wartet auf Ihre Zahlung",
|
|
176
176
|
"unavailable": "Diese Zahlungsart ist für diese Bestellung gerade nicht verfügbar. Bitte kontaktieren Sie uns.",
|
|
177
|
-
"settled": "Diese Bestellung wartet nicht mehr auf eine Zahlung."
|
|
177
|
+
"settled": "Diese Bestellung wartet nicht mehr auf eine Zahlung.",
|
|
178
|
+
"methodNotAllowedForOrganization": "Diese Zahlart steht für Ihr Unternehmen nicht zur Verfügung."
|
|
178
179
|
},
|
|
179
180
|
"messages": {
|
|
180
181
|
"title": "Nachrichten zu dieser Bestellung",
|
|
@@ -29,6 +29,8 @@
|
|
|
29
29
|
"emailFormat": "Bitte geben Sie eine gültige E-Mail-Adresse ein",
|
|
30
30
|
"passwordsMismatch": "Passwörter stimmen nicht überein",
|
|
31
31
|
"registrationDisabled": "Die Registrierung ist derzeit geschlossen. Bitte kontaktieren Sie uns, um ein Konto einzurichten.",
|
|
32
|
+
"vatIdInvalid": "Die USt-IdNr. wurde nicht angenommen. Bitte prüfen Sie die Nummer.",
|
|
33
|
+
"addressInvalid": "Die Rechnungsadresse wurde nicht angenommen. Bitte prüfen Sie Straße, PLZ, Ort und Land.",
|
|
32
34
|
"emailExists": "Für diese E-Mail-Adresse besteht bereits ein Konto. Bitte melden Sie sich an oder setzen Sie Ihr Passwort zurück.",
|
|
33
35
|
"network": "Server nicht erreichbar. Bitte prüfen Sie Ihre Verbindung und versuchen Sie es erneut.",
|
|
34
36
|
"unknown": "Etwas ist schiefgelaufen. Bitte versuchen Sie es erneut."
|
|
@@ -163,6 +163,7 @@
|
|
|
163
163
|
"cardDetails": "Kartendaten",
|
|
164
164
|
"cardOnProviderPage": "Sie geben Ihre Kartendaten nach dem Absenden auf der Zahlungsseite des Anbieters ein.",
|
|
165
165
|
"cardFieldUnavailable": "Das Kartenfeld ist gerade nicht verfügbar. Bitte versuchen Sie es erneut oder wählen Sie eine andere Zahlungsart.",
|
|
166
|
+
"methodNotAllowedForOrganization": "Diese Zahlart steht für Ihr Unternehmen nicht zur Verfügung.",
|
|
166
167
|
"change": "Ändern",
|
|
167
168
|
"noMethod": "Keine Zahlungsmethode ausgewählt",
|
|
168
169
|
"confirm": "Bestätigen",
|
|
@@ -174,7 +174,8 @@
|
|
|
174
174
|
"failed": "The payment did not go through",
|
|
175
175
|
"due": "This order is waiting for your payment",
|
|
176
176
|
"unavailable": "This payment method cannot be used for this order right now. Please contact us.",
|
|
177
|
-
"settled": "This order is no longer waiting for a payment."
|
|
177
|
+
"settled": "This order is no longer waiting for a payment.",
|
|
178
|
+
"methodNotAllowedForOrganization": "This payment method is not available for your company."
|
|
178
179
|
},
|
|
179
180
|
"messages": {
|
|
180
181
|
"title": "Messages about this order",
|
|
@@ -29,6 +29,8 @@
|
|
|
29
29
|
"emailFormat": "Please enter a valid email address",
|
|
30
30
|
"passwordsMismatch": "Passwords do not match",
|
|
31
31
|
"registrationDisabled": "Registration is currently closed. Please contact us to set up an account.",
|
|
32
|
+
"vatIdInvalid": "The VAT ID was not accepted. Please check the number.",
|
|
33
|
+
"addressInvalid": "The billing address was not accepted. Please check street, postcode, city and country.",
|
|
32
34
|
"emailExists": "An account with this email address already exists. Please sign in, or reset your password.",
|
|
33
35
|
"network": "Server unreachable. Please check your connection and try again.",
|
|
34
36
|
"unknown": "Something went wrong. Please try again."
|
|
@@ -163,6 +163,7 @@
|
|
|
163
163
|
"cardDetails": "Card details",
|
|
164
164
|
"cardOnProviderPage": "After you place the order, you enter your card details on the payment provider's page.",
|
|
165
165
|
"cardFieldUnavailable": "The card field is not available right now. Please try again or choose another payment method.",
|
|
166
|
+
"methodNotAllowedForOrganization": "This payment method is not available for your company.",
|
|
166
167
|
"change": "Change",
|
|
167
168
|
"noMethod": "No payment method selected",
|
|
168
169
|
"confirm": "Confirm",
|
package/nuxt.config.ts
CHANGED
|
@@ -149,11 +149,20 @@ export default defineNuxtConfig({
|
|
|
149
149
|
// (PE-1103) writes the JSON-LD: a WebSite and WebPage on every page, the
|
|
150
150
|
// Organization from the rules (useSeoHead), Product and BreadcrumbList from
|
|
151
151
|
// the product and category pages.
|
|
152
|
+
//
|
|
153
|
+
// Analytics: @revenexx/beats-nuxt sends page views and the theme events
|
|
154
|
+
// (theme-events/1, mapped onto beats commerce events) to beats. There is
|
|
155
|
+
// no key here: the platform's Site router sets x-revenexx-beats-key on
|
|
156
|
+
// each request to the tenant's ingest key (and drops client copies), and
|
|
157
|
+
// the module hands it to the browser. A host without a key (a preview, the
|
|
158
|
+
// docs website, local dev) sends nothing. Cookieless; nothing identifies
|
|
159
|
+
// the visitor.
|
|
152
160
|
modules: [
|
|
153
161
|
"@formkit/nuxt",
|
|
154
162
|
"@nuxt/scripts",
|
|
155
163
|
"@revenexx/consent-manager-nuxt",
|
|
156
164
|
"@revenexx/tag-manager-nuxt",
|
|
165
|
+
"@revenexx/beats-nuxt",
|
|
157
166
|
"nuxt-site-config",
|
|
158
167
|
"nuxt-seo-utils",
|
|
159
168
|
"nuxt-schema-org",
|
|
@@ -161,6 +170,10 @@ export default defineNuxtConfig({
|
|
|
161
170
|
"nuxt-og-image",
|
|
162
171
|
],
|
|
163
172
|
|
|
173
|
+
beats: {
|
|
174
|
+
apiHost: "https://beats.revenexx.com",
|
|
175
|
+
},
|
|
176
|
+
|
|
164
177
|
// Broken links while developing; a production build has no use for it.
|
|
165
178
|
$development: {
|
|
166
179
|
modules: ["nuxt-link-checker"],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@revenexx/cover",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.2",
|
|
4
4
|
"description": "Cover — revenexx design system for Nuxt. Distributed as a Nuxt layer: generic UI components, theming tokens and stores shared by the demo shop, custom storefronts and the Blokkli theme.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./nuxt.config.ts",
|
|
@@ -34,38 +34,40 @@
|
|
|
34
34
|
"./validations/*": "./app/validations/*.ts"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@formkit/barcode": "^1.0
|
|
38
|
-
"@formkit/core": "^
|
|
39
|
-
"@formkit/i18n": "^
|
|
40
|
-
"@formkit/nuxt": "^
|
|
41
|
-
"@formkit/themes": "^
|
|
42
|
-
"@formkit/vue": "^
|
|
43
|
-
"@iconify-json/lucide": "^1.2.
|
|
44
|
-
"@internationalized/date": "^3.12.
|
|
37
|
+
"@formkit/barcode": "^1.1.0",
|
|
38
|
+
"@formkit/core": "^2.9.0",
|
|
39
|
+
"@formkit/i18n": "^2.9.0",
|
|
40
|
+
"@formkit/nuxt": "^2.9.0",
|
|
41
|
+
"@formkit/themes": "^2.9.0",
|
|
42
|
+
"@formkit/vue": "^2.9.0",
|
|
43
|
+
"@iconify-json/lucide": "^1.2.157",
|
|
44
|
+
"@internationalized/date": "^3.12.4",
|
|
45
45
|
"@nuxt/scripts": "^1.3.0",
|
|
46
46
|
"@nuxtjs/robots": "7.0.2",
|
|
47
|
-
"@revenexx/
|
|
48
|
-
"@revenexx/
|
|
49
|
-
"@revenexx/
|
|
50
|
-
"@revenexx/
|
|
51
|
-
"@
|
|
52
|
-
"@
|
|
47
|
+
"@revenexx/beats-nuxt": "0.2.0",
|
|
48
|
+
"@revenexx/consent-manager-nuxt": "^0.1.1",
|
|
49
|
+
"@revenexx/sdk": "^0.9.0",
|
|
50
|
+
"@revenexx/storage-model-viewer": "^0.3.1",
|
|
51
|
+
"@revenexx/tag-manager-nuxt": "^0.1.1",
|
|
52
|
+
"@takumi-rs/core": "2.22.1",
|
|
53
|
+
"@vueuse/core": "^15.0.0",
|
|
53
54
|
"nuxt-link-checker": "6.0.1",
|
|
54
55
|
"nuxt-og-image": "7.0.7",
|
|
55
56
|
"nuxt-schema-org": "7.0.1",
|
|
56
|
-
"nuxt-seo-utils": "9.0.
|
|
57
|
+
"nuxt-seo-utils": "9.0.2",
|
|
57
58
|
"nuxt-site-config": "5.0.3",
|
|
58
|
-
"typesense": "^3.0
|
|
59
|
+
"typesense": "^3.2.0"
|
|
59
60
|
},
|
|
60
61
|
"peerDependencies": {
|
|
61
62
|
"@nuxt/ui": "^4.5.1",
|
|
62
|
-
"pinia": "^3.0.4",
|
|
63
|
+
"pinia": "^3.0.4 || ^4.0.0",
|
|
63
64
|
"vue": "^3.5.0",
|
|
64
|
-
"vue-i18n": "^11.
|
|
65
|
+
"vue-i18n": "^11.4.23"
|
|
65
66
|
},
|
|
66
67
|
"devDependencies": {
|
|
67
|
-
"@nuxt/kit": "^4.6.
|
|
68
|
-
"nuxt": "^4.6.
|
|
68
|
+
"@nuxt/kit": "^4.6.4",
|
|
69
|
+
"nuxt": "^4.6.4",
|
|
70
|
+
"pinia": "^4.1.0"
|
|
69
71
|
},
|
|
70
72
|
"publishConfig": {
|
|
71
73
|
"registry": "https://registry.npmjs.org",
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
|
+
isMethodRefusedForOrganization,
|
|
3
|
+
methodRefusedForOrganizationError,
|
|
2
4
|
orderAwaitsPayment,
|
|
3
5
|
orderPaymentRequest,
|
|
4
6
|
paymentCustomerOf,
|
|
@@ -94,6 +96,11 @@ export default defineEventHandler(async (event) => {
|
|
|
94
96
|
});
|
|
95
97
|
}
|
|
96
98
|
catch (err) {
|
|
99
|
+
// The merchant limited the buyer's company to other methods.
|
|
100
|
+
if (isMethodRefusedForOrganization(err)) {
|
|
101
|
+
getLogService().warn(`Payment method for order ${number} refused for the organization`, apiErrorContext(err));
|
|
102
|
+
throw methodRefusedForOrganizationError();
|
|
103
|
+
}
|
|
97
104
|
// 409 is payments saying the order does not owe this — already paid, or
|
|
98
105
|
// in another currency; 400/422 a method or instrument it refused. All of
|
|
99
106
|
// them are the buyer's to read.
|
|
@@ -1,19 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
mode: "new" | "existing";
|
|
3
|
-
company: string;
|
|
4
|
-
vatId?: string;
|
|
5
|
-
customerNumber?: string;
|
|
6
|
-
address?: {
|
|
7
|
-
street: string;
|
|
8
|
-
streetNumber: string;
|
|
9
|
-
zip: string;
|
|
10
|
-
city: string;
|
|
11
|
-
country: string;
|
|
12
|
-
};
|
|
13
|
-
salutation?: string;
|
|
14
|
-
jobTitle?: string;
|
|
15
|
-
phone?: string;
|
|
16
|
-
}
|
|
1
|
+
import type { RegistrationProfilePayload } from "../../utils/registration";
|
|
17
2
|
|
|
18
3
|
interface RegisterPayload {
|
|
19
4
|
email: string;
|
|
@@ -63,35 +48,17 @@ export default defineEventHandler(async (event) => {
|
|
|
63
48
|
return user;
|
|
64
49
|
}
|
|
65
50
|
|
|
66
|
-
// Public-API mode: the customers app is the system of record
|
|
67
|
-
//
|
|
68
|
-
//
|
|
69
|
-
//
|
|
70
|
-
// registration creates the organization (and its platform team) in the
|
|
71
|
-
// same call; the contact mirrors to a platform user behind the scenes.
|
|
72
|
-
const fullName = (name ?? "").trim();
|
|
73
|
-
const splitAt = fullName.lastIndexOf(" ");
|
|
74
|
-
const firstName = splitAt > 0 ? fullName.slice(0, splitAt) : fullName;
|
|
75
|
-
const lastName = splitAt > 0 ? fullName.slice(splitAt + 1) : "";
|
|
76
|
-
|
|
51
|
+
// Public-API mode: the customers app is the system of record and gets the
|
|
52
|
+
// whole form — company, VAT id, customer number, contact details and the
|
|
53
|
+
// billing address (RAD-507). The JSON request store above is mock-only:
|
|
54
|
+
// in a live shop nobody reads it, and a redeploy loses it.
|
|
77
55
|
try {
|
|
78
|
-
const { contact, user_id: userId } = await
|
|
79
|
-
email,
|
|
80
|
-
password,
|
|
81
|
-
...(firstName ? { firstName } : {}),
|
|
82
|
-
...(lastName ? { lastName } : {}),
|
|
83
|
-
...(profile?.company ? { organizationName: profile.company } : {}),
|
|
84
|
-
locale: await resolveStoreLocale(event),
|
|
85
|
-
}) as unknown as {
|
|
56
|
+
const { contact, user_id: userId } = await registerCustomer<{
|
|
86
57
|
contact: { id: string; email: string };
|
|
87
58
|
user_id: string;
|
|
88
|
-
};
|
|
59
|
+
}>({ email, password, name, profile, locale: await resolveStoreLocale(event) });
|
|
89
60
|
|
|
90
|
-
|
|
91
|
-
if (profile?.company) {
|
|
92
|
-
await persistRegistrationRequest(user, profile);
|
|
93
|
-
}
|
|
94
|
-
return user;
|
|
61
|
+
return { $id: userId, name: splitFullName(name).fullName || email, email: contact.email };
|
|
95
62
|
}
|
|
96
63
|
catch (err) {
|
|
97
64
|
// The tenant turned self-registration off — a deliberate 403 the
|
|
@@ -100,6 +67,13 @@ export default defineEventHandler(async (event) => {
|
|
|
100
67
|
if (err instanceof RevenexxException && err.code === 403) {
|
|
101
68
|
throw createError({ statusCode: 403, data: { type: "registration_disabled" } });
|
|
102
69
|
}
|
|
70
|
+
// A field of the form the customers app refused — the VAT id, the
|
|
71
|
+
// billing address. The form shows it at that field instead of a
|
|
72
|
+
// generic failure.
|
|
73
|
+
const fieldError = registrationFieldErrorType(err);
|
|
74
|
+
if (fieldError) {
|
|
75
|
+
throw createError({ statusCode: 400, data: { type: fieldError } });
|
|
76
|
+
}
|
|
103
77
|
if (isApiUserError(err)) {
|
|
104
78
|
throw createError({ statusCode: err.code, data: { type: apiAuthErrorType(err) } });
|
|
105
79
|
}
|
|
@@ -25,7 +25,7 @@ export default defineEventHandler(async (event) => {
|
|
|
25
25
|
return { recorded: 0 };
|
|
26
26
|
}
|
|
27
27
|
const contactId = sessionOrderRefs(event).contact_id;
|
|
28
|
-
const market =
|
|
28
|
+
const market = requestMarket(event);
|
|
29
29
|
const sessionKey = getOrCreateCartSessionId(event);
|
|
30
30
|
try {
|
|
31
31
|
await getMarketingService(event).recordTouches(event, touches.map(touch => ({
|
|
@@ -7,6 +7,8 @@ import { orderLinePrices, type PriceResolveAnswer } from "../../utils/orderLineP
|
|
|
7
7
|
import { toIsoCountry } from "../../utils/country";
|
|
8
8
|
import {
|
|
9
9
|
checkoutTakesPayment,
|
|
10
|
+
isMethodRefusedForOrganization,
|
|
11
|
+
methodRefusedForOrganizationError,
|
|
10
12
|
orderPaymentRequest,
|
|
11
13
|
paymentCustomerOf,
|
|
12
14
|
recordOrderPaymentStatus,
|
|
@@ -662,6 +664,11 @@ export default defineEventHandler(async (event) => {
|
|
|
662
664
|
if (isError(err)) {
|
|
663
665
|
throw err;
|
|
664
666
|
}
|
|
667
|
+
// The merchant limited the buyer's company to other methods.
|
|
668
|
+
if (isMethodRefusedForOrganization(err)) {
|
|
669
|
+
getLogService().warn("Payment method refused for the organization", apiErrorContext(err));
|
|
670
|
+
throw methodRefusedForOrganizationError();
|
|
671
|
+
}
|
|
665
672
|
// 409 is payments refusing a payment its order does not owe.
|
|
666
673
|
if (err instanceof RevenexxException && [400, 409, 422].includes(err.code)) {
|
|
667
674
|
getLogService().error("Payment rejected", apiErrorContext(err));
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import type { PaymentOption } from "../../../app/interfaces/payment";
|
|
2
|
+
import { eligiblePaymentMethods } from "../../utils/eligiblePaymentMethods";
|
|
2
3
|
import type { Locale } from "../../utils/locale";
|
|
3
|
-
import {
|
|
4
|
+
import { paymentOptionOf } from "../../utils/paymentOptions";
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* The checkout's payment question — "what can THIS buyer pay with?".
|
|
7
8
|
* Live mode resolves against the payments app (restrictions + fees are
|
|
8
9
|
* evaluated server-side there); mock mode answers the demo profile's
|
|
9
|
-
* static methods. Body: { amount, country, currency? }
|
|
10
|
+
* static methods. Body: { amount, country, currency? }; the buyer's
|
|
11
|
+
* organization is added from the verified session, never from the body.
|
|
10
12
|
*/
|
|
11
13
|
export default defineEventHandler(async (event) => {
|
|
12
14
|
const { amount = 0, country = "", currency = "EUR" } = await readBody<{
|
|
@@ -25,11 +27,16 @@ export default defineEventHandler(async (event) => {
|
|
|
25
27
|
|
|
26
28
|
const locale: Locale = resolveLocale(event);
|
|
27
29
|
try {
|
|
28
|
-
|
|
30
|
+
// The buyer's company, when they are signed in for one: a merchant may
|
|
31
|
+
// limit it to some methods, and the payments app filters by it
|
|
32
|
+
// (RAD-513). Verified for this request, never taken from the body.
|
|
33
|
+
const { organization_id: organizationId } = sessionOrderRefs(event);
|
|
34
|
+
const methods = await eligiblePaymentMethods({
|
|
29
35
|
amount,
|
|
30
36
|
country,
|
|
31
37
|
currency,
|
|
32
|
-
|
|
38
|
+
...(organizationId ? { organizationId } : {}),
|
|
39
|
+
});
|
|
33
40
|
|
|
34
41
|
const options: PaymentOption[] = methods.map(m => paymentOptionOf(m, locale));
|
|
35
42
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Paths that never call an app: the bundler's, @nuxt/image's, the OG images,
|
|
3
|
+
* module plumbing under `/api/_`, and anything that names a file.
|
|
4
|
+
*/
|
|
5
|
+
const NO_APP_CALLS = ["/_nuxt/", "/__nuxt", "/_ipx/", "/_og/", "/@", "/node_modules/", "/api/_"];
|
|
6
|
+
const FILE_PATH = /\.[a-z0-9]{2,5}$/i;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Decide the request's market before any handler calls an app (RAD-479).
|
|
10
|
+
*
|
|
11
|
+
* The shop used to send `X-Revenexx-Market` only when the buyer had picked a
|
|
12
|
+
* market, so a buyer who never touched the selector created carts that
|
|
13
|
+
* belonged to no market. Resolved here once, every SDK call of the request
|
|
14
|
+
* carries it (useRevenexxSdk reads requestMarket()): the buyer's choice, else
|
|
15
|
+
* the market the domain is bound to in Experience Studio (RAD-471), else the
|
|
16
|
+
* tenant's default market.
|
|
17
|
+
*/
|
|
18
|
+
export default defineEventHandler(async (event) => {
|
|
19
|
+
const path = event.path.split("?")[0] ?? "";
|
|
20
|
+
if (FILE_PATH.test(path) || NO_APP_CALLS.some(prefix => path.startsWith(prefix))) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
await resolveRequestMarket(event);
|
|
24
|
+
});
|