@revenexx/cover 0.14.0 → 0.16.0
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/api/account.ts +1 -0
- package/app/components/RevenexxForm.vue +183 -19
- package/app/components/account/address/AccountAddressCard.vue +8 -2
- package/app/components/account/address/AccountAddressView.vue +5 -1
- package/app/components/account/carts/AccountCartsTable.vue +85 -3
- package/app/components/account/dashboard/AccountDashboardBudgets.vue +2 -1
- package/app/components/account/dashboard/AccountDashboardRecentOrders.vue +2 -1
- package/app/components/account/dashboard/AccountDashboardRequisitions.vue +2 -1
- package/app/components/account/directorder/AccountDirectOrder.vue +100 -12
- package/app/components/account/governance/AccountApprovalLimitsTable.vue +124 -8
- package/app/components/account/governance/AccountCostCenterDetail.vue +3 -2
- package/app/components/account/governance/AccountCostCentersTable.vue +133 -6
- package/app/components/account/governance/AccountRequisitionDetail.vue +2 -1
- package/app/components/account/governance/AccountRequisitionsTable.vue +102 -6
- package/app/components/account/governance/AccountWorkflowDetail.vue +3 -2
- package/app/components/account/governance/AccountWorkflowsTable.vue +76 -1
- package/app/components/account/governance/GovernanceApprovalLimitModal.vue +8 -0
- package/app/components/account/governance/GovernanceCostCenterModal.vue +7 -0
- package/app/components/account/governance/GovernanceWorkflowModal.vue +7 -0
- package/app/components/account/orderlists/AccountOrderListDetail.vue +14 -4
- package/app/components/account/orderlists/AccountOrderListsTable.vue +115 -7
- package/app/components/account/orders/AccountOrderDetail.vue +67 -3
- package/app/components/account/orders/AccountOrderPay.vue +211 -0
- package/app/components/account/orders/AccountOrdersTable.vue +119 -10
- package/app/components/account/organization/AccountOrganization.vue +6 -0
- package/app/components/account/profile/AccountPasswordForm.vue +2 -0
- package/app/components/account/profile/AccountProfileForm.vue +4 -0
- package/app/components/account/quotes/AccountQuoteDetail.vue +7 -10
- package/app/components/account/team/AccountTeam.vue +91 -0
- package/app/components/auth/AuthLoginTeaser.vue +1 -1
- package/app/components/auth/AuthRegisterPanel.vue +22 -3
- package/app/components/cart/manage/CartNameModal.vue +4 -0
- package/app/components/checkout/onepage/CheckoutAddressSection.vue +5 -1
- package/app/components/checkout/onepage/CheckoutGuestDetailsSection.vue +9 -1
- package/app/components/checkout/onepage/CheckoutSummarySection.vue +6 -1
- package/app/components/form/FormPage.vue +7 -4
- package/app/components/layout/footer/Footer.vue +15 -2
- package/app/components/layout/header/LocaleSwitcher.vue +79 -12
- package/app/components/ui/forms/PasswordInput.vue +2 -0
- package/app/components/ui/forms/SearchInput.vue +205 -8
- package/app/components/ui/table/TableCardList.vue +69 -0
- package/app/components/ui/table/TableSortButton.vue +1 -1
- package/app/components/ui/table/TableToolbar.vue +2 -0
- package/app/components/withdrawal/WithdrawalDeclaration.vue +286 -0
- package/app/composables/useCheckoutOnePage.ts +22 -0
- package/app/composables/useMobileTableSort.ts +82 -0
- package/app/composables/useProductCard.ts +14 -0
- package/app/composables/useProductListing.ts +27 -1
- package/app/composables/useSearchEvents.ts +67 -0
- package/app/config/forms.ts +8 -0
- package/app/config/navigation.ts +8 -0
- package/app/formkit.config.ts +21 -0
- package/app/interfaces/account/order-list.ts +11 -0
- package/app/interfaces/account/quotes.ts +7 -3
- package/app/interfaces/market.ts +7 -0
- package/app/pages/punchout/transfer.vue +36 -1
- package/app/pages/widerruf.vue +33 -0
- package/app/plugins/search-events.client.ts +41 -0
- package/app/shared/addressLines.ts +66 -0
- package/app/shared/checkoutAddressRefusal.ts +63 -0
- package/app/shared/locale.ts +133 -0
- package/app/shared/searchAttribution.ts +91 -0
- package/app/shared/themeEvents.ts +1 -1
- package/i18n/locales/de/account.json +13 -1
- package/i18n/locales/de/cart.json +1 -0
- package/i18n/locales/de/checkout.json +1 -1
- package/i18n/locales/de/common.json +7 -0
- package/i18n/locales/de/search.json +7 -0
- package/i18n/locales/de/withdrawal.json +34 -0
- package/i18n/locales/en/account.json +13 -1
- package/i18n/locales/en/cart.json +1 -0
- package/i18n/locales/en/checkout.json +1 -1
- package/i18n/locales/en/common.json +7 -0
- package/i18n/locales/en/search.json +7 -0
- package/i18n/locales/en/withdrawal.json +34 -0
- package/nuxt.config.ts +3 -0
- package/package.json +1 -1
- package/server/api/account/orders/[id]/pay.post.ts +100 -0
- package/server/api/account/orders/[id].get.ts +5 -1
- package/server/api/account/quotes/[id]/order.post.ts +22 -22
- package/server/api/brands.get.ts +3 -2
- package/server/api/categories/[slug]/subcategories.get.ts +9 -6
- package/server/api/forms/[slug].get.ts +1 -3
- package/server/api/orders/index.post.ts +33 -50
- package/server/api/products/index.get.ts +6 -1
- package/server/api/punchout/return.post.ts +3 -1
- package/server/api/search/events.post.ts +65 -0
- package/server/api/typesense/search.post.ts +12 -1
- package/server/api/typesense/suggest.post.ts +43 -22
- package/server/data/forms/authored.json +69 -8
- package/server/dev/errorHandler.ts +47 -0
- package/server/interfaces/brand.ts +3 -2
- package/server/interfaces/product.ts +5 -0
- package/server/interfaces/punchout.ts +5 -0
- package/server/middleware/missing-media.ts +35 -0
- package/server/middleware/punchout-hand-back-csp.ts +17 -0
- package/server/plugins/vue-devtools-sink.ts +28 -0
- package/server/services/ApiBrandService.ts +8 -8
- package/server/services/ApiMarketService.ts +9 -2
- package/server/services/ApiProductService.ts +1 -1
- package/server/services/MockFormsService.ts +3 -1
- package/server/utils/addressRefusal.ts +63 -0
- package/server/utils/country.ts +23 -0
- package/server/utils/forms.ts +23 -1
- package/server/utils/liveOrders.ts +44 -2
- package/server/utils/locale.ts +58 -4
- package/server/utils/orderPayment.ts +155 -0
- package/server/utils/punchoutFormAction.ts +44 -0
- package/server/utils/searchClient.ts +27 -4
- package/server/utils/searchEvents.ts +46 -0
- package/server/utils/searchMultiSearchFallback.ts +2 -0
- package/server/utils/searchSuggest.ts +207 -0
- package/server/utils/suggestTiles.ts +141 -0
|
@@ -53,6 +53,13 @@
|
|
|
53
53
|
"searchPlaceholder": "In dieser Kategorie suchen…",
|
|
54
54
|
"allProducts": "Alle Produkte",
|
|
55
55
|
"productCount": "{count} Produkt | {count} Produkte"
|
|
56
|
+
},
|
|
57
|
+
"suggest": {
|
|
58
|
+
"categories": "Kategorien",
|
|
59
|
+
"manufacturers": "Hersteller",
|
|
60
|
+
"products": "Produkte",
|
|
61
|
+
"pages": "Seiten",
|
|
62
|
+
"productCount": "{count} Artikel"
|
|
56
63
|
}
|
|
57
64
|
}
|
|
58
65
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"withdrawal": {
|
|
3
|
+
"cta": "Vertrag widerrufen",
|
|
4
|
+
"title": "Vertrag widerrufen",
|
|
5
|
+
"intro": "Hier erklären Sie den Widerruf eines Vertrags, den Sie bei uns geschlossen haben. Sie brauchen dafür kein Kundenkonto und müssen keinen Grund angeben.",
|
|
6
|
+
"requiredHint": "Mit * markierte Felder sind Pflichtfelder.",
|
|
7
|
+
"fields": {
|
|
8
|
+
"name": "Name",
|
|
9
|
+
"email": "E-Mail-Adresse",
|
|
10
|
+
"emailHelp": "An diese Adresse senden wir die Eingangsbestätigung Ihres Widerrufs.",
|
|
11
|
+
"orderId": "Bestellnummer",
|
|
12
|
+
"orderIdHelp": "Steht in Ihrer Bestellbestätigung.",
|
|
13
|
+
"statement": "Ihre Erklärung",
|
|
14
|
+
"statementHelp": "Nennen Sie gern, welche Artikel Sie widerrufen, wenn es nicht die ganze Bestellung ist."
|
|
15
|
+
},
|
|
16
|
+
"defaultStatement": "Hiermit widerrufe ich den von mir abgeschlossenen Vertrag über die Bestellung {order}.",
|
|
17
|
+
"defaultStatementNoOrder": "Hiermit widerrufe ich den von mir abgeschlossenen Vertrag.",
|
|
18
|
+
"confirm": "Widerruf bestätigen",
|
|
19
|
+
"errors": {
|
|
20
|
+
"nameRequired": "Bitte geben Sie Ihren Namen an.",
|
|
21
|
+
"emailRequired": "Bitte geben Sie Ihre E-Mail-Adresse an.",
|
|
22
|
+
"emailInvalid": "Bitte geben Sie eine gültige E-Mail-Adresse an.",
|
|
23
|
+
"orderIdRequired": "Bitte geben Sie die Bestellnummer an.",
|
|
24
|
+
"statementRequired": "Bitte formulieren Sie Ihre Widerrufserklärung.",
|
|
25
|
+
"failed": "Ihr Widerruf konnte nicht übermittelt werden. Bitte versuchen Sie es noch einmal oder erklären Sie den Widerruf per E-Mail an uns.",
|
|
26
|
+
"rejected": "Ihr Widerruf ist nicht angekommen. Bitte versuchen Sie es noch einmal oder erklären Sie den Widerruf per E-Mail an uns."
|
|
27
|
+
},
|
|
28
|
+
"done": {
|
|
29
|
+
"title": "Ihr Widerruf ist eingegangen",
|
|
30
|
+
"receivedAt": "Eingegangen am {date}",
|
|
31
|
+
"intro": "Wir haben Ihre Widerrufserklärung mit folgenden Angaben erhalten. Eine Bestätigung senden wir Ihnen zusätzlich per E-Mail."
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -150,6 +150,18 @@
|
|
|
150
150
|
"done": "Order cancelled",
|
|
151
151
|
"failed": "The order could not be cancelled"
|
|
152
152
|
},
|
|
153
|
+
"pay": {
|
|
154
|
+
"action": "Pay now",
|
|
155
|
+
"title": "Pay order {number}",
|
|
156
|
+
"intro": "This order is waiting for your payment of {amount}.",
|
|
157
|
+
"method": "Payment method",
|
|
158
|
+
"confirm": "Pay {amount}",
|
|
159
|
+
"done": "Thank you — the payment is on its way",
|
|
160
|
+
"failed": "The payment did not go through",
|
|
161
|
+
"due": "This order is waiting for your payment",
|
|
162
|
+
"unavailable": "This payment method cannot be used for this order right now. Please contact us.",
|
|
163
|
+
"settled": "This order is no longer waiting for a payment."
|
|
164
|
+
},
|
|
153
165
|
"messages": {
|
|
154
166
|
"title": "Messages about this order",
|
|
155
167
|
"you": "You",
|
|
@@ -741,7 +753,7 @@
|
|
|
741
753
|
"note": "Note for the order (optional)",
|
|
742
754
|
"terms": "Our terms and conditions apply to your order.",
|
|
743
755
|
"cancel": "Cancel",
|
|
744
|
-
"submit": "Place
|
|
756
|
+
"submit": "Place order and pay",
|
|
745
757
|
"success": "Order {number} placed",
|
|
746
758
|
"failed": "Order failed"
|
|
747
759
|
},
|
|
@@ -191,6 +191,7 @@
|
|
|
191
191
|
"page": {
|
|
192
192
|
"title": "Carts",
|
|
193
193
|
"description": "All carts you are currently filling — switch, rename or delete them here.",
|
|
194
|
+
"positionsCount": "{count} item | {count} items",
|
|
194
195
|
"searchPlaceholder": "Search by name…",
|
|
195
196
|
"columns": {
|
|
196
197
|
"name": "Name",
|
|
@@ -148,7 +148,7 @@
|
|
|
148
148
|
"promoCode": "Promo Code",
|
|
149
149
|
"promoCodePlaceholder": "Promo code",
|
|
150
150
|
"applyPromo": "Apply",
|
|
151
|
-
"placeOrder": "Place
|
|
151
|
+
"placeOrder": "Place order and pay",
|
|
152
152
|
"backToCart": "Back to Cart",
|
|
153
153
|
"termsText": "I accept the {link}",
|
|
154
154
|
"termsLink": "Terms & Conditions and Privacy Policy",
|
|
@@ -101,6 +101,13 @@
|
|
|
101
101
|
},
|
|
102
102
|
"table": {
|
|
103
103
|
"filterAll": "All",
|
|
104
|
+
"sortBy": "Sort by",
|
|
105
|
+
"sortAsc": "{column} (A–Z)",
|
|
106
|
+
"sortDesc": "{column} (Z–A)",
|
|
107
|
+
"sortNewest": "{column} (newest first)",
|
|
108
|
+
"sortOldest": "{column} (oldest first)",
|
|
109
|
+
"sortHigh": "{column} (highest first)",
|
|
110
|
+
"sortLow": "{column} (lowest first)",
|
|
104
111
|
"noResults": {
|
|
105
112
|
"title": "No matches",
|
|
106
113
|
"description": "Adjust your search or filters to see results."
|
|
@@ -53,6 +53,13 @@
|
|
|
53
53
|
"searchPlaceholder": "Search within this category…",
|
|
54
54
|
"allProducts": "All products",
|
|
55
55
|
"productCount": "{count} product | {count} products"
|
|
56
|
+
},
|
|
57
|
+
"suggest": {
|
|
58
|
+
"categories": "Categories",
|
|
59
|
+
"manufacturers": "Manufacturers",
|
|
60
|
+
"products": "Products",
|
|
61
|
+
"pages": "Pages",
|
|
62
|
+
"productCount": "{count} item | {count} items"
|
|
56
63
|
}
|
|
57
64
|
}
|
|
58
65
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"withdrawal": {
|
|
3
|
+
"cta": "Withdraw from contract",
|
|
4
|
+
"title": "Withdraw from contract",
|
|
5
|
+
"intro": "Use this page to withdraw from a contract you concluded with us. You do not need a customer account and you do not have to give a reason.",
|
|
6
|
+
"requiredHint": "Fields marked * are required.",
|
|
7
|
+
"fields": {
|
|
8
|
+
"name": "Name",
|
|
9
|
+
"email": "Email address",
|
|
10
|
+
"emailHelp": "We send the confirmation of receipt of your withdrawal to this address.",
|
|
11
|
+
"orderId": "Order number",
|
|
12
|
+
"orderIdHelp": "You find it in your order confirmation.",
|
|
13
|
+
"statement": "Your declaration",
|
|
14
|
+
"statementHelp": "If you are not withdrawing from the whole order, tell us which items it concerns."
|
|
15
|
+
},
|
|
16
|
+
"defaultStatement": "I hereby withdraw from the contract I concluded for order {order}.",
|
|
17
|
+
"defaultStatementNoOrder": "I hereby withdraw from the contract I concluded.",
|
|
18
|
+
"confirm": "Confirm withdrawal",
|
|
19
|
+
"errors": {
|
|
20
|
+
"nameRequired": "Please enter your name.",
|
|
21
|
+
"emailRequired": "Please enter your email address.",
|
|
22
|
+
"emailInvalid": "Please enter a valid email address.",
|
|
23
|
+
"orderIdRequired": "Please enter the order number.",
|
|
24
|
+
"statementRequired": "Please state your declaration of withdrawal.",
|
|
25
|
+
"failed": "Your withdrawal could not be sent. Please try again or declare your withdrawal to us by email.",
|
|
26
|
+
"rejected": "Your withdrawal did not reach us. Please try again or declare your withdrawal to us by email."
|
|
27
|
+
},
|
|
28
|
+
"done": {
|
|
29
|
+
"title": "Your withdrawal has been received",
|
|
30
|
+
"receivedAt": "Received on {date}",
|
|
31
|
+
"intro": "We have received your declaration of withdrawal with the details below. We will also send you a confirmation by email."
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
package/nuxt.config.ts
CHANGED
|
@@ -188,6 +188,9 @@ export default defineNuxtConfig({
|
|
|
188
188
|
if (!useNuxt().options.dev) {
|
|
189
189
|
return;
|
|
190
190
|
}
|
|
191
|
+
// Nitro's dev error handler leaks WebAssembly memory per error — see the
|
|
192
|
+
// handler for the full story.
|
|
193
|
+
nitroConfig.errorHandler = resolve(currentDir, "server/dev/errorHandler.ts");
|
|
191
194
|
nitroConfig.handlers = [
|
|
192
195
|
...(nitroConfig.handlers ?? []),
|
|
193
196
|
...["seed", "drop", "health"].map(name => ({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@revenexx/cover",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
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",
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { orderAwaitsPayment, orderPaymentRequest, recordOrderPaymentStatus } from "../../../../utils/orderPayment";
|
|
2
|
+
|
|
3
|
+
interface PayOrderPayload {
|
|
4
|
+
/** PSP single-use token from the order page's card field. */
|
|
5
|
+
paymentInstrument?: { token?: string };
|
|
6
|
+
/** Where the PSP returns the buyer after a redirect/3DS step-up. */
|
|
7
|
+
returnUrl?: string;
|
|
8
|
+
/** One per attempt, so a double click pays once. */
|
|
9
|
+
idempotencyKey?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The buyer pays an order that took no payment at the checkout (RAD-173).
|
|
14
|
+
*
|
|
15
|
+
* An order that waited for somebody's approval was not paid when it was
|
|
16
|
+
* requested — there was nothing to pay for yet. Once approved it is placed and
|
|
17
|
+
* open, and this is where its payment is made: the order's own method, over the
|
|
18
|
+
* order's own total, naming the order so the payments app can refuse a payment
|
|
19
|
+
* the order does not owe.
|
|
20
|
+
*
|
|
21
|
+
* Their own order only, as with cancelling: somebody else's is a 404.
|
|
22
|
+
*/
|
|
23
|
+
export default defineEventHandler(async (event) => {
|
|
24
|
+
const number = getRouterParam(event, "id") ?? "";
|
|
25
|
+
const body = await readBody<PayOrderPayload>(event).catch(() => ({} as PayOrderPayload));
|
|
26
|
+
|
|
27
|
+
const user = await getAuthService(event).me(event);
|
|
28
|
+
if (!user) {
|
|
29
|
+
throw createError({ statusCode: 401, message: "Unauthorized" });
|
|
30
|
+
}
|
|
31
|
+
if (resolveOrderServiceKey(event) !== "api" || resolvePaymentServiceKey(event) !== "api") {
|
|
32
|
+
throw createError({ statusCode: 501, message: "This storefront does not take payments on demo data" });
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const order = await getLiveOrderByNumber(number, user.contactId);
|
|
36
|
+
if (!order) {
|
|
37
|
+
throw createError({ statusCode: 404, message: "Order not found" });
|
|
38
|
+
}
|
|
39
|
+
const idempotencyKey = typeof body?.idempotencyKey === "string" && body.idempotencyKey.trim()
|
|
40
|
+
? `order-${order.id}-${body.idempotencyKey.trim()}`
|
|
41
|
+
: `order-${order.id}-${crypto.randomUUID()}`;
|
|
42
|
+
|
|
43
|
+
// Asked again here, the same question the page asked: a stale page must not
|
|
44
|
+
// pay an order that meanwhile was paid, called off, or is still waiting for
|
|
45
|
+
// its approval — nor one an older payment already sits on. The payment this
|
|
46
|
+
// same attempt made is not in the way: it goes through to payments, which
|
|
47
|
+
// replays it. A method is part of the answer; read here so the type says so.
|
|
48
|
+
//
|
|
49
|
+
// 409 and not a refusal: nothing went wrong, the order simply owes nothing
|
|
50
|
+
// now, and the page tells the buyer that rather than "did not go through".
|
|
51
|
+
const method = order.payment?.method;
|
|
52
|
+
if (!method || !(await orderAwaitsPayment(event, order, idempotencyKey))) {
|
|
53
|
+
throw createError({
|
|
54
|
+
statusCode: 409,
|
|
55
|
+
message: "This order is not waiting for a payment",
|
|
56
|
+
data: { type: "not_awaiting_payment" },
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
let created: { id: string; status: string; error_message?: string | null; next_action?: { type?: string; url?: string } | null };
|
|
61
|
+
try {
|
|
62
|
+
created = await useRevenexxSdk().call<typeof created>("POST", "/v1/payments", {
|
|
63
|
+
body: orderPaymentRequest({
|
|
64
|
+
method,
|
|
65
|
+
amount: Number(order.grand_total),
|
|
66
|
+
currency: order.currency,
|
|
67
|
+
country: paymentCountry(order) ?? "",
|
|
68
|
+
orderRef: order.number,
|
|
69
|
+
orderId: order.id,
|
|
70
|
+
contactId: principalContactId(event),
|
|
71
|
+
idempotencyKey,
|
|
72
|
+
token: body?.paymentInstrument?.token,
|
|
73
|
+
returnUrl: body?.returnUrl,
|
|
74
|
+
}),
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
catch (err) {
|
|
78
|
+
// 409 is payments saying the order does not owe this — already paid, or
|
|
79
|
+
// in another currency; 400/422 a method or instrument it refused. All of
|
|
80
|
+
// them are the buyer's to read.
|
|
81
|
+
if (err instanceof RevenexxException && [400, 409, 422].includes(err.code)) {
|
|
82
|
+
getLogService().error(`Payment for order ${number} rejected`, apiErrorContext(err));
|
|
83
|
+
throw createError({ statusCode: 422, message: err.message });
|
|
84
|
+
}
|
|
85
|
+
getLogService().error(`Payment for order ${number} failed`, apiErrorContext(err));
|
|
86
|
+
throw createError({ statusCode: 502, message: "Payment service unavailable" });
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (created.status === "failed") {
|
|
90
|
+
throw createError({ statusCode: 402, message: created.error_message ?? "Payment was declined" });
|
|
91
|
+
}
|
|
92
|
+
await recordOrderPaymentStatus(order.id, created.status);
|
|
93
|
+
|
|
94
|
+
// The PSP needs the buyer (3DS / redirect PSPs): hand the redirect back, the
|
|
95
|
+
// payment settles on their return.
|
|
96
|
+
if (created.status === "requires_action" && created.next_action?.url) {
|
|
97
|
+
return { status: "requires-action" as const, requiresAction: true, redirectUrl: created.next_action.url, paymentId: created.id };
|
|
98
|
+
}
|
|
99
|
+
return { status: created.status, requiresAction: false, paymentId: created.id };
|
|
100
|
+
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AccountOrder, AccountOrderListResponse } from "../../../../app/interfaces/account/order-list";
|
|
2
|
+
import { orderAwaitsPayment } from "../../../utils/orderPayment";
|
|
2
3
|
|
|
3
4
|
/** Single order from the account history (live: by display number). */
|
|
4
5
|
export default defineEventHandler(async (event) => {
|
|
@@ -15,7 +16,10 @@ export default defineEventHandler(async (event) => {
|
|
|
15
16
|
if (!order) {
|
|
16
17
|
throw createError({ statusCode: 404, message: "Order not found" });
|
|
17
18
|
}
|
|
18
|
-
|
|
19
|
+
// Whether it waits for the buyer's payment (RAD-173) — asked here, on
|
|
20
|
+
// the one order the page shows, because only the payments app can say
|
|
21
|
+
// whether a payment already sits on it.
|
|
22
|
+
return { ...mapLiveOrderToAccount(order), payable: await orderAwaitsPayment(event, order) };
|
|
19
23
|
}
|
|
20
24
|
catch (err) {
|
|
21
25
|
if (isError(err)) {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { OrderPaymentStatus } from "@revenexx/sdk";
|
|
2
1
|
import type { Models } from "@revenexx/sdk";
|
|
3
2
|
|
|
4
3
|
import type { QuoteOrderPayload, QuoteOrderResult } from "../../../../../app/interfaces/account/quotes";
|
|
4
|
+
import { addressRefusalOf } from "../../../../utils/addressRefusal";
|
|
5
|
+
import { toIsoCountry } from "../../../../utils/country";
|
|
6
|
+
import { orderPaymentRequest, recordOrderPaymentStatus } from "../../../../utils/orderPayment";
|
|
5
7
|
|
|
6
8
|
/**
|
|
7
9
|
* Order a quote at the quoted figures (RX-783).
|
|
@@ -17,15 +19,6 @@ import type { QuoteOrderPayload, QuoteOrderResult } from "../../../../../app/int
|
|
|
17
19
|
* stacking a campaign on top of it is a decision the merchant makes in the
|
|
18
20
|
* price, not one the storefront makes afterwards.
|
|
19
21
|
*/
|
|
20
|
-
function toIsoCountry(value: unknown): string {
|
|
21
|
-
const raw = String(value ?? "").trim();
|
|
22
|
-
if (/^[A-Za-z]{2}$/.test(raw)) {
|
|
23
|
-
return raw.toUpperCase();
|
|
24
|
-
}
|
|
25
|
-
const names: Record<string, string> = { deutschland: "DE", germany: "DE", österreich: "AT", austria: "AT", schweiz: "CH", switzerland: "CH" };
|
|
26
|
-
return names[raw.toLowerCase()] ?? raw;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
22
|
export default defineEventHandler(async (event): Promise<QuoteOrderResult> => {
|
|
30
23
|
const id = getRouterParam(event, "id") ?? "";
|
|
31
24
|
const body = await readBody<QuoteOrderPayload>(event).catch(() => ({} as QuoteOrderPayload));
|
|
@@ -136,6 +129,11 @@ export default defineEventHandler(async (event): Promise<QuoteOrderResult> => {
|
|
|
136
129
|
// order and can place it by hand, which beats a buyer retrying into a
|
|
137
130
|
// second acceptance of a quote that has nothing left open.
|
|
138
131
|
getLogService().error(`Order placement for quote ${quote.number} failed after acceptance`, apiErrorContext(err));
|
|
132
|
+
// An address the orders app refuses names the field; say which (RAD-236).
|
|
133
|
+
const badAddress = addressRefusalOf(err);
|
|
134
|
+
if (badAddress) {
|
|
135
|
+
throw createError({ statusCode: 422, message: badAddress.message, data: { type: "invalid_address", ...badAddress } });
|
|
136
|
+
}
|
|
139
137
|
if (err instanceof RevenexxException && (err.code === 400 || err.code === 422)) {
|
|
140
138
|
throw createError({ statusCode: 422, message: err.message });
|
|
141
139
|
}
|
|
@@ -146,22 +144,24 @@ export default defineEventHandler(async (event): Promise<QuoteOrderResult> => {
|
|
|
146
144
|
const payerContactId = principalContactId(event);
|
|
147
145
|
try {
|
|
148
146
|
const payment = await sdk.call<{ id: string; status: string }>("POST", "/v1/payments", {
|
|
149
|
-
body: {
|
|
150
|
-
|
|
151
|
-
amount:
|
|
147
|
+
body: orderPaymentRequest({
|
|
148
|
+
method: paymentMethod,
|
|
149
|
+
amount: placed.grand_total ?? view.grandTotal,
|
|
152
150
|
currency: draft.currency,
|
|
153
|
-
|
|
154
|
-
|
|
151
|
+
// The type's key first; the old flat one is what a draft carried before (RAD-236).
|
|
152
|
+
country: toIsoCountry(
|
|
153
|
+
draft.billing_address?.country_code ?? draft.billing_address?.country
|
|
154
|
+
?? draft.shipping_address?.country_code ?? draft.shipping_address?.country,
|
|
155
|
+
),
|
|
156
|
+
orderRef: placed.number,
|
|
157
|
+
orderId: placed.id,
|
|
155
158
|
// The buyer's own payment, listed on their payments page (RAD-171).
|
|
156
|
-
|
|
157
|
-
|
|
159
|
+
contactId: payerContactId,
|
|
160
|
+
idempotencyKey: `quote-${quote.id}-${placed.id}`,
|
|
158
161
|
metadata: { quote_number: quote.number },
|
|
159
|
-
},
|
|
162
|
+
}),
|
|
160
163
|
});
|
|
161
|
-
|
|
162
|
-
? OrderPaymentStatus.Paid
|
|
163
|
-
: payment.status === "authorized" ? OrderPaymentStatus.Authorized : OrderPaymentStatus.Pending;
|
|
164
|
-
await useTenantSdk().orders.ordersPaymentStatusUpdate({ id: placed.id, status: mapped });
|
|
164
|
+
await recordOrderPaymentStatus(placed.id, payment.status);
|
|
165
165
|
}
|
|
166
166
|
catch (err) {
|
|
167
167
|
// An invoice order stands without a captured payment; the payment
|
package/server/api/brands.get.ts
CHANGED
|
@@ -16,9 +16,10 @@ export default defineEventHandler(async (event) => {
|
|
|
16
16
|
try {
|
|
17
17
|
const service = getBrandService(event);
|
|
18
18
|
const locale = resolveLocale(event);
|
|
19
|
+
const searchLocale = await resolveMarketLocale(event);
|
|
19
20
|
return wantsAll
|
|
20
|
-
? await service.listBrandNames(locale)
|
|
21
|
-
: await service.listBrands(limit, locale);
|
|
21
|
+
? await service.listBrandNames(locale, searchLocale)
|
|
22
|
+
: await service.listBrands(limit, locale, searchLocale);
|
|
22
23
|
}
|
|
23
24
|
catch (err) {
|
|
24
25
|
getLogService().error("Service error: brands/list", toErrorContext(err));
|
|
@@ -85,7 +85,7 @@ function toTiles(
|
|
|
85
85
|
* the view the category page's listing asks, so the cards and the filter rail
|
|
86
86
|
* can never disagree. The service pins locale and enabled products.
|
|
87
87
|
*/
|
|
88
|
-
async function liveCounts(categorySlug: string, locale: Locale): Promise<Map<string, number>> {
|
|
88
|
+
async function liveCounts(categorySlug: string, locale: Locale, searchLocale: string): Promise<Map<string, number>> {
|
|
89
89
|
const { branchOf } = await liveSubcategoryIndex(categorySlug, locale);
|
|
90
90
|
const leafCodes = await liveCategorySubtreeCodes([categorySlug]);
|
|
91
91
|
if (!leafCodes.length) {
|
|
@@ -96,7 +96,7 @@ async function liveCounts(categorySlug: string, locale: Locale): Promise<Map<str
|
|
|
96
96
|
view: "category",
|
|
97
97
|
filters: { categories: leafCodes },
|
|
98
98
|
perPage: 1,
|
|
99
|
-
locale,
|
|
99
|
+
locale: searchLocale,
|
|
100
100
|
});
|
|
101
101
|
|
|
102
102
|
return rollUpSubcategoryCounts(
|
|
@@ -114,7 +114,7 @@ async function liveCounts(categorySlug: string, locale: Locale): Promise<Map<str
|
|
|
114
114
|
* which is exactly how this looked when it was broken. A child whose lookup
|
|
115
115
|
* fails keeps its icon; the others keep their images.
|
|
116
116
|
*/
|
|
117
|
-
async function liveImages(categorySlug: string, locale: Locale): Promise<Map<string, string>> {
|
|
117
|
+
async function liveImages(categorySlug: string, locale: Locale, searchLocale: string): Promise<Map<string, string>> {
|
|
118
118
|
const { branchOf } = await liveSubcategoryIndex(categorySlug, locale);
|
|
119
119
|
|
|
120
120
|
// Invert leaf → child into child → its leaves. No extra catalogue call: the
|
|
@@ -134,7 +134,7 @@ async function liveImages(categorySlug: string, locale: Locale): Promise<Map<str
|
|
|
134
134
|
view: "category",
|
|
135
135
|
filters: { categories: leavesByChild.get(child) ?? [child] },
|
|
136
136
|
perPage: 1,
|
|
137
|
-
locale,
|
|
137
|
+
locale: searchLocale,
|
|
138
138
|
})));
|
|
139
139
|
|
|
140
140
|
const failed = results.find((r): r is PromiseRejectedResult => r.status === "rejected");
|
|
@@ -267,14 +267,17 @@ export default defineEventHandler(async (event): Promise<SubcategoryTile[]> => {
|
|
|
267
267
|
}
|
|
268
268
|
|
|
269
269
|
const isLive = resolveProductServiceKey(event) === "api";
|
|
270
|
+
// The market's locale for this page: the counts must come from the same
|
|
271
|
+
// language index the category listing searches (PE-866).
|
|
272
|
+
const searchLocale = isLive ? await resolveMarketLocale(event) : locale;
|
|
270
273
|
|
|
271
274
|
const [counts, images] = await Promise.all([
|
|
272
275
|
(isLive
|
|
273
|
-
? liveCounts(category.slug, locale)
|
|
276
|
+
? liveCounts(category.slug, locale, searchLocale)
|
|
274
277
|
: mockCounts(category.slug)
|
|
275
278
|
).catch(degrade<number>("product counts")),
|
|
276
279
|
(isLive
|
|
277
|
-
? liveImages(category.slug, locale)
|
|
280
|
+
? liveImages(category.slug, locale, searchLocale)
|
|
278
281
|
: mockImages(category.slug, category.subcategories)
|
|
279
282
|
).catch(degrade<string>("preview images")),
|
|
280
283
|
]);
|
|
@@ -25,9 +25,7 @@ export default defineEventHandler(async (event): Promise<FormPublic> => {
|
|
|
25
25
|
name: form.name,
|
|
26
26
|
slug: form.slug,
|
|
27
27
|
definition: localizeDefinition(definition, form.settings, locale),
|
|
28
|
-
settings: form.settings
|
|
29
|
-
? { submit_label: form.settings.submit_label, success_message: form.settings.success_message }
|
|
30
|
-
: null,
|
|
28
|
+
settings: localizeSettings(form.settings, locale),
|
|
31
29
|
// Never a name the form itself declares: a decoy that collides with a
|
|
32
30
|
// real field would drop the visitor's own answer.
|
|
33
31
|
honeypot: policy.honeypotField && !namedFields(definition).has(policy.honeypotField)
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PromotionsRedemptionsReleaseReason } from "@revenexx/sdk";
|
|
2
2
|
import type { Models } from "@revenexx/sdk";
|
|
3
3
|
|
|
4
|
+
import { addressRefusalOf } from "../../utils/addressRefusal";
|
|
4
5
|
import { type EligibleMethodFee, paymentFee } from "../../utils/paymentFee";
|
|
5
6
|
import { orderLinePrices, type PriceResolveAnswer } from "../../utils/orderLinePrices";
|
|
7
|
+
import { toIsoCountry } from "../../utils/country";
|
|
8
|
+
import { checkoutTakesPayment, orderPaymentRequest, recordOrderPaymentStatus } from "../../utils/orderPayment";
|
|
6
9
|
|
|
7
10
|
// Method codes are generic — live mode validates them against the
|
|
8
11
|
// payments app; the demo-only methods keep their extra fields.
|
|
@@ -47,30 +50,6 @@ function isNonEmptyString(v: unknown): v is string {
|
|
|
47
50
|
return typeof v === "string" && v.trim().length > 0;
|
|
48
51
|
}
|
|
49
52
|
|
|
50
|
-
// Customer addresses may carry the country as a display name ("Deutschland",
|
|
51
|
-
// "Austria") — the payments app's eligibility check expects ISO 3166-1
|
|
52
|
-
// alpha-2 codes. Two-letter values pass through unchanged.
|
|
53
|
-
const COUNTRY_NAME_TO_ISO: Record<string, string> = {
|
|
54
|
-
deutschland: "DE", germany: "DE",
|
|
55
|
-
österreich: "AT", austria: "AT",
|
|
56
|
-
schweiz: "CH", switzerland: "CH",
|
|
57
|
-
niederlande: "NL", netherlands: "NL",
|
|
58
|
-
frankreich: "FR", france: "FR",
|
|
59
|
-
italien: "IT", italy: "IT",
|
|
60
|
-
spanien: "ES", spain: "ES",
|
|
61
|
-
belgien: "BE", belgium: "BE",
|
|
62
|
-
polen: "PL", poland: "PL",
|
|
63
|
-
tschechien: "CZ", "czech republic": "CZ", czechia: "CZ",
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
function toIsoCountry(value: unknown): string {
|
|
67
|
-
const raw = String(value ?? "").trim();
|
|
68
|
-
if (/^[A-Za-z]{2}$/.test(raw)) {
|
|
69
|
-
return raw.toUpperCase();
|
|
70
|
-
}
|
|
71
|
-
return COUNTRY_NAME_TO_ISO[raw.toLowerCase()] ?? raw;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
53
|
function validateAddress(address: Record<string, unknown>, customerType: "business" | "private"): string | null {
|
|
75
54
|
const requiredFields = customerType === "private"
|
|
76
55
|
? REQUIRED_ADDRESS_FIELDS_PRIVATE
|
|
@@ -539,6 +518,17 @@ export default defineEventHandler(async (event) => {
|
|
|
539
518
|
if (isError(err)) {
|
|
540
519
|
throw err;
|
|
541
520
|
}
|
|
521
|
+
// An address the orders app holds to its country's rules and
|
|
522
|
+
// refuses: the sentence goes to the field it names, so the buyer
|
|
523
|
+
// corrects that rather than reading a generic failure (RAD-236).
|
|
524
|
+
const badAddress = addressRefusalOf(err);
|
|
525
|
+
if (badAddress) {
|
|
526
|
+
throw createError({
|
|
527
|
+
status: 422,
|
|
528
|
+
message: badAddress.message,
|
|
529
|
+
data: { type: "invalid_address", ...badAddress },
|
|
530
|
+
});
|
|
531
|
+
}
|
|
542
532
|
if (err instanceof RevenexxException && (err.code === 400 || err.code === 422)) {
|
|
543
533
|
throw createError({ status: 422, message: err.message });
|
|
544
534
|
}
|
|
@@ -563,11 +553,15 @@ export default defineEventHandler(async (event) => {
|
|
|
563
553
|
// eligibility (countries, order-value bounds) is enforced there
|
|
564
554
|
// again; a declined payment fails the order with 402 (and cancels
|
|
565
555
|
// the already placed live order).
|
|
556
|
+
//
|
|
557
|
+
// Not for a purchase that waits for a (demo) approval (RAD-173): there
|
|
558
|
+
// is no order to pay yet, and the approval may never produce one. It is
|
|
559
|
+
// paid from the order's page once somebody approved it.
|
|
566
560
|
let livePaymentStatus: string | null = null;
|
|
567
561
|
// Set when the PSP needs buyer action (3DS step-up / redirect PSPs) —
|
|
568
562
|
// the checkout hands the buyer to redirectUrl and confirms on return.
|
|
569
563
|
let pendingAction: { paymentId: string; redirectUrl: string } | null = null;
|
|
570
|
-
if (livePayments) {
|
|
564
|
+
if (checkoutTakesPayment(livePayments, blockingApprovals.length > 0)) {
|
|
571
565
|
const totalRow = calculation.totals.find(row => row.key === "total");
|
|
572
566
|
const address = body.address as Record<string, unknown> | undefined;
|
|
573
567
|
const billing = address?.billingAddressSameAsShipping === false
|
|
@@ -584,25 +578,23 @@ export default defineEventHandler(async (event) => {
|
|
|
584
578
|
"POST",
|
|
585
579
|
"/v1/payments",
|
|
586
580
|
{
|
|
587
|
-
body: {
|
|
588
|
-
|
|
581
|
+
body: orderPaymentRequest({
|
|
582
|
+
method: payment.method,
|
|
589
583
|
// Charge exactly what the orders app computed (incl. shipping tax).
|
|
590
|
-
amount:
|
|
584
|
+
amount: liveOrderTotal ?? totalRow?.amount ?? 0,
|
|
591
585
|
currency: selectedCurrency ?? calculation.currency,
|
|
592
586
|
country,
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
...(instrument?.token ? { token: instrument.token } : {}),
|
|
600
|
-
...(body.returnUrl ? { return_url: body.returnUrl } : {}),
|
|
587
|
+
orderRef: orderId,
|
|
588
|
+
orderId: liveOrderUuid,
|
|
589
|
+
contactId: payerContactId,
|
|
590
|
+
idempotencyKey: body.checkoutSessionToken,
|
|
591
|
+
token: instrument?.token,
|
|
592
|
+
returnUrl: body.returnUrl,
|
|
601
593
|
metadata: {
|
|
602
594
|
...(payment.poNumber ? { po_number: payment.poNumber } : {}),
|
|
603
595
|
...(payment.costCenter ? { cost_center: payment.costCenter } : {}),
|
|
604
596
|
},
|
|
605
|
-
},
|
|
597
|
+
}),
|
|
606
598
|
},
|
|
607
599
|
);
|
|
608
600
|
if (created.status === "failed") {
|
|
@@ -627,7 +619,8 @@ export default defineEventHandler(async (event) => {
|
|
|
627
619
|
if (isError(err)) {
|
|
628
620
|
throw err;
|
|
629
621
|
}
|
|
630
|
-
|
|
622
|
+
// 409 is payments refusing a payment its order does not owe.
|
|
623
|
+
if (err instanceof RevenexxException && [400, 409, 422].includes(err.code)) {
|
|
631
624
|
getLogService().error("Payment rejected", apiErrorContext(err));
|
|
632
625
|
throw createError({ status: 422, message: err.message });
|
|
633
626
|
}
|
|
@@ -637,18 +630,8 @@ export default defineEventHandler(async (event) => {
|
|
|
637
630
|
}
|
|
638
631
|
|
|
639
632
|
// The payment dimension of the live order follows the payment outcome.
|
|
640
|
-
// The payments app's terminal "paid" state is `captured` (PSP auto/
|
|
641
|
-
// manual capture); `succeeded`/`paid` are accepted as synonyms.
|
|
642
633
|
if (liveOrderUuid && livePaymentStatus) {
|
|
643
|
-
|
|
644
|
-
? OrderPaymentStatus.Paid
|
|
645
|
-
: livePaymentStatus === "authorized" ? OrderPaymentStatus.Authorized : OrderPaymentStatus.Pending;
|
|
646
|
-
try {
|
|
647
|
-
await useTenantSdk().orders.ordersPaymentStatusUpdate({ id: liveOrderUuid, status: mapped });
|
|
648
|
-
}
|
|
649
|
-
catch (err) {
|
|
650
|
-
getLogService().error("Order payment-status sync failed", apiErrorContext(err));
|
|
651
|
-
}
|
|
634
|
+
await recordOrderPaymentStatus(liveOrderUuid, livePaymentStatus);
|
|
652
635
|
}
|
|
653
636
|
|
|
654
637
|
// The live cart freezes as the order source (best-effort).
|
|
@@ -7,7 +7,12 @@ export default defineEventHandler(async (event) => {
|
|
|
7
7
|
try {
|
|
8
8
|
// Catalog shell only — price + availability are the Offer domain,
|
|
9
9
|
// resolved separately via POST /api/offers (never blocks the catalog).
|
|
10
|
-
return await getProductService(event).listProducts({
|
|
10
|
+
return await getProductService(event).listProducts({
|
|
11
|
+
category,
|
|
12
|
+
subcategory,
|
|
13
|
+
locale,
|
|
14
|
+
searchLocale: await resolveMarketLocale(event),
|
|
15
|
+
});
|
|
11
16
|
}
|
|
12
17
|
catch (err) {
|
|
13
18
|
getLogService().error("Service error: products/list", toErrorContext(err));
|
|
@@ -51,7 +51,9 @@ export default defineEventHandler(async (event): Promise<PunchoutReturnPayload>
|
|
|
51
51
|
throw createError({ statusCode: 503, data: { type: "service_unavailable" } });
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
// The origin goes on the visit so the hand-back page can be answered with a
|
|
55
|
+
// `form-action` that lets the browser submit there (PE-994).
|
|
56
|
+
updatePunchoutVisit(event, { handedBack: true, handBackOrigin: handBackOrigin(payload.target_url) });
|
|
55
57
|
|
|
56
58
|
// Sign out only once the payload is in hand: a logout that ran first would
|
|
57
59
|
// be a visit closed with the cart still here.
|