@revenexx/cover 0.21.0 → 0.21.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.
|
@@ -8,9 +8,11 @@ import { type PspInstrument, PspInputError, type PspMountContext, type PspTokeni
|
|
|
8
8
|
* secure.novalnet.de. `tokenize()` asks the iframe for the card's `pan_hash`
|
|
9
9
|
* and `unique_id`; only those reach the BFF, never card data.
|
|
10
10
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* `do_redirect` in the iframe's answer means the card needs 3-D Secure. It is
|
|
12
|
+
* not a request for the hosted page: the pan hash is still the instrument, the
|
|
13
|
+
* payment is created with it, and Novalnet answers a `redirect_url` to the
|
|
14
|
+
* 3-D Secure step only. Dropping the hash there sent the buyer to the full
|
|
15
|
+
* payment page to type the card a second time.
|
|
14
16
|
*/
|
|
15
17
|
|
|
16
18
|
export const NOVALNET_UTILITY_JS = "https://cdn.novalnet.de/js/v2/NovalnetUtility-1.1.2.js";
|
|
@@ -130,14 +132,11 @@ export function novalnetFormConfig(
|
|
|
130
132
|
}
|
|
131
133
|
|
|
132
134
|
/**
|
|
133
|
-
* What the iframe's hash answer becomes for the order: the instrument
|
|
134
|
-
*
|
|
135
|
+
* What the iframe's hash answer becomes for the order: the instrument. A
|
|
136
|
+
* `do_redirect` answer carries one as well (the card needs 3-D Secure, which
|
|
137
|
+
* the payment's redirect takes care of), so it is handed on like any other.
|
|
135
138
|
*/
|
|
136
139
|
export function novalnetInstrumentOf(answer: NovalnetHashAnswer): PspInstrument {
|
|
137
|
-
const redirect = answer.do_redirect;
|
|
138
|
-
if (redirect === 1 || redirect === "1" || redirect === true) {
|
|
139
|
-
return {};
|
|
140
|
-
}
|
|
141
140
|
const panHash = answer.hash ?? answer.pan_hash;
|
|
142
141
|
if (!panHash || !answer.unique_id) {
|
|
143
142
|
// Novalnet names what is wrong with the card the buyer typed; without a
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@revenexx/cover",
|
|
3
|
-
"version": "0.21.
|
|
3
|
+
"version": "0.21.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",
|
|
@@ -47,19 +47,39 @@ function clientAdding(client: SdkClient, extra: Record<string, unknown>): SdkCli
|
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Keys of a placement the typed SDK does not map and silently drops, sent on
|
|
52
|
+
* the wire as they are given. `discounts` is what the promotions app decided
|
|
53
|
+
* and reserved for this cart: without it the order is stored at the full
|
|
54
|
+
* price while the redemption is committed against it.
|
|
55
|
+
*/
|
|
56
|
+
const UNMAPPED_KEYS = ["discounts"] as const;
|
|
57
|
+
|
|
58
|
+
function unmappedOf(submission: unknown): Record<string, unknown> {
|
|
59
|
+
const body = (submission ?? {}) as Record<string, unknown>;
|
|
60
|
+
return Object.fromEntries(UNMAPPED_KEYS
|
|
61
|
+
.filter(key => Array.isArray(body[key]) ? (body[key] as unknown[]).length > 0 : body[key] !== undefined)
|
|
62
|
+
.map(key => [key, body[key]]));
|
|
63
|
+
}
|
|
64
|
+
|
|
50
65
|
export async function placeOrderWithAttribution<T>(submission: unknown, attribution: Attribution | null): Promise<T> {
|
|
51
66
|
const sdk = useRevenexxSdk();
|
|
67
|
+
const unmapped = unmappedOf(submission);
|
|
68
|
+
const place = async (extra: Record<string, unknown>): Promise<T> => (Object.keys(extra).length
|
|
69
|
+
? await new Orders(clientAdding(sdk.client, extra) as never).ordersPlace(submission as never)
|
|
70
|
+
: await sdk.orders.ordersPlace(submission as never)) as unknown as T;
|
|
71
|
+
|
|
52
72
|
if (!attribution) {
|
|
53
|
-
return await
|
|
73
|
+
return await place(unmapped);
|
|
54
74
|
}
|
|
55
75
|
try {
|
|
56
|
-
return await
|
|
76
|
+
return await place({ ...unmapped, attribution });
|
|
57
77
|
}
|
|
58
78
|
catch (err) {
|
|
59
79
|
if (!isAttributionRefusal(err)) {
|
|
60
80
|
throw err;
|
|
61
81
|
}
|
|
62
82
|
getLogService().warn("order attribution refused, placed without it", apiErrorContext(err));
|
|
63
|
-
return await
|
|
83
|
+
return await place(unmapped);
|
|
64
84
|
}
|
|
65
85
|
}
|
|
@@ -55,6 +55,8 @@ interface OrderLikePayload {
|
|
|
55
55
|
payment?: { method: string };
|
|
56
56
|
shipping?: { method: string; price: number; tax_rate: number };
|
|
57
57
|
items: Array<Record<string, unknown>>;
|
|
58
|
+
/** The promotions evaluated and reserved for this cart, in the orders app's own shape. */
|
|
59
|
+
discounts?: Array<Record<string, unknown>>;
|
|
58
60
|
userData?: Record<string, unknown>;
|
|
59
61
|
}
|
|
60
62
|
|
|
@@ -82,6 +84,9 @@ export async function submitThroughProcurement(payload: OrderLikePayload): Promi
|
|
|
82
84
|
...(payload.payment ? { payment: payload.payment } : {}),
|
|
83
85
|
...(payload.shipping ? { shipping: payload.shipping } : {}),
|
|
84
86
|
...(payload.userData ? { user_data: payload.userData } : {}),
|
|
87
|
+
// Without them a direct order was placed at the undiscounted price while
|
|
88
|
+
// the promotion's use was committed (procurement forwards them to orders).
|
|
89
|
+
...(payload.discounts?.length ? { discounts: payload.discounts } : {}),
|
|
85
90
|
items: payload.items,
|
|
86
91
|
},
|
|
87
92
|
});
|