@revenexx/cover 0.20.0 → 0.21.1

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.
Files changed (57) hide show
  1. package/app/components/account/approvals/AccountPendingApprovals.vue +54 -13
  2. package/app/components/account/approvals/AccountPendingOrderDetail.vue +156 -0
  3. package/app/components/account/orders/AccountOrderContents.vue +142 -0
  4. package/app/components/account/orders/AccountOrderDetail.vue +16 -178
  5. package/app/components/account/orders/AccountOrderHead.vue +79 -0
  6. package/app/components/account/orders/AccountOrderPay.vue +13 -3
  7. package/app/components/account/orders/AccountOrdersTable.vue +2 -0
  8. package/app/components/cart/position/CartPosition.vue +6 -6
  9. package/app/components/checkout/onepage/CheckoutPaymentSection.vue +20 -8
  10. package/app/components/checkout/return/CheckoutPaymentReturn.vue +209 -0
  11. package/app/composables/useAccountDashboard.ts +1 -0
  12. package/app/composables/useCheckoutOnePage.ts +71 -7
  13. package/app/composables/usePendingApprovals.ts +11 -3
  14. package/app/composables/usePspCheckout.ts +130 -29
  15. package/app/config/colorRamp.ts +55 -0
  16. package/app/interfaces/account/approvals.ts +34 -1
  17. package/app/interfaces/account/order-list.ts +8 -1
  18. package/app/interfaces/cart-calculation.ts +7 -1
  19. package/app/interfaces/cart-item.ts +12 -0
  20. package/app/interfaces/payment.ts +22 -0
  21. package/app/pages/checkout/payment-return.vue +17 -0
  22. package/app/payments/psp/novalnet.ts +254 -0
  23. package/app/payments/psp/registry.ts +7 -3
  24. package/app/payments/psp/rules.ts +99 -0
  25. package/app/payments/psp/stripe.ts +6 -2
  26. package/app/payments/psp/types.ts +72 -6
  27. package/app/shared/pspReturn.ts +62 -0
  28. package/i18n/locales/de/account.json +17 -3
  29. package/i18n/locales/de/cart.json +4 -2
  30. package/i18n/locales/de/checkout.json +32 -0
  31. package/i18n/locales/de/editor.json +10 -0
  32. package/i18n/locales/en/account.json +17 -3
  33. package/i18n/locales/en/cart.json +4 -2
  34. package/i18n/locales/en/checkout.json +32 -0
  35. package/i18n/locales/en/editor.json +10 -0
  36. package/package.json +3 -2
  37. package/server/api/account/orders/[id]/pay.post.ts +47 -7
  38. package/server/api/account/pending-approvals/index.get.ts +16 -12
  39. package/server/api/account/pending-approvals/orders/[number]/approve.post.ts +6 -0
  40. package/server/api/account/pending-approvals/orders/[number]/reject.post.ts +6 -0
  41. package/server/api/account/pending-approvals/orders/[number].get.ts +15 -0
  42. package/server/api/checkout/payment-return.post.ts +30 -0
  43. package/server/api/orders/index.post.ts +37 -11
  44. package/server/api/payment/methods.post.ts +19 -9
  45. package/server/api/payment/psp-config.get.ts +5 -4
  46. package/server/services/ApiCartService.ts +6 -0
  47. package/server/services/ApiProductService.ts +6 -2
  48. package/server/services/MockCartCalculationService.ts +29 -0
  49. package/server/utils/cartItemHints.ts +29 -0
  50. package/server/utils/checkoutSession.ts +16 -0
  51. package/server/utils/liveCatalog.ts +244 -31
  52. package/server/utils/liveOrders.ts +33 -0
  53. package/server/utils/orderPayment.ts +79 -0
  54. package/server/utils/pendingApprovals.ts +157 -2
  55. package/server/utils/procurementCheckout.ts +5 -0
  56. package/server/utils/pspConfig.ts +125 -13
  57. package/server/utils/pspReturn.ts +267 -0
@@ -1,3 +1,4 @@
1
+ import { createNovalnetTokenizer } from "./novalnet";
1
2
  import { createStripeTokenizer } from "./stripe";
2
3
  import type { PspTokenizerFactory } from "./types";
3
4
 
@@ -5,12 +6,15 @@ import type { PspTokenizerFactory } from "./types";
5
6
  * PSP tokenizer registry — the single extension point. A PSP that needs inline
6
7
  * card collection gets a factory here; everything else (BFF token threading,
7
8
  * the generic redirect/next_action handler, the order flow) is provider-
