@djust-b2b/djust-front-sdk 2.5.0 → 2.5.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/lib/index.d.ts CHANGED
@@ -1,6 +1,10 @@
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
+ initPayment({ browserInfo, countryCode, customerUserIP, paymentMethodData, reference, referenceType, returnPath, storePaymentMethod, }: import("./services/payment/definitions").InitPaymentRequest): Promise<import("./services/payment/definitions").InitPaymentResponse>;
5
+ getPaymentDetails({ details, }: import("./services/payment/definitions").GetPaymentDetailsRequest): Promise<import("./services/payment/definitions").GetPaymentDetailsResponse>;
6
+ getPaymentMethods({ reference, countryCode, referenceType, locale, }: import("./services/payment/definitions").GetPaymentMethodsRequest): Promise<import("./services/payment/definitions").GetPaymentMethodsResponse>;
7
+ deleteStoredPaymentMethodById({ storedPaymentMethodId, }: import("./services/payment/definitions").DeleteStoredPaymentMethodByIdRequest): Promise<void>;
4
8
  getCustomFields(params: import("./services/custom-field/definitions").GetCustomFieldParameters): Promise<import("./services/custom-field/definitions").GetCustomFieldResponse>;
5
9
  postMediaCustomField(params: import("./services/custom-field/definitions").PostMediaCustomFieldParameters): Promise<string>;
6
10
  getMediaUrl(params: import("./services/custom-field/definitions").GetMediaUrlParameters): Promise<string>;
package/lib/index.js CHANGED
@@ -50,6 +50,7 @@ const LogisticOrderServices = __importStar(require("./services/logistic-order"))
50
50
  const IncidentServices = __importStar(require("./services/incident"));
51
51
  const OfferServices = __importStar(require("./services/offer-inventories"));
52
52
  const CustomFieldServices = __importStar(require("./services/custom-field"));
53
+ const PaymentServices = __importStar(require("./services/payment"));
53
54
  const fetch_instance_1 = require("./settings/fetch-instance");
