@finteqhub/sdk-js 0.16.0-beta.1 → 0.16.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/CHANGELOG.md CHANGED
@@ -4,9 +4,14 @@ Notable changes to `@finteqhub/sdk-js`. The format is based on [Keep a Changelog
4
4
 
5
5
  ## 0.16.0
6
6
 
7
+ ### Breaking changes
8
+
9
+ - The SDK no longer sends the `x-merchant-id` header (previously on every request) or the `x-project-id` header (previously on `submit-form` and `operations` requests, taken from the session response). This release requires a backend that no longer expects these headers; against older backends `submit-form` and `sessions` requests are rejected with 400.
10
+ - The `merchantId` constructor argument was removed together with the header. The constructor is now `new FinteqHubProcessing(apiUrl, fingerprintVisitorId, sessionId, isSecure?, retryOptions?)` — every argument after `fingerprintVisitorId` shifts one position to the left. Callers must drop the third argument; a call site that still passes it fails argument validation (`isSecure` receives the session id, which is not a boolean, and the constructor throws a `TypeError`).
11
+
7
12
  ### Changed
8
13
 
9
- - The SDK no longer sends the `x-merchant-id` header (previously on every request) or the `x-project-id` header (previously on `submit-form` and `operations` requests, taken from the session response). The constructor signature is unchanged: `merchantId` is still accepted, but it is no longer validated (the constructor does not throw when it is empty or missing) and is not transmitted. This release requires a backend that no longer expects these headers; against older backends `submit-form` and `sessions` requests are rejected with 400.
14
+ - README: `getSession` is documented as optional and the Usage section shows a submit-only flow next to the render-from-session one. `submitForm` never depended on the session response apart from `projectId`, which is no longer sent.
10
15
 
11
16
  ## 0.15.0
12
17
 
package/README.md CHANGED
@@ -1,18 +1,16 @@
1
1
  # processing-sdk
2
2
 
3
- Use `new FinteqHubProcessing(apiUrl: string, fingerprintVisitorId: string, merchantId: string, sessionId: string, isSecure?: boolean, retryOptions?: RetryOptions)` to create an instance of the FinteqHubProcessing object. The FinteqHubProcessing object is your entrypoint to FinteqHub processing SDK.
3
+ Use `new FinteqHubProcessing(apiUrl: string, fingerprintVisitorId: string, sessionId: string, isSecure?: boolean, retryOptions?: RetryOptions)` to create an instance of the FinteqHubProcessing object. The FinteqHubProcessing object is your entrypoint to FinteqHub processing SDK.
4
4
 
5
5
  ```
6
- const processing = new FinteqHubProcessing('api-url', 'fingerprint-visitor-id', 'merchant-id', 'session-id');
6
+ const processing = new FinteqHubProcessing('api-url', 'fingerprint-visitor-id', 'session-id');
7
7
  ```
8
8
 
9
9
  The constructor validates its arguments and throws a `TypeError` when `apiUrl`, `fingerprintVisitorId` or `sessionId` is missing, empty or not a string, when `isSecure` is not a boolean, or when `retryOptions` is malformed (see [Retries and error diagnostics](#retries-and-error-diagnostics)).
10
10
 
11
- `merchantId` is accepted for compatibility but is neither validated nor sent to the API since 0.16.0.
12
-
13
11
  ## Retries and error diagnostics
14
12
 
15
- Failed HTTP requests are retried automatically with exponential backoff (`100ms → 200ms → 500ms → 1000ms → 2000ms`; every retry after the fifth waits 2000ms). Retries can be configured via the optional `retryOptions` constructor argument (the sixth one, after `isSecure`):
13
+ Failed HTTP requests are retried automatically with exponential backoff (`100ms → 200ms → 500ms → 1000ms → 2000ms`; every retry after the fifth waits 2000ms). Retries can be configured via the optional `retryOptions` constructor argument (the fifth one, after `isSecure`):
16
14
 
17
15
  ```
18
16
  interface RetryOptions {
@@ -20,7 +18,7 @@ interface RetryOptions {
20
18
  retryStatusCode?: (statusCode: number) => boolean; // default: statusCode < 200 || statusCode === 408 || statusCode >= 500
21
19
  }
22
20
 
23
- const processing = new FinteqHubProcessing('api-url', 'fingerprint-visitor-id', 'merchant-id', 'session-id', false, {
21
+ const processing = new FinteqHubProcessing('api-url', 'fingerprint-visitor-id', 'session-id', false, {
24
22
  retryCount: 3,
25
23
  });
26
24
  ```
@@ -28,7 +26,7 @@ const processing = new FinteqHubProcessing('api-url', 'fingerprint-visitor-id',
28
26
  To disable retries entirely, pass `retryCount: 0` — every request is then sent exactly once, as in 0.11.0. Error diagnostics (`RequestError`, the `console.error` dump) are still collected:
29
27
 
30
28
  ```
31
- const processing = new FinteqHubProcessing('api-url', 'fingerprint-visitor-id', 'merchant-id', 'session-id', false, {
29
+ const processing = new FinteqHubProcessing('api-url', 'fingerprint-visitor-id', 'session-id', false, {
32
30
  retryCount: 0,
33
31
  });
34
32
  ```
@@ -69,7 +67,7 @@ The header is added automatically to every request and cannot be disabled.
69
67
 
70
68
  ### processing.getSession()
71
69
 
72
- Use `processing.getSession` to get session information.
70
+ Use `processing.getSession` to get session information (payment methods, credential fields, operation amount and currency, init credentials) for rendering the form. It is optional: `submitForm` does not depend on it and can be called right after constructing the instance.
73
71
 
74
72
  ```
75
73
  processing
@@ -91,6 +89,10 @@ processing
91
89
 
92
90
  ## Usage
93
91
 
92
+ ### Submit only
93
+
94
+ The minimal flow is to construct the instance and call `submitForm` — no other request is needed before it. Use it when your own UI already knows what to collect from the customer (for example, the payment method and its credential fields are fixed on your side):
95
+
94
96
  ```
95
97
  import { FinteqHubProcessing } from "@finteqhub/sdk-js";
96
98
  import FingerprintJS from "@fingerprintjs/fingerprintjs";
@@ -98,10 +100,26 @@ import FingerprintJS from "@fingerprintjs/fingerprintjs";
98
100
  const fp = await FingerprintJS.load();
99
101
  const result = await fp.get();
100
102
 
101
- const processing = new FinteqHubProcessing(apiUrl, result.visitorId, merchantId, sessionId);
103
+ const processing = new FinteqHubProcessing(apiUrl, result.visitorId, sessionId);
104
+
105
+ const data = {/** collect data from form **/}
106
+
107
+ processing
108
+ .submitForm(data)
109
+ .then(result => console.log(result))
110
+ .catch(error => console.warn(error));
111
+ ```
112
+
113
+ ### Render the form from session data
114
+
115
+ Call `getSession` first when the form itself is built from the session: available payment methods, their credential fields, the operation amount and currency. `submitForm` does not use the result — it only drives your UI:
116
+
117
+ ```
118
+ const processing = new FinteqHubProcessing(apiUrl, result.visitorId, sessionId);
119
+
102
120
  const session = await processing.getSession();
103
121
 
104
- const data = {/** collect data from form and session **/}
122
+ const data = {/** collect data from form rendered from session **/}
105
123
 
106
124
  processing
107
125
  .submitForm(data)
@@ -47,12 +47,11 @@ export declare class RequestError extends Error {
47
47
  export declare class FinteqHubProcessing {
48
48
  private apiUrl;
49
49
  private fingerprintVisitorId;
50
- private merchantId;
51
50
  private sessionId;
52
51
  private projectId;
53
52
  private isSecure;
54
53
  private retryOptions;
55
- constructor(apiUrl: string, fingerprintVisitorId: string, merchantId: string, sessionId: string, isSecure?: boolean, retryOptions?: RetryOptions);
54
+ constructor(apiUrl: string, fingerprintVisitorId: string, sessionId: string, isSecure?: boolean, retryOptions?: RetryOptions);
56
55
  getSession(): Promise<SessionResponse>;
57
56
  submitForm(data: SubmitData): Promise<ProcessOperationRedirectResponse>;
58
57
  private processOperation;
@@ -25,11 +25,10 @@ const sanitizeBody = (body) => body.slice(0, MAX_BODY_SNIPPET_LENGTH).replace(/\
25
25
  // failures and for duplicate-submit rejections — retrying either only delays the error
26
26
  const defaultRetryStatusCode = (statusCode) => statusCode < 200 || statusCode === 408 || statusCode >= 500;
27
27
  export class FinteqHubProcessing {
28
- constructor(apiUrl, fingerprintVisitorId, merchantId, sessionId, isSecure = false, retryOptions = {}) {
29
- validateArguments({ apiUrl, fingerprintVisitorId, merchantId, sessionId, isSecure, retryOptions });
28
+ constructor(apiUrl, fingerprintVisitorId, sessionId, isSecure = false, retryOptions = {}) {
29
+ validateArguments({ apiUrl, fingerprintVisitorId, sessionId, isSecure, retryOptions });
30
30
  this.apiUrl = apiUrl;
31
31
  this.fingerprintVisitorId = fingerprintVisitorId;
32
- this.merchantId = merchantId;
33
32
  this.sessionId = sessionId;
34
33
  this.isSecure = isSecure;
35
34
  this.retryOptions = retryOptions;
@@ -13,7 +13,6 @@ export declare function getDeviceType(): string;
13
13
  declare type ConstructorArguments = {
14
14
  apiUrl: string;
15
15
  fingerprintVisitorId: string;
16
- merchantId: string;
17
16
  sessionId: string;
18
17
  isSecure: boolean;
19
18
  retryOptions: RetryOptions;
@@ -1,3 +1,3 @@
1
1
  export declare const SDK_HEADER_NAME = "x-pgw-sdk";
2
- export declare const SDK_VERSION = "0.16.0-beta.1";
2
+ export declare const SDK_VERSION = "0.16.0";
3
3
  export declare const SDK_HEADER_VALUE: string;
@@ -1,3 +1,3 @@
1
1
  export const SDK_HEADER_NAME = "x-pgw-sdk";
2
- export const SDK_VERSION = "0.16.0-beta.1";
2
+ export const SDK_VERSION = "0.16.0";
3
3
  export const SDK_HEADER_VALUE = `sdk-js/${SDK_VERSION}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@finteqhub/sdk-js",
3
- "version": "0.16.0-beta.1",
3
+ "version": "0.16.0",
4
4
  "description": "SDK for interacting with FinteqHub processing API",
5
5
  "main": "./dist/index.js",
6
6
  "typings": "./dist/index.d.ts",