8
- * agnostic. To add Novalnet/Mollie later: implement its tokenizer and add one
9
- * line here.
9
+ * agnostic. To add another PSP: implement its tokenizer and add one line here.
10
+ *
11
+ * A tokenizer here does not mean every payment of that provider uses a field:
12
+ * Novalnet mounts one only where the merchant chose the embedded checkout
13
+ * (`checkoutMode`, see /api/payment/psp-config); otherwise it redirects.
10
14
  */
11
15
  export const pspTokenizers: Record<string, PspTokenizerFactory> = {
12
16
  stripe: createStripeTokenizer,
13
- // novalnet: createNovalnetTokenizer,
17
+ novalnet: createNovalnetTokenizer,
14
18
  // mollie: createMollieTokenizer,
15
19
  };
16
20
 
@@ -0,0 +1,99 @@
1
+ import { pspTokenizerFor } from "./registry";
2
+ import type { PspInstrument } from "./types";
3
+ import type { PaymentOption } from "../../interfaces/payment";
4
+
5
+ /**
6
+ * The checkout's rules for a PSP (FE-5), provider-agnostic and kept apart from
7
+ * the composable so they can be tested without a browser. Nothing here names a
8
+ * provider: what a PSP does is its config (`checkoutMode`) plus whether the
9
+ * registry holds a tokenizer for it.
10
+ */
11
+
12
+ /** A PSP as the checkout treats it. */
13
+ export interface PspCheckoutProvider {
14
+ /** `embedded` mounts the PSP's field; `hosted` sends the buyer to the PSP's page. */
15
+ checkoutMode?: "embedded" | "hosted";
16
+ publicKey?: string;
17
+ /** Legacy name of `publicKey`. */
18
+ publishableKey?: string;
19
+ testMode: boolean;
20
+ /** True when a field that cannot be used gives way to the PSP's hosted page. */
21
+ hostedFallback?: boolean;
22
+ }
23
+
24
+ /**
25
+ * The PSP behind a method, as the checkout treats it. The method's own
26
+ * `checkout` block (the payments app's eligibility answer, RAD-364) wins; a
27
+ * method without one falls back to `/api/payment/psp-config` by provider, the
28
+ * pre-RAD-364 path. A method with a block falls back to the hosted page only
29
+ * when its provider supports one (`checkoutModes`).
30
+ */
31
+ export function pspProviderFor(option: PaymentOption | null | undefined, providers: Record<string, PspCheckoutProvider> | undefined): PspCheckoutProvider | undefined {
32
+ if (!option || option.kind !== "psp") {
33
+ return undefined;
34
+ }
35
+ if (option.checkout) {
36
+ const modes = option.checkout.checkoutModes;
37
+ return {
38
+ checkoutMode: option.checkout.checkoutMode,
39
+ publicKey: option.checkout.publicKey,
40
+ testMode: option.checkout.testMode,
41
+ // Only a provider that has a hosted page can take the order without
42
+ // the field. An older payments app does not say — then it may, as
43
+ // before: it takes both flows whatever the mode.
44
+ hostedFallback: modes ? modes.includes("hosted") : true,
45
+ };
46
+ }
47
+ return option.provider ? providers?.[option.provider] : undefined;
48
+ }
49
+
50
+ /** The PSP's public key, under either name. */
51
+ export function pspPublicKey(provider: PspCheckoutProvider | undefined): string {
52
+ return provider?.publicKey || provider?.publishableKey || "";
53
+ }
54
+
55
+ /** The mode in force; a config from before FE-5 carries none and was always a field. */
56
+ export function pspCheckoutMode(provider: PspCheckoutProvider | undefined): "embedded" | "hosted" {
57
+ return provider?.checkoutMode ?? "embedded";
58
+ }
59
+
60
+ /**
61
+ * Whether the checkout mounts a card field for this method: a PSP method in
62
+ * `embedded` mode with a public key and a registered tokenizer. In every other
63
+ * case the order carries no instrument and the checkout follows the PSP's
64
+ * redirect — which is the hosted page.
65
+ */
66
+ export function pspNeedsCardField(option: PaymentOption | null | undefined, providers: Record<string, PspCheckoutProvider> | undefined): boolean {
67
+ const name = option?.checkout?.provider ?? option?.provider;
68
+ const provider = pspProviderFor(option, providers);
69
+ if (!name || !provider || pspCheckoutMode(provider) !== "embedded" || !pspPublicKey(provider)) {
70
+ return false;
71
+ }
72
+ return Boolean(pspTokenizerFor(name));
73
+ }
74
+
75
+ /** Whether a field that cannot be used (mount or tokenize failed) may give way to the hosted page. */
76
+ export function pspFallsBackToHosted(provider: PspCheckoutProvider | undefined): boolean {
77
+ return provider?.hostedFallback === true;
78
+ }
79
+
80
+ /**
81
+ * The instrument as it travels in the order: a provider instrument
82
+ * (`{ type: "<provider>_<kind>", …fields }`), the legacy single-use token, or
83
+ * nothing — and nothing is the hosted page, not an error. Only string fields
84
+ * travel, and an instrument without a `type` is no instrument.
85
+ */
86
+ export function pspPaymentInstrument(result: PspInstrument | null | undefined): PspInstrument | null {
87
+ if (!result) {
88
+ return null;
89
+ }
90
+ const out: PspInstrument = {};
91
+ if (typeof result.token === "string" && result.token) {
92
+ out.token = result.token;
93
+ }
94
+ const raw = result.instrument;
95
+ if (raw && typeof raw === "object" && typeof raw.type === "string" && raw.type) {
96
+ out.instrument = Object.fromEntries(Object.entries(raw).filter(([, v]) => typeof v === "string" && v !== ""));
97
+ }
98
+ return out.token || out.instrument ? out : null;
99
+ }
@@ -1,4 +1,4 @@
1
- import type { PspMountContext, PspTokenizer } from "./types";
1
+ import { PspInputError, type PspMountContext, type PspTokenizer } from "./types";
2
2
 
