@joai/sdk 14.0.1 → 14.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +4 -1
- package/dist/index.mjs +11 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -299,7 +299,10 @@ declare function createGuestCommerceStorage(options: GuestCommerceStorageOptions
|
|
|
299
299
|
accessToken
|
|
300
300
|
}: GuestOrderAccess): void;
|
|
301
301
|
readOrderAccess(orderId: string): string | null;
|
|
302
|
-
listOrderAccess(): GuestOrderAccess[]; /**
|
|
302
|
+
listOrderAccess(): GuestOrderAccess[]; /** Remember the order being paid so a gateway return without `?order=` can reopen it. */
|
|
303
|
+
savePendingOrderReturn(orderId: string): void;
|
|
304
|
+
readPendingOrderReturn(): string | null;
|
|
305
|
+
clearPendingOrderReturn(): void; /** Absolute shop URL from a path or full URL (e.g. orders page). */
|
|
303
306
|
shopUrl(ordersPage: string): string; /** Thank-you → shop handoff URL with capability token query params. */
|
|
304
307
|
orderReturnUrl(ordersPage: string, orderId: string, accessToken: string): string; /** Persist `order` + `orderAccessToken` from the shop handoff query, then strip the token. */
|
|
305
308
|
claimOrderReturn(): GuestOrderAccess | null;
|
package/dist/index.mjs
CHANGED
|
@@ -286,6 +286,7 @@ const orderAccessPrefix = "joai:order-access:";
|
|
|
286
286
|
const checkoutKey = (namespace) => `joai:guest-checkout:${namespace}`;
|
|
287
287
|
const ordersKey = (namespace) => `joai:guest-orders:${namespace}`;
|
|
288
288
|
const orderAccessKey = (namespace, orderId) => `${orderAccessPrefix}${namespace}:${orderId}`;
|
|
289
|
+
const pendingOrderReturnKey = (namespace) => `joai:guest-pending-order-return:${namespace}`;
|
|
289
290
|
const safeGet$1 = (key) => {
|
|
290
291
|
if (typeof localStorage === "undefined") return null;
|
|
291
292
|
try {
|
|
@@ -397,6 +398,16 @@ function createGuestCommerceStorage(options) {
|
|
|
397
398
|
accessToken: entry.accessToken || safeGet$1(orderAccessKey(options.namespace, entry.orderId))
|
|
398
399
|
}));
|
|
399
400
|
},
|
|
401
|
+
/** Remember the order being paid so a gateway return without `?order=` can reopen it. */
|
|
402
|
+
savePendingOrderReturn(orderId) {
|
|
403
|
+
safeSet$1(pendingOrderReturnKey(options.namespace), orderId);
|
|
404
|
+
},
|
|
405
|
+
readPendingOrderReturn() {
|
|
406
|
+
return safeGet$1(pendingOrderReturnKey(options.namespace));
|
|
407
|
+
},
|
|
408
|
+
clearPendingOrderReturn() {
|
|
409
|
+
safeRemove$1(pendingOrderReturnKey(options.namespace));
|
|
410
|
+
},
|
|
400
411
|
/** Absolute shop URL from a path or full URL (e.g. orders page). */
|
|
401
412
|
shopUrl(ordersPage) {
|
|
402
413
|
return absoluteOrdersPageUrl(ordersPage);
|