@djust-b2b/djust-front-sdk 2.0.0 → 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/interfaces/models/common.d.ts +11 -0
- package/lib/interfaces/models/payment.d.ts +1 -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
|
@@ -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
|
+
}
|
|
@@ -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 {
|
|
@@ -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
|
+
}
|