3
3
  /**
4
4
  * Stripe tokenizer — loads Stripe.js (no npm dep; the CDN script is the
@@ -10,7 +10,7 @@ interface StripeCardElement { mount: (el: HTMLElement) => void; unmount: () => v
10
10
  interface StripeElements { create: (type: string, options?: unknown) => StripeCardElement }
11
11
  interface StripeInstance {
12
12
  elements: (options?: unknown) => StripeElements;
13
- createPaymentMethod: (params: unknown) => Promise<{ paymentMethod?: { id: string }; error?: { message: string } }>;
13
+ createPaymentMethod: (params: unknown) => Promise<{ paymentMethod?: { id: string }; error?: { message: string; type?: string } }>;
14
14
  }
15
15
  type StripeCtor = (key: string) => StripeInstance;
16
16
 
@@ -56,6 +56,10 @@ export function createStripeTokenizer(): PspTokenizer {
56
56
  }
57
57
  const { paymentMethod, error } = await stripe.createPaymentMethod({ type: "card", card });
58
58
  if (error || !paymentMethod) {
59
+ // Stripe's card and validation errors are the buyer's to correct.
60
+ if (error && (error.type === "card_error" || error.type === "validation_error")) {
61
+ throw new PspInputError(error.message);
62
+ }
59
63
  throw new Error(error?.message ?? "could not tokenize card");
60
64
  }
61
65
  return { token: paymentMethod.id };
@@ -3,27 +3,93 @@
3
3
  * sensitive instrument) data through the PSP's own secure field and turns it
4
4
  * into a single-use token — the raw data never touches our servers (PCI-safe).
5
5
  *
6
- * One implementation per PSP that needs inline collection (Stripe → Elements).
7
- * PSPs that only redirect need NO tokenizer — the generic next_action/redirect
8
- * handler covers them. Add Novalnet/Mollie by adding a factory to the registry.
6
+ * One implementation per PSP that needs inline collection (Stripe → Elements,
7
+ * Novalnet → its card iframe). PSPs that only redirect need NO tokenizer — the
8
+ * generic next_action/redirect handler covers them. Add one by adding a factory
9
+ * to the registry.
9
10
  */
11
+
12
+ /** Who pays, as far as a card field may prefill or check it (all optional). */
13
+ export interface PspMountCustomer {
14
+ firstName?: string;
15
+ lastName?: string;
16
+ email?: string;
17
+ billing?: {
18
+ street?: string;
19
+ city?: string;
20
+ zip?: string;
21
+ /** ISO 3166-1 alpha-2. */
22
+ countryCode?: string;
23
+ };
24
+ }
25
+
10
26
  export interface PspMountContext {
11
- /** Public/publishable key for the PSP (from /api/payment/psp-config). */
27
+ /**
28
+ * Public key for the PSP (from /api/payment/psp-config): Stripe's
29
+ * publishable key, Novalnet's client key.
30
+ */
12
31
  publishableKey: string;
13
32
  testMode: boolean;
14
33
  /** Element the PSP mounts its secure card field into. */
15
34
  el: HTMLElement;
16
35
  /** UI locale, e.g. "de" / "en". */
17
36
  locale?: string;
37
+ /**
38
+ * What the buyer is about to pay, in major units (e.g. 119.5). Informational
39
+ * for the field (Novalnet's 3-D Secure check reads it); the charge itself is
40
+ * always the server's total. Optional — Stripe ignores it.
41
+ */
42
+ amount?: number;
43
+ /** ISO 4217, with `amount`. */
44
+ currency?: string;
45
+ /** Optional prefill (card holder name, 3-D Secure data). */
46
+ customer?: PspMountCustomer;
47
+ }
48
+
49
+ /**
50
+ * What a tokenizer hands the order: a single-use token (Stripe `pm_…`), a
51
+ * provider instrument (Novalnet `{ type: "novalnet_card", pan_hash, unique_id }`),
52
+ * or neither. Neither means "no instrument from the field — take the provider's
53
+ * hosted page": the order is placed without one and the buyer is redirected.
54
+ */
55
+ export interface PspInstrument {
56
+ token?: string;
57
+ instrument?: Record<string, string>;
18
58
  }
