@djust-b2b/djust-front-sdk 1.29.3 → 2.1.0
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/lib/index.d.ts +3 -0
- package/lib/index.js +2 -0
- package/lib/interfaces/models/common.d.ts +11 -0
- package/lib/interfaces/models/offer.d.ts +29 -1
- package/lib/interfaces/models/payment.d.ts +1 -0
- package/lib/interfaces/models/product.d.ts +1 -1
- package/lib/services/offer-inventories/definitions.d.ts +72 -0
- package/lib/services/offer-inventories/definitions.js +2 -0
- package/lib/services/offer-inventories/index.d.ts +119 -0
- package/lib/services/offer-inventories/index.js +174 -0
- package/lib/services/payment/definitions.d.ts +61 -0
- package/lib/services/payment/definitions.js +2 -0
- package/lib/services/payment/index.d.ts +132 -0
- package/lib/services/payment/index.js +195 -0
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
export declare const DjustSDK: {
|
|
2
2
|
initialize: (initConfig: import("./settings/fetch-instance").ClientConfig) => void;
|
|
3
3
|
updateConfiguration: (newConfig: Partial<import("./settings/fetch-instance").ClientConfig>) => void;
|
|
4
|
+
getPaginatedOfferInventories({ page, size, sort, productStatus, offerInventoryStatus, variantStatus, offerPriceStatus, supplierId, offersIds, offerPriceIds, currency, hasStock, idType, }: import("./services/offer-inventories/definitions").GetPaginatedOfferInventoriesParameters): Promise<import("./services/offer-inventories/definitions").GetOfferInventoriesResponse>;
|
|
5
|
+
getPaginatedOfferInventoriesV2({ page, size, sort, variantExternalId, }: import("./services/offer-inventories/definitions").GetPaginatedOfferInventoriesV2Parameters): Promise<import("./services/offer-inventories/definitions").GetOfferInventoriesV2Response>;
|
|
6
|
+
getOfferInventoryCustomFields({ externalId, page, size, sort, locale, }: import("./services/offer-inventories/definitions").GetOfferInventoryCustomFieldsParameters): Promise<import("./services/offer-inventories/definitions").GetOfferInventoryCustomFieldsResponse>;
|
|
4
7
|
getIncidents({ customerAccountIds, linkedType, ids, status, idType, page, size, sort, }: import("./services/incident/definitions").getIncidentsParameters): Promise<import("./services/incident/definitions").getIncidentsResponse>;
|
|
5
8
|
getIncident({ incidentId, idType, }: import("./services/incident/definitions").getIncidentParameters): Promise<import("./services/incident/definitions").getIncidentResponse>;
|
|
6
9
|
createOrderLogisticIncident({ logisticOrderId, idType, customField, reasonCode, }: import("./services/incident/definitions").createOrderLogisticIncidentParameters): Promise<import("./services/incident/definitions").createOrderLogisticIncidentResponse>;
|
package/lib/index.js
CHANGED
|
@@ -49,6 +49,7 @@ const SupplierServices = __importStar(require("./services/supplier"));
|
|
|
49
49
|
const CommercialOrderServices = __importStar(require("./services/commercial-order"));
|
|
50
50
|
const LogisticOrderServices = __importStar(require("./services/logistic-order"));
|
|
51
51
|
const IncidentServices = __importStar(require("./services/incident"));
|
|
52
|
+
const OfferServices = __importStar(require("./services/offer-inventories"));
|
|
52
53
|
const fetch_instance_1 = require("./settings/fetch-instance");
|
|
53
54
|
exports.DjustSDK = {
|
|
54
55
|
...AuthServices,
|
|
@@ -63,6 +64,7 @@ exports.DjustSDK = {
|
|
|
63
64
|
...LogisticOrderServices,
|
|
64
65
|
...CommercialOrderServices,
|
|
65
66
|
...IncidentServices,
|
|
67
|
+
...OfferServices,
|
|
66
68
|
initialize: fetch_instance_1.initialize,
|
|
67
69
|
updateConfiguration: fetch_instance_1.updateConfiguration,
|
|
68
70
|
};
|
|
@@ -54,3 +54,14 @@ export interface DjustConfig {
|
|
|
54
54
|
storeId?: string;
|
|
55
55
|
storeViewId?: string;
|
|
56
56
|
}
|
|
57
|
+
export interface BrowserInfo {
|
|
58
|
+
acceptHeader: string;
|
|
59
|
+
colorDepth: number;
|
|
60
|
+
javaEnabled: boolean;
|
|
61
|
+
javaScriptEnabled: boolean;
|
|
62
|
+
language: string;
|
|
63
|
+
screenHeight: number;
|
|
64
|
+
screenWidth: number;
|
|
65
|
+
timeZoneOffset: number;
|
|
66
|
+
userAgent: string;
|
|
67
|
+
}
|
|
@@ -3,7 +3,8 @@ import { ProductVariantResponse } from "./product";
|
|
|
3
3
|
import { SupplierResponse } from "./supplier";
|
|
4
4
|
import { PriceDto } from "./price";
|
|
5
5
|
export type PackingType = "BOX" | "BOTTLE" | "UNIT";
|
|
6
|
-
export type OfferStatus = "ACTIVE" | "INACTIVE" | "DELETED";
|
|
6
|
+
export type OfferStatus = "ACTIVE" | "INACTIVE" | "DELETED" | "NEW";
|
|
7
|
+
export type OfferInventoryStatus = "ACTIVE" | "INACTIVE";
|
|
7
8
|
export type OfferPriceType = "PUBLIC" | "GROUP" | "ACCOUNT";
|
|
8
9
|
export interface OfferDto {
|
|
9
10
|
currency: string;
|
|
@@ -73,6 +74,33 @@ export interface OfferResponse {
|
|
|
73
74
|
offerPrices: OfferPriceResponse[];
|
|
74
75
|
supplier: SupplierResponse;
|
|
75
76
|
}
|
|
77
|
+
export interface OfferInventories extends OfferResponse {
|
|
78
|
+
}
|
|
79
|
+
export interface OfferInventoriesV2 {
|
|
80
|
+
currency: string;
|
|
81
|
+
externalId: string;
|
|
82
|
+
externalSource: string;
|
|
83
|
+
id: string;
|
|
84
|
+
leadTimeToShip: number;
|
|
85
|
+
maxOrderQuantity: number;
|
|
86
|
+
minOrderQuantity: number;
|
|
87
|
+
minShippingPrice: number;
|
|
88
|
+
minShippingPriceAdditional: number;
|
|
89
|
+
minShippingType: string;
|
|
90
|
+
minShippingZone: string;
|
|
91
|
+
minStockAlert: number;
|
|
92
|
+
packingType: string;
|
|
93
|
+
productUnit: string;
|
|
94
|
+
quantityPerItem: number;
|
|
95
|
+
status: string;
|
|
96
|
+
stock: number;
|
|
97
|
+
}
|
|
98
|
+
export interface OfferInventoryCustomField {
|
|
99
|
+
externalId: string;
|
|
100
|
+
name: string;
|
|
101
|
+
value: string;
|
|
102
|
+
values: string[];
|
|
103
|
+
}
|
|
76
104
|
export interface DeliveryDates {
|
|
77
105
|
code: string;
|
|
78
106
|
deliveryTimeRange: DeliveryTime;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export type PaymentType = "ON_ACCEPTANCE" | "DUE_DATE";
|
|
2
2
|
export type PaymentOption = "BANK_WIRE" | "BANK_WIRE_ON_DUE_DATE" | "CREDIT_CARD" | "DIRECT_PAYMENT" | "BANK_WIRE_ON_ACCEPTANCE";
|
|
3
3
|
export type PaymentStatus = "AUTHORIZED" | "WAITING_AUTHORIZATION" | "WAITING_PAYMENT" | "PAID" | "PARTIALLY_PAID" | "OVER_PAID" | "REFUSED" | "WAITING_REFUND" | "PARTIALLY_REFUNDED" | "REFUNDED";
|
|
4
|
+
export type PaymentReferenceType = "LOGISTIC" | "COMMERCIAL";
|
|
4
5
|
type PaymentDueDateMode = "SIMPLE" | "END_OF_MONTH";
|
|
5
6
|
export type PaymentProvider = "MANGOPAY" | "THUNES" | "LEMONWAY";
|
|
6
7
|
export interface PaymentDueDate {
|
|
@@ -3,7 +3,7 @@ import { SimpleUserView } from "./customer-user";
|
|
|
3
3
|
import { BestOffer } from "./offer";
|
|
4
4
|
import { NavigationCategorySimpleView } from "./navigation-category";
|
|
5
5
|
import { ExternalSource, Order, PageableObject } from "./common";
|
|
6
|
-
export type ProductStatus = "ACTIVE" | "INACTIVE" | "DELETED";
|
|
6
|
+
export type ProductStatus = "ACTIVE" | "INACTIVE" | "DELETED" | "NEW";
|
|
7
7
|
export type ProductVariantAttributeType = "TEXT" | "COLOR" | "DATE" | "BOOLEAN";
|
|
8
8
|
export type UnitType = "ITEM" | "WEIGHT_METRIC" | "VOLUME_METRIC" | "LENGTH_METRIC" | "AREA_METRIC" | "WEIGHT_IMPERIAL" | "VOLUME_IMPERIAL" | "LENGTH_IMPERIAL" | "AREA_IMPERIAL";
|
|
9
9
|
export type ProductIdType = "SKU" | "ID" | "EXTERNAL_ID";
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { OfferInventories, OfferInventoriesV2, OfferInventoryCustomField, OfferInventoryStatus } from "../../interfaces/models/offer";
|
|
2
|
+
import { ProductStatus } from "../../interfaces/models/product";
|
|
3
|
+
import { IdType, Order, PageableObject } from "../../interfaces/models/common";
|
|
4
|
+
/**
|
|
5
|
+
* Requests parameters type definitions
|
|
6
|
+
*/
|
|
7
|
+
export interface GetPaginatedOfferInventoriesParameters {
|
|
8
|
+
page?: number;
|
|
9
|
+
size?: number;
|
|
10
|
+
sort?: string;
|
|
11
|
+
productStatus?: ProductStatus;
|
|
12
|
+
offerInventoryStatus?: OfferInventoryStatus;
|
|
13
|
+
variantStatus?: ProductStatus;
|
|
14
|
+
offerPriceStatus?: OfferInventoryStatus;
|
|
15
|
+
supplierId?: string;
|
|
16
|
+
offersIds?: string[];
|
|
17
|
+
offerPriceIds?: string[];
|
|
18
|
+
currency: string;
|
|
19
|
+
hasStock?: string;
|
|
20
|
+
idType?: IdType;
|
|
21
|
+
}
|
|
22
|
+
export interface GetPaginatedOfferInventoriesV2Parameters {
|
|
23
|
+
page?: number;
|
|
24
|
+
size?: number;
|
|
25
|
+
sort?: string;
|
|
26
|
+
variantExternalId?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface GetOfferInventoriesResponse {
|
|
29
|
+
content: OfferInventories[];
|
|
30
|
+
empty: boolean;
|
|
31
|
+
first: boolean;
|
|
32
|
+
last: boolean;
|
|
33
|
+
number: number;
|
|
34
|
+
numberOfElements: number;
|
|
35
|
+
pageable: PageableObject;
|
|
36
|
+
size: number;
|
|
37
|
+
sort: Order[];
|
|
38
|
+
totalElements: number;
|
|
39
|
+
totalPages: number;
|
|
40
|
+
}
|
|
41
|
+
export interface GetOfferInventoriesV2Response {
|
|
42
|
+
content: OfferInventoriesV2[];
|
|
43
|
+
empty: boolean;
|
|
44
|
+
first: boolean;
|
|
45
|
+
last: boolean;
|
|
46
|
+
number: number;
|
|
47
|
+
numberOfElements: number;
|
|
48
|
+
pageable: PageableObject;
|
|
49
|
+
size: number;
|
|
50
|
+
sort: Order[];
|
|
51
|
+
totalElements: number;
|
|
52
|
+
}
|
|
53
|
+
export interface GetOfferInventoryCustomFieldsParameters {
|
|
54
|
+
externalId: string;
|
|
55
|
+
locale?: string;
|
|
56
|
+
page?: number;
|
|
57
|
+
size?: number;
|
|
58
|
+
sort?: string;
|
|
59
|
+
}
|
|
60
|
+
export interface GetOfferInventoryCustomFieldsResponse {
|
|
61
|
+
content: OfferInventoryCustomField[];
|
|
62
|
+
empty: boolean;
|
|
63
|
+
first: boolean;
|
|
64
|
+
last: boolean;
|
|
65
|
+
number: number;
|
|
66
|
+
numberOfElements: number;
|
|
67
|
+
pageable: PageableObject;
|
|
68
|
+
size: number;
|
|
69
|
+
sort: Order[];
|
|
70
|
+
totalElements: number;
|
|
71
|
+
totalPages: number;
|
|
72
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { GetOfferInventoriesResponse, GetOfferInventoriesV2Response, GetOfferInventoryCustomFieldsParameters, GetOfferInventoryCustomFieldsResponse, GetPaginatedOfferInventoriesParameters, GetPaginatedOfferInventoriesV2Parameters } from "./definitions";
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated
|
|
4
|
+
* 📄 Gets offer inventories.
|
|
5
|
+
*
|
|
6
|
+
* This function retrieves offer inventories with various filtering options.
|
|
7
|
+
* The `currency` parameter is mandatory and validated before the request is executed.
|
|
8
|
+
*
|
|
9
|
+
* 🛠 **Endpoint**: `GET /v1/offer-inventories` [OFFER-550]
|
|
10
|
+
*
|
|
11
|
+
* | Parameter | Type | Required | Description |
|
|
12
|
+
* |------------------------|--------------|----------|---------------------------------------------|
|
|
13
|
+
* | `page` | `number` | ❌ | The page number to fetch (0-based index). |
|
|
14
|
+
* | `size` | `number` | ❌ | The number of items per page. |
|
|
15
|
+
* | `sort` | `string` | ❌ | The sort to apply to the results. |
|
|
16
|
+
* | `productStatus` | `string` | ❌ | Filter by product status. |
|
|
17
|
+
* | `offerInventoryStatus` | `string` | ❌ | Filter by offer inventory status. |
|
|
18
|
+
* | `variantStatus` | `string` | ❌ | Filter by variant status. |
|
|
19
|
+
* | `offerPriceStatus` | `string` | ❌ | Filter by offer price status. |
|
|
20
|
+
* | `supplierId` | `string` | ❌ | Filter by supplier ID. |
|
|
21
|
+
* | `offersIds` | `string[]` | ❌ | Filter by offer IDs. |
|
|
22
|
+
* | `offerPriceIds` | `string[]` | ❌ | Filter by offer price IDs. |
|
|
23
|
+
* | `currency` | `string` | ✅ | The currency for price formatting. |
|
|
24
|
+
* | `hasStock` | `string` | ❌ | Filter by stock availability. |
|
|
25
|
+
* | `idType` | `string` | ❌ | The ID type to use. |
|
|
26
|
+
*
|
|
27
|
+
* 📤 **Returns**:
|
|
28
|
+
* A `Promise` resolving to a `GetOfferInventoriesResponse` containing the offer inventories.
|
|
29
|
+
*
|
|
30
|
+
* 🛠 **Example usage**:
|
|
31
|
+
* ```typescript
|
|
32
|
+
* const inventories = await getOfferInventories({
|
|
33
|
+
* page: 0,
|
|
34
|
+
* size: 20,
|
|
35
|
+
* sort: "createdAt,desc",
|
|
36
|
+
* currency: "EUR",
|
|
37
|
+
* hasStock: "true",
|
|
38
|
+
* });
|
|
39
|
+
* console.log(inventories);
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* @deprecated This function is deprecated and will be probably removed in a future version.
|
|
43
|
+
* @param {GetPaginatedOfferInventoriesParameters} params - The parameters for the request
|
|
44
|
+
* @throws {Error} If `currency` is missing
|
|
45
|
+
* @returns {Promise<GetOfferInventoriesResponse>} A promise resolving to the response containing the offer inventories
|
|
46
|
+
*/
|
|
47
|
+
export declare function getPaginatedOfferInventories({ page, size, sort, productStatus, offerInventoryStatus, variantStatus, offerPriceStatus, supplierId, offersIds, offerPriceIds, currency, hasStock, idType, }: GetPaginatedOfferInventoriesParameters): Promise<GetOfferInventoriesResponse>;
|
|
48
|
+
/**
|
|
49
|
+
* 📄 Gets paginated offer inventories V2.
|
|
50
|
+
*
|
|
51
|
+
* This function retrieves paginated offer inventories with filtering by variant external ID.
|
|
52
|
+
* The `variantExternalId` parameter is mandatory and validated before the request is executed.
|
|
53
|
+
*
|
|
54
|
+
* 🛠 **Endpoint**: `GET /v2/offer-inventories` [OFFER-551]
|
|
55
|
+
*
|
|
56
|
+
* | Parameter | Type | Required | Description |
|
|
57
|
+
* |---------------------|----------|----------|------------------------------------------------|
|
|
58
|
+
* | `page` | `number` | ❌ | The page number to fetch (0-based index). |
|
|
59
|
+
* | `size` | `number` | ❌ | The number of items per page. |
|
|
60
|
+
* | `sort` | `string` | ❌ | The sort to apply to the results. |
|
|
61
|
+
* | `variantExternalId` | `string` | ✅ | The external ID of the product variant. |
|
|
62
|
+
*
|
|
63
|
+
* 📤 **Returns**:
|
|
64
|
+
* A `Promise` resolving to a `GetOfferInventoriesV2Response` containing the paginated offer inventories.
|
|
65
|
+
*
|
|
66
|
+
* 🛠 **Example usage**:
|
|
67
|
+
* ```typescript
|
|
68
|
+
* const inventories = await getPaginatedOfferInventoriesV2({
|
|
69
|
+
* variantExternalId: "variant123",
|
|
70
|
+
* page: 0,
|
|
71
|
+
* size: 20,
|
|
72
|
+
* sort: "createdAt,desc",
|
|
73
|
+
* });
|
|
74
|
+
* console.log(inventories);
|
|
75
|
+
* ```
|
|
76
|
+
*
|
|
77
|
+
* @param {GetPaginatedOfferInventoriesV2Parameters} params - The parameters for the request
|
|
78
|
+
* @throws {Error} If `variantExternalId` is missing
|
|
79
|
+
* @returns {Promise<GetOfferInventoriesV2Response>} A promise resolving to the response containing the paginated offer inventories
|
|
80
|
+
*/
|
|
81
|
+
export declare function getPaginatedOfferInventoriesV2({ page, size, sort, variantExternalId, }: GetPaginatedOfferInventoriesV2Parameters): Promise<GetOfferInventoriesV2Response>;
|
|
82
|
+
/**
|
|
83
|
+
* @deprecated
|
|
84
|
+
* 📄 Gets offer inventory custom fields.
|
|
85
|
+
*
|
|
86
|
+
* This function retrieves custom fields for a specific offer inventory identified by the `externalId`.
|
|
87
|
+
* The `externalId` parameter is mandatory and validated before the request is executed.
|
|
88
|
+
*
|
|
89
|
+
* 🛠 **Endpoint**: `GET /v1/offer-inventories/${externalId}/custom-fields` [OFFER-552]
|
|
90
|
+
*
|
|
91
|
+
* | Parameter | Type | Required | Description |
|
|
92
|
+
* |-------------|----------|----------|------------------------------------------------|
|
|
93
|
+
* | `externalId`| `string` | ✅ | The external ID of the offer inventory. |
|
|
94
|
+
* | `page` | `number` | ❌ | The page number to fetch (0-based index). |
|
|
95
|
+
* | `size` | `number` | ❌ | The number of items per page. |
|
|
96
|
+
* | `sort` | `string` | ❌ | The sort to apply to the results. |
|
|
97
|
+
* | `locale` | `string` | ❌ | The locale for the response data. |
|
|
98
|
+
*
|
|
99
|
+
* 📤 **Returns**:
|
|
100
|
+
* A `Promise` resolving to a `GetOfferInventoryCustomFieldsResponse` containing the custom fields.
|
|
101
|
+
*
|
|
102
|
+
* 🛠 **Example usage**:
|
|
103
|
+
* ```typescript
|
|
104
|
+
* const customFields = await getOfferInventoryCustomFields({
|
|
105
|
+
* externalId: "inventory123",
|
|
106
|
+
* page: 0,
|
|
107
|
+
* size: 20,
|
|
108
|
+
* sort: "name,asc",
|
|
109
|
+
* locale: "en",
|
|
110
|
+
* });
|
|
111
|
+
* console.log(customFields);
|
|
112
|
+
* ```
|
|
113
|
+
*
|
|
114
|
+
* @deprecated This function is deprecated and will be probably removed in a future version.
|
|
115
|
+
* @param {GetOfferInventoryCustomFieldsParameters} params - The parameters for the request
|
|
116
|
+
* @throws {Error} If `externalId` is missing
|
|
117
|
+
* @returns {Promise<GetOfferInventoryCustomFieldsResponse>} A promise resolving to the response containing the custom fields
|
|
118
|
+
*/
|
|
119
|
+
export declare function getOfferInventoryCustomFields({ externalId, page, size, sort, locale, }: GetOfferInventoryCustomFieldsParameters): Promise<GetOfferInventoryCustomFieldsResponse>;
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPaginatedOfferInventories = getPaginatedOfferInventories;
|
|
4
|
+
exports.getPaginatedOfferInventoriesV2 = getPaginatedOfferInventoriesV2;
|
|
5
|
+
exports.getOfferInventoryCustomFields = getOfferInventoryCustomFields;
|
|
6
|
+
const parameters_validation_1 = require("../../helpers/parameters-validation");
|
|
7
|
+
const fetch_instance_1 = require("../../settings/fetch-instance");
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated
|
|
10
|
+
* 📄 Gets offer inventories.
|
|
11
|
+
*
|
|
12
|
+
* This function retrieves offer inventories with various filtering options.
|
|
13
|
+
* The `currency` parameter is mandatory and validated before the request is executed.
|
|
14
|
+
*
|
|
15
|
+
* 🛠 **Endpoint**: `GET /v1/offer-inventories` [OFFER-550]
|
|
16
|
+
*
|
|
17
|
+
* | Parameter | Type | Required | Description |
|
|
18
|
+
* |------------------------|--------------|----------|---------------------------------------------|
|
|
19
|
+
* | `page` | `number` | ❌ | The page number to fetch (0-based index). |
|
|
20
|
+
* | `size` | `number` | ❌ | The number of items per page. |
|
|
21
|
+
* | `sort` | `string` | ❌ | The sort to apply to the results. |
|
|
22
|
+
* | `productStatus` | `string` | ❌ | Filter by product status. |
|
|
23
|
+
* | `offerInventoryStatus` | `string` | ❌ | Filter by offer inventory status. |
|
|
24
|
+
* | `variantStatus` | `string` | ❌ | Filter by variant status. |
|
|
25
|
+
* | `offerPriceStatus` | `string` | ❌ | Filter by offer price status. |
|
|
26
|
+
* | `supplierId` | `string` | ❌ | Filter by supplier ID. |
|
|
27
|
+
* | `offersIds` | `string[]` | ❌ | Filter by offer IDs. |
|
|
28
|
+
* | `offerPriceIds` | `string[]` | ❌ | Filter by offer price IDs. |
|
|
29
|
+
* | `currency` | `string` | ✅ | The currency for price formatting. |
|
|
30
|
+
* | `hasStock` | `string` | ❌ | Filter by stock availability. |
|
|
31
|
+
* | `idType` | `string` | ❌ | The ID type to use. |
|
|
32
|
+
*
|
|
33
|
+
* 📤 **Returns**:
|
|
34
|
+
* A `Promise` resolving to a `GetOfferInventoriesResponse` containing the offer inventories.
|
|
35
|
+
*
|
|
36
|
+
* 🛠 **Example usage**:
|
|
37
|
+
* ```typescript
|
|
38
|
+
* const inventories = await getOfferInventories({
|
|
39
|
+
* page: 0,
|
|
40
|
+
* size: 20,
|
|
41
|
+
* sort: "createdAt,desc",
|
|
42
|
+
* currency: "EUR",
|
|
43
|
+
* hasStock: "true",
|
|
44
|
+
* });
|
|
45
|
+
* console.log(inventories);
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @deprecated This function is deprecated and will be probably removed in a future version.
|
|
49
|
+
* @param {GetPaginatedOfferInventoriesParameters} params - The parameters for the request
|
|
50
|
+
* @throws {Error} If `currency` is missing
|
|
51
|
+
* @returns {Promise<GetOfferInventoriesResponse>} A promise resolving to the response containing the offer inventories
|
|
52
|
+
*/
|
|
53
|
+
async function getPaginatedOfferInventories({ page, size, sort, productStatus, offerInventoryStatus, variantStatus, offerPriceStatus, supplierId, offersIds, offerPriceIds, currency, hasStock, idType, }) {
|
|
54
|
+
(0, parameters_validation_1.required)({ currency });
|
|
55
|
+
const { data } = await (0, fetch_instance_1.enhancedFetch)({
|
|
56
|
+
method: "GET",
|
|
57
|
+
path: `/v1/offer-inventories`,
|
|
58
|
+
params: {
|
|
59
|
+
page,
|
|
60
|
+
size,
|
|
61
|
+
sort,
|
|
62
|
+
productStatus,
|
|
63
|
+
offerInventoryStatus,
|
|
64
|
+
variantStatus,
|
|
65
|
+
offerPriceStatus,
|
|
66
|
+
supplierId,
|
|
67
|
+
offersIds,
|
|
68
|
+
offerPriceIds,
|
|
69
|
+
currency,
|
|
70
|
+
hasStock,
|
|
71
|
+
idType,
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
return data;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* 📄 Gets paginated offer inventories V2.
|
|
78
|
+
*
|
|
79
|
+
* This function retrieves paginated offer inventories with filtering by variant external ID.
|
|
80
|
+
* The `variantExternalId` parameter is mandatory and validated before the request is executed.
|
|
81
|
+
*
|
|
82
|
+
* 🛠 **Endpoint**: `GET /v2/offer-inventories` [OFFER-551]
|
|
83
|
+
*
|
|
84
|
+
* | Parameter | Type | Required | Description |
|
|
85
|
+
* |---------------------|----------|----------|------------------------------------------------|
|
|
86
|
+
* | `page` | `number` | ❌ | The page number to fetch (0-based index). |
|
|
87
|
+
* | `size` | `number` | ❌ | The number of items per page. |
|
|
88
|
+
* | `sort` | `string` | ❌ | The sort to apply to the results. |
|
|
89
|
+
* | `variantExternalId` | `string` | ✅ | The external ID of the product variant. |
|
|
90
|
+
*
|
|
91
|
+
* 📤 **Returns**:
|
|
92
|
+
* A `Promise` resolving to a `GetOfferInventoriesV2Response` containing the paginated offer inventories.
|
|
93
|
+
*
|
|
94
|
+
* 🛠 **Example usage**:
|
|
95
|
+
* ```typescript
|
|
96
|
+
* const inventories = await getPaginatedOfferInventoriesV2({
|
|
97
|
+
* variantExternalId: "variant123",
|
|
98
|
+
* page: 0,
|
|
99
|
+
* size: 20,
|
|
100
|
+
* sort: "createdAt,desc",
|
|
101
|
+
* });
|
|
102
|
+
* console.log(inventories);
|
|
103
|
+
* ```
|
|
104
|
+
*
|
|
105
|
+
* @param {GetPaginatedOfferInventoriesV2Parameters} params - The parameters for the request
|
|
106
|
+
* @throws {Error} If `variantExternalId` is missing
|
|
107
|
+
* @returns {Promise<GetOfferInventoriesV2Response>} A promise resolving to the response containing the paginated offer inventories
|
|
108
|
+
*/
|
|
109
|
+
async function getPaginatedOfferInventoriesV2({ page, size, sort, variantExternalId, }) {
|
|
110
|
+
(0, parameters_validation_1.required)({ variantExternalId });
|
|
111
|
+
const { data } = await (0, fetch_instance_1.enhancedFetch)({
|
|
112
|
+
method: "GET",
|
|
113
|
+
path: `/v2/offer-inventories`,
|
|
114
|
+
params: {
|
|
115
|
+
variantExternalId,
|
|
116
|
+
page,
|
|
117
|
+
size,
|
|
118
|
+
sort,
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
return data;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* @deprecated
|
|
125
|
+
* 📄 Gets offer inventory custom fields.
|
|
126
|
+
*
|
|
127
|
+
* This function retrieves custom fields for a specific offer inventory identified by the `externalId`.
|
|
128
|
+
* The `externalId` parameter is mandatory and validated before the request is executed.
|
|
129
|
+
*
|
|
130
|
+
* 🛠 **Endpoint**: `GET /v1/offer-inventories/${externalId}/custom-fields` [OFFER-552]
|
|
131
|
+
*
|
|
132
|
+
* | Parameter | Type | Required | Description |
|
|
133
|
+
* |-------------|----------|----------|------------------------------------------------|
|
|
134
|
+
* | `externalId`| `string` | ✅ | The external ID of the offer inventory. |
|
|
135
|
+
* | `page` | `number` | ❌ | The page number to fetch (0-based index). |
|
|
136
|
+
* | `size` | `number` | ❌ | The number of items per page. |
|
|
137
|
+
* | `sort` | `string` | ❌ | The sort to apply to the results. |
|
|
138
|
+
* | `locale` | `string` | ❌ | The locale for the response data. |
|
|
139
|
+
*
|
|
140
|
+
* 📤 **Returns**:
|
|
141
|
+
* A `Promise` resolving to a `GetOfferInventoryCustomFieldsResponse` containing the custom fields.
|
|
142
|
+
*
|
|
143
|
+
* 🛠 **Example usage**:
|
|
144
|
+
* ```typescript
|
|
145
|
+
* const customFields = await getOfferInventoryCustomFields({
|
|
146
|
+
* externalId: "inventory123",
|
|
147
|
+
* page: 0,
|
|
148
|
+
* size: 20,
|
|
149
|
+
* sort: "name,asc",
|
|
150
|
+
* locale: "en",
|
|
151
|
+
* });
|
|
152
|
+
* console.log(customFields);
|
|
153
|
+
* ```
|
|
154
|
+
*
|
|
155
|
+
* @deprecated This function is deprecated and will be probably removed in a future version.
|
|
156
|
+
* @param {GetOfferInventoryCustomFieldsParameters} params - The parameters for the request
|
|
157
|
+
* @throws {Error} If `externalId` is missing
|
|
158
|
+
* @returns {Promise<GetOfferInventoryCustomFieldsResponse>} A promise resolving to the response containing the custom fields
|
|
159
|
+
*/
|
|
160
|
+
async function getOfferInventoryCustomFields({ externalId, page, size, sort, locale, }) {
|
|
161
|
+
(0, parameters_validation_1.required)({ externalId });
|
|
162
|
+
const { data } = await (0, fetch_instance_1.enhancedFetch)({
|
|
163
|
+
method: "GET",
|
|
164
|
+
path: `/v1/offer-inventories/${externalId}/custom-fields`,
|
|
165
|
+
params: {
|
|
166
|
+
externalId,
|
|
167
|
+
page,
|
|
168
|
+
size,
|
|
169
|
+
sort,
|
|
170
|
+
locale,
|
|
171
|
+
},
|
|
172
|
+
});
|
|
173
|
+
return data;
|
|
174
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { BrowserInfo } from "../../interfaces/models/common";
|
|
2
|
+
import { PaymentReferenceType } from "../../interfaces/models/payment";
|
|
3
|
+
/**
|
|
4
|
+
* Request parameters type definitions
|
|
5
|
+
*/
|
|
6
|
+
export interface GetCommercialOrdersParameters {
|
|
7
|
+
locale: string;
|
|
8
|
+
nbPreviewLines?: number;
|
|
9
|
+
page?: number;
|
|
10
|
+
size?: number;
|
|
11
|
+
sort?: string[];
|
|
12
|
+
connectedUserOnly?: boolean;
|
|
13
|
+
customerAccountIds?: string[];
|
|
14
|
+
isValidated?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface InitPaymentRequest {
|
|
17
|
+
bankTransfer?: boolean;
|
|
18
|
+
browserInfo: BrowserInfo;
|
|
19
|
+
commercialOrder?: boolean;
|
|
20
|
+
countryCode: string;
|
|
21
|
+
customerUserIP: string;
|
|
22
|
+
paymentMethodData: object;
|
|
23
|
+
reference: string;
|
|
24
|
+
referenceType?: PaymentReferenceType;
|
|
25
|
+
returnPath: string;
|
|
26
|
+
storePaymentMethod?: boolean;
|
|
27
|
+
}
|
|
28
|
+
export interface InitPaymentResponse {
|
|
29
|
+
action: {
|
|
30
|
+
type: string;
|
|
31
|
+
beneficiary: string;
|
|
32
|
+
bic: string;
|
|
33
|
+
iban: string;
|
|
34
|
+
paymentMethodType: string;
|
|
35
|
+
totalAmountCurrency: string;
|
|
36
|
+
totalAmountValue: number;
|
|
37
|
+
url: string;
|
|
38
|
+
};
|
|
39
|
+
pspReference: string;
|
|
40
|
+
resultCode: string;
|
|
41
|
+
}
|
|
42
|
+
export interface AddPaymentDetailsRequest {
|
|
43
|
+
details: string;
|
|
44
|
+
}
|
|
45
|
+
export interface AddPaymentDetailsResponse {
|
|
46
|
+
pspReference: string;
|
|
47
|
+
resultCode: string;
|
|
48
|
+
}
|
|
49
|
+
export interface GetPaymentMethodsRequest {
|
|
50
|
+
reference: string;
|
|
51
|
+
countryCode?: string;
|
|
52
|
+
referenceType?: PaymentReferenceType;
|
|
53
|
+
locale?: string;
|
|
54
|
+
}
|
|
55
|
+
export interface GetPaymentMethodsResponse {
|
|
56
|
+
adyenPaymentMethods: string;
|
|
57
|
+
enableCreditCardStorage: boolean;
|
|
58
|
+
}
|
|
59
|
+
export interface DeleteStoredPaymentMethodByIdRequest {
|
|
60
|
+
storedPaymentMethodId: string;
|
|
61
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { AddPaymentDetailsRequest, AddPaymentDetailsResponse, DeleteStoredPaymentMethodByIdRequest, GetPaymentMethodsRequest, GetPaymentMethodsResponse, InitPaymentRequest, InitPaymentResponse } from "./definitions";
|
|
2
|
+
/**
|
|
3
|
+
* 💳 Initializes a payment transaction.
|
|
4
|
+
*
|
|
5
|
+
* This endpoint initializes a payment transaction.
|
|
6
|
+
* It supports:
|
|
7
|
+
* - Card authorizations with or without 3D Secure (3DS).
|
|
8
|
+
* - 3DS authentication flows, including redirection steps if required.
|
|
9
|
+
* - Bank transfer payment initialization using virtual IBAN feature.
|
|
10
|
+
*
|
|
11
|
+
* The response indicates the result of the transaction attempt and may contain an action
|
|
12
|
+
* (such as a redirection or bank transfer instructions) that must be followed to complete the payment.
|
|
13
|
+
*
|
|
14
|
+
* 🛠 **Endpoint**: `POST /v1/shop/payments` [PAY-101]
|
|
15
|
+
*
|
|
16
|
+
* | Parameter | Type | Required | Description |
|
|
17
|
+
* |---------------------|---------------------|----------|------------------------------------------------|
|
|
18
|
+
* | `bankTransfer` | `BankTransfer` | ✅ | Bank transfer configuration. |
|
|
19
|
+
* | `browserInfo` | `BrowserInfo` | ✅ | Browser information for 3DS authentication. |
|
|
20
|
+
* | `commercialOrder` | `CommercialOrder` | ❌ | Commercial order details. |
|
|
21
|
+
* | `countryCode` | `string` | ✅ | Country code for payment processing. |
|
|
22
|
+
* | `customerUserIP` | `string` | ✅ | Customer's IP address. |
|
|
23
|
+
* | `paymentMethodData` | `PaymentMethodData` | ✅ | Payment method configuration. |
|
|
24
|
+
* | `reference` | `string` | ✅ | Payment reference identifier. |
|
|
25
|
+
* | `referenceType` | `string` | ❌ | Type of reference. |
|
|
26
|
+
* | `returnPath` | `string` | ✅ | Return URL after payment completion. |
|
|
27
|
+
* | `storePaymentMethod`| `boolean` | ❌ | Whether to store the payment method. |
|
|
28
|
+
*
|
|
29
|
+
* 📤 **Returns**:
|
|
30
|
+
* A `Promise` resolving to an `InitPaymentResponse` containing the payment initialization result.
|
|
31
|
+
*
|
|
32
|
+
* 🛠 **Example usage**:
|
|
33
|
+
* ```ts
|
|
34
|
+
* const response = await initPayment({
|
|
35
|
+
* bankTransfer: false,
|
|
36
|
+
* browserInfo: {
|
|
37
|
+
* acceptHeader: "......",
|
|
38
|
+
* colorDepth: 24,
|
|
39
|
+
* javaEnabled: true,
|
|
40
|
+
* javaScriptEnabled: true,
|
|
41
|
+
* language: "en-US",
|
|
42
|
+
* screenHeight: 1080,
|
|
43
|
+
* screenWidth: 1920,
|
|
44
|
+
* timeZoneOffset: 0,
|
|
45
|
+
* userAgent: "......",
|
|
46
|
+
* },
|
|
47
|
+
* commercialOrder: false,
|
|
48
|
+
* countryCode: "FR",
|
|
49
|
+
* customerUserIP: "127.0.0.1",
|
|
50
|
+
* paymentMethodData: {
|
|
51
|
+
* description: "......",
|
|
52
|
+
* },
|
|
53
|
+
* reference: "......",
|
|
54
|
+
* referenceType: "......",
|
|
55
|
+
* returnPath: "......",
|
|
56
|
+
* storePaymentMethod: true,
|
|
57
|
+
* });
|
|
58
|
+
* console.log(response);
|
|
59
|
+
*
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
* @param {InitPaymentRequest} params - The parameters for the payment initialization
|
|
63
|
+
* @throws {Error} If required parameters are missing
|
|
64
|
+
* @returns {Promise<InitPaymentResponse>} A promise resolving to the payment initialization response
|
|
65
|
+
*/
|
|
66
|
+
export declare function initPayment({ bankTransfer, browserInfo, commercialOrder, countryCode, customerUserIP, paymentMethodData, reference, referenceType, returnPath, storePaymentMethod, }: InitPaymentRequest): Promise<InitPaymentResponse>;
|
|
67
|
+
/**
|
|
68
|
+
* 💳 Adds payment details.
|
|
69
|
+
*
|
|
70
|
+
* This function adds additional details to an existing payment transaction.
|
|
71
|
+
* The `details` parameter is mandatory and validated before the request is executed.
|
|
72
|
+
*
|
|
73
|
+
* 🛠 **Endpoint**: `POST /v1/shop/payments/details` [PAY-102]
|
|
74
|
+
*
|
|
75
|
+
* | Parameter | Type | Required | Description |
|
|
76
|
+
* |-----------|----------|----------|--------------------------------|
|
|
77
|
+
* | `details` | `object` | ✅ | The payment details to add. |
|
|
78
|
+
*
|
|
79
|
+
* 📤 **Returns**:
|
|
80
|
+
* A `Promise` resolving to an `AddPaymentDetailsResponse` containing the result of adding payment details.
|
|
81
|
+
*
|
|
82
|
+
* @param {AddPaymentDetailsRequest} params - The parameters for adding payment details
|
|
83
|
+
* @throws {Error} If `details` is missing
|
|
84
|
+
* @returns {Promise<AddPaymentDetailsResponse>} A promise resolving to the response containing the result
|
|
85
|
+
*/
|
|
86
|
+
export declare function addPaymentDetails({ details, }: AddPaymentDetailsRequest): Promise<AddPaymentDetailsResponse>;
|
|
87
|
+
/**
|
|
88
|
+
* 💳 Gets available payment methods.
|
|
89
|
+
*
|
|
90
|
+
* This endpoint retrieves the available payment methods based on the country, locale, amount, and currency.
|
|
91
|
+
* It provides a list of payment methods that can be used for checkout based on the merchant's Adyen configuration.
|
|
92
|
+
* The `reference` parameter is mandatory and validated before the request is executed.
|
|
93
|
+
*
|
|
94
|
+
* 🛠 **Endpoint**: `GET /v1/shop/payments/methods` [PAY-501]
|
|
95
|
+
*
|
|
96
|
+
* | Parameter | Type | Required | Description |
|
|
97
|
+
* |----------------|----------|----------|------------------------------------------------|
|
|
98
|
+
* | `reference` | `string` | ✅ | The payment reference identifier. |
|
|
99
|
+
* | `countryCode` | `string` | ❌ | The country code for payment method filtering.|
|
|
100
|
+
* | `referenceType`| `string` | ❌ | The type of reference. |
|
|
101
|
+
* | `locale` | `string` | ❌ | The locale for payment method localization. |
|
|
102
|
+
*
|
|
103
|
+
* 📤 **Returns**:
|
|
104
|
+
* A `Promise` resolving to a `GetPaymentMethodsResponse` containing the available payment methods.
|
|
105
|
+
*
|
|
106
|
+
* @param {GetPaymentMethodsRequest} params - The parameters for retrieving payment methods
|
|
107
|
+
* @throws {Error} If `reference` is missing
|
|
108
|
+
* @returns {Promise<GetPaymentMethodsResponse>} A promise resolving to the response containing available payment methods
|
|
109
|
+
*/
|
|
110
|
+
export declare function getPaymentMethods({ reference, countryCode, referenceType, locale, }: GetPaymentMethodsRequest): Promise<GetPaymentMethodsResponse>;
|
|
111
|
+
/**
|
|
112
|
+
* 💳 Deletes a stored payment method.
|
|
113
|
+
*
|
|
114
|
+
* This endpoint deletes a stored payment method (e.g., saved card) associated with the current shopper.
|
|
115
|
+
* It is intended for use on the storefront. If the specified ID does not exist or does not belong
|
|
116
|
+
* to the authenticated user, a 404 will be returned.
|
|
117
|
+
* The `storedPaymentMethodId` parameter is mandatory and validated before the request is executed.
|
|
118
|
+
*
|
|
119
|
+
* 🛠 **Endpoint**: `DELETE /v1/shop/payments/stored-payment-methods/{storedPaymentMethodId}` [PAY-300]
|
|
120
|
+
*
|
|
121
|
+
* | Parameter | Type | Required | Description |
|
|
122
|
+
* |------------------------|----------|----------|------------------------------------------------|
|
|
123
|
+
* | `storedPaymentMethodId`| `string` | ✅ | The ID of the stored payment method to delete.|
|
|
124
|
+
*
|
|
125
|
+
* 📤 **Returns**:
|
|
126
|
+
* A `Promise` resolving to `void` when the stored payment method is successfully deleted.
|
|
127
|
+
*
|
|
128
|
+
* @param {DeleteStoredPaymentMethodByIdRequest} params - The parameters for deleting the stored payment method
|
|
129
|
+
* @throws {Error} If `storedPaymentMethodId` is missing
|
|
130
|
+
* @returns {Promise<void>} A promise resolving when the stored payment method is successfully deleted
|
|
131
|
+
*/
|
|
132
|
+
export declare function deleteStoredPaymentMethodById({ storedPaymentMethodId, }: DeleteStoredPaymentMethodByIdRequest): Promise<void>;
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.initPayment = initPayment;
|
|
4
|
+
exports.addPaymentDetails = addPaymentDetails;
|
|
5
|
+
exports.getPaymentMethods = getPaymentMethods;
|
|
6
|
+
exports.deleteStoredPaymentMethodById = deleteStoredPaymentMethodById;
|
|
7
|
+
const parameters_validation_1 = require("../../helpers/parameters-validation");
|
|
8
|
+
const fetch_instance_1 = require("../../settings/fetch-instance");
|
|
9
|
+
/**
|
|
10
|
+
* 💳 Initializes a payment transaction.
|
|
11
|
+
*
|
|
12
|
+
* This endpoint initializes a payment transaction.
|
|
13
|
+
* It supports:
|
|
14
|
+
* - Card authorizations with or without 3D Secure (3DS).
|
|
15
|
+
* - 3DS authentication flows, including redirection steps if required.
|
|
16
|
+
* - Bank transfer payment initialization using virtual IBAN feature.
|
|
17
|
+
*
|
|
18
|
+
* The response indicates the result of the transaction attempt and may contain an action
|
|
19
|
+
* (such as a redirection or bank transfer instructions) that must be followed to complete the payment.
|
|
20
|
+
*
|
|
21
|
+
* 🛠 **Endpoint**: `POST /v1/shop/payments` [PAY-101]
|
|
22
|
+
*
|
|
23
|
+
* | Parameter | Type | Required | Description |
|
|
24
|
+
* |---------------------|---------------------|----------|------------------------------------------------|
|
|
25
|
+
* | `bankTransfer` | `BankTransfer` | ✅ | Bank transfer configuration. |
|
|
26
|
+
* | `browserInfo` | `BrowserInfo` | ✅ | Browser information for 3DS authentication. |
|
|
27
|
+
* | `commercialOrder` | `CommercialOrder` | ❌ | Commercial order details. |
|
|
28
|
+
* | `countryCode` | `string` | ✅ | Country code for payment processing. |
|
|
29
|
+
* | `customerUserIP` | `string` | ✅ | Customer's IP address. |
|
|
30
|
+
* | `paymentMethodData` | `PaymentMethodData` | ✅ | Payment method configuration. |
|
|
31
|
+
* | `reference` | `string` | ✅ | Payment reference identifier. |
|
|
32
|
+
* | `referenceType` | `string` | ❌ | Type of reference. |
|
|
33
|
+
* | `returnPath` | `string` | ✅ | Return URL after payment completion. |
|
|
34
|
+
* | `storePaymentMethod`| `boolean` | ❌ | Whether to store the payment method. |
|
|
35
|
+
*
|
|
36
|
+
* 📤 **Returns**:
|
|
37
|
+
* A `Promise` resolving to an `InitPaymentResponse` containing the payment initialization result.
|
|
38
|
+
*
|
|
39
|
+
* 🛠 **Example usage**:
|
|
40
|
+
* ```ts
|
|
41
|
+
* const response = await initPayment({
|
|
42
|
+
* bankTransfer: false,
|
|
43
|
+
* browserInfo: {
|
|
44
|
+
* acceptHeader: "......",
|
|
45
|
+
* colorDepth: 24,
|
|
46
|
+
* javaEnabled: true,
|
|
47
|
+
* javaScriptEnabled: true,
|
|
48
|
+
* language: "en-US",
|
|
49
|
+
* screenHeight: 1080,
|
|
50
|
+
* screenWidth: 1920,
|
|
51
|
+
* timeZoneOffset: 0,
|
|
52
|
+
* userAgent: "......",
|
|
53
|
+
* },
|
|
54
|
+
* commercialOrder: false,
|
|
55
|
+
* countryCode: "FR",
|
|
56
|
+
* customerUserIP: "127.0.0.1",
|
|
57
|
+
* paymentMethodData: {
|
|
58
|
+
* description: "......",
|
|
59
|
+
* },
|
|
60
|
+
* reference: "......",
|
|
61
|
+
* referenceType: "......",
|
|
62
|
+
* returnPath: "......",
|
|
63
|
+
* storePaymentMethod: true,
|
|
64
|
+
* });
|
|
65
|
+
* console.log(response);
|
|
66
|
+
*
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* @param {InitPaymentRequest} params - The parameters for the payment initialization
|
|
70
|
+
* @throws {Error} If required parameters are missing
|
|
71
|
+
* @returns {Promise<InitPaymentResponse>} A promise resolving to the payment initialization response
|
|
72
|
+
*/
|
|
73
|
+
async function initPayment({ bankTransfer, browserInfo, commercialOrder, countryCode, customerUserIP, paymentMethodData, reference, referenceType, returnPath, storePaymentMethod, }) {
|
|
74
|
+
(0, parameters_validation_1.required)({
|
|
75
|
+
bankTransfer,
|
|
76
|
+
browserInfo,
|
|
77
|
+
countryCode,
|
|
78
|
+
customerUserIP,
|
|
79
|
+
paymentMethodData,
|
|
80
|
+
reference,
|
|
81
|
+
returnPath,
|
|
82
|
+
});
|
|
83
|
+
const { data } = await (0, fetch_instance_1.enhancedFetch)({
|
|
84
|
+
method: "POST",
|
|
85
|
+
path: `/v1/shop/payments`,
|
|
86
|
+
body: JSON.stringify({
|
|
87
|
+
bankTransfer,
|
|
88
|
+
browserInfo,
|
|
89
|
+
commercialOrder,
|
|
90
|
+
countryCode,
|
|
91
|
+
customerUserIP,
|
|
92
|
+
paymentMethodData,
|
|
93
|
+
reference,
|
|
94
|
+
referenceType,
|
|
95
|
+
returnPath,
|
|
96
|
+
storePaymentMethod,
|
|
97
|
+
}),
|
|
98
|
+
});
|
|
99
|
+
return data;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* 💳 Adds payment details.
|
|
103
|
+
*
|
|
104
|
+
* This function adds additional details to an existing payment transaction.
|
|
105
|
+
* The `details` parameter is mandatory and validated before the request is executed.
|
|
106
|
+
*
|
|
107
|
+
* 🛠 **Endpoint**: `POST /v1/shop/payments/details` [PAY-102]
|
|
108
|
+
*
|
|
109
|
+
* | Parameter | Type | Required | Description |
|
|
110
|
+
* |-----------|----------|----------|--------------------------------|
|
|
111
|
+
* | `details` | `object` | ✅ | The payment details to add. |
|
|
112
|
+
*
|
|
113
|
+
* 📤 **Returns**:
|
|
114
|
+
* A `Promise` resolving to an `AddPaymentDetailsResponse` containing the result of adding payment details.
|
|
115
|
+
*
|
|
116
|
+
* @param {AddPaymentDetailsRequest} params - The parameters for adding payment details
|
|
117
|
+
* @throws {Error} If `details` is missing
|
|
118
|
+
* @returns {Promise<AddPaymentDetailsResponse>} A promise resolving to the response containing the result
|
|
119
|
+
*/
|
|
120
|
+
async function addPaymentDetails({ details, }) {
|
|
121
|
+
(0, parameters_validation_1.required)({ details });
|
|
122
|
+
const { data } = await (0, fetch_instance_1.enhancedFetch)({
|
|
123
|
+
method: "POST",
|
|
124
|
+
path: `/v1/shop/payments/details`,
|
|
125
|
+
body: JSON.stringify({
|
|
126
|
+
details,
|
|
127
|
+
}),
|
|
128
|
+
});
|
|
129
|
+
return data;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* 💳 Gets available payment methods.
|
|
133
|
+
*
|
|
134
|
+
* This endpoint retrieves the available payment methods based on the country, locale, amount, and currency.
|
|
135
|
+
* It provides a list of payment methods that can be used for checkout based on the merchant's Adyen configuration.
|
|
136
|
+
* The `reference` parameter is mandatory and validated before the request is executed.
|
|
137
|
+
*
|
|
138
|
+
* 🛠 **Endpoint**: `GET /v1/shop/payments/methods` [PAY-501]
|
|
139
|
+
*
|
|
140
|
+
* | Parameter | Type | Required | Description |
|
|
141
|
+
* |----------------|----------|----------|------------------------------------------------|
|
|
142
|
+
* | `reference` | `string` | ✅ | The payment reference identifier. |
|
|
143
|
+
* | `countryCode` | `string` | ❌ | The country code for payment method filtering.|
|
|
144
|
+
* | `referenceType`| `string` | ❌ | The type of reference. |
|
|
145
|
+
* | `locale` | `string` | ❌ | The locale for payment method localization. |
|
|
146
|
+
*
|
|
147
|
+
* 📤 **Returns**:
|
|
148
|
+
* A `Promise` resolving to a `GetPaymentMethodsResponse` containing the available payment methods.
|
|
149
|
+
*
|
|
150
|
+
* @param {GetPaymentMethodsRequest} params - The parameters for retrieving payment methods
|
|
151
|
+
* @throws {Error} If `reference` is missing
|
|
152
|
+
* @returns {Promise<GetPaymentMethodsResponse>} A promise resolving to the response containing available payment methods
|
|
153
|
+
*/
|
|
154
|
+
async function getPaymentMethods({ reference, countryCode, referenceType, locale, }) {
|
|
155
|
+
(0, parameters_validation_1.required)({ reference });
|
|
156
|
+
const { data } = await (0, fetch_instance_1.enhancedFetch)({
|
|
157
|
+
method: "GET",
|
|
158
|
+
path: `/v1/shop/payments/methods`,
|
|
159
|
+
params: {
|
|
160
|
+
reference,
|
|
161
|
+
countryCode,
|
|
162
|
+
referenceType,
|
|
163
|
+
locale,
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
return data;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* 💳 Deletes a stored payment method.
|
|
170
|
+
*
|
|
171
|
+
* This endpoint deletes a stored payment method (e.g., saved card) associated with the current shopper.
|
|
172
|
+
* It is intended for use on the storefront. If the specified ID does not exist or does not belong
|
|
173
|
+
* to the authenticated user, a 404 will be returned.
|
|
174
|
+
* The `storedPaymentMethodId` parameter is mandatory and validated before the request is executed.
|
|
175
|
+
*
|
|
176
|
+
* 🛠 **Endpoint**: `DELETE /v1/shop/payments/stored-payment-methods/{storedPaymentMethodId}` [PAY-300]
|
|
177
|
+
*
|
|
178
|
+
* | Parameter | Type | Required | Description |
|
|
179
|
+
* |------------------------|----------|----------|------------------------------------------------|
|
|
180
|
+
* | `storedPaymentMethodId`| `string` | ✅ | The ID of the stored payment method to delete.|
|
|
181
|
+
*
|
|
182
|
+
* 📤 **Returns**:
|
|
183
|
+
* A `Promise` resolving to `void` when the stored payment method is successfully deleted.
|
|
184
|
+
*
|
|
185
|
+
* @param {DeleteStoredPaymentMethodByIdRequest} params - The parameters for deleting the stored payment method
|
|
186
|
+
* @throws {Error} If `storedPaymentMethodId` is missing
|
|
187
|
+
* @returns {Promise<void>} A promise resolving when the stored payment method is successfully deleted
|
|
188
|
+
*/
|
|
189
|
+
async function deleteStoredPaymentMethodById({ storedPaymentMethodId, }) {
|
|
190
|
+
(0, parameters_validation_1.required)({ storedPaymentMethodId });
|
|
191
|
+
await (0, fetch_instance_1.enhancedFetch)({
|
|
192
|
+
method: "DELETE",
|
|
193
|
+
path: `/v1/shop/payments/stored-payment-methods/${storedPaymentMethodId}`,
|
|
194
|
+
});
|
|
195
|
+
}
|