@aforoai/storefront-widgets 1.0.6 → 1.0.12
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/CHANGELOG.md +108 -0
- package/dist/{AforoEmbed-VYb6_GXB.d.cts → AforoEmbed-BX2HPXWT.d.cts} +1 -1
- package/dist/{AforoEmbed-BkJF1hAN.d.ts → AforoEmbed-PsTY7zh0.d.ts} +1 -1
- package/dist/index.cjs +54 -36
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.mjs +54 -36
- package/dist/loader.js +1 -1
- package/dist/loader.mjs +1 -1
- package/dist/sri.json +11 -11
- package/dist/{types-BbQw2_32.d.cts → types-RMTEXoGw.d.cts} +7 -2
- package/dist/{types-BbQw2_32.d.ts → types-RMTEXoGw.d.ts} +7 -2
- package/dist/vanilla/index.cjs +54 -36
- package/dist/vanilla/index.d.cts +2 -2
- package/dist/vanilla/index.d.ts +2 -2
- package/dist/vanilla/index.mjs +54 -36
- package/dist/vue/index.cjs +54 -36
- package/dist/vue/index.d.cts +1 -1
- package/dist/vue/index.d.ts +1 -1
- package/dist/vue/index.mjs +54 -36
- package/dist/widgets/checkout-flow.js +5 -5
- package/dist/widgets/invoice-list.js +5 -5
- package/dist/widgets/payment-method.js +5 -5
- package/dist/widgets/pricing-card.js +7 -7
- package/dist/widgets/subscribe-button.js +7 -7
- package/dist/widgets/subscription-manager.js +5 -5
- package/dist/widgets/upgrade-cancel.js +4 -4
- package/dist/widgets/usage-meter.js +8 -8
- package/loader.sri.txt +1 -1
- package/package.json +1 -1
package/dist/vue/index.cjs
CHANGED
|
@@ -28,7 +28,7 @@ var React7__namespace = /*#__PURE__*/_interopNamespace(React7);
|
|
|
28
28
|
// src/vue/index.ts
|
|
29
29
|
|
|
30
30
|
// src/core/version.ts
|
|
31
|
-
var VERSION = "1.0.
|
|
31
|
+
var VERSION = "1.0.12";
|
|
32
32
|
|
|
33
33
|
// src/core/AforoEmbed.ts
|
|
34
34
|
var mountedElements = /* @__PURE__ */ new WeakMap();
|
|
@@ -889,8 +889,9 @@ var _BridgeClient = class _BridgeClient {
|
|
|
889
889
|
}
|
|
890
890
|
if (!resp.ok) return emptyPage;
|
|
891
891
|
try {
|
|
892
|
-
const
|
|
893
|
-
if (!
|
|
892
|
+
const raw = await resp.json();
|
|
893
|
+
if (!raw || typeof raw !== "object") return emptyPage;
|
|
894
|
+
const body = raw.data ?? raw;
|
|
894
895
|
return {
|
|
895
896
|
content: Array.isArray(body.content) ? body.content : [],
|
|
896
897
|
totalElements: typeof body.totalElements === "number" && Number.isFinite(body.totalElements) ? body.totalElements : 0,
|
|
@@ -933,7 +934,8 @@ var _BridgeClient = class _BridgeClient {
|
|
|
933
934
|
}
|
|
934
935
|
if (!resp.ok) return null;
|
|
935
936
|
try {
|
|
936
|
-
const
|
|
937
|
+
const raw = await resp.json();
|
|
938
|
+
const body = raw ? raw.data ?? raw : null;
|
|
937
939
|
if (!body || typeof body.downloadUrl !== "string" || body.downloadUrl.length === 0) {
|
|
938
940
|
return null;
|
|
939
941
|
}
|
|
@@ -1022,7 +1024,8 @@ var _BridgeClient = class _BridgeClient {
|
|
|
1022
1024
|
}
|
|
1023
1025
|
let body;
|
|
1024
1026
|
try {
|
|
1025
|
-
|
|
1027
|
+
const raw = await resp.json();
|
|
1028
|
+
body = raw?.data ?? raw;
|
|
1026
1029
|
} catch {
|
|
1027
1030
|
throw new BridgeClientError(
|
|
1028
1031
|
"Malformed invoice-payment-initiate response (not JSON)",
|
|
@@ -1333,9 +1336,9 @@ var _BridgeClient = class _BridgeClient {
|
|
|
1333
1336
|
if (!resp.ok) {
|
|
1334
1337
|
throw await this.parseError(resp);
|
|
1335
1338
|
}
|
|
1336
|
-
let
|
|
1339
|
+
let raw;
|
|
1337
1340
|
try {
|
|
1338
|
-
|
|
1341
|
+
raw = await resp.json();
|
|
1339
1342
|
} catch {
|
|
1340
1343
|
throw new BridgeClientError(
|
|
1341
1344
|
"Malformed confirmCart response (not JSON)",
|
|
@@ -1344,6 +1347,7 @@ var _BridgeClient = class _BridgeClient {
|
|
|
1344
1347
|
false
|
|
1345
1348
|
);
|
|
1346
1349
|
}
|
|
1350
|
+
const body = raw?.data ?? raw ?? {};
|
|
1347
1351
|
if (!body.cartId || !body.status) {
|
|
1348
1352
|
throw new BridgeClientError(
|
|
1349
1353
|
"Malformed confirmCart response (missing required fields)",
|
|
@@ -1408,9 +1412,9 @@ var _BridgeClient = class _BridgeClient {
|
|
|
1408
1412
|
* undefined access.
|
|
1409
1413
|
*/
|
|
1410
1414
|
async parseCartResponse(resp, methodName) {
|
|
1411
|
-
let
|
|
1415
|
+
let raw;
|
|
1412
1416
|
try {
|
|
1413
|
-
|
|
1417
|
+
raw = await resp.json();
|
|
1414
1418
|
} catch {
|
|
1415
1419
|
throw new BridgeClientError(
|
|
1416
1420
|
`Malformed ${methodName} response (not JSON)`,
|
|
@@ -1419,7 +1423,8 @@ var _BridgeClient = class _BridgeClient {
|
|
|
1419
1423
|
false
|
|
1420
1424
|
);
|
|
1421
1425
|
}
|
|
1422
|
-
|
|
1426
|
+
const data = raw?.data ?? raw ?? {};
|
|
1427
|
+
if (!data.cartId || !data.cartType || !data.status || !data.targetId) {
|
|
1423
1428
|
throw new BridgeClientError(
|
|
1424
1429
|
`Malformed ${methodName} response (missing required fields)`,
|
|
1425
1430
|
500,
|
|
@@ -1428,21 +1433,21 @@ var _BridgeClient = class _BridgeClient {
|
|
|
1428
1433
|
);
|
|
1429
1434
|
}
|
|
1430
1435
|
return {
|
|
1431
|
-
cartId:
|
|
1432
|
-
cartType:
|
|
1433
|
-
targetId:
|
|
1434
|
-
status:
|
|
1435
|
-
totalCents: typeof
|
|
1436
|
-
currency: typeof
|
|
1437
|
-
gatewayProvider:
|
|
1438
|
-
gatewayClientSecret:
|
|
1439
|
-
gatewayOrderId:
|
|
1440
|
-
gatewayApprovalUrl:
|
|
1441
|
-
gatewaySandboxMode:
|
|
1442
|
-
subscriptionId:
|
|
1443
|
-
invoiceId:
|
|
1444
|
-
expiresAt: typeof
|
|
1445
|
-
completedAt:
|
|
1436
|
+
cartId: data.cartId,
|
|
1437
|
+
cartType: data.cartType,
|
|
1438
|
+
targetId: data.targetId,
|
|
1439
|
+
status: data.status,
|
|
1440
|
+
totalCents: typeof data.totalCents === "number" && Number.isFinite(data.totalCents) ? data.totalCents : 0,
|
|
1441
|
+
currency: typeof data.currency === "string" ? data.currency : "USD",
|
|
1442
|
+
gatewayProvider: data.gatewayProvider ?? null,
|
|
1443
|
+
gatewayClientSecret: data.gatewayClientSecret ?? null,
|
|
1444
|
+
gatewayOrderId: data.gatewayOrderId ?? null,
|
|
1445
|
+
gatewayApprovalUrl: data.gatewayApprovalUrl ?? null,
|
|
1446
|
+
gatewaySandboxMode: data.gatewaySandboxMode ?? null,
|
|
1447
|
+
subscriptionId: data.subscriptionId ?? null,
|
|
1448
|
+
invoiceId: data.invoiceId ?? null,
|
|
1449
|
+
expiresAt: typeof data.expiresAt === "string" ? data.expiresAt : (/* @__PURE__ */ new Date(0)).toISOString(),
|
|
1450
|
+
completedAt: data.completedAt ?? null
|
|
1446
1451
|
};
|
|
1447
1452
|
}
|
|
1448
1453
|
/** Public liveness probe. Returns null on failure (not an error). */
|
|
@@ -1674,7 +1679,8 @@ var _BridgeClient = class _BridgeClient {
|
|
|
1674
1679
|
}
|
|
1675
1680
|
if (!resp.ok) return null;
|
|
1676
1681
|
try {
|
|
1677
|
-
const
|
|
1682
|
+
const raw = await resp.json();
|
|
1683
|
+
const body = raw?.data ?? raw ?? {};
|
|
1678
1684
|
if (!body || typeof body !== "object" || !body.subscriptionId) {
|
|
1679
1685
|
return null;
|
|
1680
1686
|
}
|
|
@@ -1803,14 +1809,17 @@ var _BridgeClient = class _BridgeClient {
|
|
|
1803
1809
|
idempotencyKey,
|
|
1804
1810
|
sessionJwt
|
|
1805
1811
|
}),
|
|
1806
|
-
|
|
1812
|
+
// 2026-08-29 fix: same bug as cancelSubscription() below — EmbedUpgradeRequest
|
|
1813
|
+
// requires idempotencyKey as a @NotBlank BODY field, but this only ever sent
|
|
1814
|
+
// it via the Idempotency-Key header.
|
|
1815
|
+
body: JSON.stringify({ ...request, idempotencyKey })
|
|
1807
1816
|
});
|
|
1808
1817
|
if (!resp.ok) {
|
|
1809
1818
|
throw await this.parseError(resp);
|
|
1810
1819
|
}
|
|
1811
|
-
let
|
|
1820
|
+
let raw;
|
|
1812
1821
|
try {
|
|
1813
|
-
|
|
1822
|
+
raw = await resp.json();
|
|
1814
1823
|
} catch {
|
|
1815
1824
|
throw new BridgeClientError(
|
|
1816
1825
|
"Malformed upgrade response (not JSON)",
|
|
@@ -1819,6 +1828,7 @@ var _BridgeClient = class _BridgeClient {
|
|
|
1819
1828
|
false
|
|
1820
1829
|
);
|
|
1821
1830
|
}
|
|
1831
|
+
const body = raw ? raw.data ?? raw : {};
|
|
1822
1832
|
if (!body.subscriptionId || !body.previousOfferingId || !body.newOfferingId || !body.status) {
|
|
1823
1833
|
throw new BridgeClientError(
|
|
1824
1834
|
"Malformed upgrade response (missing required fields)",
|
|
@@ -1882,14 +1892,19 @@ var _BridgeClient = class _BridgeClient {
|
|
|
1882
1892
|
idempotencyKey,
|
|
1883
1893
|
sessionJwt
|
|
1884
1894
|
}),
|
|
1885
|
-
|
|
1895
|
+
// 2026-08-29 fix: EmbedCancelRequest (storefront-service) requires
|
|
1896
|
+
// idempotencyKey as a @NotBlank BODY field — this only ever sent it
|
|
1897
|
+
// via the Idempotency-Key header, so every real cancellation 400'd
|
|
1898
|
+
// with "idempotencyKey is required" regardless of any other field.
|
|
1899
|
+
// Confirmed live against production.
|
|
1900
|
+
body: JSON.stringify({ ...request, idempotencyKey })
|
|
1886
1901
|
});
|
|
1887
1902
|
if (!resp.ok) {
|
|
1888
1903
|
throw await this.parseError(resp);
|
|
1889
1904
|
}
|
|
1890
|
-
let
|
|
1905
|
+
let raw;
|
|
1891
1906
|
try {
|
|
1892
|
-
|
|
1907
|
+
raw = await resp.json();
|
|
1893
1908
|
} catch {
|
|
1894
1909
|
throw new BridgeClientError(
|
|
1895
1910
|
"Malformed cancel response (not JSON)",
|
|
@@ -1898,7 +1913,8 @@ var _BridgeClient = class _BridgeClient {
|
|
|
1898
1913
|
false
|
|
1899
1914
|
);
|
|
1900
1915
|
}
|
|
1901
|
-
|
|
1916
|
+
const body = raw ? raw.data ?? raw : null;
|
|
1917
|
+
if (!body || !body.subscriptionId || !body.status || !body.effectiveAt) {
|
|
1902
1918
|
throw new BridgeClientError(
|
|
1903
1919
|
"Malformed cancel response (missing required fields)",
|
|
1904
1920
|
500,
|
|
@@ -1911,7 +1927,7 @@ var _BridgeClient = class _BridgeClient {
|
|
|
1911
1927
|
status: body.status,
|
|
1912
1928
|
cancelledAt: body.cancelledAt ?? null,
|
|
1913
1929
|
effectiveAt: body.effectiveAt,
|
|
1914
|
-
feedbackId: body.feedbackId,
|
|
1930
|
+
feedbackId: body.feedbackId ?? null,
|
|
1915
1931
|
creditNoteId: body.creditNoteId ?? null
|
|
1916
1932
|
};
|
|
1917
1933
|
}
|
|
@@ -1941,7 +1957,8 @@ var _BridgeClient = class _BridgeClient {
|
|
|
1941
1957
|
if (!resp.ok) {
|
|
1942
1958
|
return { methods: [], defaultMethodId: null };
|
|
1943
1959
|
}
|
|
1944
|
-
const
|
|
1960
|
+
const raw = await resp.json();
|
|
1961
|
+
const body = raw ? raw.data ?? raw : {};
|
|
1945
1962
|
return {
|
|
1946
1963
|
methods: Array.isArray(body.methods) ? body.methods : [],
|
|
1947
1964
|
defaultMethodId: body.defaultMethodId ?? null
|
|
@@ -1971,7 +1988,8 @@ var _BridgeClient = class _BridgeClient {
|
|
|
1971
1988
|
body: JSON.stringify({})
|
|
1972
1989
|
});
|
|
1973
1990
|
if (!resp.ok) return null;
|
|
1974
|
-
const
|
|
1991
|
+
const raw = await resp.json();
|
|
1992
|
+
const body = raw ? raw.data ?? raw : {};
|
|
1975
1993
|
if (!body.clientSecret) return null;
|
|
1976
1994
|
return {
|
|
1977
1995
|
clientSecret: body.clientSecret,
|
package/dist/vue/index.d.cts
CHANGED
package/dist/vue/index.d.ts
CHANGED
package/dist/vue/index.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
|
6
6
|
// src/vue/index.ts
|
|
7
7
|
|
|
8
8
|
// src/core/version.ts
|
|
9
|
-
var VERSION = "1.0.
|
|
9
|
+
var VERSION = "1.0.12";
|
|
10
10
|
|
|
11
11
|
// src/core/AforoEmbed.ts
|
|
12
12
|
var mountedElements = /* @__PURE__ */ new WeakMap();
|
|
@@ -867,8 +867,9 @@ var _BridgeClient = class _BridgeClient {
|
|
|
867
867
|
}
|
|
868
868
|
if (!resp.ok) return emptyPage;
|
|
869
869
|
try {
|
|
870
|
-
const
|
|
871
|
-
if (!
|
|
870
|
+
const raw = await resp.json();
|
|
871
|
+
if (!raw || typeof raw !== "object") return emptyPage;
|
|
872
|
+
const body = raw.data ?? raw;
|
|
872
873
|
return {
|
|
873
874
|
content: Array.isArray(body.content) ? body.content : [],
|
|
874
875
|
totalElements: typeof body.totalElements === "number" && Number.isFinite(body.totalElements) ? body.totalElements : 0,
|
|
@@ -911,7 +912,8 @@ var _BridgeClient = class _BridgeClient {
|
|
|
911
912
|
}
|
|
912
913
|
if (!resp.ok) return null;
|
|
913
914
|
try {
|
|
914
|
-
const
|
|
915
|
+
const raw = await resp.json();
|
|
916
|
+
const body = raw ? raw.data ?? raw : null;
|
|
915
917
|
if (!body || typeof body.downloadUrl !== "string" || body.downloadUrl.length === 0) {
|
|
916
918
|
return null;
|
|
917
919
|
}
|
|
@@ -1000,7 +1002,8 @@ var _BridgeClient = class _BridgeClient {
|
|
|
1000
1002
|
}
|
|
1001
1003
|
let body;
|
|
1002
1004
|
try {
|
|
1003
|
-
|
|
1005
|
+
const raw = await resp.json();
|
|
1006
|
+
body = raw?.data ?? raw;
|
|
1004
1007
|
} catch {
|
|
1005
1008
|
throw new BridgeClientError(
|
|
1006
1009
|
"Malformed invoice-payment-initiate response (not JSON)",
|
|
@@ -1311,9 +1314,9 @@ var _BridgeClient = class _BridgeClient {
|
|
|
1311
1314
|
if (!resp.ok) {
|
|
1312
1315
|
throw await this.parseError(resp);
|
|
1313
1316
|
}
|
|
1314
|
-
let
|
|
1317
|
+
let raw;
|
|
1315
1318
|
try {
|
|
1316
|
-
|
|
1319
|
+
raw = await resp.json();
|
|
1317
1320
|
} catch {
|
|
1318
1321
|
throw new BridgeClientError(
|
|
1319
1322
|
"Malformed confirmCart response (not JSON)",
|
|
@@ -1322,6 +1325,7 @@ var _BridgeClient = class _BridgeClient {
|
|
|
1322
1325
|
false
|
|
1323
1326
|
);
|
|
1324
1327
|
}
|
|
1328
|
+
const body = raw?.data ?? raw ?? {};
|
|
1325
1329
|
if (!body.cartId || !body.status) {
|
|
1326
1330
|
throw new BridgeClientError(
|
|
1327
1331
|
"Malformed confirmCart response (missing required fields)",
|
|
@@ -1386,9 +1390,9 @@ var _BridgeClient = class _BridgeClient {
|
|
|
1386
1390
|
* undefined access.
|
|
1387
1391
|
*/
|
|
1388
1392
|
async parseCartResponse(resp, methodName) {
|
|
1389
|
-
let
|
|
1393
|
+
let raw;
|
|
1390
1394
|
try {
|
|
1391
|
-
|
|
1395
|
+
raw = await resp.json();
|
|
1392
1396
|
} catch {
|
|
1393
1397
|
throw new BridgeClientError(
|
|
1394
1398
|
`Malformed ${methodName} response (not JSON)`,
|
|
@@ -1397,7 +1401,8 @@ var _BridgeClient = class _BridgeClient {
|
|
|
1397
1401
|
false
|
|
1398
1402
|
);
|
|
1399
1403
|
}
|
|
1400
|
-
|
|
1404
|
+
const data = raw?.data ?? raw ?? {};
|
|
1405
|
+
if (!data.cartId || !data.cartType || !data.status || !data.targetId) {
|
|
1401
1406
|
throw new BridgeClientError(
|
|
1402
1407
|
`Malformed ${methodName} response (missing required fields)`,
|
|
1403
1408
|
500,
|
|
@@ -1406,21 +1411,21 @@ var _BridgeClient = class _BridgeClient {
|
|
|
1406
1411
|
);
|
|
1407
1412
|
}
|
|
1408
1413
|
return {
|
|
1409
|
-
cartId:
|
|
1410
|
-
cartType:
|
|
1411
|
-
targetId:
|
|
1412
|
-
status:
|
|
1413
|
-
totalCents: typeof
|
|
1414
|
-
currency: typeof
|
|
1415
|
-
gatewayProvider:
|
|
1416
|
-
gatewayClientSecret:
|
|
1417
|
-
gatewayOrderId:
|
|
1418
|
-
gatewayApprovalUrl:
|
|
1419
|
-
gatewaySandboxMode:
|
|
1420
|
-
subscriptionId:
|
|
1421
|
-
invoiceId:
|
|
1422
|
-
expiresAt: typeof
|
|
1423
|
-
completedAt:
|
|
1414
|
+
cartId: data.cartId,
|
|
1415
|
+
cartType: data.cartType,
|
|
1416
|
+
targetId: data.targetId,
|
|
1417
|
+
status: data.status,
|
|
1418
|
+
totalCents: typeof data.totalCents === "number" && Number.isFinite(data.totalCents) ? data.totalCents : 0,
|
|
1419
|
+
currency: typeof data.currency === "string" ? data.currency : "USD",
|
|
1420
|
+
gatewayProvider: data.gatewayProvider ?? null,
|
|
1421
|
+
gatewayClientSecret: data.gatewayClientSecret ?? null,
|
|
1422
|
+
gatewayOrderId: data.gatewayOrderId ?? null,
|
|
1423
|
+
gatewayApprovalUrl: data.gatewayApprovalUrl ?? null,
|
|
1424
|
+
gatewaySandboxMode: data.gatewaySandboxMode ?? null,
|
|
1425
|
+
subscriptionId: data.subscriptionId ?? null,
|
|
1426
|
+
invoiceId: data.invoiceId ?? null,
|
|
1427
|
+
expiresAt: typeof data.expiresAt === "string" ? data.expiresAt : (/* @__PURE__ */ new Date(0)).toISOString(),
|
|
1428
|
+
completedAt: data.completedAt ?? null
|
|
1424
1429
|
};
|
|
1425
1430
|
}
|
|
1426
1431
|
/** Public liveness probe. Returns null on failure (not an error). */
|
|
@@ -1652,7 +1657,8 @@ var _BridgeClient = class _BridgeClient {
|
|
|
1652
1657
|
}
|
|
1653
1658
|
if (!resp.ok) return null;
|
|
1654
1659
|
try {
|
|
1655
|
-
const
|
|
1660
|
+
const raw = await resp.json();
|
|
1661
|
+
const body = raw?.data ?? raw ?? {};
|
|
1656
1662
|
if (!body || typeof body !== "object" || !body.subscriptionId) {
|
|
1657
1663
|
return null;
|
|
1658
1664
|
}
|
|
@@ -1781,14 +1787,17 @@ var _BridgeClient = class _BridgeClient {
|
|
|
1781
1787
|
idempotencyKey,
|
|
1782
1788
|
sessionJwt
|
|
1783
1789
|
}),
|
|
1784
|
-
|
|
1790
|
+
// 2026-08-29 fix: same bug as cancelSubscription() below — EmbedUpgradeRequest
|
|
1791
|
+
// requires idempotencyKey as a @NotBlank BODY field, but this only ever sent
|
|
1792
|
+
// it via the Idempotency-Key header.
|
|
1793
|
+
body: JSON.stringify({ ...request, idempotencyKey })
|
|
1785
1794
|
});
|
|
1786
1795
|
if (!resp.ok) {
|
|
1787
1796
|
throw await this.parseError(resp);
|
|
1788
1797
|
}
|
|
1789
|
-
let
|
|
1798
|
+
let raw;
|
|
1790
1799
|
try {
|
|
1791
|
-
|
|
1800
|
+
raw = await resp.json();
|
|
1792
1801
|
} catch {
|
|
1793
1802
|
throw new BridgeClientError(
|
|
1794
1803
|
"Malformed upgrade response (not JSON)",
|
|
@@ -1797,6 +1806,7 @@ var _BridgeClient = class _BridgeClient {
|
|
|
1797
1806
|
false
|
|
1798
1807
|
);
|
|
1799
1808
|
}
|
|
1809
|
+
const body = raw ? raw.data ?? raw : {};
|
|
1800
1810
|
if (!body.subscriptionId || !body.previousOfferingId || !body.newOfferingId || !body.status) {
|
|
1801
1811
|
throw new BridgeClientError(
|
|
1802
1812
|
"Malformed upgrade response (missing required fields)",
|
|
@@ -1860,14 +1870,19 @@ var _BridgeClient = class _BridgeClient {
|
|
|
1860
1870
|
idempotencyKey,
|
|
1861
1871
|
sessionJwt
|
|
1862
1872
|
}),
|
|
1863
|
-
|
|
1873
|
+
// 2026-08-29 fix: EmbedCancelRequest (storefront-service) requires
|
|
1874
|
+
// idempotencyKey as a @NotBlank BODY field — this only ever sent it
|
|
1875
|
+
// via the Idempotency-Key header, so every real cancellation 400'd
|
|
1876
|
+
// with "idempotencyKey is required" regardless of any other field.
|
|
1877
|
+
// Confirmed live against production.
|
|
1878
|
+
body: JSON.stringify({ ...request, idempotencyKey })
|
|
1864
1879
|
});
|
|
1865
1880
|
if (!resp.ok) {
|
|
1866
1881
|
throw await this.parseError(resp);
|
|
1867
1882
|
}
|
|
1868
|
-
let
|
|
1883
|
+
let raw;
|
|
1869
1884
|
try {
|
|
1870
|
-
|
|
1885
|
+
raw = await resp.json();
|
|
1871
1886
|
} catch {
|
|
1872
1887
|
throw new BridgeClientError(
|
|
1873
1888
|
"Malformed cancel response (not JSON)",
|
|
@@ -1876,7 +1891,8 @@ var _BridgeClient = class _BridgeClient {
|
|
|
1876
1891
|
false
|
|
1877
1892
|
);
|
|
1878
1893
|
}
|
|
1879
|
-
|
|
1894
|
+
const body = raw ? raw.data ?? raw : null;
|
|
1895
|
+
if (!body || !body.subscriptionId || !body.status || !body.effectiveAt) {
|
|
1880
1896
|
throw new BridgeClientError(
|
|
1881
1897
|
"Malformed cancel response (missing required fields)",
|
|
1882
1898
|
500,
|
|
@@ -1889,7 +1905,7 @@ var _BridgeClient = class _BridgeClient {
|
|
|
1889
1905
|
status: body.status,
|
|
1890
1906
|
cancelledAt: body.cancelledAt ?? null,
|
|
1891
1907
|
effectiveAt: body.effectiveAt,
|
|
1892
|
-
feedbackId: body.feedbackId,
|
|
1908
|
+
feedbackId: body.feedbackId ?? null,
|
|
1893
1909
|
creditNoteId: body.creditNoteId ?? null
|
|
1894
1910
|
};
|
|
1895
1911
|
}
|
|
@@ -1919,7 +1935,8 @@ var _BridgeClient = class _BridgeClient {
|
|
|
1919
1935
|
if (!resp.ok) {
|
|
1920
1936
|
return { methods: [], defaultMethodId: null };
|
|
1921
1937
|
}
|
|
1922
|
-
const
|
|
1938
|
+
const raw = await resp.json();
|
|
1939
|
+
const body = raw ? raw.data ?? raw : {};
|
|
1923
1940
|
return {
|
|
1924
1941
|
methods: Array.isArray(body.methods) ? body.methods : [],
|
|
1925
1942
|
defaultMethodId: body.defaultMethodId ?? null
|
|
@@ -1949,7 +1966,8 @@ var _BridgeClient = class _BridgeClient {
|
|
|
1949
1966
|
body: JSON.stringify({})
|
|
1950
1967
|
});
|
|
1951
1968
|
if (!resp.ok) return null;
|
|
1952
|
-
const
|
|
1969
|
+
const raw = await resp.json();
|
|
1970
|
+
const body = raw ? raw.data ?? raw : {};
|
|
1953
1971
|
if (!body.clientSecret) return null;
|
|
1954
1972
|
return {
|
|
1955
1973
|
clientSecret: body.clientSecret,
|