19
59
 
20
60
  export interface PspTokenizer {
21
61
  /** Mount the secure field into `ctx.el`; resolves once it is ready. */
22
62
  mount: (ctx: PspMountContext) => Promise<void>;
23
- /** Produce a single-use token (e.g. Stripe `pm_…`) from the mounted field. */
24
- tokenize: () => Promise<{ token: string }>;
63
+ /** Produce the single-use token or instrument from the mounted field. */
64
+ tokenize: () => Promise<PspInstrument>;
25
65
  /** Tear the field down (on unmount / method change). */
26
66
  destroy: () => void;
27
67
  }
28
68
 
29
69
  export type PspTokenizerFactory = () => PspTokenizer;
70
+
71
+
72
+
73
+ /**
74
+ * A card the buyer has to correct (an invalid number, an expired date) — shown
75
+ * at the field, never a reason to leave for the hosted page. A tokenizer throws
76
+ * this for the buyer's own input; anything else it throws is the field failing.
77
+ */
78
+ export class PspInputError extends Error {
79
+ constructor(message: string) {
80
+ super(message);
81
+ this.name = "PspInputError";
82
+ }
83
+ }
84
+
85
+ /**
86
+ * The card field cannot be used and the provider has no hosted page to fall
87
+ * back to. The order is not placed; the buyer is told the card field is
88
+ * unavailable and may choose another method.
89
+ */
90
+ export class PspFieldUnavailableError extends Error {
91
+ constructor(message = "card field unavailable") {
92
+ super(message);
93
+ this.name = "PspFieldUnavailableError";
94
+ }
95
+ }
@@ -0,0 +1,62 @@
1
+ /**
2
+ * What a buyer coming back from a payment provider is told (FE-5), from the
3
+ * payment's status as the payments app answers it after the confirm. Shared by
4
+ * the BFF route that confirms and the return page that shows the outcome.
5
+ *
6
+ * - `paid` — the money is held or taken: the order confirmation.
7
+ * - `failed` — declined, cancelled at the provider, expired: nothing was
8
+ * taken, the order is not paid, and it can be paid again.
9
+ * - `pending` — the provider has not decided yet (or still waits for the
10
+ * buyer): the payment is being processed.
11
+ * - `retry` — the buyer left the provider's page without paying, and the
12
+ * payment still waits for them with its page (`requires_action`
13
+ * with a redirect): offered again, as the same payment.
14
+ * - `unverified` — the payments app could not verify the return (a checksum
15
+ * that does not match, a transaction for another amount or
16
+ * payment): nothing moved, the order is not paid, and the buyer
17
+ * is told the payment could not be verified. Never decided from a
18
+ * status — only from the payments app refusing the confirm.
19
+ */
20
+ export type PspReturnOutcome = "paid" | "failed" | "pending" | "retry" | "unverified";
21
+
22
+ const PAID = new Set(["authorized", "captured", "succeeded", "paid"]);
23
+ const FAILED = new Set(["failed", "cancelled", "canceled", "expired"]);
24
+
25
+ export function pspReturnOutcome(status: string | null | undefined): Exclude<PspReturnOutcome, "retry" | "unverified"> {
26
+ const s = String(status ?? "").toLowerCase();
27
+ if (PAID.has(s)) {
28
+ return "paid";
29
+ }
30
+ if (FAILED.has(s)) {
31
+ return "failed";
32
+ }
33
+ return "pending";
34
+ }
35
+
36
+ /** The query parameter the payments app appends to the return address: the payment's id. */
37
+ export const PSP_RETURN_PAYMENT_PARAM = "rx_payment";
38
+ /** The query parameter the BFF puts on the return address: the order's number. */
39
+ export const PSP_RETURN_ORDER_PARAM = "order";
40
+
41
+ /**
42
+ * The provider's return parameters as they may travel to the payments app:
43
+ * every query parameter, strings only (the first of a repeated one), bounded
44
+ * in count and length. The provider's own names are kept verbatim — the
45
+ * payments app verifies them (Novalnet: tid, status, checksum, txn_secret).
46
+ */
47
+ export function pspReturnParams(query: Record<string, unknown>): Record<string, string> {
48
+ const out: Record<string, string> = {};
49
+ let count = 0;
50
+ for (const [key, raw] of Object.entries(query)) {
51
+ if (count >= 50 || key.length > 128) {
52
+ continue;
53
+ }
54
+ const value = Array.isArray(raw) ? raw[0] : raw;
55
+ if (typeof value !== "string" || value.length > 4096) {
56
+ continue;
57
+ }
58
+ out[key] = value;
59
+ count += 1;
60
+ }
61
+ return out;
62
+ }
@@ -71,8 +71,18 @@
71
71
  "failed": "Entscheidung nicht möglich",
