@curless/hotel-storefront 0.38.5 → 0.38.7
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/backend.d.ts +18 -1
- package/dist/backend.d.ts.map +1 -1
- package/dist/backend.js.map +1 -1
- package/dist/card.generated.d.ts +1 -1
- package/dist/card.generated.js +2 -2
- package/dist/card.generated.js.map +1 -1
- package/dist/huazhu/backend.d.ts.map +1 -1
- package/dist/huazhu/backend.js +20 -11
- package/dist/huazhu/backend.js.map +1 -1
- package/dist/lib.d.ts +1 -1
- package/dist/lib.d.ts.map +1 -1
- package/dist/lib.js.map +1 -1
- package/dist/server.d.ts +2 -2
- package/dist/server.js +2 -2
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +4 -0
- package/dist/tools.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"card.generated.js","sourceRoot":"","sources":["../src/card.generated.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,wEAAwE;AACxE,gFAAgF;AAChF,4DAA4D;AAC5D,MAAM,CAAC,MAAM,eAAe,GAAW,MAAM,CAAC,IAAI,CAChD,
|
|
1
|
+
{"version":3,"file":"card.generated.js","sourceRoot":"","sources":["../src/card.generated.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,wEAAwE;AACxE,gFAAgF;AAChF,4DAA4D;AAC5D,MAAM,CAAC,MAAM,eAAe,GAAW,MAAM,CAAC,IAAI,CAChD,kwu2BAAkwu2B,EAClwu2B,QAAQ,CACT,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AAEnB,6GAA6G;AAC7G,MAAM,CAAC,MAAM,qBAAqB,GAChC,kEAAkE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"backend.d.ts","sourceRoot":"","sources":["../../src/huazhu/backend.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,mBAAmB,EAExB,KAA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GAAI,QAAQ,WAAW,EAAE,EAAE,KAAK,MAAM,KAAG,WAAW,EAO3E,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,GAAI,SAAS,MAAM,EAAE,IAAI,MAAM,EAAE,WAAU,IAAI,GAAG,IAAW,KAAG,MAKtF,CAAC;AAiCF;;;GAGG;AACH,eAAO,MAAM,UAAU,GACrB,OAAO,UAAU,GAAG,SAAS,EAC7B,GAAG,KAAK;AACR,kGAAkG;AAClG,eAAY,KACX,MAAM,GAAG,SAwBX,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAC7B,MAAM,mBAAmB,KACxB,YAAY,GAAG;IAChB,YAAY,EAAE,mBAAmB,CAAC;IAClC,YAAY,IAAI,MAAM,EAAE,CAAC;IACzB,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAAC;IACnE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAinG9B,CAAC"}
|
package/dist/huazhu/backend.js
CHANGED
|
@@ -29,6 +29,10 @@ export const HUAZHU_CAPABILITIES = {
|
|
|
29
29
|
// the guest - email and phone are its optional fields - and what Huazhu
|
|
30
30
|
// does not require, neither do we (robin, 2026-10-15). It was required from
|
|
31
31
|
// 2026-10-05, for the hotel to reach a guest who had paid nothing.
|
|
32
|
+
// But asked, optional (robin, 2026-10-15: "电话不是必填的,但是还是要可以
|
|
33
|
+
// 输入才行"): given, it goes to Huazhu as the contact's phone - see `isPhone`.
|
|
34
|
+
// Set by 香格里拉 at 华住's word ("你顺手在华住那边一起设了也行").
|
|
35
|
+
asksPhone: true,
|
|
32
36
|
// Its hotels are in China and charge in yuan.
|
|
33
37
|
oneCurrency: true,
|
|
34
38
|
// What the card shows as an example code: ours, from `newPublicCode`.
|
|
@@ -2323,16 +2327,20 @@ export const createHuazhuHotels = (opts) => {
|
|
|
2323
2327
|
const found = findOwn(code, { ...who, email: asked });
|
|
2324
2328
|
if (!found || found.guest.email.trim().toLowerCase() !== asked)
|
|
2325
2329
|
return undefined;
|
|
2326
|
-
const refused = (why) => ({
|
|
2330
|
+
const refused = (why, code) => ({
|
|
2331
|
+
kind: 'refused',
|
|
2332
|
+
why,
|
|
2333
|
+
code,
|
|
2334
|
+
});
|
|
2327
2335
|
const notWaiting = (b) => !b.prepaid
|
|
2328
|
-
? `${b.confirmationCode} is paid at the hotel - there is nothing to pay now
|
|
2336
|
+
? refused(`${b.confirmationCode} is paid at the hotel - there is nothing to pay now.`, 'paid-at-hotel')
|
|
2329
2337
|
: b.status !== 'awaiting-payment'
|
|
2330
|
-
? `${b.confirmationCode} is ${b.status} - it is not waiting for a payment
|
|
2338
|
+
? refused(`${b.confirmationCode} is ${b.status} - it is not waiting for a payment.`, 'not-awaiting')
|
|
2331
2339
|
: undefined;
|
|
2332
2340
|
const first = store.get(found.id) ?? found;
|
|
2333
2341
|
const no = notWaiting(first);
|
|
2334
2342
|
if (no)
|
|
2335
|
-
return
|
|
2343
|
+
return no;
|
|
2336
2344
|
if (first.prepaid?.method === 'unionpay' && first.prepaid.url)
|
|
2337
2345
|
return { kind: 'confirm', url: first.prepaid.url, booking: publicBooking(first) };
|
|
2338
2346
|
let cards;
|
|
@@ -2340,7 +2348,7 @@ export const createHuazhuHotels = (opts) => {
|
|
|
2340
2348
|
cards = await unionpay.cardsOf(first.guest.email);
|
|
2341
2349
|
}
|
|
2342
2350
|
catch (err) {
|
|
2343
|
-
return refused(`UnionPay could not be reached (${err.message}). Nothing changed - the card page still works, or ask again
|
|
2351
|
+
return refused(`UnionPay could not be reached (${err.message}). Nothing changed - the card page still works, or ask again.`, 'unreachable');
|
|
2344
2352
|
}
|
|
2345
2353
|
const card = cards[0];
|
|
2346
2354
|
// No card yet: UnionPay's page to bind one - and nothing else changes.
|
|
@@ -2349,14 +2357,14 @@ export const createHuazhuHotels = (opts) => {
|
|
|
2349
2357
|
return { kind: 'enroll', url: (await unionpay.enroll(first.guest.email)).url };
|
|
2350
2358
|
}
|
|
2351
2359
|
catch (err) {
|
|
2352
|
-
return refused(`UnionPay's page for adding a card could not be opened (${err.message}). Nothing changed - ask again
|
|
2360
|
+
return refused(`UnionPay's page for adding a card could not be opened (${err.message}). Nothing changed - ask again.`, 'unreachable');
|
|
2353
2361
|
}
|
|
2354
2362
|
}
|
|
2355
2363
|
return inTurn(async () => {
|
|
2356
2364
|
const row = store.get(first.id) ?? first;
|
|
2357
2365
|
const again = notWaiting(row);
|
|
2358
2366
|
if (again)
|
|
2359
|
-
return
|
|
2367
|
+
return again;
|
|
2360
2368
|
const p = row.prepaid;
|
|
2361
2369
|
if (p.method === 'unionpay' && p.url)
|
|
2362
2370
|
return { kind: 'confirm', url: p.url, booking: publicBooking(row) };
|
|
@@ -2367,7 +2375,7 @@ export const createHuazhuHotels = (opts) => {
|
|
|
2367
2375
|
state = await checkout.close(p.sessionId);
|
|
2368
2376
|
}
|
|
2369
2377
|
catch (err) {
|
|
2370
|
-
return refused(`The card page could not be closed (${err.message}). Nothing changed - ask again
|
|
2378
|
+
return refused(`The card page could not be closed (${err.message}). Nothing changed - ask again.`, 'unreachable');
|
|
2371
2379
|
}
|
|
2372
2380
|
if (state === 'paid') {
|
|
2373
2381
|
await settlePrepaid(row);
|
|
@@ -2404,9 +2412,10 @@ export const createHuazhuHotels = (opts) => {
|
|
|
2404
2412
|
status: 'expired',
|
|
2405
2413
|
prepaid: { ...p, sessionId: undefined, url: undefined, lapsedAt: now() },
|
|
2406
2414
|
});
|
|
2407
|
-
|
|
2415
|
+
const said = refusalCode(err, row.rooms).code;
|
|
2416
|
+
return refused(`Nothing was booked or charged: ${refusalWords(err, `${row.hotelName} - ${title}`, p.currency)}`, said === 'price-changed' || said === 'sold-out' ? said : 'hotel-refused');
|
|
2408
2417
|
}
|
|
2409
|
-
return refused(`Huazhu could not be reached to check the stay (${err.message}). Nothing was charged - ask again
|
|
2418
|
+
return refused(`Huazhu could not be reached to check the stay (${err.message}). Nothing was charged - ask again.`, 'unreachable');
|
|
2410
2419
|
}
|
|
2411
2420
|
const names = hotelNamesOf(row.hotelId);
|
|
2412
2421
|
const nights = row.quote.lines[0]?.nights ?? 1;
|
|
@@ -2426,7 +2435,7 @@ export const createHuazhuHotels = (opts) => {
|
|
|
2426
2435
|
});
|
|
2427
2436
|
}
|
|
2428
2437
|
catch (err) {
|
|
2429
|
-
return refused(`UnionPay's page could not be opened (${err.message}). Nothing was charged - ask again
|
|
2438
|
+
return refused(`UnionPay's page could not be opened (${err.message}). Nothing was charged - ask again.`, 'unreachable');
|
|
2430
2439
|
}
|
|
2431
2440
|
const updated = store.update(row.id, {
|
|
2432
2441
|
paymentType: 'CCPN',
|