@01.software/sdk 0.49.0 → 0.56.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/CHANGELOG.md +257 -1
- package/MIGRATION.md +56 -0
- package/README.md +269 -56
- package/dist/client.cjs +608 -190
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +6 -6
- package/dist/client.d.ts +6 -6
- package/dist/client.js +608 -190
- package/dist/client.js.map +1 -1
- package/dist/{collection-client-DnDt6EQz.d.ts → collection-client-Bmr53saa.d.ts} +6 -4
- package/dist/{collection-client-XfGLPuTf.d.cts → collection-client-DxuBDso_.d.cts} +6 -4
- package/dist/{const-CBba4lDo.d.cts → const-BKUqg96Q.d.ts} +5 -5
- package/dist/{const-DCNV5Kq7.d.ts → const-Cv1DCsp6.d.cts} +5 -5
- package/dist/embedded-admin/server.cjs +306 -0
- package/dist/embedded-admin/server.cjs.map +1 -0
- package/dist/embedded-admin/server.d.cts +33 -0
- package/dist/embedded-admin/server.d.ts +33 -0
- package/dist/embedded-admin/server.js +288 -0
- package/dist/embedded-admin/server.js.map +1 -0
- package/dist/embedded-admin.cjs +400 -0
- package/dist/embedded-admin.cjs.map +1 -0
- package/dist/embedded-admin.d.cts +61 -0
- package/dist/embedded-admin.d.ts +61 -0
- package/dist/embedded-admin.js +377 -0
- package/dist/embedded-admin.js.map +1 -0
- package/dist/errors.cjs +1 -0
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.cts +3 -3
- package/dist/errors.d.ts +3 -3
- package/dist/errors.js +1 -0
- package/dist/errors.js.map +1 -1
- package/dist/{index-DUuIqUS8.d.ts → index-CGsT4AQ8.d.cts} +89 -10
- package/dist/{index-CbKyoEzy.d.cts → index-DFHLLqYu.d.ts} +89 -10
- package/dist/index.cjs +752 -436
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -69
- package/dist/index.d.ts +12 -69
- package/dist/index.js +752 -436
- package/dist/index.js.map +1 -1
- package/dist/{payload-types-MKbx5MuJ.d.cts → payload-types-Bk-duc5k.d.cts} +545 -141
- package/dist/{payload-types-MKbx5MuJ.d.ts → payload-types-Bk-duc5k.d.ts} +545 -141
- package/dist/query.cjs +108 -71
- package/dist/query.cjs.map +1 -1
- package/dist/query.d.cts +5 -5
- package/dist/query.d.ts +5 -5
- package/dist/query.js +108 -71
- package/dist/query.js.map +1 -1
- package/dist/realtime.d.cts +2 -2
- package/dist/realtime.d.ts +2 -2
- package/dist/server.cjs +502 -175
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +9 -8
- package/dist/server.d.ts +9 -8
- package/dist/server.js +502 -175
- package/dist/server.js.map +1 -1
- package/dist/storefront-cache.cjs +1 -0
- package/dist/storefront-cache.cjs.map +1 -1
- package/dist/storefront-cache.js +1 -0
- package/dist/storefront-cache.js.map +1 -1
- package/dist/{types-1UeOk1Uy.d.cts → types-CEK8uTvU.d.ts} +287 -30
- package/dist/{types-BKr_2avj.d.cts → types-CNdpj2fI.d.cts} +2 -2
- package/dist/{types-L_nh-ED7.d.ts → types-D4mjGFj4.d.ts} +2 -2
- package/dist/{types-Du4s5anw.d.ts → types-Dhk5NX7Z.d.cts} +287 -30
- package/dist/ui/form.d.cts +1 -1
- package/dist/ui/form.d.ts +1 -1
- package/dist/ui/video.d.cts +1 -1
- package/dist/ui/video.d.ts +1 -1
- package/dist/webhook.cjs +135 -80
- package/dist/webhook.cjs.map +1 -1
- package/dist/webhook.d.cts +21 -5
- package/dist/webhook.d.ts +21 -5
- package/dist/webhook.js +135 -80
- package/dist/webhook.js.map +1 -1
- package/package.json +28 -6
package/dist/server.cjs
CHANGED
|
@@ -22,12 +22,14 @@ var server_exports = {};
|
|
|
22
22
|
__export(server_exports, {
|
|
23
23
|
CollectionClient: () => CollectionClient,
|
|
24
24
|
CommunityClient: () => CommunityClient,
|
|
25
|
+
CustomerGroupApi: () => CustomerGroupApi,
|
|
25
26
|
EventsClient: () => EventsClient,
|
|
26
27
|
ModerationApi: () => ModerationApi,
|
|
27
28
|
ServerClient: () => ServerClient,
|
|
28
29
|
ServerCollectionClient: () => ServerCollectionClient,
|
|
29
30
|
ServerCommerceClient: () => ServerCommerceClient,
|
|
30
31
|
ServerPreviewClient: () => ServerPreviewClient,
|
|
32
|
+
TENANT_CONTEXT_PATH: () => TENANT_CONTEXT_PATH,
|
|
31
33
|
TenantIntrospectionApi: () => TenantIntrospectionApi,
|
|
32
34
|
createServerClient: () => createServerClient,
|
|
33
35
|
isApiError: () => isApiError,
|
|
@@ -147,6 +149,7 @@ var COMMERCE_ERROR_CODES = [
|
|
|
147
149
|
"payment_session_not_cancelable",
|
|
148
150
|
"payment_session_conflict",
|
|
149
151
|
"provider_identity_mismatch",
|
|
152
|
+
"managed_refund_attestation_forbidden",
|
|
150
153
|
"payment_method_unavailable",
|
|
151
154
|
"provider_unavailable",
|
|
152
155
|
"lock_timeout",
|
|
@@ -689,11 +692,11 @@ function parseRetryAfter(response) {
|
|
|
689
692
|
permitsAutomaticRetry: seconds <= MAX_AUTOMATIC_RETRY_AFTER_SECONDS
|
|
690
693
|
};
|
|
691
694
|
}
|
|
692
|
-
function mapResponseToError(status, parsed, details, requestId, retryAfter,
|
|
695
|
+
function mapResponseToError(status, parsed, details, requestId, retryAfter, canonicalCommerceError) {
|
|
693
696
|
const errorDetails = {
|
|
694
697
|
...details,
|
|
695
698
|
...parsed.errors && { errors: parsed.errors },
|
|
696
|
-
|
|
699
|
+
...!canonicalCommerceError && parsed.body && { body: parsed.body }
|
|
697
700
|
};
|
|
698
701
|
const suggestion = getParsedErrorSuggestion(status, parsed);
|
|
699
702
|
const finalize = (error) => {
|
|
@@ -701,7 +704,7 @@ function mapResponseToError(status, parsed, details, requestId, retryAfter, erro
|
|
|
701
704
|
if (retryAfter !== void 0) {
|
|
702
705
|
Object.assign(withRequestId, { retryAfter });
|
|
703
706
|
}
|
|
704
|
-
return
|
|
707
|
+
return canonicalCommerceError ? enhanceCommerceError(withRequestId, parsed.body, requestId) : enhanceNonCommerceError(withRequestId, parsed.reason);
|
|
705
708
|
};
|
|
706
709
|
if (status === 400 || status === 422) {
|
|
707
710
|
return finalize(
|
|
@@ -807,6 +810,7 @@ async function httpFetch(url, options) {
|
|
|
807
810
|
retry,
|
|
808
811
|
onUnauthorized,
|
|
809
812
|
errorFamily,
|
|
813
|
+
typedCommerceErrorReasons,
|
|
810
814
|
...requestInit
|
|
811
815
|
} = options || {};
|
|
812
816
|
const baseUrl = resolveApiUrl(apiUrl);
|
|
@@ -860,7 +864,8 @@ async function httpFetch(url, options) {
|
|
|
860
864
|
});
|
|
861
865
|
if (!response.ok) {
|
|
862
866
|
const parsed = await parseErrorBody(response);
|
|
863
|
-
const
|
|
867
|
+
const canonicalCommerceError = errorFamily === "commerce" || typeof parsed.reason === "string" && typedCommerceErrorReasons?.includes(parsed.reason) === true;
|
|
868
|
+
const commerceEnvelope = canonicalCommerceError ? parseCommerceErrorEnvelope(parsed.body, requestId) : void 0;
|
|
864
869
|
if (isUsageLimitExceededResponse(response)) {
|
|
865
870
|
const limit = parseInt(
|
|
866
871
|
response.headers.get("X-Usage-Limit") || "0",
|
|
@@ -888,7 +893,7 @@ async function httpFetch(url, options) {
|
|
|
888
893
|
),
|
|
889
894
|
requestId
|
|
890
895
|
);
|
|
891
|
-
throw
|
|
896
|
+
throw canonicalCommerceError ? enhanceCommerceError(usageError, parsed.body, requestId) : enhanceNonCommerceError(usageError, parsed.reason);
|
|
892
897
|
}
|
|
893
898
|
if (response.status === 401 && onUnauthorized && customerToken && !hasRetried401 && (commerceEnvelope?.reason ?? parsed.reason) === "token_expired") {
|
|
894
899
|
hasRetried401 = true;
|
|
@@ -913,7 +918,7 @@ async function httpFetch(url, options) {
|
|
|
913
918
|
details,
|
|
914
919
|
requestId,
|
|
915
920
|
retryAfter.seconds,
|
|
916
|
-
|
|
921
|
+
canonicalCommerceError
|
|
917
922
|
);
|
|
918
923
|
const method2 = (requestInit.method || "GET").toUpperCase();
|
|
919
924
|
const isTerminal = error instanceof RateLimitError || error instanceof UsageLimitError;
|
|
@@ -1091,15 +1096,15 @@ var HttpClient = class {
|
|
|
1091
1096
|
throw err;
|
|
1092
1097
|
}
|
|
1093
1098
|
}
|
|
1094
|
-
buildUrl(
|
|
1095
|
-
if (!options) return
|
|
1099
|
+
buildUrl(endpoint, options) {
|
|
1100
|
+
if (!options) return endpoint;
|
|
1096
1101
|
const { fallbackLocale, ...rest } = options;
|
|
1097
1102
|
const queryOptions = fallbackLocale === void 0 ? rest : {
|
|
1098
1103
|
...rest,
|
|
1099
1104
|
"fallback-locale": fallbackLocale === false ? "none" : fallbackLocale
|
|
1100
1105
|
};
|
|
1101
1106
|
const queryString = (0, import_qs_esm.stringify)(queryOptions, { addQueryPrefix: true });
|
|
1102
|
-
return queryString ? `${
|
|
1107
|
+
return queryString ? `${endpoint}${queryString}` : endpoint;
|
|
1103
1108
|
}
|
|
1104
1109
|
assertJsonResponse(response) {
|
|
1105
1110
|
const contentType = response.headers.get("content-type");
|
|
@@ -1290,16 +1295,16 @@ var CollectionQueryBuilder = class {
|
|
|
1290
1295
|
* @returns Payload CMS mutation response with doc and message
|
|
1291
1296
|
*/
|
|
1292
1297
|
async create(data, options) {
|
|
1293
|
-
const
|
|
1298
|
+
const endpoint = `/api/${String(this.collection)}`;
|
|
1294
1299
|
if (options?.file) {
|
|
1295
1300
|
return this.api.requestCreateWithFile(
|
|
1296
|
-
|
|
1301
|
+
endpoint,
|
|
1297
1302
|
data,
|
|
1298
1303
|
options.file,
|
|
1299
1304
|
options.filename
|
|
1300
1305
|
);
|
|
1301
1306
|
}
|
|
1302
|
-
return this.api.requestCreate(
|
|
1307
|
+
return this.api.requestCreate(endpoint, data);
|
|
1303
1308
|
}
|
|
1304
1309
|
/**
|
|
1305
1310
|
* Update a document by ID
|
|
@@ -1307,16 +1312,16 @@ var CollectionQueryBuilder = class {
|
|
|
1307
1312
|
* @returns Payload CMS mutation response with doc and message
|
|
1308
1313
|
*/
|
|
1309
1314
|
async update(id, data, options) {
|
|
1310
|
-
const
|
|
1315
|
+
const endpoint = `/api/${String(this.collection)}/${String(id)}`;
|
|
1311
1316
|
if (options?.file) {
|
|
1312
1317
|
return this.api.requestUpdateWithFile(
|
|
1313
|
-
|
|
1318
|
+
endpoint,
|
|
1314
1319
|
data,
|
|
1315
1320
|
options.file,
|
|
1316
1321
|
options.filename
|
|
1317
1322
|
);
|
|
1318
1323
|
}
|
|
1319
|
-
return this.api.requestUpdate(
|
|
1324
|
+
return this.api.requestUpdate(endpoint, data);
|
|
1320
1325
|
}
|
|
1321
1326
|
/**
|
|
1322
1327
|
* Count documents
|
|
@@ -1412,8 +1417,8 @@ var CollectionClient = class extends HttpClient {
|
|
|
1412
1417
|
* Find documents (list query)
|
|
1413
1418
|
* GET /api/{collection}
|
|
1414
1419
|
*/
|
|
1415
|
-
async requestFind(
|
|
1416
|
-
const url = this.buildUrl(
|
|
1420
|
+
async requestFind(endpoint, options) {
|
|
1421
|
+
const url = this.buildUrl(endpoint, options);
|
|
1417
1422
|
const response = await this.fetchWithTracking(url, {
|
|
1418
1423
|
...this.defaultOptions,
|
|
1419
1424
|
method: "GET"
|
|
@@ -1424,8 +1429,8 @@ var CollectionClient = class extends HttpClient {
|
|
|
1424
1429
|
* Find-like response from a custom endpoint
|
|
1425
1430
|
* POST /api/...custom-endpoint
|
|
1426
1431
|
*/
|
|
1427
|
-
async requestFindEndpoint(
|
|
1428
|
-
const response = await this.fetchWithTracking(
|
|
1432
|
+
async requestFindEndpoint(endpoint, data) {
|
|
1433
|
+
const response = await this.fetchWithTracking(endpoint, {
|
|
1429
1434
|
...this.defaultOptions,
|
|
1430
1435
|
method: "POST",
|
|
1431
1436
|
body: data ? JSON.stringify(data) : void 0
|
|
@@ -1435,8 +1440,8 @@ var CollectionClient = class extends HttpClient {
|
|
|
1435
1440
|
/**
|
|
1436
1441
|
* Find-like response from a cacheable GET custom endpoint.
|
|
1437
1442
|
*/
|
|
1438
|
-
async requestFindEndpointGet(
|
|
1439
|
-
const response = await this.fetchWithTracking(
|
|
1443
|
+
async requestFindEndpointGet(endpoint) {
|
|
1444
|
+
const response = await this.fetchWithTracking(endpoint, {
|
|
1440
1445
|
...this.defaultOptions,
|
|
1441
1446
|
method: "GET"
|
|
1442
1447
|
});
|
|
@@ -1446,8 +1451,8 @@ var CollectionClient = class extends HttpClient {
|
|
|
1446
1451
|
* Find document by ID
|
|
1447
1452
|
* GET /api/{collection}/{id}
|
|
1448
1453
|
*/
|
|
1449
|
-
async requestFindById(
|
|
1450
|
-
const url = this.buildUrl(
|
|
1454
|
+
async requestFindById(endpoint, options) {
|
|
1455
|
+
const url = this.buildUrl(endpoint, options);
|
|
1451
1456
|
const response = await this.fetchWithTracking(url, {
|
|
1452
1457
|
...this.defaultOptions,
|
|
1453
1458
|
method: "GET"
|
|
@@ -1458,8 +1463,8 @@ var CollectionClient = class extends HttpClient {
|
|
|
1458
1463
|
* Create document
|
|
1459
1464
|
* POST /api/{collection}
|
|
1460
1465
|
*/
|
|
1461
|
-
async requestCreate(
|
|
1462
|
-
const response = await this.fetchWithTracking(
|
|
1466
|
+
async requestCreate(endpoint, data) {
|
|
1467
|
+
const response = await this.fetchWithTracking(endpoint, {
|
|
1463
1468
|
...this.defaultOptions,
|
|
1464
1469
|
method: "POST",
|
|
1465
1470
|
body: data ? JSON.stringify(data) : void 0
|
|
@@ -1470,8 +1475,8 @@ var CollectionClient = class extends HttpClient {
|
|
|
1470
1475
|
* Update document
|
|
1471
1476
|
* PATCH /api/{collection}/{id}
|
|
1472
1477
|
*/
|
|
1473
|
-
async requestUpdate(
|
|
1474
|
-
const response = await this.fetchWithTracking(
|
|
1478
|
+
async requestUpdate(endpoint, data) {
|
|
1479
|
+
const response = await this.fetchWithTracking(endpoint, {
|
|
1475
1480
|
...this.defaultOptions,
|
|
1476
1481
|
method: "PATCH",
|
|
1477
1482
|
body: data ? JSON.stringify(data) : void 0
|
|
@@ -1482,8 +1487,8 @@ var CollectionClient = class extends HttpClient {
|
|
|
1482
1487
|
* Count documents
|
|
1483
1488
|
* GET /api/{collection}/count
|
|
1484
1489
|
*/
|
|
1485
|
-
async requestCount(
|
|
1486
|
-
const url = this.buildUrl(
|
|
1490
|
+
async requestCount(endpoint, options) {
|
|
1491
|
+
const url = this.buildUrl(endpoint, options);
|
|
1487
1492
|
const response = await this.fetchWithTracking(url, {
|
|
1488
1493
|
...this.defaultOptions,
|
|
1489
1494
|
method: "GET"
|
|
@@ -1494,8 +1499,8 @@ var CollectionClient = class extends HttpClient {
|
|
|
1494
1499
|
* Update multiple documents (bulk update)
|
|
1495
1500
|
* PATCH /api/{collection}
|
|
1496
1501
|
*/
|
|
1497
|
-
async requestUpdateMany(
|
|
1498
|
-
const response = await this.fetchWithTracking(
|
|
1502
|
+
async requestUpdateMany(endpoint, data) {
|
|
1503
|
+
const response = await this.fetchWithTracking(endpoint, {
|
|
1499
1504
|
...this.defaultOptions,
|
|
1500
1505
|
method: "PATCH",
|
|
1501
1506
|
body: JSON.stringify(data)
|
|
@@ -1506,8 +1511,8 @@ var CollectionClient = class extends HttpClient {
|
|
|
1506
1511
|
* Delete document
|
|
1507
1512
|
* DELETE /api/{collection}/{id}
|
|
1508
1513
|
*/
|
|
1509
|
-
async requestDelete(
|
|
1510
|
-
const url = this.buildUrl(
|
|
1514
|
+
async requestDelete(endpoint, options) {
|
|
1515
|
+
const url = this.buildUrl(endpoint, options);
|
|
1511
1516
|
const response = await this.fetchWithTracking(url, {
|
|
1512
1517
|
...this.defaultOptions,
|
|
1513
1518
|
method: "DELETE"
|
|
@@ -1518,8 +1523,8 @@ var CollectionClient = class extends HttpClient {
|
|
|
1518
1523
|
* Delete multiple documents (bulk delete)
|
|
1519
1524
|
* DELETE /api/{collection}
|
|
1520
1525
|
*/
|
|
1521
|
-
async requestDeleteMany(
|
|
1522
|
-
const response = await this.fetchWithTracking(
|
|
1526
|
+
async requestDeleteMany(endpoint, data) {
|
|
1527
|
+
const response = await this.fetchWithTracking(endpoint, {
|
|
1523
1528
|
...this.defaultOptions,
|
|
1524
1529
|
method: "DELETE",
|
|
1525
1530
|
body: JSON.stringify(data)
|
|
@@ -1530,8 +1535,8 @@ var CollectionClient = class extends HttpClient {
|
|
|
1530
1535
|
* Create document with file upload
|
|
1531
1536
|
* POST /api/{collection} (multipart/form-data)
|
|
1532
1537
|
*/
|
|
1533
|
-
async requestCreateWithFile(
|
|
1534
|
-
const response = await this.fetchWithTracking(
|
|
1538
|
+
async requestCreateWithFile(endpoint, data, file, filename) {
|
|
1539
|
+
const response = await this.fetchWithTracking(endpoint, {
|
|
1535
1540
|
...this.defaultOptions,
|
|
1536
1541
|
method: "POST",
|
|
1537
1542
|
body: buildPayloadFormData(data, file, filename)
|
|
@@ -1542,8 +1547,8 @@ var CollectionClient = class extends HttpClient {
|
|
|
1542
1547
|
* Update document with file upload
|
|
1543
1548
|
* PATCH /api/{collection}/{id} (multipart/form-data)
|
|
1544
1549
|
*/
|
|
1545
|
-
async requestUpdateWithFile(
|
|
1546
|
-
const response = await this.fetchWithTracking(
|
|
1550
|
+
async requestUpdateWithFile(endpoint, data, file, filename) {
|
|
1551
|
+
const response = await this.fetchWithTracking(endpoint, {
|
|
1547
1552
|
...this.defaultOptions,
|
|
1548
1553
|
method: "PATCH",
|
|
1549
1554
|
body: buildPayloadFormData(data, file, filename)
|
|
@@ -1558,7 +1563,7 @@ var ServerCollectionClient = class extends CollectionClient {
|
|
|
1558
1563
|
};
|
|
1559
1564
|
|
|
1560
1565
|
// src/core/api/parse-response.ts
|
|
1561
|
-
async function parseApiResponse(response,
|
|
1566
|
+
async function parseApiResponse(response, endpoint, options = {}) {
|
|
1562
1567
|
if (response.status === 204 || response.headers.get("content-length") === "0") {
|
|
1563
1568
|
return void 0;
|
|
1564
1569
|
}
|
|
@@ -1567,7 +1572,7 @@ async function parseApiResponse(response, endpoint2, options = {}) {
|
|
|
1567
1572
|
parsed = await response.json();
|
|
1568
1573
|
} catch {
|
|
1569
1574
|
throw createApiError(
|
|
1570
|
-
`Invalid JSON response from ${
|
|
1575
|
+
`Invalid JSON response from ${endpoint}`,
|
|
1571
1576
|
response.status,
|
|
1572
1577
|
void 0,
|
|
1573
1578
|
"Server returned an invalid response.",
|
|
@@ -1617,6 +1622,7 @@ async function parseApiResponse(response, endpoint2, options = {}) {
|
|
|
1617
1622
|
|
|
1618
1623
|
// ../../internal/http-contracts/src/index.ts
|
|
1619
1624
|
var operationBrand = /* @__PURE__ */ Symbol("sdk-http-operation");
|
|
1625
|
+
var PORTONE_STANDARD_ACTION_CAPABILITIES_MEDIA_TYPE = "application/vnd.01software.portone-action-capabilities.v1+json";
|
|
1620
1626
|
var operation = (collection, method, path, errorFamily) => Object.freeze({
|
|
1621
1627
|
[operationBrand]: true,
|
|
1622
1628
|
collection,
|
|
@@ -1625,6 +1631,10 @@ var operation = (collection, method, path, errorFamily) => Object.freeze({
|
|
|
1625
1631
|
...errorFamily && { errorFamily }
|
|
1626
1632
|
});
|
|
1627
1633
|
var strictCommerceOperation = (collection, method, path) => operation(collection, method, path, "commerce");
|
|
1634
|
+
var selectiveCommerceOperation = (collection, method, path, typedCommerceErrorReasons) => Object.freeze({
|
|
1635
|
+
...operation(collection, method, path),
|
|
1636
|
+
typedCommerceErrorReasons: Object.freeze([...typedCommerceErrorReasons])
|
|
1637
|
+
});
|
|
1628
1638
|
var COMMERCE_ENDPOINT_OPERATIONS = {
|
|
1629
1639
|
products: {
|
|
1630
1640
|
detail: operation("products", "get", "/detail"),
|
|
@@ -1656,7 +1666,12 @@ var COMMERCE_ENDPOINT_OPERATIONS = {
|
|
|
1656
1666
|
confirmPayment: operation("orders", "post", "/confirm-payment"),
|
|
1657
1667
|
byPayment: operation("orders", "get", "/by-payment"),
|
|
1658
1668
|
cancel: operation("orders", "post", "/cancel"),
|
|
1659
|
-
resolveCancelRefund:
|
|
1669
|
+
resolveCancelRefund: selectiveCommerceOperation(
|
|
1670
|
+
"orders",
|
|
1671
|
+
"post",
|
|
1672
|
+
"/resolve-cancel-refund",
|
|
1673
|
+
["managed_refund_attestation_forbidden"]
|
|
1674
|
+
),
|
|
1660
1675
|
checkout: strictCommerceOperation("orders", "post", "/checkout"),
|
|
1661
1676
|
createFulfillment: operation("orders", "post", "/create-fulfillment"),
|
|
1662
1677
|
updateFulfillment: operation("orders", "post", "/update-fulfillment")
|
|
@@ -1665,6 +1680,11 @@ var COMMERCE_ENDPOINT_OPERATIONS = {
|
|
|
1665
1680
|
detail: strictCommerceOperation("checkouts", "post", "/detail"),
|
|
1666
1681
|
query: strictCommerceOperation("checkouts", "post", "/query")
|
|
1667
1682
|
},
|
|
1683
|
+
draftOrders: {
|
|
1684
|
+
calculate: operation("draft-orders", "post", "/:id/calculate"),
|
|
1685
|
+
complete: operation("draft-orders", "post", "/:id/complete"),
|
|
1686
|
+
finalize: operation("draft-orders", "post", "/:id/finalize")
|
|
1687
|
+
},
|
|
1668
1688
|
transactions: {
|
|
1669
1689
|
update: operation("transactions", "post", "/update")
|
|
1670
1690
|
},
|
|
@@ -1727,6 +1747,16 @@ var COMMERCE_ENDPOINT_OPERATIONS = {
|
|
|
1727
1747
|
"payment-sessions",
|
|
1728
1748
|
"post",
|
|
1729
1749
|
"/server/confirm"
|
|
1750
|
+
),
|
|
1751
|
+
findPortOne: strictCommerceOperation(
|
|
1752
|
+
"payment-sessions",
|
|
1753
|
+
"post",
|
|
1754
|
+
"/server/portone/find"
|
|
1755
|
+
),
|
|
1756
|
+
reconcilePortOne: strictCommerceOperation(
|
|
1757
|
+
"payment-sessions",
|
|
1758
|
+
"post",
|
|
1759
|
+
"/server/portone/reconcile"
|
|
1730
1760
|
)
|
|
1731
1761
|
},
|
|
1732
1762
|
custom: {
|
|
@@ -1746,12 +1776,34 @@ var COMMERCE_ENDPOINT_OPERATIONS = {
|
|
|
1746
1776
|
validate: operation("discounts", "post", "/validate")
|
|
1747
1777
|
}
|
|
1748
1778
|
};
|
|
1779
|
+
var portOneStandardActionCapabilityOperations = /* @__PURE__ */ new Set([
|
|
1780
|
+
COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.create,
|
|
1781
|
+
COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.retrieve,
|
|
1782
|
+
COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.server.create,
|
|
1783
|
+
COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.server.retrieve
|
|
1784
|
+
]);
|
|
1749
1785
|
var MEMBERSHIP_ENDPOINT_OPERATIONS = {
|
|
1750
1786
|
subscribe: operation(null, "post", "/memberships/subscribe"),
|
|
1751
1787
|
cancel: operation(null, "post", "/memberships/:id/cancel"),
|
|
1752
|
-
me: operation(null, "get", "/memberships/me")
|
|
1788
|
+
me: operation(null, "get", "/memberships/me"),
|
|
1789
|
+
chargeResult: operation(null, "post", "/memberships/:id/charge-result"),
|
|
1790
|
+
refundResult: operation(null, "post", "/memberships/:id/refund-result"),
|
|
1791
|
+
revoke: operation(null, "post", "/memberships/:id/revoke")
|
|
1792
|
+
};
|
|
1793
|
+
var CUSTOMER_GROUP_ENDPOINT_OPERATIONS = {
|
|
1794
|
+
members: operation("customer-groups", "get", "/:id/members"),
|
|
1795
|
+
grant: operation("customer-groups", "post", "/:id/members/grant"),
|
|
1796
|
+
revoke: operation("customer-groups", "post", "/:id/members/revoke")
|
|
1797
|
+
};
|
|
1798
|
+
var EMBEDDED_ADMIN_ENDPOINT_OPERATIONS = {
|
|
1799
|
+
show: operation("tenants", "get", "/embedded-admin-app"),
|
|
1800
|
+
configure: operation("tenants", "patch", "/embedded-admin-app"),
|
|
1801
|
+
disable: operation("tenants", "delete", "/embedded-admin-app")
|
|
1753
1802
|
};
|
|
1754
1803
|
var EVENTS_ENDPOINT_OPERATIONS = {
|
|
1804
|
+
events: {
|
|
1805
|
+
convertSchedule: operation("events", "post", "/:id/schedule")
|
|
1806
|
+
},
|
|
1755
1807
|
occurrences: {
|
|
1756
1808
|
range: operation("event-occurrences", "get", "/range"),
|
|
1757
1809
|
admissionAvailability: operation(
|
|
@@ -1792,46 +1844,54 @@ function resolveOperationMethod(descriptor) {
|
|
|
1792
1844
|
}
|
|
1793
1845
|
|
|
1794
1846
|
// src/core/api/endpoints.ts
|
|
1795
|
-
var endpoint = (method, path) => ({ method, path });
|
|
1796
1847
|
var sharedEndpoint = (descriptor) => descriptor;
|
|
1797
|
-
function resolveOperationMethod2(descriptor) {
|
|
1798
|
-
return "collection" in descriptor ? resolveOperationMethod(descriptor) : descriptor.method;
|
|
1799
|
-
}
|
|
1800
1848
|
function resolveOperationErrorFamily(descriptor) {
|
|
1801
|
-
return
|
|
1849
|
+
return descriptor.errorFamily;
|
|
1802
1850
|
}
|
|
1803
|
-
function
|
|
1804
|
-
|
|
1805
|
-
return resolveOperationPath(descriptor, options);
|
|
1806
|
-
}
|
|
1807
|
-
const query = options?.query?.toString().replace(/^\?/, "");
|
|
1808
|
-
return query ? `${descriptor.path}?${query}` : descriptor.path;
|
|
1851
|
+
function resolveOperationTypedCommerceErrorReasons(descriptor) {
|
|
1852
|
+
return descriptor.typedCommerceErrorReasons;
|
|
1809
1853
|
}
|
|
1810
1854
|
var COMMERCE_ENDPOINTS = {
|
|
1811
1855
|
products: {
|
|
1812
|
-
detail:
|
|
1813
|
-
detailCatalog:
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1856
|
+
detail: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.products.detail),
|
|
1857
|
+
detailCatalog: sharedEndpoint(
|
|
1858
|
+
COMMERCE_ENDPOINT_OPERATIONS.products.detailCatalog
|
|
1859
|
+
),
|
|
1860
|
+
listingGroups: sharedEndpoint(
|
|
1861
|
+
COMMERCE_ENDPOINT_OPERATIONS.products.listingGroups
|
|
1862
|
+
),
|
|
1863
|
+
listingGroupsCatalog: sharedEndpoint(
|
|
1864
|
+
COMMERCE_ENDPOINT_OPERATIONS.products.listingGroupsCatalog
|
|
1865
|
+
),
|
|
1866
|
+
// The manifest keeps the GET read and the POST body-query apart; this
|
|
1867
|
+
// semantic name has always resolved to the GET one.
|
|
1868
|
+
listingGroupsQuery: sharedEndpoint(
|
|
1869
|
+
COMMERCE_ENDPOINT_OPERATIONS.products.listingGroupsQueryGet
|
|
1870
|
+
),
|
|
1871
|
+
listingGroupsQueryCatalog: sharedEndpoint(
|
|
1872
|
+
COMMERCE_ENDPOINT_OPERATIONS.products.listingGroupsQueryCatalog
|
|
1873
|
+
),
|
|
1874
|
+
stockCheck: sharedEndpoint(
|
|
1875
|
+
COMMERCE_ENDPOINT_OPERATIONS.products.stockCheck
|
|
1818
1876
|
),
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
"GET",
|
|
1822
|
-
"/api/products/listing-groups/query/catalog"
|
|
1877
|
+
stockSnapshot: sharedEndpoint(
|
|
1878
|
+
COMMERCE_ENDPOINT_OPERATIONS.products.stockSnapshot
|
|
1823
1879
|
),
|
|
1824
|
-
|
|
1825
|
-
stockSnapshot: endpoint("GET", "/api/products/stock"),
|
|
1826
|
-
upsert: endpoint("POST", "/api/products/upsert")
|
|
1880
|
+
upsert: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.products.upsert)
|
|
1827
1881
|
},
|
|
1828
1882
|
orders: {
|
|
1829
|
-
update:
|
|
1830
|
-
byPayment:
|
|
1831
|
-
cancel:
|
|
1832
|
-
resolveCancelRefund:
|
|
1833
|
-
|
|
1834
|
-
|
|
1883
|
+
update: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.orders.update),
|
|
1884
|
+
byPayment: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.orders.byPayment),
|
|
1885
|
+
cancel: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.orders.cancel),
|
|
1886
|
+
resolveCancelRefund: sharedEndpoint(
|
|
1887
|
+
COMMERCE_ENDPOINT_OPERATIONS.orders.resolveCancelRefund
|
|
1888
|
+
),
|
|
1889
|
+
createFulfillment: sharedEndpoint(
|
|
1890
|
+
COMMERCE_ENDPOINT_OPERATIONS.orders.createFulfillment
|
|
1891
|
+
),
|
|
1892
|
+
updateFulfillment: sharedEndpoint(
|
|
1893
|
+
COMMERCE_ENDPOINT_OPERATIONS.orders.updateFulfillment
|
|
1894
|
+
)
|
|
1835
1895
|
},
|
|
1836
1896
|
checkouts: {
|
|
1837
1897
|
create: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.orders.checkout),
|
|
@@ -1843,18 +1903,21 @@ var COMMERCE_ENDPOINTS = {
|
|
|
1843
1903
|
}
|
|
1844
1904
|
},
|
|
1845
1905
|
returns: {
|
|
1846
|
-
create:
|
|
1847
|
-
update:
|
|
1848
|
-
returnRefund:
|
|
1906
|
+
create: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.returns.create),
|
|
1907
|
+
update: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.returns.update),
|
|
1908
|
+
returnRefund: sharedEndpoint(
|
|
1909
|
+
COMMERCE_ENDPOINT_OPERATIONS.returns.returnRefund
|
|
1910
|
+
)
|
|
1849
1911
|
},
|
|
1850
1912
|
fulfillmentOrders: {
|
|
1851
|
-
prepare:
|
|
1852
|
-
|
|
1853
|
-
"/api/fulfillment-orders/prepare-fulfillment-order"
|
|
1913
|
+
prepare: sharedEndpoint(
|
|
1914
|
+
COMMERCE_ENDPOINT_OPERATIONS.fulfillmentOrders.prepare
|
|
1854
1915
|
)
|
|
1855
1916
|
},
|
|
1856
1917
|
fulfillments: {
|
|
1857
|
-
bulkImport:
|
|
1918
|
+
bulkImport: sharedEndpoint(
|
|
1919
|
+
COMMERCE_ENDPOINT_OPERATIONS.fulfillments.bulkImport
|
|
1920
|
+
)
|
|
1858
1921
|
},
|
|
1859
1922
|
carts: {
|
|
1860
1923
|
create: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.create),
|
|
@@ -1919,42 +1982,21 @@ var COMMERCE_ENDPOINTS = {
|
|
|
1919
1982
|
),
|
|
1920
1983
|
confirm: sharedEndpoint(
|
|
1921
1984
|
COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.server.confirm
|
|
1985
|
+
),
|
|
1986
|
+
findPortOne: sharedEndpoint(
|
|
1987
|
+
COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.server.findPortOne
|
|
1988
|
+
),
|
|
1989
|
+
reconcilePortOne: sharedEndpoint(
|
|
1990
|
+
COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.server.reconcilePortOne
|
|
1922
1991
|
)
|
|
1923
1992
|
}
|
|
1924
1993
|
},
|
|
1925
1994
|
shippingPolicies: {
|
|
1926
|
-
calculate:
|
|
1995
|
+
calculate: sharedEndpoint(
|
|
1996
|
+
COMMERCE_ENDPOINT_OPERATIONS.shippingPolicies.calculate
|
|
1997
|
+
)
|
|
1927
1998
|
}
|
|
1928
1999
|
};
|
|
1929
|
-
function isCommerceEndpointDescriptor(value) {
|
|
1930
|
-
if (!value || typeof value !== "object") return false;
|
|
1931
|
-
const candidate = value;
|
|
1932
|
-
return typeof candidate.method === "string" && typeof candidate.path === "string";
|
|
1933
|
-
}
|
|
1934
|
-
function flattenEndpointPaths(value) {
|
|
1935
|
-
if (isCommerceEndpointDescriptor(value)) return [resolveOperationPath2(value)];
|
|
1936
|
-
if (!value || typeof value !== "object") return [];
|
|
1937
|
-
return Object.values(value).flatMap((entry) => flattenEndpointPaths(entry));
|
|
1938
|
-
}
|
|
1939
|
-
function flattenEndpointDescriptors(value) {
|
|
1940
|
-
if (isCommerceEndpointDescriptor(value)) return [value];
|
|
1941
|
-
if (!value || typeof value !== "object") return [];
|
|
1942
|
-
return Object.values(value).flatMap(
|
|
1943
|
-
(entry) => flattenEndpointDescriptors(entry)
|
|
1944
|
-
);
|
|
1945
|
-
}
|
|
1946
|
-
var COMMERCE_ENDPOINT_PATHS = flattenEndpointPaths(COMMERCE_ENDPOINTS);
|
|
1947
|
-
var COMMERCE_ENDPOINT_DESCRIPTORS = flattenEndpointDescriptors(COMMERCE_ENDPOINTS);
|
|
1948
|
-
var MEMBERSHIP_ENDPOINTS = {
|
|
1949
|
-
subscribe: "/api/memberships/subscribe",
|
|
1950
|
-
cancel: (id) => `/api/memberships/${id}/cancel`,
|
|
1951
|
-
me: "/api/memberships/me"
|
|
1952
|
-
};
|
|
1953
|
-
var MEMBERSHIP_ENDPOINT_PATHS = [
|
|
1954
|
-
MEMBERSHIP_ENDPOINTS.subscribe,
|
|
1955
|
-
MEMBERSHIP_ENDPOINTS.cancel(":id"),
|
|
1956
|
-
MEMBERSHIP_ENDPOINTS.me
|
|
1957
|
-
];
|
|
1958
2000
|
|
|
1959
2001
|
// src/core/api/customer-scoped-api.ts
|
|
1960
2002
|
var CustomerScopedTransport = class {
|
|
@@ -1975,10 +2017,10 @@ var CustomerScopedTransport = class {
|
|
|
1975
2017
|
this.onUnauthorized = options.onUnauthorized;
|
|
1976
2018
|
this.onRequestId = options.onRequestId;
|
|
1977
2019
|
}
|
|
1978
|
-
async request(
|
|
2020
|
+
async request(endpoint, options) {
|
|
1979
2021
|
const token = typeof this.customerToken === "function" ? this.customerToken() : this.customerToken;
|
|
1980
2022
|
try {
|
|
1981
|
-
const response = await httpFetch(
|
|
2023
|
+
const response = await httpFetch(endpoint, {
|
|
1982
2024
|
method: options.method,
|
|
1983
2025
|
apiUrl: this.apiUrl,
|
|
1984
2026
|
publishableKey: this.publishableKey,
|
|
@@ -1992,7 +2034,7 @@ var CustomerScopedTransport = class {
|
|
|
1992
2034
|
...options.errorFamily && { errorFamily: options.errorFamily }
|
|
1993
2035
|
});
|
|
1994
2036
|
this.onRequestId?.(response.headers.get("x-request-id") ?? null);
|
|
1995
|
-
return parseApiResponse(response,
|
|
2037
|
+
return parseApiResponse(response, endpoint, {
|
|
1996
2038
|
errorFamily: options.errorFamily
|
|
1997
2039
|
});
|
|
1998
2040
|
} catch (err) {
|
|
@@ -2006,12 +2048,12 @@ var CustomerScopedApi = class {
|
|
|
2006
2048
|
constructor(apiName, options) {
|
|
2007
2049
|
this.transport = new CustomerScopedTransport(apiName, options);
|
|
2008
2050
|
}
|
|
2009
|
-
requestEndpoint(
|
|
2010
|
-
return this.transport.request(
|
|
2011
|
-
method:
|
|
2051
|
+
requestEndpoint(endpoint, body, options) {
|
|
2052
|
+
return this.transport.request(resolveOperationPath(endpoint, options), {
|
|
2053
|
+
method: resolveOperationMethod(endpoint),
|
|
2012
2054
|
body,
|
|
2013
2055
|
headers: options?.headers,
|
|
2014
|
-
errorFamily: resolveOperationErrorFamily(
|
|
2056
|
+
errorFamily: resolveOperationErrorFamily(endpoint)
|
|
2015
2057
|
});
|
|
2016
2058
|
}
|
|
2017
2059
|
};
|
|
@@ -2019,8 +2061,8 @@ var RawCustomerScopedApi = class {
|
|
|
2019
2061
|
constructor(apiName, options) {
|
|
2020
2062
|
this.transport = new CustomerScopedTransport(apiName, options);
|
|
2021
2063
|
}
|
|
2022
|
-
request(
|
|
2023
|
-
return this.transport.request(
|
|
2064
|
+
request(endpoint, options) {
|
|
2065
|
+
return this.transport.request(endpoint, options);
|
|
2024
2066
|
}
|
|
2025
2067
|
};
|
|
2026
2068
|
|
|
@@ -2095,11 +2137,11 @@ var CommunityClient = class extends RawCustomerScopedApi {
|
|
|
2095
2137
|
if (params.page !== void 0) urlParams.set("page", String(params.page));
|
|
2096
2138
|
return `/api/comments/public?${urlParams.toString()}`;
|
|
2097
2139
|
}
|
|
2098
|
-
async execute(
|
|
2099
|
-
return this.request(
|
|
2140
|
+
async execute(endpoint, method, body) {
|
|
2141
|
+
return this.request(endpoint, { method, body });
|
|
2100
2142
|
}
|
|
2101
|
-
async executeDoc(
|
|
2102
|
-
const response = await this.execute(
|
|
2143
|
+
async executeDoc(endpoint, method, body) {
|
|
2144
|
+
const response = await this.execute(endpoint, method, body);
|
|
2103
2145
|
return unwrapPayloadDoc(response);
|
|
2104
2146
|
}
|
|
2105
2147
|
createPost(params) {
|
|
@@ -2378,20 +2420,23 @@ var ServerApiTransport = class {
|
|
|
2378
2420
|
this.apiUrl = options.apiUrl;
|
|
2379
2421
|
this.onRequestId = options.onRequestId;
|
|
2380
2422
|
}
|
|
2381
|
-
async request(
|
|
2423
|
+
async request(endpoint, body, options) {
|
|
2382
2424
|
const method = options?.method ?? "POST";
|
|
2383
2425
|
try {
|
|
2384
|
-
const response = await httpFetch(
|
|
2426
|
+
const response = await httpFetch(endpoint, {
|
|
2385
2427
|
method,
|
|
2386
2428
|
apiUrl: this.apiUrl,
|
|
2387
2429
|
publishableKey: this.publishableKey,
|
|
2388
2430
|
secretKey: this.secretKey,
|
|
2389
2431
|
...body !== void 0 && { body: JSON.stringify(body) },
|
|
2390
2432
|
...options?.headers && { headers: options.headers },
|
|
2391
|
-
...options?.errorFamily && { errorFamily: options.errorFamily }
|
|
2433
|
+
...options?.errorFamily && { errorFamily: options.errorFamily },
|
|
2434
|
+
...options?.typedCommerceErrorReasons && {
|
|
2435
|
+
typedCommerceErrorReasons: options.typedCommerceErrorReasons
|
|
2436
|
+
}
|
|
2392
2437
|
});
|
|
2393
2438
|
this.onRequestId?.(response.headers.get("x-request-id") ?? null);
|
|
2394
|
-
return parseApiResponse(response,
|
|
2439
|
+
return parseApiResponse(response, endpoint, {
|
|
2395
2440
|
errorFamily: options?.errorFamily
|
|
2396
2441
|
});
|
|
2397
2442
|
} catch (err) {
|
|
@@ -2405,14 +2450,15 @@ var BaseApi = class {
|
|
|
2405
2450
|
constructor(apiName, options) {
|
|
2406
2451
|
this.transport = new ServerApiTransport(apiName, options);
|
|
2407
2452
|
}
|
|
2408
|
-
requestEndpoint(
|
|
2453
|
+
requestEndpoint(endpoint, body, options) {
|
|
2409
2454
|
return this.transport.request(
|
|
2410
|
-
|
|
2455
|
+
resolveOperationPath(endpoint, options),
|
|
2411
2456
|
body,
|
|
2412
2457
|
{
|
|
2413
|
-
method:
|
|
2458
|
+
method: resolveOperationMethod(endpoint),
|
|
2414
2459
|
headers: options?.headers,
|
|
2415
|
-
errorFamily: resolveOperationErrorFamily(
|
|
2460
|
+
errorFamily: resolveOperationErrorFamily(endpoint),
|
|
2461
|
+
typedCommerceErrorReasons: resolveOperationTypedCommerceErrorReasons(endpoint)
|
|
2416
2462
|
}
|
|
2417
2463
|
);
|
|
2418
2464
|
}
|
|
@@ -2429,8 +2475,8 @@ var RawBaseApi = class {
|
|
|
2429
2475
|
this.apiUrl = options.apiUrl;
|
|
2430
2476
|
this.onRequestId = options.onRequestId;
|
|
2431
2477
|
}
|
|
2432
|
-
request(
|
|
2433
|
-
return this.transport.request(
|
|
2478
|
+
request(endpoint, body, options) {
|
|
2479
|
+
return this.transport.request(endpoint, body, options);
|
|
2434
2480
|
}
|
|
2435
2481
|
};
|
|
2436
2482
|
|
|
@@ -2469,7 +2515,10 @@ var MAX_COMMERCE_CAPABILITY_LENGTH = 512;
|
|
|
2469
2515
|
var MAX_CART_DISCOUNT_CODE_LENGTH = 128;
|
|
2470
2516
|
var CHECKOUT_STATUSES = ["open", "placed", "abandoned"];
|
|
2471
2517
|
var ABANDONED_REASONS = ["expired", "customer", "operator"];
|
|
2472
|
-
|
|
2518
|
+
function managedPaymentProviders(providers) {
|
|
2519
|
+
return providers;
|
|
2520
|
+
}
|
|
2521
|
+
var PAYMENT_PROVIDERS = managedPaymentProviders(["toss", "portone"]);
|
|
2473
2522
|
var PAYMENT_PROVIDER_STATUSES = [
|
|
2474
2523
|
"requires_payment_method",
|
|
2475
2524
|
"requires_action",
|
|
@@ -2491,6 +2540,18 @@ var PAYMENT_FAILURE_REASONS = [
|
|
|
2491
2540
|
"provider_terminal_failure",
|
|
2492
2541
|
"unknown_provider_terminal_failure"
|
|
2493
2542
|
];
|
|
2543
|
+
var PAYMENT_RECONCILIATION_REASONS = [
|
|
2544
|
+
"provider_outcome_unknown",
|
|
2545
|
+
"local_commit_ambiguous",
|
|
2546
|
+
"amount_mismatch",
|
|
2547
|
+
"currency_mismatch",
|
|
2548
|
+
"excess_capture_pending_order",
|
|
2549
|
+
"inventory_unavailable",
|
|
2550
|
+
"admission_unavailable",
|
|
2551
|
+
"excess_capture",
|
|
2552
|
+
"late_capture",
|
|
2553
|
+
"cross_checkout_duplicate"
|
|
2554
|
+
];
|
|
2494
2555
|
var CART_WARNING_CODES = [
|
|
2495
2556
|
"DISCOUNT_CODE_NOT_HONOURED",
|
|
2496
2557
|
"DISCOUNT_CURRENTLY_INACTIVE",
|
|
@@ -2517,6 +2578,26 @@ function invalidCanonicalResponse(resource, details) {
|
|
|
2517
2578
|
function fail(resource, path, expected) {
|
|
2518
2579
|
invalidCanonicalResponse(resource, { path, expected });
|
|
2519
2580
|
}
|
|
2581
|
+
function providerMismatch(resource, expected, actual, operation2) {
|
|
2582
|
+
if (operation2 === "cancel") {
|
|
2583
|
+
const method = {
|
|
2584
|
+
toss: "cancel()",
|
|
2585
|
+
portone: "cancelPortOne()"
|
|
2586
|
+
}[actual];
|
|
2587
|
+
throw createApiError(
|
|
2588
|
+
`Canonical ${resource} response provider mismatch: expected ${expected}, received ${actual}.`,
|
|
2589
|
+
502,
|
|
2590
|
+
{ resource, path: "$.provider", expected, actual },
|
|
2591
|
+
`The server applied the cancellation to a ${actual} PaymentSession, but this SDK method expects ${expected}.`,
|
|
2592
|
+
`Re-invoke ${method} with the same idempotencyKey; do not create a new key.`
|
|
2593
|
+
);
|
|
2594
|
+
}
|
|
2595
|
+
invalidCanonicalResponse(resource, {
|
|
2596
|
+
path: "$.provider",
|
|
2597
|
+
expected,
|
|
2598
|
+
actual
|
|
2599
|
+
});
|
|
2600
|
+
}
|
|
2520
2601
|
function record(value, resource, path) {
|
|
2521
2602
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
2522
2603
|
fail(resource, path, "object");
|
|
@@ -2552,6 +2633,9 @@ function nullableString(value, resource, path) {
|
|
|
2552
2633
|
fail(resource, path, "string or null");
|
|
2553
2634
|
}
|
|
2554
2635
|
}
|
|
2636
|
+
function nullableNonEmptyString(value, resource, path) {
|
|
2637
|
+
if (value !== null) string(value, resource, path);
|
|
2638
|
+
}
|
|
2555
2639
|
function nonBlankString(value, resource, path) {
|
|
2556
2640
|
const parsed = string(value, resource, path);
|
|
2557
2641
|
if (parsed.trim().length === 0) {
|
|
@@ -3072,8 +3156,8 @@ function validateCheckoutItem(value, resource, path) {
|
|
|
3072
3156
|
validateReference(item.product, resource, `${path}.product`);
|
|
3073
3157
|
validateReference(item.variant, resource, `${path}.variant`);
|
|
3074
3158
|
string(item.productTitle, resource, `${path}.productTitle`);
|
|
3075
|
-
|
|
3076
|
-
|
|
3159
|
+
nullableNonEmptyString(item.variantTitle, resource, `${path}.variantTitle`);
|
|
3160
|
+
nullableNonEmptyString(item.sku, resource, `${path}.sku`);
|
|
3077
3161
|
validateAdmissions(item.admissions, resource, `${path}.admissions`);
|
|
3078
3162
|
cartLineQuantity(item.quantity, resource, `${path}.quantity`);
|
|
3079
3163
|
const unitPrice = safeMinor(
|
|
@@ -3441,6 +3525,141 @@ function validateRetrievedCustomPaymentSession(value) {
|
|
|
3441
3525
|
nullableResourceId(session.orderId, resource, "$.orderId");
|
|
3442
3526
|
return value;
|
|
3443
3527
|
}
|
|
3528
|
+
function validatePortOnePaymentCurrentState(value, resource, path) {
|
|
3529
|
+
const current = record(value, resource, path);
|
|
3530
|
+
exact(
|
|
3531
|
+
current,
|
|
3532
|
+
["paymentSession", "checkout", "order", "money"],
|
|
3533
|
+
[],
|
|
3534
|
+
resource,
|
|
3535
|
+
path
|
|
3536
|
+
);
|
|
3537
|
+
const session = record(
|
|
3538
|
+
current.paymentSession,
|
|
3539
|
+
resource,
|
|
3540
|
+
`${path}.paymentSession`
|
|
3541
|
+
);
|
|
3542
|
+
exact(
|
|
3543
|
+
session,
|
|
3544
|
+
[
|
|
3545
|
+
"id",
|
|
3546
|
+
"provider",
|
|
3547
|
+
"providerStatus",
|
|
3548
|
+
"finalizationStatus",
|
|
3549
|
+
"sessionRole",
|
|
3550
|
+
"reconciliation"
|
|
3551
|
+
],
|
|
3552
|
+
[],
|
|
3553
|
+
resource,
|
|
3554
|
+
`${path}.paymentSession`
|
|
3555
|
+
);
|
|
3556
|
+
boundedString(
|
|
3557
|
+
session.id,
|
|
3558
|
+
MAX_COMMERCE_RESOURCE_ID_LENGTH,
|
|
3559
|
+
resource,
|
|
3560
|
+
`${path}.paymentSession.id`
|
|
3561
|
+
);
|
|
3562
|
+
if (session.provider !== "portone") {
|
|
3563
|
+
fail(resource, `${path}.paymentSession.provider`, "portone");
|
|
3564
|
+
}
|
|
3565
|
+
enumValue(
|
|
3566
|
+
session.providerStatus,
|
|
3567
|
+
PAYMENT_PROVIDER_STATUSES,
|
|
3568
|
+
resource,
|
|
3569
|
+
`${path}.paymentSession.providerStatus`
|
|
3570
|
+
);
|
|
3571
|
+
enumValue(
|
|
3572
|
+
session.finalizationStatus,
|
|
3573
|
+
["not_ready", "pending", "committed"],
|
|
3574
|
+
resource,
|
|
3575
|
+
`${path}.paymentSession.finalizationStatus`
|
|
3576
|
+
);
|
|
3577
|
+
enumValue(
|
|
3578
|
+
session.sessionRole,
|
|
3579
|
+
["active", "canonical_candidate", "canonical", "residual", "historical"],
|
|
3580
|
+
resource,
|
|
3581
|
+
`${path}.paymentSession.sessionRole`
|
|
3582
|
+
);
|
|
3583
|
+
const reconciliation = record(
|
|
3584
|
+
session.reconciliation,
|
|
3585
|
+
resource,
|
|
3586
|
+
`${path}.paymentSession.reconciliation`
|
|
3587
|
+
);
|
|
3588
|
+
if (reconciliation.status === "none") {
|
|
3589
|
+
validateNoReconciliation(
|
|
3590
|
+
reconciliation,
|
|
3591
|
+
resource,
|
|
3592
|
+
`${path}.paymentSession.reconciliation`
|
|
3593
|
+
);
|
|
3594
|
+
} else {
|
|
3595
|
+
validateRequiredReconciliation(
|
|
3596
|
+
reconciliation,
|
|
3597
|
+
PAYMENT_RECONCILIATION_REASONS,
|
|
3598
|
+
resource,
|
|
3599
|
+
`${path}.paymentSession.reconciliation`
|
|
3600
|
+
);
|
|
3601
|
+
}
|
|
3602
|
+
const checkout = record(current.checkout, resource, `${path}.checkout`);
|
|
3603
|
+
exact(checkout, ["id"], [], resource, `${path}.checkout`);
|
|
3604
|
+
boundedString(
|
|
3605
|
+
checkout.id,
|
|
3606
|
+
MAX_COMMERCE_RESOURCE_ID_LENGTH,
|
|
3607
|
+
resource,
|
|
3608
|
+
`${path}.checkout.id`
|
|
3609
|
+
);
|
|
3610
|
+
if (current.order !== null) {
|
|
3611
|
+
const order = record(current.order, resource, `${path}.order`);
|
|
3612
|
+
exact(order, ["id", "orderNumber"], [], resource, `${path}.order`);
|
|
3613
|
+
boundedString(
|
|
3614
|
+
order.id,
|
|
3615
|
+
MAX_COMMERCE_RESOURCE_ID_LENGTH,
|
|
3616
|
+
resource,
|
|
3617
|
+
`${path}.order.id`
|
|
3618
|
+
);
|
|
3619
|
+
nonBlankString(order.orderNumber, resource, `${path}.order.orderNumber`);
|
|
3620
|
+
}
|
|
3621
|
+
validateMoney(current.money, resource, `${path}.money`);
|
|
3622
|
+
}
|
|
3623
|
+
function validatePortOnePaymentFacadeResult(value, mutating) {
|
|
3624
|
+
const resource = mutating ? "PortOne payment reconciliation result" : "PortOne payment find result";
|
|
3625
|
+
const result = record(value, resource, "$");
|
|
3626
|
+
boolean(result.found, resource, "$.found");
|
|
3627
|
+
if (result.found === false) {
|
|
3628
|
+
exact(
|
|
3629
|
+
result,
|
|
3630
|
+
mutating ? ["found", "disposition"] : ["found"],
|
|
3631
|
+
[],
|
|
3632
|
+
resource,
|
|
3633
|
+
"$"
|
|
3634
|
+
);
|
|
3635
|
+
if (mutating && result.disposition !== "requires_attention") {
|
|
3636
|
+
fail(resource, "$.disposition", "requires_attention");
|
|
3637
|
+
}
|
|
3638
|
+
return value;
|
|
3639
|
+
}
|
|
3640
|
+
exact(
|
|
3641
|
+
result,
|
|
3642
|
+
mutating ? ["found", "disposition", "current"] : ["found", "current"],
|
|
3643
|
+
[],
|
|
3644
|
+
resource,
|
|
3645
|
+
"$"
|
|
3646
|
+
);
|
|
3647
|
+
if (mutating) {
|
|
3648
|
+
enumValue(
|
|
3649
|
+
result.disposition,
|
|
3650
|
+
[
|
|
3651
|
+
"applied",
|
|
3652
|
+
"observed",
|
|
3653
|
+
"recovered_after_ambiguous_result",
|
|
3654
|
+
"requires_attention"
|
|
3655
|
+
],
|
|
3656
|
+
resource,
|
|
3657
|
+
"$.disposition"
|
|
3658
|
+
);
|
|
3659
|
+
}
|
|
3660
|
+
validatePortOnePaymentCurrentState(result.current, resource, "$.current");
|
|
3661
|
+
return value;
|
|
3662
|
+
}
|
|
3444
3663
|
function validateConfirmCustomPaymentSessionResponse(value) {
|
|
3445
3664
|
const resource = "custom PaymentSession confirmation";
|
|
3446
3665
|
const result = record(value, resource, "$");
|
|
@@ -3495,11 +3714,21 @@ function validateNextAction(value, provider, resource, path) {
|
|
|
3495
3714
|
const action = record(value, resource, path);
|
|
3496
3715
|
if (provider === "portone") {
|
|
3497
3716
|
if (action.type === "portone_sdk") {
|
|
3717
|
+
const hasCancelable = "cancelable" in action;
|
|
3718
|
+
const hasRetryPolicy = "retryPolicy" in action;
|
|
3719
|
+
if (hasCancelable !== hasRetryPolicy) {
|
|
3720
|
+
fail(
|
|
3721
|
+
resource,
|
|
3722
|
+
path,
|
|
3723
|
+
"exact released action or exact negotiated capability action"
|
|
3724
|
+
);
|
|
3725
|
+
}
|
|
3498
3726
|
exact(
|
|
3499
3727
|
action,
|
|
3500
3728
|
[
|
|
3501
3729
|
"type",
|
|
3502
3730
|
"version",
|
|
3731
|
+
...hasCancelable ? ["cancelable", "retryPolicy"] : [],
|
|
3503
3732
|
"storeId",
|
|
3504
3733
|
"channelKey",
|
|
3505
3734
|
"paymentId",
|
|
@@ -3514,6 +3743,11 @@ function validateNextAction(value, provider, resource, path) {
|
|
|
3514
3743
|
path
|
|
3515
3744
|
);
|
|
3516
3745
|
if (action.version !== "v2") fail(resource, `${path}.version`, "v2");
|
|
3746
|
+
if (hasCancelable && action.cancelable !== false)
|
|
3747
|
+
fail(resource, `${path}.cancelable`, "false");
|
|
3748
|
+
if (hasRetryPolicy && action.retryPolicy !== "same_action_only") {
|
|
3749
|
+
fail(resource, `${path}.retryPolicy`, "same_action_only");
|
|
3750
|
+
}
|
|
3517
3751
|
for (const key of ["storeId", "channelKey"]) {
|
|
3518
3752
|
boundedString(action[key], 255, resource, `${path}.${key}`);
|
|
3519
3753
|
}
|
|
@@ -3560,6 +3794,10 @@ function validateNextAction(value, provider, resource, path) {
|
|
|
3560
3794
|
"HTTPS or loopback URL without embedded credentials"
|
|
3561
3795
|
);
|
|
3562
3796
|
}
|
|
3797
|
+
if (!hasCancelable) {
|
|
3798
|
+
action.cancelable = false;
|
|
3799
|
+
action.retryPolicy = "same_action_only";
|
|
3800
|
+
}
|
|
3563
3801
|
return;
|
|
3564
3802
|
}
|
|
3565
3803
|
exact(action, ["type", "checkoutUrl"], [], resource, path);
|
|
@@ -3636,7 +3874,7 @@ function validateNextAction(value, provider, resource, path) {
|
|
|
3636
3874
|
if (action.customerEmail !== void 0)
|
|
3637
3875
|
validateCustomer({ email: action.customerEmail }, resource, path);
|
|
3638
3876
|
}
|
|
3639
|
-
function validatePublicPaymentSession(value, expectedProvider) {
|
|
3877
|
+
function validatePublicPaymentSession(value, expectedProvider, operation2) {
|
|
3640
3878
|
const resource = "PaymentSession";
|
|
3641
3879
|
const session = record(value, resource, "$");
|
|
3642
3880
|
const provider = enumValue(
|
|
@@ -3645,9 +3883,6 @@ function validatePublicPaymentSession(value, expectedProvider) {
|
|
|
3645
3883
|
resource,
|
|
3646
3884
|
"$.provider"
|
|
3647
3885
|
);
|
|
3648
|
-
if (expectedProvider !== void 0 && provider !== expectedProvider) {
|
|
3649
|
-
fail(resource, "$.provider", expectedProvider);
|
|
3650
|
-
}
|
|
3651
3886
|
const status = enumValue(
|
|
3652
3887
|
session.providerStatus,
|
|
3653
3888
|
PAYMENT_PROVIDER_STATUSES,
|
|
@@ -3851,6 +4086,16 @@ function validatePublicPaymentSession(value, expectedProvider) {
|
|
|
3851
4086
|
"$.cancellationReason"
|
|
3852
4087
|
);
|
|
3853
4088
|
}
|
|
4089
|
+
if (expectedProvider !== void 0 && provider !== expectedProvider) {
|
|
4090
|
+
if (operation2 === "cancel" && status !== "canceling" && status !== "canceled") {
|
|
4091
|
+
fail(
|
|
4092
|
+
resource,
|
|
4093
|
+
"$.providerStatus",
|
|
4094
|
+
"canceling or canceled after a successful cancellation"
|
|
4095
|
+
);
|
|
4096
|
+
}
|
|
4097
|
+
providerMismatch(resource, expectedProvider, provider, operation2);
|
|
4098
|
+
}
|
|
3854
4099
|
return value;
|
|
3855
4100
|
}
|
|
3856
4101
|
|
|
@@ -3877,8 +4122,8 @@ var CartApi = class extends CustomerScopedApi {
|
|
|
3877
4122
|
endpoint(key) {
|
|
3878
4123
|
return this.serverTransport ? COMMERCE_ENDPOINTS.carts.server[key] : COMMERCE_ENDPOINTS.carts[key];
|
|
3879
4124
|
}
|
|
3880
|
-
execute(
|
|
3881
|
-
return this.requestEndpoint(
|
|
4125
|
+
execute(endpoint, body, idempotencyKey) {
|
|
4126
|
+
return this.requestEndpoint(endpoint, body, {
|
|
3882
4127
|
...idempotencyKey && {
|
|
3883
4128
|
headers: { "X-Idempotency-Key": idempotencyKey }
|
|
3884
4129
|
}
|
|
@@ -3895,26 +4140,26 @@ var CartApi = class extends CustomerScopedApi {
|
|
|
3895
4140
|
);
|
|
3896
4141
|
}
|
|
3897
4142
|
mine(params = {}) {
|
|
3898
|
-
const
|
|
3899
|
-
return this.execute(
|
|
4143
|
+
const endpoint = this.endpoint("mine");
|
|
4144
|
+
return this.execute(endpoint, params).then(
|
|
3900
4145
|
(value) => validateCartMineResult(value)
|
|
3901
4146
|
);
|
|
3902
4147
|
}
|
|
3903
4148
|
merge(params) {
|
|
3904
4149
|
const { idempotencyKey, ...body } = params;
|
|
3905
4150
|
assertCommerceIdempotencyKey(idempotencyKey);
|
|
3906
|
-
const
|
|
3907
|
-
return this.execute(
|
|
4151
|
+
const endpoint = this.endpoint("merge");
|
|
4152
|
+
return this.execute(endpoint, body, idempotencyKey).then(
|
|
3908
4153
|
(value) => validateCartMergeResult(value)
|
|
3909
4154
|
);
|
|
3910
4155
|
}
|
|
3911
4156
|
addItem(params) {
|
|
3912
4157
|
return this.mutate(this.endpoint("addItem"), params);
|
|
3913
4158
|
}
|
|
3914
|
-
mutate(
|
|
4159
|
+
mutate(endpoint, params) {
|
|
3915
4160
|
const { idempotencyKey, ...body } = params;
|
|
3916
4161
|
assertCommerceIdempotencyKey(idempotencyKey);
|
|
3917
|
-
return this.execute(
|
|
4162
|
+
return this.execute(endpoint, body, idempotencyKey).then(
|
|
3918
4163
|
(value) => validateCartMutationResult(value)
|
|
3919
4164
|
);
|
|
3920
4165
|
}
|
|
@@ -5323,8 +5568,8 @@ var CheckoutApi = class extends CustomerScopedApi {
|
|
|
5323
5568
|
constructor(options) {
|
|
5324
5569
|
super("CheckoutApi", { ...options, requiresCredential: false });
|
|
5325
5570
|
}
|
|
5326
|
-
post(
|
|
5327
|
-
return this.requestEndpoint(
|
|
5571
|
+
post(endpoint, body, idempotencyKey) {
|
|
5572
|
+
return this.requestEndpoint(endpoint, body, {
|
|
5328
5573
|
...idempotencyKey && {
|
|
5329
5574
|
headers: { "X-Idempotency-Key": idempotencyKey }
|
|
5330
5575
|
}
|
|
@@ -5391,15 +5636,23 @@ var PaymentSessionApi = class extends CustomerScopedApi {
|
|
|
5391
5636
|
super("PaymentSessionApi", { ...options, requiresCredential: false });
|
|
5392
5637
|
this.serverTransport = Boolean(options.secretKey);
|
|
5393
5638
|
}
|
|
5394
|
-
post(
|
|
5395
|
-
|
|
5396
|
-
...idempotencyKey && {
|
|
5397
|
-
|
|
5639
|
+
post(endpoint, body, idempotencyKey, negotiateStandardActionCapabilities = false) {
|
|
5640
|
+
const headers = {
|
|
5641
|
+
...idempotencyKey && { "X-Idempotency-Key": idempotencyKey },
|
|
5642
|
+
...negotiateStandardActionCapabilities && {
|
|
5643
|
+
Accept: PORTONE_STANDARD_ACTION_CAPABILITIES_MEDIA_TYPE
|
|
5398
5644
|
}
|
|
5645
|
+
};
|
|
5646
|
+
return this.requestEndpoint(endpoint, body, {
|
|
5647
|
+
...Object.keys(headers).length > 0 && { headers }
|
|
5399
5648
|
});
|
|
5400
5649
|
}
|
|
5401
|
-
async paymentSession(result, expectedProvider) {
|
|
5402
|
-
return validatePublicPaymentSession(
|
|
5650
|
+
async paymentSession(result, expectedProvider, operation2) {
|
|
5651
|
+
return validatePublicPaymentSession(
|
|
5652
|
+
await result,
|
|
5653
|
+
expectedProvider,
|
|
5654
|
+
operation2
|
|
5655
|
+
);
|
|
5403
5656
|
}
|
|
5404
5657
|
create(params) {
|
|
5405
5658
|
const { idempotencyKey, ...body } = params;
|
|
@@ -5420,41 +5673,44 @@ var PaymentSessionApi = class extends CustomerScopedApi {
|
|
|
5420
5673
|
this.post(
|
|
5421
5674
|
this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.create : COMMERCE_ENDPOINTS.paymentSessions.create,
|
|
5422
5675
|
body,
|
|
5423
|
-
idempotencyKey
|
|
5676
|
+
idempotencyKey,
|
|
5677
|
+
body.providerOptions.profile === "standard_v2"
|
|
5424
5678
|
),
|
|
5425
5679
|
"portone"
|
|
5426
5680
|
);
|
|
5427
5681
|
}
|
|
5428
5682
|
retrieve(params) {
|
|
5429
|
-
const
|
|
5683
|
+
const endpoint = this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.retrieve : COMMERCE_ENDPOINTS.paymentSessions.retrieve;
|
|
5430
5684
|
return this.paymentSession(
|
|
5431
|
-
this.post(
|
|
5685
|
+
this.post(endpoint, params),
|
|
5432
5686
|
"toss"
|
|
5433
5687
|
);
|
|
5434
5688
|
}
|
|
5435
5689
|
retrievePortOne(params) {
|
|
5436
|
-
const
|
|
5690
|
+
const endpoint = this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.retrieve : COMMERCE_ENDPOINTS.paymentSessions.retrieve;
|
|
5437
5691
|
return this.paymentSession(
|
|
5438
|
-
this.post(
|
|
5692
|
+
this.post(endpoint, params, void 0, true),
|
|
5439
5693
|
"portone"
|
|
5440
5694
|
);
|
|
5441
5695
|
}
|
|
5442
5696
|
cancel(params) {
|
|
5443
5697
|
const { idempotencyKey, ...body } = params;
|
|
5444
5698
|
assertCommerceIdempotencyKey(idempotencyKey);
|
|
5445
|
-
const
|
|
5699
|
+
const endpoint = this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.cancel : COMMERCE_ENDPOINTS.paymentSessions.cancel;
|
|
5446
5700
|
return this.paymentSession(
|
|
5447
|
-
this.post(
|
|
5448
|
-
"toss"
|
|
5701
|
+
this.post(endpoint, body, idempotencyKey),
|
|
5702
|
+
"toss",
|
|
5703
|
+
"cancel"
|
|
5449
5704
|
);
|
|
5450
5705
|
}
|
|
5451
5706
|
cancelPortOne(params) {
|
|
5452
5707
|
const { idempotencyKey, ...body } = params;
|
|
5453
5708
|
assertCommerceIdempotencyKey(idempotencyKey);
|
|
5454
|
-
const
|
|
5709
|
+
const endpoint = this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.cancel : COMMERCE_ENDPOINTS.paymentSessions.cancel;
|
|
5455
5710
|
return this.paymentSession(
|
|
5456
|
-
this.post(
|
|
5457
|
-
"portone"
|
|
5711
|
+
this.post(endpoint, body, idempotencyKey),
|
|
5712
|
+
"portone",
|
|
5713
|
+
"cancel"
|
|
5458
5714
|
);
|
|
5459
5715
|
}
|
|
5460
5716
|
confirm(params) {
|
|
@@ -5470,6 +5726,34 @@ var PaymentSessionApi = class extends CustomerScopedApi {
|
|
|
5470
5726
|
);
|
|
5471
5727
|
}
|
|
5472
5728
|
};
|
|
5729
|
+
var PortOnePaymentReconciliationApi = class extends BaseApi {
|
|
5730
|
+
constructor(options) {
|
|
5731
|
+
super("PortOnePaymentReconciliationApi", options);
|
|
5732
|
+
}
|
|
5733
|
+
async find(params) {
|
|
5734
|
+
const result = await this.requestEndpoint(
|
|
5735
|
+
COMMERCE_ENDPOINTS.paymentSessions.server.findPortOne,
|
|
5736
|
+
params
|
|
5737
|
+
);
|
|
5738
|
+
return validatePortOnePaymentFacadeResult(
|
|
5739
|
+
result,
|
|
5740
|
+
false
|
|
5741
|
+
);
|
|
5742
|
+
}
|
|
5743
|
+
async reconcile(params) {
|
|
5744
|
+
const { idempotencyKey, ...body } = params;
|
|
5745
|
+
assertCommerceIdempotencyKey(idempotencyKey);
|
|
5746
|
+
const result = await this.requestEndpoint(
|
|
5747
|
+
COMMERCE_ENDPOINTS.paymentSessions.server.reconcilePortOne,
|
|
5748
|
+
body,
|
|
5749
|
+
{ headers: { "X-Idempotency-Key": idempotencyKey } }
|
|
5750
|
+
);
|
|
5751
|
+
return validatePortOnePaymentFacadeResult(
|
|
5752
|
+
result,
|
|
5753
|
+
true
|
|
5754
|
+
);
|
|
5755
|
+
}
|
|
5756
|
+
};
|
|
5473
5757
|
var CustomPaymentSessionApi = class extends BaseApi {
|
|
5474
5758
|
constructor(options) {
|
|
5475
5759
|
super("CustomPaymentSessionApi", options);
|
|
@@ -5599,6 +5883,9 @@ var ServerCommerceClient = class {
|
|
|
5599
5883
|
const orderApi = new OrderApi(serverOptions);
|
|
5600
5884
|
const checkoutApi = new CheckoutApi(serverOptions);
|
|
5601
5885
|
const paymentSessionApi = new PaymentSessionApi(serverOptions);
|
|
5886
|
+
const portOneReconciliationApi = new PortOnePaymentReconciliationApi(
|
|
5887
|
+
serverOptions
|
|
5888
|
+
);
|
|
5602
5889
|
const customPaymentSessionApi = new CustomPaymentSessionApi(serverOptions);
|
|
5603
5890
|
this.product = {
|
|
5604
5891
|
stockCheck: productApi.stockCheck.bind(productApi),
|
|
@@ -5649,6 +5936,10 @@ var ServerCommerceClient = class {
|
|
|
5649
5936
|
cancel: (params) => paymentSessionApi.cancel(params),
|
|
5650
5937
|
cancelPortOne: (params) => paymentSessionApi.cancelPortOne(params),
|
|
5651
5938
|
confirm: paymentSessionApi.confirm.bind(paymentSessionApi),
|
|
5939
|
+
findPortOne: portOneReconciliationApi.find.bind(portOneReconciliationApi),
|
|
5940
|
+
reconcilePortOne: portOneReconciliationApi.reconcile.bind(
|
|
5941
|
+
portOneReconciliationApi
|
|
5942
|
+
),
|
|
5652
5943
|
custom: {
|
|
5653
5944
|
create: customPaymentSessionApi.create.bind(customPaymentSessionApi),
|
|
5654
5945
|
retrieve: customPaymentSessionApi.retrieve.bind(
|
|
@@ -5730,11 +6021,11 @@ var EventsClient = class {
|
|
|
5730
6021
|
{ useCustomerAuth: false }
|
|
5731
6022
|
);
|
|
5732
6023
|
}
|
|
5733
|
-
async execute(
|
|
6024
|
+
async execute(endpoint, method, body, options = {}) {
|
|
5734
6025
|
const useCustomerAuth = options.useCustomerAuth === true;
|
|
5735
6026
|
const token = useCustomerAuth ? typeof this.customerToken === "function" ? this.customerToken() : this.customerToken : void 0;
|
|
5736
6027
|
try {
|
|
5737
|
-
const response = await httpFetch(
|
|
6028
|
+
const response = await httpFetch(endpoint, {
|
|
5738
6029
|
method,
|
|
5739
6030
|
apiUrl: this.apiUrl,
|
|
5740
6031
|
publishableKey: this.publishableKey,
|
|
@@ -5743,7 +6034,7 @@ var EventsClient = class {
|
|
|
5743
6034
|
...body !== void 0 && { body: JSON.stringify(body) }
|
|
5744
6035
|
});
|
|
5745
6036
|
this.onRequestId?.(response.headers.get("x-request-id") ?? null);
|
|
5746
|
-
return parseApiResponse(response,
|
|
6037
|
+
return parseApiResponse(response, endpoint);
|
|
5747
6038
|
} catch (err) {
|
|
5748
6039
|
const id = err instanceof SDKError ? err.requestId ?? null : null;
|
|
5749
6040
|
this.onRequestId?.(id);
|
|
@@ -5845,13 +6136,14 @@ var MarketDiscovery = class {
|
|
|
5845
6136
|
};
|
|
5846
6137
|
|
|
5847
6138
|
// src/core/api/tenant-introspection-api.ts
|
|
6139
|
+
var TENANT_CONTEXT_PATH = "/api/tenants/context";
|
|
5848
6140
|
var TenantIntrospectionApi = class extends RawBaseApi {
|
|
5849
6141
|
constructor(options) {
|
|
5850
6142
|
super("TenantIntrospectionApi", options);
|
|
5851
6143
|
}
|
|
5852
6144
|
context(params = {}) {
|
|
5853
|
-
const
|
|
5854
|
-
return this.request(
|
|
6145
|
+
const endpoint = params.includeCounts ? `${TENANT_CONTEXT_PATH}?counts=true` : TENANT_CONTEXT_PATH;
|
|
6146
|
+
return this.request(endpoint, void 0, {
|
|
5855
6147
|
method: "GET"
|
|
5856
6148
|
});
|
|
5857
6149
|
}
|
|
@@ -5879,9 +6171,10 @@ var MembershipApi = class extends BaseApi {
|
|
|
5879
6171
|
super("MembershipApi", options);
|
|
5880
6172
|
}
|
|
5881
6173
|
/**
|
|
5882
|
-
*
|
|
5883
|
-
*
|
|
5884
|
-
* `
|
|
6174
|
+
* Prepare a delegated first charge for a paid Membership, or immediately
|
|
6175
|
+
* start a trial. For a paid response, charge through the tenant PSP with
|
|
6176
|
+
* `firstCharge.idempotencyKey`, then post the existing signed charge result
|
|
6177
|
+
* to activate the membership.
|
|
5885
6178
|
*
|
|
5886
6179
|
* `subscribeIntentKey` is used as the HTTP idempotency key so the call is
|
|
5887
6180
|
* safely retryable.
|
|
@@ -5910,6 +6203,39 @@ var MembershipApi = class extends BaseApi {
|
|
|
5910
6203
|
}
|
|
5911
6204
|
};
|
|
5912
6205
|
|
|
6206
|
+
// src/core/api/customer-group-api.ts
|
|
6207
|
+
var CustomerGroupApi = class extends BaseApi {
|
|
6208
|
+
constructor(options) {
|
|
6209
|
+
super("CustomerGroupApi", options);
|
|
6210
|
+
}
|
|
6211
|
+
listMembers(params) {
|
|
6212
|
+
const query = new URLSearchParams();
|
|
6213
|
+
if (params.page !== void 0) query.set("page", String(params.page));
|
|
6214
|
+
if (params.limit !== void 0) query.set("limit", String(params.limit));
|
|
6215
|
+
return this.requestEndpoint(
|
|
6216
|
+
CUSTOMER_GROUP_ENDPOINT_OPERATIONS.members,
|
|
6217
|
+
void 0,
|
|
6218
|
+
{ pathParams: { id: params.groupId }, query }
|
|
6219
|
+
);
|
|
6220
|
+
}
|
|
6221
|
+
grantMember(params) {
|
|
6222
|
+
const { groupId, ...body } = params;
|
|
6223
|
+
return this.requestEndpoint(
|
|
6224
|
+
CUSTOMER_GROUP_ENDPOINT_OPERATIONS.grant,
|
|
6225
|
+
body,
|
|
6226
|
+
{ pathParams: { id: groupId } }
|
|
6227
|
+
);
|
|
6228
|
+
}
|
|
6229
|
+
revokeMember(params) {
|
|
6230
|
+
const { groupId, ...body } = params;
|
|
6231
|
+
return this.requestEndpoint(
|
|
6232
|
+
CUSTOMER_GROUP_ENDPOINT_OPERATIONS.revoke,
|
|
6233
|
+
body,
|
|
6234
|
+
{ pathParams: { id: groupId } }
|
|
6235
|
+
);
|
|
6236
|
+
}
|
|
6237
|
+
};
|
|
6238
|
+
|
|
5913
6239
|
// src/core/client/client.server.ts
|
|
5914
6240
|
var ServerClient = class _ServerClient {
|
|
5915
6241
|
constructor(options) {
|
|
@@ -5949,6 +6275,7 @@ var ServerClient = class _ServerClient {
|
|
|
5949
6275
|
subscribe: membershipApi.subscribe.bind(membershipApi),
|
|
5950
6276
|
cancel: membershipApi.cancel.bind(membershipApi)
|
|
5951
6277
|
};
|
|
6278
|
+
this.customerGroups = new CustomerGroupApi(serverOptions);
|
|
5952
6279
|
const tenantIntrospectionApi = new TenantIntrospectionApi(serverOptions);
|
|
5953
6280
|
this.tenant = {
|
|
5954
6281
|
context: tenantIntrospectionApi.context.bind(tenantIntrospectionApi),
|