72
72
  "empty": {
73
73
  "title": "Nichts wartet auf Sie",
74
- "description": "Sobald eine Anfrage Ihre Freigabe braucht, erscheint sie hier."
75
- }
74
+ "description": "Sobald eine Anfrage oder Bestellung Ihre Freigabe braucht, erscheint sie hier."
75
+ },
76
+ "order": "Bestellung {number}",
77
+ "review": "Ansehen",
78
+ "declineOrderTitle": "Bestellung ablehnen",
79
+ "declineOrderIntro": "Die Bestellung wird storniert. Die bestellende Person sieht Ihren Grund.",
80
+ "reasonRequired": "Bitte geben Sie einen Grund an."
81
+ },
82
+ "order": {
83
+ "title": "Bestellung {number}",
84
+ "requestedBy": "Bestellt von {name}",
85
+ "notPending": "Diese Bestellung wartet nicht mehr auf eine Entscheidung."
76
86
  }
77
87
  },
78
88
  "payments": {
@@ -123,7 +133,11 @@
123
133
  "approval-pending": "Freigabe ausstehend",
124
134
  "shipped": "Versendet",
125
135
  "delivered": "Geliefert",
126
- "cancelled": "Storniert"
136
+ "cancelled": "Storniert",
137
+ "rejected": "Abgelehnt"
138
+ },
139
+ "rejected": {
140
+ "title": "Diese Bestellung wurde nicht freigegeben"
127
141
  },
128
142
  "payment": {
129
143
  "open": "Zahlung offen",
@@ -276,13 +276,15 @@
276
276
  "place": "Nur {available} Stück verfügbar. Der Rest wird nachgeliefert.",
277
277
  "drop": "Nur {available} Stück verfügbar. Diese Position entfällt bei der Bestellung.",
278
278
  "refuse": "Nur {available} Stück verfügbar. Solange diese Position im Warenkorb liegt, kann nicht bestellt werden."
279
- }
279
+ },
280
+ "unitChanged": "{sku} ist nicht in {sent} erhältlich. Auf {unit} umgestellt."
280
281
  },
281
282
  "messages": {
282
283
  "costCentersUnassigned": "Sie haben keine Kostenstellen, bitte wenden Sie sich an Ihren Organisationsadministrator.",
283
284
  "positionsNotOrderable": "{count} Position(en) sind derzeit nicht bestellbar. Bitte passen Sie die Menge an oder entfernen Sie sie.",
284
285
  "positionsWillBeDropped": "{count} Position(en) sind nicht bestellbar und entfallen bei der Bestellung.",
285
- "costCenterRequired": "Bitte wählen Sie für alle Positionen eine Kostenstelle aus."
286
+ "costCenterRequired": "Bitte wählen Sie für alle Positionen eine Kostenstelle aus.",
287
+ "unitsChanged": "Bei einigen Positionen wurde die Einheit umgestellt. Bitte prüfen Sie deren Mengen."
286
288
  },
