@finteqhub/sdk-js 0.9.0 → 0.10.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.
@@ -5,7 +5,8 @@ export declare class FinteqHubProcessing {
5
5
  private merchantId;
6
6
  private sessionId;
7
7
  private projectId;
8
- constructor(apiUrl: string, fingerprintVisitorId: string, merchantId: string, sessionId: string);
8
+ private isSecure;
9
+ constructor(apiUrl: string, fingerprintVisitorId: string, merchantId: string, sessionId: string, isSecure?: boolean);
9
10
  getSession(): Promise<SessionResponse>;
10
11
  submitForm(data: SubmitData): Promise<ProcessOperationRedirectResponse>;
11
12
  private processOperation;
@@ -9,17 +9,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import { getDeviceData, uuid } from "./utils";
11
11
  export class FinteqHubProcessing {
12
- constructor(apiUrl, fingerprintVisitorId, merchantId, sessionId) {
12
+ constructor(apiUrl, fingerprintVisitorId, merchantId, sessionId, isSecure = false) {
13
13
  this.apiUrl = apiUrl;
14
14
  this.fingerprintVisitorId = fingerprintVisitorId;
15
15
  this.merchantId = merchantId;
16
16
  this.sessionId = sessionId;
17
+ this.isSecure = isSecure;
17
18
  }
18
19
  getSession() {
19
20
  return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
20
21
  var _a;
21
22
  try {
22
- const response = yield fetch(`${this.apiUrl}/v1/sessions/${this.sessionId}`, {
23
+ const url = this.isSecure ? `${this.apiUrl}/v1/secure/sessions/${this.sessionId}` : `${this.apiUrl}/v1/sessions/${this.sessionId}`;
24
+ const response = yield fetch(url, {
23
25
  method: "GET",
24
26
  headers: {
25
27
  "Content-Type": "application/json;charset=UTF-8",
@@ -44,13 +46,15 @@ export class FinteqHubProcessing {
44
46
  submitForm(data) {
45
47
  return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
46
48
  try {
47
- const response = yield this.sendPost(`${this.apiUrl}/v1/transactions/submit-form`, Object.assign({ session: Object.assign({ fingerprint: this.fingerprintVisitorId }, getDeviceData()) }, data));
49
+ const url = this.isSecure ? `${this.apiUrl}/v1/secure/transactions/submit-form` : `${this.apiUrl}/v1/transactions/submit-form`;
50
+ const response = yield this.sendPost(url, Object.assign({ session: Object.assign({ fingerprint: this.fingerprintVisitorId }, getDeviceData()) }, data));
48
51
  const result = yield response.json();
49
52
  if (result.error || response.status !== 200) {
50
53
  reject(new Error(result.error));
51
54
  }
52
55
  else {
53
- this.processOperation(`${this.apiUrl}/v1/operations/${result.operationId}`, resolve, reject);
56
+ const url = this.isSecure ? `${this.apiUrl}/v1/secure/operations/${result.operationId}` : `${this.apiUrl}/v1/operations/${result.operationId}`;
57
+ this.processOperation(url, resolve, reject);
54
58
  }
55
59
  }
56
60
  catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@finteqhub/sdk-js",
3
- "version": "0.9.0",
3
+ "version": "0.10.1",
4
4
  "description": "SDK for interacting with FinteqHub processing API",
5
5
  "main": "./dist/index.js",
6
6
  "typings": "./dist/index.d.ts",