54
55
  exports.DjustSDK = {
55
56
  ...AuthServices,
@@ -65,6 +66,7 @@ exports.DjustSDK = {
65
66
  ...IncidentServices,
66
67
  ...OfferServices,
67
68
  ...CustomFieldServices,
69
+ ...PaymentServices,
68
70
  initialize: fetch_instance_1.initialize,
69
71
  updateConfiguration: fetch_instance_1.updateConfiguration,
70
72
  };
@@ -3,6 +3,7 @@ import { PaymentReferenceType } from "../../interfaces/models/payment";
3
3
  /**
4
4
  * Request parameters type definitions
5
5
  */
6
+ export type ResultCode = "AuthenticationFinished" | "AuthenticationNotRequired" | "Authorised" | "Cancelled" | "ChallengeShopper" | "Error" | "IdentifyShopper" | "PartiallyAuthorised" | "Pending" | "PresentToShopper" | "Received" | "RedirectShopper" | "Refused";
6
7
  export interface GetCommercialOrdersParameters {
7
8
  locale: string;
8
9
  nbPreviewLines?: number;
@@ -14,35 +15,38 @@ export interface GetCommercialOrdersParameters {
14
15
  isValidated?: boolean;
15
16
  }
16
17
  export interface InitPaymentRequest {
17
- bankTransfer?: boolean;
18
18
  browserInfo: BrowserInfo;
19
- commercialOrder?: boolean;
20
19
  countryCode: string;
21
- customerUserIP: string;
22
- paymentMethodData: object;
20
+ customerUserIP?: string;
21
+ paymentMethodData?: Record<string, unknown>;
23
22
  reference: string;
24
- referenceType?: PaymentReferenceType;
23
+ referenceType?: string;
25
24
  returnPath: string;
26
25
  storePaymentMethod?: boolean;
27
26
  }
28
27
  export interface InitPaymentResponse {
29
28
  action: {
30
- type: string;
29
+ type: "bankTransfer" | "redirect" | "threeDS2" | "await" | "qrCode" | "voucher" | "sdk";
31
30
  beneficiary: string;
32
31
  bic: string;
33
32
  iban: string;
34
33
  paymentMethodType: string;
34
+ paymentData: string;
35
35
  totalAmountCurrency: string;
36
36
  totalAmountValue: number;
37
37
  url: string;
38
+ method: string;
39
+ authorisationToken: string;
40
+ subtype: string;
41
+ token: string;
38
42
  };
39
43
  pspReference: string;
40
- resultCode: string;
44
+ resultCode: ResultCode;
41
45
  }
42
- export interface AddPaymentDetailsRequest {
46
+ export interface GetPaymentDetailsRequest {
43
47
  details: string;
44
48
  }
45
- export interface AddPaymentDetailsResponse {
49
+ export interface GetPaymentDetailsResponse {
46
50
  pspReference: string;
47
51
  resultCode: string;
48
52
  }
@@ -1,4 +1,4 @@
1
- import { AddPaymentDetailsRequest, AddPaymentDetailsResponse, DeleteStoredPaymentMethodByIdRequest, GetPaymentMethodsRequest, GetPaymentMethodsResponse, InitPaymentRequest, InitPaymentResponse } from "./definitions";
1
+ import { GetPaymentDetailsRequest, GetPaymentDetailsResponse, DeleteStoredPaymentMethodByIdRequest, GetPaymentMethodsRequest, GetPaymentMethodsResponse, InitPaymentRequest, InitPaymentResponse } from "./definitions";
2
2
  /**
3
3
  * 💳 Initializes a payment transaction.
4
4
  *
@@ -15,12 +15,10 @@ import { AddPaymentDetailsRequest, AddPaymentDetailsResponse, DeleteStoredPaymen
15
15
  *
16
16
  * | Parameter | Type | Required | Description |
17
17
  * |---------------------|---------------------|----------|------------------------------------------------|
18
- * | `bankTransfer` | `BankTransfer` | ✅ | Bank transfer configuration. |
19
18
  * | `browserInfo` | `BrowserInfo` | ✅ | Browser information for 3DS authentication. |
20
- * | `commercialOrder` | `CommercialOrder` | ❌ | Commercial order details. |
21
19
  * | `countryCode` | `string` | ✅ | Country code for payment processing. |
22
- * | `customerUserIP` | `string` | | Customer's IP address. |
23
- * | `paymentMethodData` | `PaymentMethodData` | | Payment method configuration. |
20
+ * | `customerUserIP` | `string` | | Customer's IP address. |
21
+ * | `paymentMethodData` | `PaymentMethodData` | | Payment method configuration. |
24
22
  * | `reference` | `string` | ✅ | Payment reference identifier. |
25
23
  * | `referenceType` | `string` | ❌ | Type of reference. |
26
24
  * | `returnPath` | `string` | ✅ | Return URL after payment completion. |
@@ -32,7 +30,6 @@ import { AddPaymentDetailsRequest, AddPaymentDetailsResponse, DeleteStoredPaymen
32
30
  * 🛠 **Example usage**:
33
31
  * ```ts
34
32
  * const response = await initPayment({
35
- * bankTransfer: false,
36
33
  * browserInfo: {
37
34
  * acceptHeader: "......",
38
35
  * colorDepth: 24,
@@ -44,7 +41,6 @@ import { AddPaymentDetailsRequest, AddPaymentDetailsResponse, DeleteStoredPaymen
44
41
  * timeZoneOffset: 0,
45
42
  * userAgent: "......",
46
43
  * },
47
- * commercialOrder: false,
48
44
  * countryCode: "FR",
49
45
  * customerUserIP: "127.0.0.1",
50
46
  * paymentMethodData: {
@@ -63,11 +59,11 @@ import { AddPaymentDetailsRequest, AddPaymentDetailsResponse, DeleteStoredPaymen
63
59
  * @throws {Error} If required parameters are missing
64
60
  * @returns {Promise<InitPaymentResponse>} A promise resolving to the payment initialization response
65
61
  */
66
- export declare function initPayment({ bankTransfer, browserInfo, commercialOrder, countryCode, customerUserIP, paymentMethodData, reference, referenceType, returnPath, storePaymentMethod, }: InitPaymentRequest): Promise<InitPaymentResponse>;
62
+ export declare function initPayment({ browserInfo, countryCode, customerUserIP, paymentMethodData, reference, referenceType, returnPath, storePaymentMethod, }: InitPaymentRequest): Promise<InitPaymentResponse>;
67
63
  /**
68
- * 💳 Adds payment details.
64
+ * 💳 Gets payment details.
69
65
  *
70
- * This function adds additional details to an existing payment transaction.
66
+ * This function gets additional details to an existing payment transaction.
71
67
  * The `details` parameter is mandatory and validated before the request is executed.
72
68
  *
73
69
  * 🛠 **Endpoint**: `POST /v1/shop/payments/details` [PAY-102]
@@ -83,7 +79,7 @@ export declare function initPayment({ bankTransfer, browserInfo, commercialOrder
83
79
  * @throws {Error} If `details` is missing
84
80
  * @returns {Promise<AddPaymentDetailsResponse>} A promise resolving to the response containing the result
85
81
  */
86
- export declare function addPaymentDetails({ details, }: AddPaymentDetailsRequest): Promise<AddPaymentDetailsResponse>;
82
+ export declare function getPaymentDetails({ details, }: GetPaymentDetailsRequest): Promise<GetPaymentDetailsResponse>;
87
83
  /**
88
84
  * 💳 Gets available payment methods.
89
85
  *
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.initPayment = initPayment;
4
- exports.addPaymentDetails = addPaymentDetails;
4
+ exports.getPaymentDetails = getPaymentDetails;
5
5
  exports.getPaymentMethods = getPaymentMethods;
6
6
  exports.deleteStoredPaymentMethodById = deleteStoredPaymentMethodById;
7
7
  const parameters_validation_1 = require("../../helpers/parameters-validation");
@@ -22,12 +22,10 @@ const fetch_instance_1 = require("../../settings/fetch-instance");
22
22
  *
23
23
  * | Parameter | Type | Required | Description |
24
24
  * |---------------------|---------------------|----------|------------------------------------------------|
25
- * | `bankTransfer` | `BankTransfer` | ✅ | Bank transfer configuration. |
26
25
  * | `browserInfo` | `BrowserInfo` | ✅ | Browser information for 3DS authentication. |
27
- * | `commercialOrder` | `CommercialOrder` | ❌ | Commercial order details. |
28
26
  * | `countryCode` | `string` | ✅ | Country code for payment processing. |
29
- * | `customerUserIP` | `string` | | Customer's IP address. |
30
- * | `paymentMethodData` | `PaymentMethodData` | | Payment method configuration. |
27
+ * | `customerUserIP` | `string` | | Customer's IP address. |
28
+ * | `paymentMethodData` | `PaymentMethodData` | | Payment method configuration. |
31
29
  * | `reference` | `string` | ✅ | Payment reference identifier. |
32
30
  * | `referenceType` | `string` | ❌ | Type of reference. |
33
31
  * | `returnPath` | `string` | ✅ | Return URL after payment completion. |
@@ -39,7 +37,6 @@ const fetch_instance_1 = require("../../settings/fetch-instance");
39
37
  * 🛠 **Example usage**:
40
38
  * ```ts
41
39
  * const response = await initPayment({
42
- * bankTransfer: false,
43
40
  * browserInfo: {
44
41
  * acceptHeader: "......",
45
42
  * colorDepth: 24,
@@ -51,7 +48,6 @@ const fetch_instance_1 = require("../../settings/fetch-instance");
51
48
  * timeZoneOffset: 0,
52
49
  * userAgent: "......",
53
50
  * },
54
- * commercialOrder: false,
55
51
  * countryCode: "FR",
56
52
  * customerUserIP: "127.0.0.1",
57
53
  * paymentMethodData: {
@@ -70,13 +66,10 @@ const fetch_instance_1 = require("../../settings/fetch-instance");
70
66
  * @throws {Error} If required parameters are missing
71
67
  * @returns {Promise<InitPaymentResponse>} A promise resolving to the payment initialization response
72
68
  */
73
- async function initPayment({ bankTransfer, browserInfo, commercialOrder, countryCode, customerUserIP, paymentMethodData, reference, referenceType, returnPath, storePaymentMethod, }) {
69
+ async function initPayment({ browserInfo, countryCode, customerUserIP, paymentMethodData, reference, referenceType, returnPath, storePaymentMethod, }) {
74
70
  (0, parameters_validation_1.required)({
75
- bankTransfer,
76
71
  browserInfo,
77
72
  countryCode,
78
- customerUserIP,
79
- paymentMethodData,
80
73
  reference,
81
74
  returnPath,
82
75
  });
@@ -84,9 +77,7 @@ async function initPayment({ bankTransfer, browserInfo, commercialOrder, country
84
77
  method: "POST",
85
78
  path: `/v1/shop/payments`,
86
79
  body: JSON.stringify({
87
- bankTransfer,
88
80
  browserInfo,
89
- commercialOrder,
90
81
  countryCode,
91
82
  customerUserIP,
92
83
  paymentMethodData,
@@ -99,9 +90,9 @@ async function initPayment({ bankTransfer, browserInfo, commercialOrder, country
99
90
  return data;
100
91
  }
101
92
  /**
102
- * 💳 Adds payment details.
93
+ * 💳 Gets payment details.
103
94
  *
104
- * This function adds additional details to an existing payment transaction.
95
+ * This function gets additional details to an existing payment transaction.
105
96
  * The `details` parameter is mandatory and validated before the request is executed.
106
97
  *
107
98
  * 🛠 **Endpoint**: `POST /v1/shop/payments/details` [PAY-102]
@@ -117,7 +108,7 @@ async function initPayment({ bankTransfer, browserInfo, commercialOrder, country
117
108
  * @throws {Error} If `details` is missing
118
109
  * @returns {Promise<AddPaymentDetailsResponse>} A promise resolving to the response containing the result
119
110
  */
120
- async function addPaymentDetails({ details, }) {
111
+ async function getPaymentDetails({ details, }) {
121
112
  (0, parameters_validation_1.required)({ details });
122
113
  const { data } = await (0, fetch_instance_1.enhancedFetch)({
123
114
  method: "POST",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@djust-b2b/djust-front-sdk",
3
- "version": "2.5.0",
3
+ "version": "2.5.1",
4
4
  "description": "DJUST Front SDK is a versatile JavaScript Software Development Kit (SDK)",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",