287
289
  "incentives": {
288
290
  "freeShipping": "versandkostenfreie Lieferung",
@@ -1,4 +1,34 @@
1
1
  {
2
+ "paymentReturn": {
3
+ "title": "Zahlung",
4
+ "checking": "Wir prüfen Ihre Zahlung …",
5
+ "toShop": "Zum Shop",
6
+ "toOrder": "Zur Bestellung",
7
+ "failed": {
8
+ "title": "Die Zahlung ist nicht durchgegangen",
9
+ "text": "Ihre Bestellung {id} wurde nicht bezahlt. Es wurde nichts abgebucht.",
10
+ "payAgain": "Erneut bezahlen",
11
+ "guestHint": "Bitte kontaktieren Sie uns mit Ihrer Bestellnummer, wenn Sie die Bestellung bezahlen möchten."
12
+ },
13
+ "retry": {
14
+ "title": "Zahlung nicht abgeschlossen",
15
+ "text": "Sie haben die Zahlung für Ihre Bestellung {id} nicht abgeschlossen. Es wurde nichts abgebucht. Sie können sie jetzt erneut beim Zahlungsanbieter vornehmen.",
16
+ "again": "Erneut zur Zahlung"
17
+ },
18
+ "pending": {
19
+ "title": "Ihre Zahlung wird verarbeitet",
20
+ "text": "Der Zahlungsanbieter hat die Zahlung für Ihre Bestellung {id} noch nicht abgeschlossen. Sie erhalten eine Bestätigung, sobald sie eingegangen ist.",
21
+ "checkAgain": "Erneut prüfen"
22
+ },
23
+ "unverified": {
24
+ "title": "Ihre Zahlung konnte nicht bestätigt werden",
25
+ "text": "Wir konnten die Zahlung für Ihre Bestellung {id} nicht bestätigen. Die Bestellung ist nicht als bezahlt vermerkt. Bitte kontaktieren Sie uns mit Ihrer Bestellnummer."
26
+ },
27
+ "error": {
28
+ "title": "Wir konnten Ihre Zahlung nicht prüfen",
29
+ "text": "Bitte versuchen Sie es später erneut oder kontaktieren Sie uns. Eine erfolgreiche Zahlung geht dadurch nicht verloren."
30
+ }
31
+ },
2
32
  "confirmation": {
3
33
  "order": {
4
34
  "title": "Bestellung bestätigt!",
@@ -131,6 +161,8 @@
131
161
  "poNumberPlaceholder": "Bestellnummer eingeben...",
132
162
  "costCenter": "Kostenstelle",
133
163
  "cardDetails": "Kartendaten",
164
+ "cardOnProviderPage": "Sie geben Ihre Kartendaten nach dem Absenden auf der Zahlungsseite des Anbieters ein.",
165
+ "cardFieldUnavailable": "Das Kartenfeld ist gerade nicht verfügbar. Bitte versuchen Sie es erneut oder wählen Sie eine andere Zahlungsart.",
134
166
  "change": "Ändern",
135
167
  "noMethod": "Keine Zahlungsmethode ausgewählt",
136
168
  "confirm": "Bestätigen",
@@ -124,6 +124,16 @@
124
124
  },
125
125
  "design": {
126
126
  "title": "Shop-Design",
127
+ "logo": "Logo",
128
+ "logoHint": "URL oder Pfad im Medienspeicher. Erscheint in Header, Footer und Checkout; leer lässt das Theme-Logo stehen.",
129
+ "favicon": "Favicon",
130
+ "faviconHint": "Quadratisches Bild, mindestens 180 × 180 px. Daraus entstehen die Icons für Browser-Tabs und Homescreens; leer lässt das Theme-Favicon stehen.",
131
+ "upload": "Bild hochladen",
132
+ "uploading": "Lädt hoch …",
133
+ "uploadFailed": "Das Bild konnte nicht hochgeladen werden.",
134
+ "uploadUnavailable": "Hochladen ist hier nicht verfügbar: Es ist kein Medienspeicher konfiguriert. Bitte eine URL eintragen.",
135
+ "logoRejected": "Gespeichert, aber nicht verwendet: Das ist weder eine URL noch ein Storage-Pfad. Der Shop zeigt weiter das bisherige Logo.",
136
+ "faviconRejected": "Gespeichert, aber nicht verwendet: Das ist weder eine URL noch ein Storage-Pfad. Der Shop behält das Theme-Favicon.",
127
137
  "brand": "Markenfarbe",
128
138
  "neutral": "Neutralfarbe",
129
139
  "radius": "Eckenradius",
@@ -71,8 +71,18 @@
71
71
  "failed": "The decision could not be recorded",
72
72
  "empty": {
73
73
  "title": "Nothing is waiting on you",
74
- "description": "A request needing your approval appears here."
75
- }
74
+ "description": "A request or order needing your approval appears here."
75
+ },
76
+ "order": "Order {number}",
77
+ "review": "Review",
78
+ "declineOrderTitle": "Reject the order",
79
+ "declineOrderIntro": "The order is cancelled. The requester sees your reason.",
80
+ "reasonRequired": "Please give a reason."
81
+ },
82
+ "order": {
83
+ "title": "Order {number}",
84
+ "requestedBy": "Requested by {name}",
85
+ "notPending": "This order is no longer waiting for a decision."
76
86
  }
77
87
  },
78
88
  "payments": {
@@ -123,7 +133,11 @@
123
133
  "approval-pending": "Approval pending",
124
134
  "shipped": "Shipped",
125
135
  "delivered": "Delivered",
126
- "cancelled": "Cancelled"
136
+ "cancelled": "Cancelled",
137
+ "rejected": "Rejected"
138
+ },
139
+ "rejected": {
140
+ "title": "This order was not approved"
127
141
  },
128
142
  "payment": {
129
143
  "open": "Payment open",
@@ -276,13 +276,15 @@
276
276
  "place": "Only {available} available. The rest follows later.",
277
277
  "drop": "Only {available} available. This position will be left out of the order.",
278
278
  "refuse": "Only {available} available. The cart cannot be ordered while this position is in it."
279
- }
279
+ },
280
+ "unitChanged": "{sku} is not available in {sent}. Switched to {unit}."
280
281
  },
