@final-commerce/command-frame 0.8.0-online.4 → 0.8.0-preprod.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.
- package/dist/CommonTypes.d.ts +26 -1
- package/dist/actions/add-booking-to-cart/action.d.ts +6 -0
- package/dist/actions/add-booking-to-cart/action.js +8 -0
- package/dist/actions/add-booking-to-cart/mock.d.ts +2 -0
- package/dist/actions/add-booking-to-cart/mock.js +66 -0
- package/dist/actions/add-booking-to-cart/types.d.ts +27 -0
- package/dist/actions/cancel-booking/action.d.ts +6 -0
- package/dist/actions/cancel-booking/action.js +8 -0
- package/dist/actions/cancel-booking/mock.d.ts +2 -0
- package/dist/actions/cancel-booking/mock.js +31 -0
- package/dist/actions/cancel-booking/types.d.ts +14 -0
- package/dist/actions/get-booking-availability/action.d.ts +6 -0
- package/dist/actions/get-booking-availability/action.js +8 -0
- package/dist/actions/get-booking-availability/mock.d.ts +2 -0
- package/dist/actions/get-booking-availability/mock.js +12 -0
- package/dist/actions/get-booking-availability/types.d.ts +37 -0
- package/dist/actions/get-booking-resources/action.d.ts +6 -0
- package/dist/actions/get-booking-resources/action.js +8 -0
- package/dist/actions/get-booking-resources/mock.d.ts +2 -0
- package/dist/actions/get-booking-resources/mock.js +7 -0
- package/dist/actions/get-booking-resources/types.d.ts +16 -0
- package/dist/actions/get-booking-resources/types.js +1 -0
- package/dist/actions/get-bookings/action.d.ts +6 -0
- package/dist/actions/get-bookings/action.js +8 -0
- package/dist/actions/get-bookings/mock.d.ts +2 -0
- package/dist/actions/get-bookings/mock.js +20 -0
- package/dist/actions/get-bookings/types.d.ts +22 -0
- package/dist/actions/get-bookings/types.js +1 -0
- package/dist/actions/get-context/mock.js +4 -0
- package/dist/actions/get-product-modifier-selections/action.d.ts +1 -1
- package/dist/actions/get-product-modifier-selections/action.js +2 -2
- package/dist/actions/get-product-modifier-selections/mock.d.ts +1 -1
- package/dist/actions/get-product-modifier-selections/mock.js +5 -5
- package/dist/actions/get-product-modifier-selections/types.d.ts +1 -1
- package/dist/actions/get-products/mock.js +6 -0
- package/dist/actions/get-products/types.d.ts +25 -3
- package/dist/actions/get-refund-plan/types.d.ts +5 -2
- package/dist/actions/get-remaining-refundable-quantities/mock.js +1 -0
- package/dist/actions/get-remaining-refundable-quantities/types.d.ts +8 -0
- package/dist/actions/hold-booking/action.d.ts +6 -0
- package/dist/actions/hold-booking/action.js +8 -0
- package/dist/actions/hold-booking/mock.d.ts +2 -0
- package/dist/actions/hold-booking/mock.js +37 -0
- package/dist/actions/hold-booking/types.d.ts +28 -0
- package/dist/actions/hold-booking/types.js +1 -0
- package/dist/actions/process-partial-refund/types.d.ts +2 -2
- package/dist/actions/remove-booking-from-cart/action.d.ts +6 -0
- package/dist/actions/remove-booking-from-cart/action.js +8 -0
- package/dist/actions/remove-booking-from-cart/mock.d.ts +2 -0
- package/dist/actions/remove-booking-from-cart/mock.js +40 -0
- package/dist/actions/remove-booking-from-cart/types.d.ts +16 -0
- package/dist/actions/remove-booking-from-cart/types.js +1 -0
- package/dist/actions/set-product-modifier-selections/action.d.ts +1 -1
- package/dist/actions/set-product-modifier-selections/action.js +2 -2
- package/dist/actions/set-product-modifier-selections/mock.d.ts +1 -1
- package/dist/actions/set-product-modifier-selections/mock.js +7 -7
- package/dist/actions/set-product-modifier-selections/types.d.ts +2 -2
- package/dist/demo/database.d.ts +18 -1
- package/dist/demo/database.js +183 -0
- package/dist/index.d.ts +16 -6
- package/dist/index.js +15 -5
- package/dist/projects/render/mocks.js +14 -4
- package/dist/projects/render/types.d.ts +8 -13
- package/dist/pubsub/topics/bookings/booking-created/types.d.ts +6 -0
- package/dist/pubsub/topics/bookings/booking-created/types.js +1 -0
- package/dist/pubsub/topics/bookings/booking-setup-changed/types.d.ts +15 -0
- package/dist/pubsub/topics/bookings/booking-setup-changed/types.js +1 -0
- package/dist/pubsub/topics/bookings/booking-updated/types.d.ts +6 -0
- package/dist/pubsub/topics/bookings/booking-updated/types.js +1 -0
- package/dist/pubsub/topics/bookings/index.d.ts +3 -0
- package/dist/pubsub/topics/bookings/index.js +27 -0
- package/dist/pubsub/topics/bookings/types.d.ts +8 -0
- package/dist/pubsub/topics/bookings/types.js +3 -0
- package/dist/pubsub/topics/cart/product-modifiers-updated/types.d.ts +2 -2
- package/dist/pubsub/topics/cart/types.d.ts +33 -33
- package/dist/pubsub/topics/cart/types.js +16 -16
- package/dist/pubsub/topics/index.d.ts +17 -17
- package/dist/pubsub/topics/index.js +17 -17
- package/dist/pubsub/topics/types.d.ts +2 -8
- package/package.json +5 -2
- package/dist/actions/resume-checkout/action.d.ts +0 -6
- package/dist/actions/resume-checkout/action.js +0 -8
- package/dist/actions/resume-checkout/mock.d.ts +0 -16
- package/dist/actions/resume-checkout/mock.js +0 -51
- package/dist/actions/resume-checkout/types.d.ts +0 -59
- package/dist/actions/resume-checkout/types.js +0 -13
- package/dist/actions/start-checkout/action.d.ts +0 -6
- package/dist/actions/start-checkout/action.js +0 -8
- package/dist/actions/start-checkout/mock.d.ts +0 -16
- package/dist/actions/start-checkout/mock.js +0 -80
- package/dist/actions/start-checkout/types.d.ts +0 -81
- package/dist/actions/start-checkout/types.js +0 -10
- package/dist/pubsub/topics/checkout/checkout-started/types.d.ts +0 -26
- package/dist/pubsub/topics/checkout/index.d.ts +0 -7
- package/dist/pubsub/topics/checkout/index.js +0 -28
- package/dist/pubsub/topics/checkout/payment-completed/types.d.ts +0 -31
- package/dist/pubsub/topics/checkout/payment-failed/types.d.ts +0 -20
- package/dist/pubsub/topics/checkout/types.d.ts +0 -12
- package/dist/pubsub/topics/checkout/types.js +0 -8
- /package/dist/{pubsub/topics/checkout/checkout-started → actions/add-booking-to-cart}/types.js +0 -0
- /package/dist/{pubsub/topics/checkout/payment-completed → actions/cancel-booking}/types.js +0 -0
- /package/dist/{pubsub/topics/checkout/payment-failed → actions/get-booking-availability}/types.js +0 -0
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
export interface ResumeCheckoutParams {
|
|
2
|
-
/**
|
|
3
|
-
* Where to read the provider's return data from. Defaults to the current
|
|
4
|
-
* page URL, which is where the shopper has just landed.
|
|
5
|
-
*
|
|
6
|
-
* Only override this if you moved the query string somewhere else before
|
|
7
|
-
* calling — for example if your router strips it on mount.
|
|
8
|
-
*/
|
|
9
|
-
url?: string;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* What the return leg produced. Every field past `resumed` is absent when
|
|
13
|
-
* `resumed` is `false`.
|
|
14
|
-
*/
|
|
15
|
-
export interface ResumeCheckoutResult {
|
|
16
|
-
/**
|
|
17
|
-
* `false` means THIS WAS AN ORDINARY PAGE LOAD — no provider return data was
|
|
18
|
-
* in the URL, so there was nothing to finish and nothing happened. It is not
|
|
19
|
-
* an error, and it is the answer on every normal visit to the page. Call this
|
|
20
|
-
* unconditionally when your checkout or confirmation screen mounts and branch
|
|
21
|
-
* on this field.
|
|
22
|
-
*/
|
|
23
|
-
resumed: boolean;
|
|
24
|
-
orderId?: string;
|
|
25
|
-
receiptId?: string;
|
|
26
|
-
/**
|
|
27
|
-
* The provider's result code for the completed attempt, e.g. `Authorised` or
|
|
28
|
-
* `Refused`. As everywhere else in this topic, `Authorised` is an
|
|
29
|
-
* authorisation and NOT a settlement.
|
|
30
|
-
*/
|
|
31
|
-
resultCode?: string;
|
|
32
|
-
/** Opaque proof of the payment — see `PaymentCompletedPayload.sessionResult`. */
|
|
33
|
-
sessionResult?: string;
|
|
34
|
-
/**
|
|
35
|
-
* The one-time order password from the original checkout, recovered from
|
|
36
|
-
* browser storage. The page that held it in memory is gone, so this is the
|
|
37
|
-
* only way back to the order's status after a redirect.
|
|
38
|
-
*/
|
|
39
|
-
orderPassword?: string;
|
|
40
|
-
}
|
|
41
|
-
export interface ResumeCheckoutResponse {
|
|
42
|
-
success: boolean;
|
|
43
|
-
timestamp: string;
|
|
44
|
-
checkout: ResumeCheckoutResult;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Finish a checkout the shopper was redirected away from.
|
|
48
|
-
*
|
|
49
|
-
* SAFE TO CALL ON EVERY PAGE LOAD, and that is how it is meant to be used: on
|
|
50
|
-
* an ordinary visit it finds no return data and answers `{ resumed: false }`
|
|
51
|
-
* without touching the network. Calling it twice for one return is also safe —
|
|
52
|
-
* the return data is consumed the first time.
|
|
53
|
-
*
|
|
54
|
-
* The outcome is ALSO published on the `checkout` topic (`payment-completed` or
|
|
55
|
-
* `payment-failed`), exactly as it would have been had the shopper never left,
|
|
56
|
-
* so a page that already subscribes needs no second code path. Subscribe first,
|
|
57
|
-
* then call this, or the event fires before you are listening.
|
|
58
|
-
*/
|
|
59
|
-
export type ResumeCheckout = (params?: ResumeCheckoutParams) => Promise<ResumeCheckoutResponse>;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
// Resume Checkout Types
|
|
2
|
-
//
|
|
3
|
-
// The RETURN LEG of an online checkout. Some payment methods — and 3-D Secure
|
|
4
|
-
// on a card — take the shopper away to their bank or wallet and send them back
|
|
5
|
-
// to `returnUrl` on a FRESH PAGE LOAD. The payment is not finished at that
|
|
6
|
-
// point: the provider hands the browser a one-time result in the URL, and it
|
|
7
|
-
// has to be handed back to the provider to complete the charge.
|
|
8
|
-
//
|
|
9
|
-
// `startCheckout` cannot do this. It ran in the page that is now gone.
|
|
10
|
-
//
|
|
11
|
-
// Served ONLY by the storefront runtime (a published website), like
|
|
12
|
-
// `startCheckout`. On a register it does not exist.
|
|
13
|
-
export {};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { StartCheckout } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Standalone mock of the storefront checkout.
|
|
4
|
-
*
|
|
5
|
-
* It mirrors the REFUSALS of the real command (empty cart, missing email,
|
|
6
|
-
* container not on the page) in the same order, because those are what a
|
|
7
|
-
* builder actually hits first — a mock that accepted anything would let a
|
|
8
|
-
* checkout screen look finished and fail on the published site.
|
|
9
|
-
*
|
|
10
|
-
* The mounted box is deliberately labelled as a mock. The real command mounts
|
|
11
|
-
* the provider's hosted card fields (iframes owned by the payment provider);
|
|
12
|
-
* nothing here takes a card number, and the placeholder must never look like
|
|
13
|
-
* it does. Its button publishes `payment-completed` so a flow's subscriber —
|
|
14
|
-
* the only way the outcome ever arrives — can be exercised in preview.
|
|
15
|
-
*/
|
|
16
|
-
export declare const mockStartCheckout: StartCheckout;
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { MOCK_CART, MOCK_COMPANY, mockPublishEvent } from '../../demo/database';
|
|
2
|
-
/**
|
|
3
|
-
* Standalone mock of the storefront checkout.
|
|
4
|
-
*
|
|
5
|
-
* It mirrors the REFUSALS of the real command (empty cart, missing email,
|
|
6
|
-
* container not on the page) in the same order, because those are what a
|
|
7
|
-
* builder actually hits first — a mock that accepted anything would let a
|
|
8
|
-
* checkout screen look finished and fail on the published site.
|
|
9
|
-
*
|
|
10
|
-
* The mounted box is deliberately labelled as a mock. The real command mounts
|
|
11
|
-
* the provider's hosted card fields (iframes owned by the payment provider);
|
|
12
|
-
* nothing here takes a card number, and the placeholder must never look like
|
|
13
|
-
* it does. Its button publishes `payment-completed` so a flow's subscriber —
|
|
14
|
-
* the only way the outcome ever arrives — can be exercised in preview.
|
|
15
|
-
*/
|
|
16
|
-
export const mockStartCheckout = async (params) => {
|
|
17
|
-
console.log('[Mock] startCheckout called', params);
|
|
18
|
-
if (!params)
|
|
19
|
-
throw new Error('Params required');
|
|
20
|
-
if (!params.contact?.email || !params.contact.email.trim()) {
|
|
21
|
-
throw new Error('startCheckout: contact.email is required — it is where the receipt goes');
|
|
22
|
-
}
|
|
23
|
-
if (!params.container || typeof params.container !== 'string') {
|
|
24
|
-
throw new Error('startCheckout: container must be a CSS selector string (e.g. "#card-fields") — a DOM element cannot cross the command boundary');
|
|
25
|
-
}
|
|
26
|
-
const lineCount = (MOCK_CART.products?.length ?? 0) + (MOCK_CART.customSales?.length ?? 0);
|
|
27
|
-
if (!lineCount) {
|
|
28
|
-
throw new Error('startCheckout: cannot check out an empty cart');
|
|
29
|
-
}
|
|
30
|
-
// Resolved BEFORE the order is "created", exactly as the real command does:
|
|
31
|
-
// finding out the selector is wrong after an order exists would leave an
|
|
32
|
-
// unpaid order behind for a typo that cost nothing to catch first.
|
|
33
|
-
const container = typeof document === 'undefined' ? null : document.querySelector(params.container);
|
|
34
|
-
if (!container) {
|
|
35
|
-
throw new Error(`startCheckout: checkout container "${params.container}" was not found on the page`);
|
|
36
|
-
}
|
|
37
|
-
const serverTotal = Math.round(MOCK_CART.amountToBeCharged || MOCK_CART.total);
|
|
38
|
-
const currency = MOCK_COMPANY.settings?.currency ?? 'USD';
|
|
39
|
-
const suffix = String(Date.now()).slice(-6);
|
|
40
|
-
const order = {
|
|
41
|
-
orderId: `mock-order-${suffix}`,
|
|
42
|
-
receiptId: `ON-001-${suffix}`,
|
|
43
|
-
serverTotal,
|
|
44
|
-
currency,
|
|
45
|
-
paymentStatus: 'ready',
|
|
46
|
-
orderPassword: `mock-pw-${suffix}`,
|
|
47
|
-
};
|
|
48
|
-
mockPublishEvent('checkout', 'checkout-started', { ...order });
|
|
49
|
-
container.replaceChildren();
|
|
50
|
-
const box = document.createElement('div');
|
|
51
|
-
box.setAttribute('data-mock-checkout', 'true');
|
|
52
|
-
box.style.cssText =
|
|
53
|
-
'border:1px dashed #9aa;border-radius:8px;padding:16px;font:14px system-ui,sans-serif;text-align:center;color:#334';
|
|
54
|
-
const label = document.createElement('div');
|
|
55
|
-
label.textContent = 'Mock payment fields — the published site shows the real hosted card fields here.';
|
|
56
|
-
label.style.cssText = 'margin-bottom:12px;opacity:.75';
|
|
57
|
-
const button = document.createElement('button');
|
|
58
|
-
button.type = 'button';
|
|
59
|
-
button.textContent = `Simulate paying ${(serverTotal / 100).toFixed(2)} ${currency}`;
|
|
60
|
-
button.style.cssText =
|
|
61
|
-
'padding:10px 16px;border:0;border-radius:6px;background:#111;color:#fff;font-size:14px;cursor:pointer';
|
|
62
|
-
button.addEventListener('click', () => {
|
|
63
|
-
button.disabled = true;
|
|
64
|
-
// `Authorised` is what the real provider reports for a successful card
|
|
65
|
-
// entry. It is NOT settlement — see the checkout topic docs.
|
|
66
|
-
mockPublishEvent('checkout', 'payment-completed', {
|
|
67
|
-
orderId: order.orderId,
|
|
68
|
-
receiptId: order.receiptId,
|
|
69
|
-
resultCode: 'Authorised',
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
box.appendChild(label);
|
|
73
|
-
box.appendChild(button);
|
|
74
|
-
container.appendChild(box);
|
|
75
|
-
return {
|
|
76
|
-
success: true,
|
|
77
|
-
timestamp: new Date().toISOString(),
|
|
78
|
-
order,
|
|
79
|
-
};
|
|
80
|
-
};
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Guest contact for the order. There is no shopper account, so this is the only
|
|
3
|
-
* way to reach them — `email` is where the receipt goes and is required.
|
|
4
|
-
*/
|
|
5
|
-
export interface StartCheckoutContact {
|
|
6
|
-
email: string;
|
|
7
|
-
name?: string;
|
|
8
|
-
phone?: string;
|
|
9
|
-
}
|
|
10
|
-
export interface StartCheckoutParams {
|
|
11
|
-
contact: StartCheckoutContact;
|
|
12
|
-
/**
|
|
13
|
-
* CSS SELECTOR for the element the payment fields mount into, e.g.
|
|
14
|
-
* `'#card-fields'`. The element must already be in the DOM when this is
|
|
15
|
-
* called.
|
|
16
|
-
*
|
|
17
|
-
* A SELECTOR, NOT AN ELEMENT — and this is not a style preference. Command
|
|
18
|
-
* params cross a `postMessage` boundary, which serializes them with the
|
|
19
|
-
* structured clone algorithm; a DOM node is not cloneable, so passing
|
|
20
|
-
* `ref.current` throws `DataCloneError: HTMLDivElement object could not be
|
|
21
|
-
* cloned` before the command is ever sent. The string is resolved on the
|
|
22
|
-
* runtime's side against the same document the page rendered.
|
|
23
|
-
*/
|
|
24
|
-
container: string;
|
|
25
|
-
/**
|
|
26
|
-
* Where the provider returns the shopper after a redirect payment method
|
|
27
|
-
* (bank apps, wallets). Defaults to the current URL.
|
|
28
|
-
*
|
|
29
|
-
* Must be HTTPS and on the SAME ORIGIN the storefront token was minted for;
|
|
30
|
-
* the server rejects anything else, since this URL is handed to a payment
|
|
31
|
-
* provider and an open redirect on a checkout is a phishing primitive.
|
|
32
|
-
*/
|
|
33
|
-
returnUrl?: string;
|
|
34
|
-
/**
|
|
35
|
-
* Overrides the cart-derived idempotency key. Leave unset: the default is
|
|
36
|
-
* derived from the cart, which is what makes a shopper's double-tap on "Pay"
|
|
37
|
-
* return the SAME order instead of creating a second, abandoned one.
|
|
38
|
-
*/
|
|
39
|
-
idempotencyKey?: string;
|
|
40
|
-
/** Defaults to the outlet the storefront booted against. */
|
|
41
|
-
outletId?: string;
|
|
42
|
-
/** Forwarded verbatim to the provider's Drop-in (`showPayButton`, `locale`, field styling, …). */
|
|
43
|
-
dropinConfiguration?: Record<string, unknown>;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* The created order. Deliberately says nothing about money having moved — see
|
|
47
|
-
* `paymentStatus` and the `checkout` topic.
|
|
48
|
-
*/
|
|
49
|
-
export interface StartCheckoutOrder {
|
|
50
|
-
orderId: string;
|
|
51
|
-
receiptId: string;
|
|
52
|
-
/** The SERVER-computed total in integer minor units — the only total that matters. */
|
|
53
|
-
serverTotal: number;
|
|
54
|
-
currency: string;
|
|
55
|
-
/**
|
|
56
|
-
* `ready` — the payment fields are mounted and the shopper can pay.
|
|
57
|
-
* `unavailable` — THE ORDER EXISTS but no payment could be started, so the
|
|
58
|
-
* shopper has NOT been charged. Never report this as a failed order.
|
|
59
|
-
*/
|
|
60
|
-
paymentStatus: 'ready' | 'unavailable';
|
|
61
|
-
/**
|
|
62
|
-
* One-time password for reading this order back, returned only on the first
|
|
63
|
-
* create. It is the ONLY route to this order's status — the guest token
|
|
64
|
-
* grants order creation and deliberately not order reads — so a caller that
|
|
65
|
-
* drops it cannot check whether the payment settled.
|
|
66
|
-
*/
|
|
67
|
-
orderPassword?: string;
|
|
68
|
-
}
|
|
69
|
-
export interface StartCheckoutResponse {
|
|
70
|
-
success: boolean;
|
|
71
|
-
timestamp: string;
|
|
72
|
-
order: StartCheckoutOrder;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Creates the server-priced order and mounts the provider's hosted card fields.
|
|
76
|
-
*
|
|
77
|
-
* RESOLVES WHEN THE SHOPPER *CAN* PAY, NOT WHEN THEY HAVE. The shopper has not
|
|
78
|
-
* typed a card yet when this returns. The outcome arrives on the `checkout`
|
|
79
|
-
* topic instead.
|
|
80
|
-
*/
|
|
81
|
-
export type StartCheckout = (params: StartCheckoutParams) => Promise<StartCheckoutResponse>;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
// Start Checkout Types
|
|
2
|
-
//
|
|
3
|
-
// The ONLINE counterpart of the POS tenders: a shopper on a published website
|
|
4
|
-
// pays for the current cart with their own card. Mirrors kaching's storefront
|
|
5
|
-
// `startCheckout` input and result. All money is integer MINOR currency units.
|
|
6
|
-
//
|
|
7
|
-
// This command is served ONLY by the storefront runtime (a published website).
|
|
8
|
-
// On a register it does not exist, exactly as the till tenders (`cashPayment`,
|
|
9
|
-
// `terminalPayment`, `tapToPayPayment`, `chargeMoto`) do not exist online.
|
|
10
|
-
export {};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { TopicEvent } from "../../../types";
|
|
2
|
-
/**
|
|
3
|
-
* Payload for checkout-started event
|
|
4
|
-
*
|
|
5
|
-
* The order EXISTS and is unpaid. `serverTotal` is the server's own price for
|
|
6
|
-
* the cart, in integer minor units — the browser never sends a price, so this
|
|
7
|
-
* is the first and only authoritative total.
|
|
8
|
-
*/
|
|
9
|
-
export interface CheckoutStartedPayload {
|
|
10
|
-
orderId: string;
|
|
11
|
-
receiptId: string;
|
|
12
|
-
serverTotal: number;
|
|
13
|
-
currency: string;
|
|
14
|
-
/**
|
|
15
|
-
* `ready` — the payment fields are mounted and the shopper can pay.
|
|
16
|
-
* `unavailable` — the order exists but no payment could be started, so the
|
|
17
|
-
* shopper has NOT been charged.
|
|
18
|
-
*/
|
|
19
|
-
paymentStatus: "ready" | "unavailable";
|
|
20
|
-
/** One-time password for reading this order back. Returned only on the first create. */
|
|
21
|
-
orderPassword?: string;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Typed event for checkout-started
|
|
25
|
-
*/
|
|
26
|
-
export type CheckoutStartedEvent = TopicEvent<CheckoutStartedPayload>;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Checkout Topic Definition
|
|
3
|
-
* Defines the checkout topic and its available event types
|
|
4
|
-
*/
|
|
5
|
-
export const checkoutTopic = {
|
|
6
|
-
id: "checkout",
|
|
7
|
-
name: "Checkout",
|
|
8
|
-
description: "Topic for online (website) checkout events",
|
|
9
|
-
eventTypes: [
|
|
10
|
-
{
|
|
11
|
-
id: "checkout-started",
|
|
12
|
-
name: "Checkout Started",
|
|
13
|
-
description: "Published when the order has been created and the payment fields are mounted"
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
id: "payment-completed",
|
|
17
|
-
name: "Payment Completed",
|
|
18
|
-
description: "Published when the shopper's payment succeeds on their side (authorisation, not settlement)"
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
id: "payment-failed",
|
|
22
|
-
name: "Payment Failed",
|
|
23
|
-
description: "Published when a payment attempt is refused or errors; the shopper can retry"
|
|
24
|
-
}
|
|
25
|
-
]
|
|
26
|
-
};
|
|
27
|
-
// Re-export types
|
|
28
|
-
export * from "./types";
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { TopicEvent } from "../../../types";
|
|
2
|
-
/**
|
|
3
|
-
* Payload for payment-completed event
|
|
4
|
-
*
|
|
5
|
-
* THIS IS NOT SETTLEMENT. It reports that the SHOPPER'S side finished —
|
|
6
|
-
* `resultCode` is the provider's own outcome, typically `Authorised`. The money
|
|
7
|
-
* is confirmed by the provider's capture webhook reaching the backend, out of
|
|
8
|
-
* band and after this page is done, so this event cannot and does not claim it.
|
|
9
|
-
*/
|
|
10
|
-
export interface PaymentCompletedPayload {
|
|
11
|
-
orderId: string;
|
|
12
|
-
receiptId: string;
|
|
13
|
-
/** The provider's result code, e.g. `Authorised`. */
|
|
14
|
-
resultCode: string;
|
|
15
|
-
/**
|
|
16
|
-
* OPAQUE PROOF OF THIS PAYMENT, handed to the browser by the provider and to
|
|
17
|
-
* nobody else. Pass it to the order-status read and the server verifies it
|
|
18
|
-
* with the provider before believing a word of it.
|
|
19
|
-
*
|
|
20
|
-
* It is the only evidence of an outcome that exists outside the provider's
|
|
21
|
-
* webhook, so it is what recovers an order whose confirmation never arrived.
|
|
22
|
-
* Treat it as a credential: do not log it, do not put it in a URL you share.
|
|
23
|
-
*
|
|
24
|
-
* Absent when the provider reported no payment (see `resultCode`).
|
|
25
|
-
*/
|
|
26
|
-
sessionResult?: string;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Typed event for payment-completed
|
|
30
|
-
*/
|
|
31
|
-
export type PaymentCompletedEvent = TopicEvent<PaymentCompletedPayload>;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { TopicEvent } from "../../../types";
|
|
2
|
-
/**
|
|
3
|
-
* Payload for payment-failed event
|
|
4
|
-
*
|
|
5
|
-
* ONE DECLINED ATTEMPT, NOT A DEAD CHECKOUT. The order and the mounted payment
|
|
6
|
-
* fields both survive, so the shopper can try another card without the page
|
|
7
|
-
* starting a new checkout.
|
|
8
|
-
*/
|
|
9
|
-
export interface PaymentFailedPayload {
|
|
10
|
-
orderId: string;
|
|
11
|
-
receiptId: string;
|
|
12
|
-
/** The provider's result code, e.g. `Refused`, or an error name. */
|
|
13
|
-
resultCode: string;
|
|
14
|
-
/** Present when the failure carried a message worth showing. */
|
|
15
|
-
message?: string;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Typed event for payment-failed
|
|
19
|
-
*/
|
|
20
|
-
export type PaymentFailedEvent = TopicEvent<PaymentFailedPayload>;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Checkout Topic Types
|
|
3
|
-
* Aggregated types for all online-checkout events
|
|
4
|
-
*/
|
|
5
|
-
export * from "./checkout-started/types";
|
|
6
|
-
export * from "./payment-completed/types";
|
|
7
|
-
export * from "./payment-failed/types";
|
|
8
|
-
import type { CheckoutStartedPayload } from "./checkout-started/types";
|
|
9
|
-
import type { PaymentCompletedPayload } from "./payment-completed/types";
|
|
10
|
-
import type { PaymentFailedPayload } from "./payment-failed/types";
|
|
11
|
-
export type CheckoutEventPayload = CheckoutStartedPayload | PaymentCompletedPayload | PaymentFailedPayload;
|
|
12
|
-
export type CheckoutEventType = "checkout-started" | "payment-completed" | "payment-failed";
|
/package/dist/{pubsub/topics/checkout/checkout-started → actions/add-booking-to-cart}/types.js
RENAMED
|
File without changes
|
|
File without changes
|
/package/dist/{pubsub/topics/checkout/payment-failed → actions/get-booking-availability}/types.js
RENAMED
|
File without changes
|