281
282
  "messages": {
282
283
  "costCentersUnassigned": "You have no cost centers assigned — please contact your organization administrator.",
283
284
  "positionsNotOrderable": "{count} position(s) cannot be ordered right now. Adjust the quantity or remove them.",
284
285
  "positionsWillBeDropped": "{count} position(s) cannot be ordered and will be left out of the order.",
285
- "costCenterRequired": "Please select a cost center for every position."
286
+ "costCenterRequired": "Please select a cost center for every position.",
287
+ "unitsChanged": "The unit of some positions was switched. Please check their quantities."
286
288
  },
287
289
  "incentives": {
288
290
  "freeShipping": "free shipping",
@@ -1,4 +1,34 @@
1
1
  {
2
+ "paymentReturn": {
3
+ "title": "Payment",
4
+ "checking": "Checking your payment …",
5
+ "toShop": "Back to the shop",
6
+ "toOrder": "View order",
7
+ "failed": {
8
+ "title": "The payment did not go through",
9
+ "text": "Your order {id} has not been paid. Nothing was charged.",
10
+ "payAgain": "Pay again",
11
+ "guestHint": "Please contact us with your order number if you would like to pay for the order."
12
+ },
13
+ "retry": {
14
+ "title": "Payment not completed",
15
+ "text": "You did not complete the payment for your order {id}. Nothing was charged. You can go back to the payment provider and pay now.",
16
+ "again": "Go to payment again"
17
+ },
18
+ "pending": {
19
+ "title": "Your payment is being processed",
20
+ "text": "The payment provider has not completed the payment for your order {id} yet. You will receive a confirmation once it has arrived.",
21
+ "checkAgain": "Check again"
22
+ },
23
+ "unverified": {
24
+ "title": "Your payment could not be verified",
25
+ "text": "We could not verify the payment for your order {id}. The order is not marked as paid. Please contact us with your order number."
26
+ },
27
+ "error": {
28
+ "title": "We could not check your payment",
29
+ "text": "Please try again later or contact us. A successful payment is not lost because of this."
30
+ }
31
+ },
2
32
  "confirmation": {
3
33
  "order": {
4
34
  "title": "Order confirmed!",
@@ -131,6 +161,8 @@
131
161
  "poNumberPlaceholder": "Enter PO number...",
132
162
  "costCenter": "Cost Center",
133
163
  "cardDetails": "Card details",
164
+ "cardOnProviderPage": "After you place the order, you enter your card details on the payment provider's page.",
165
+ "cardFieldUnavailable": "The card field is not available right now. Please try again or choose another payment method.",
134
166
  "change": "Change",
135
167
  "noMethod": "No payment method selected",
136
168
  "confirm": "Confirm",
@@ -124,6 +124,16 @@
124
124
  },
125
125
  "design": {
126
126
  "title": "Site design",
127
+ "logo": "Logo",
128
+ "logoHint": "URL or media storage path. Shown in the header, footer and checkout; empty keeps the theme logo.",
129
+ "favicon": "Favicon",
130
+ "faviconHint": "Square image, at least 180 × 180 px. The icons for browser tabs and home screens are rendered from it; empty keeps the theme favicon.",
131
+ "upload": "Upload image",
132
+ "uploading": "Uploading …",
133
+ "uploadFailed": "Could not upload the image.",
134
+ "uploadUnavailable": "Uploads are not available here: no media storage is configured. Enter a URL instead.",
135
+ "logoRejected": "Saved, but not used: this is neither a URL nor a storage path. The shop keeps showing the previous logo.",
136
+ "faviconRejected": "Saved, but not used: this is neither a URL nor a storage path. The shop keeps the theme favicon.",
127
137
  "brand": "Brand colour",
128
138
  "neutral": "Neutral colour",
129
139
  "radius": "Corner radius",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@revenexx/cover",
3
- "version": "0.20.0",
3
+ "version": "0.21.1",
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",
@@ -26,6 +26,7 @@
26
26
  "./composables/*": "./app/composables/*.ts",
27
27
  "./config/*": "./app/config/*.ts",
28
28
  "./interfaces/*": "./app/interfaces/*.ts",
29
+ "./payments/*": "./app/payments/*.ts",
29
30
  "./server/interfaces/*": "./server/interfaces/*.ts",
30
31
  "./server/services/*": "./server/services/*.ts",
31
32
  "./server/utils/*": "./server/utils/*.ts",
@@ -43,7 +44,7 @@
43
44
  "@internationalized/date": "^3.12.0",
44
45
  "@nuxt/scripts": "^1.3.0",
45
46
  "@revenexx/consent-manager-nuxt": "^0.1.0",
46
- "@revenexx/sdk": "^0.2.0",
47
+ "@revenexx/sdk": "^0.5.0",
47
48
  "@revenexx/storage-model-viewer": "^0.3.0",
48
49
  "@revenexx/tag-manager-nuxt": "^0.1.0",
49
50
  "@vueuse/core": "^14.3.0",
@@ -1,10 +1,15 @@
1
- import { orderAwaitsPayment, orderPaymentRequest, recordOrderPaymentStatus } from "../../../../utils/orderPayment";
1
+ import {
2
+ orderAwaitsPayment,
3
+ orderPaymentRequest,
4
+ paymentCustomerOf,
5
+ recordOrderPaymentStatus,
6
+ sanitizePaymentInstrument,
7
+ } from "../../../../utils/orderPayment";
8
+ import { pspReturnUrl, rememberPspReturn } from "../../../../utils/pspReturn";
2
9
 
3
10
  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;
11
+ /** From the order page's card field: a provider instrument, or the legacy single-use token. */
12
+ paymentInstrument?: { token?: string; instrument?: Record<string, unknown> };
8
13
  /** One per attempt, so a double click pays once. */
9
14
  idempotencyKey?: string;
10
15
  }
@@ -69,8 +74,22 @@ export default defineEventHandler(async (event) => {
69
74
  orderId: order.id,
70
75
  contactId: principalContactId(event),
71
76
  idempotencyKey,
72
- token: body?.paymentInstrument?.token,
73
- returnUrl: body?.returnUrl,
77
+ token: typeof body?.paymentInstrument?.token === "string" && body.paymentInstrument.token
78
+ ? body.paymentInstrument.token
79
+ : undefined,
80
+ instrument: sanitizePaymentInstrument(body?.paymentInstrument?.instrument),
81
+ // The PSP brings the buyer back to the return page, which confirms
82
+ // the payment — built here, on this host, never taken from the
83
+ // browser (FE-5).
84
+ returnUrl: pspReturnUrl(event, order.number),
85
+ customer: paymentCustomerOf({
86
+ email: user.email,
87
+ contactName: user.name,
88
+ ip: getRequestIP(event, { xForwardedFor: true }) ?? null,
89
+ billing: billingForPayment(order.billing_address),
90
+ countryCode: paymentCountry(order) ?? null,
91
+ }),
92
+ language: resolveLocale(event),
74
93
  }),
75
94
  });
76
95
  }
@@ -94,7 +113,28 @@ export default defineEventHandler(async (event) => {
94
113
  // The PSP needs the buyer (3DS / redirect PSPs): hand the redirect back, the
95
114
  // payment settles on their return.
96
115
  if (created.status === "requires_action" && created.next_action?.url) {
116
+ rememberPspReturn(event, { paymentId: created.id, orderRef: order.number, orderUuid: order.id });
97
117
  return { status: "requires-action" as const, requiresAction: true, redirectUrl: created.next_action.url, paymentId: created.id };
98
118
  }
99
119
  return { status: created.status, requiresAction: false, paymentId: created.id };
100
120
  });
121
+
122
+ /** An orders-app address as the payment's billing: street line, town, postal code. */
123
+ function billingForPayment(address: Record<string, unknown> | null): { street?: string; city?: string; postalCode?: string } | null {
124
+ if (!address) {
125
+ return null;
126
+ }
127
+ const text = (...keys: string[]): string => {
128
+ for (const key of keys) {
129
+ const value = address[key];
130
+ if (typeof value === "string" && value.trim()) {
131
+ return value.trim();
132
+ }
133
+ }
134
+ return "";
135
+ };
136
+ const street = text("address_line1")
137
+ || [text("street_name"), text("house_number"), text("house_number_addition")].filter(Boolean).join(" ")
138
+ || text("street");
139
+ return { street, city: text("locality", "city"), postalCode: text("postal_code", "zip", "postalCode") };
140
+ }