tonder-web-sdk 1.16.3 → 1.16.6-beta.DEV-1433.2
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/README.md +22 -25
- package/package.json +10 -3
- package/types/common.d.ts +4 -0
- package/v1/bundle.min.js +1 -18
- package/.env-example +0 -1
- package/.husky/pre-commit +0 -4
- package/.prettierignore +0 -8
- package/.prettierrc +0 -10
- package/cypress/e2e/1-getting-started/todo.cy.js +0 -143
- package/cypress/e2e/2-advanced-examples/actions.cy.js +0 -299
- package/cypress/e2e/2-advanced-examples/aliasing.cy.js +0 -39
- package/cypress/e2e/2-advanced-examples/assertions.cy.js +0 -176
- package/cypress/e2e/2-advanced-examples/connectors.cy.js +0 -98
- package/cypress/e2e/2-advanced-examples/cookies.cy.js +0 -118
- package/cypress/e2e/2-advanced-examples/cypress_api.cy.js +0 -185
- package/cypress/e2e/2-advanced-examples/files.cy.js +0 -85
- package/cypress/e2e/2-advanced-examples/location.cy.js +0 -32
- package/cypress/e2e/2-advanced-examples/misc.cy.js +0 -104
- package/cypress/e2e/2-advanced-examples/navigation.cy.js +0 -56
- package/cypress/e2e/2-advanced-examples/network_requests.cy.js +0 -163
- package/cypress/e2e/2-advanced-examples/querying.cy.js +0 -114
- package/cypress/e2e/2-advanced-examples/spies_stubs_clocks.cy.js +0 -201
- package/cypress/e2e/2-advanced-examples/storage.cy.js +0 -110
- package/cypress/e2e/2-advanced-examples/traversal.cy.js +0 -121
- package/cypress/e2e/2-advanced-examples/utilities.cy.js +0 -108
- package/cypress/e2e/2-advanced-examples/viewport.cy.js +0 -58
- package/cypress/e2e/2-advanced-examples/waiting.cy.js +0 -30
- package/cypress/e2e/2-advanced-examples/window.cy.js +0 -22
- package/cypress/fixtures/example.json +0 -5
- package/cypress/support/commands.js +0 -25
- package/cypress/support/e2e.js +0 -20
- package/cypress.config.js +0 -9
- package/eslint.config.mjs +0 -15
- package/index.js.example +0 -50
- package/samples/react/README.md +0 -70
- package/samples/react/build/asset-manifest.json +0 -16
- package/samples/react/build/favicon.ico +0 -0
- package/samples/react/build/index.html +0 -1
- package/samples/react/build/logo192.png +0 -0
- package/samples/react/build/logo512.png +0 -0
- package/samples/react/build/manifest.json +0 -25
- package/samples/react/build/robots.txt +0 -3
- package/samples/react/build/static/css/main.073c9b0a.css +0 -2
- package/samples/react/build/static/css/main.073c9b0a.css.map +0 -1
- package/samples/react/build/static/js/787.b83ed06f.chunk.js +0 -2
- package/samples/react/build/static/js/787.b83ed06f.chunk.js.map +0 -1
- package/samples/react/build/static/js/main.0a848807.js +0 -3
- package/samples/react/build/static/js/main.0a848807.js.LICENSE.txt +0 -39
- package/samples/react/build/static/js/main.0a848807.js.map +0 -1
- package/samples/react/build/static/media/sdk-icons.b491623214b2af4cccdb.png +0 -0
- package/samples/react/package-lock.json +0 -28973
- package/samples/react/package.json +0 -44
- package/samples/react/public/favicon.ico +0 -0
- package/samples/react/public/index.html +0 -43
- package/samples/react/public/logo192.png +0 -0
- package/samples/react/public/logo512.png +0 -0
- package/samples/react/public/manifest.json +0 -25
- package/samples/react/public/robots.txt +0 -3
- package/samples/react/src/App.css +0 -38
- package/samples/react/src/App.js +0 -22
- package/samples/react/src/App.test.js +0 -8
- package/samples/react/src/assets/img/sdk-icons.png +0 -0
- package/samples/react/src/components/Cart.js +0 -29
- package/samples/react/src/components/ProductCard.js +0 -27
- package/samples/react/src/context/CartContext.js +0 -116
- package/samples/react/src/index.css +0 -13
- package/samples/react/src/index.js +0 -17
- package/samples/react/src/logo.svg +0 -1
- package/samples/react/src/reportWebVitals.js +0 -13
- package/samples/react/src/screens/Checkout.js +0 -82
- package/samples/react/src/screens/Store.js +0 -21
- package/samples/react/src/setupTests.js +0 -5
- package/samples/react/src/storeProducts.js +0 -30
- package/src/classes/3dsHandler.js +0 -199
- package/src/classes/BaseInlineCheckout.js +0 -303
- package/src/classes/LiteInlineCheckout.js +0 -217
- package/src/classes/checkout.js +0 -129
- package/src/classes/globalLoader.js +0 -31
- package/src/classes/inlineCheckout.js +0 -713
- package/src/data/apmApi.js +0 -38
- package/src/data/businessApi.js +0 -16
- package/src/data/cardApi.js +0 -134
- package/src/data/checkoutApi.js +0 -92
- package/src/data/customerApi.js +0 -32
- package/src/data/index.js +0 -17
- package/src/data/openPayApi.js +0 -16
- package/src/data/skyflowApi.js +0 -16
- package/src/helpers/skyflow.js +0 -370
- package/src/helpers/styles.js +0 -90
- package/src/helpers/template-skeleton.js +0 -59
- package/src/helpers/template.js +0 -1104
- package/src/helpers/utils.js +0 -257
- package/src/helpers/validations.js +0 -53
- package/src/index-dev.js +0 -329
- package/src/index.html +0 -180
- package/src/index.js +0 -21
- package/src/shared/catalog/commonLogosCatalog.js +0 -7
- package/src/shared/catalog/paymentMethodsCatalog.js +0 -246
- package/src/shared/constants/colors.js +0 -15
- package/src/shared/constants/displayMode.js +0 -4
- package/src/shared/constants/fieldPathNames.js +0 -4
- package/src/shared/constants/htmlTonderIds.js +0 -18
- package/src/shared/constants/messages.js +0 -11
- package/src/shared/constants/paymentMethodAPM.js +0 -63
- package/src/shared/constants/tonderUrl.js +0 -8
- package/webpack.config.js +0 -77
package/src/data/apmApi.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { buildErrorResponse, buildErrorResponseFromCatch } from "../helpers/utils";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Fetches Alternative Payment Methods (APMs) of a customer.
|
|
5
|
-
* @param {string} baseUrl - The base URL of the API.
|
|
6
|
-
* @param {string} apiKey - The API key for authentication.
|
|
7
|
-
* @param params - The query params to filter APMs
|
|
8
|
-
* @param {AbortSignal} signal - The abort signal to cancel the request.
|
|
9
|
-
* @returns {Promise<import("../../types").IPaymentMethodResponse>} The available APMs.
|
|
10
|
-
*/
|
|
11
|
-
export async function fetchCustomerAPMs(
|
|
12
|
-
baseUrl,
|
|
13
|
-
apiKey,
|
|
14
|
-
params = {
|
|
15
|
-
status: "active",
|
|
16
|
-
pagesize: "10000",
|
|
17
|
-
},
|
|
18
|
-
signal = null,
|
|
19
|
-
) {
|
|
20
|
-
try {
|
|
21
|
-
const queryString = new URLSearchParams(params).toString();
|
|
22
|
-
|
|
23
|
-
const response = await fetch(`${baseUrl}/api/v1/payment_methods?${queryString}`, {
|
|
24
|
-
method: "GET",
|
|
25
|
-
headers: {
|
|
26
|
-
Authorization: `Token ${apiKey}`,
|
|
27
|
-
"Content-Type": "application/json",
|
|
28
|
-
},
|
|
29
|
-
signal,
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
if (response.ok) return await response.json();
|
|
33
|
-
const res_json = await response.json();
|
|
34
|
-
throw await buildErrorResponse(response, res_json);
|
|
35
|
-
} catch (error) {
|
|
36
|
-
throw buildErrorResponseFromCatch(error);
|
|
37
|
-
}
|
|
38
|
-
}
|
package/src/data/businessApi.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Fetches business information.
|
|
3
|
-
* @param {string} baseUrl - The base URL of the Tonder API.
|
|
4
|
-
* @param {string} apiKey - The API key for authentication.
|
|
5
|
-
* @param {AbortSignal} signal - The abort signal to cancel the request.
|
|
6
|
-
* @returns {Promise<Object>} The business information.
|
|
7
|
-
*/
|
|
8
|
-
export async function fetchBusiness(baseUrl, apiKey, signal) {
|
|
9
|
-
const getBusiness = await fetch(`${baseUrl}/api/v1/payments/business/${apiKey}`, {
|
|
10
|
-
headers: {
|
|
11
|
-
Authorization: `Token ${apiKey}`,
|
|
12
|
-
},
|
|
13
|
-
signal: signal,
|
|
14
|
-
});
|
|
15
|
-
return await getBusiness.json();
|
|
16
|
-
}
|
package/src/data/cardApi.js
DELETED
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import { buildErrorResponse, buildErrorResponseFromCatch } from "../helpers/utils";
|
|
2
|
-
import { MESSAGES } from "../shared/constants/messages";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Saves or updates a customer's card information.
|
|
6
|
-
*
|
|
7
|
-
* This function sends a POST request to save or update the card information for a customer.
|
|
8
|
-
*
|
|
9
|
-
* @param {string} baseUrl - The base URL of the API.
|
|
10
|
-
* @param {string} customerToken - The customer's authentication token.
|
|
11
|
-
* @param {string} secureToken - Token generated by secure-token endpoint.
|
|
12
|
-
* @param {string | number} businessId - The business ID.
|
|
13
|
-
* @param {import("../../types").ISaveCardSkyflowRequest} data - The card information to be saved.
|
|
14
|
-
* @returns {Promise<import("../../types").ISaveCardResponse>} The saved card data.
|
|
15
|
-
*
|
|
16
|
-
* @throws {import("../../types").IApiError} Throws an error object if the save/update operation fails.
|
|
17
|
-
*/
|
|
18
|
-
export async function saveCustomerCard(baseUrl, customerToken, secureToken, businessId, data) {
|
|
19
|
-
try {
|
|
20
|
-
const url = `${baseUrl}/api/v1/business/${businessId}/cards/`;
|
|
21
|
-
const response = await fetch(url, {
|
|
22
|
-
method: "POST",
|
|
23
|
-
headers: {
|
|
24
|
-
Authorization: `Bearer ${secureToken}`,
|
|
25
|
-
"User-Token": customerToken,
|
|
26
|
-
"Content-Type": "application/json",
|
|
27
|
-
},
|
|
28
|
-
body: JSON.stringify(data),
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
if (response.ok) return await response.json();
|
|
32
|
-
|
|
33
|
-
const res_json = await response.json();
|
|
34
|
-
if (response.status === 409) {
|
|
35
|
-
if ((res_json.error = "Card number already exists.")) {
|
|
36
|
-
return {
|
|
37
|
-
code: 200,
|
|
38
|
-
body: res_json,
|
|
39
|
-
name: "",
|
|
40
|
-
message: res_json.error,
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
throw await buildErrorResponse(response, res_json);
|
|
45
|
-
} catch (error) {
|
|
46
|
-
throw buildErrorResponseFromCatch(error);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Removes a customer's card.
|
|
52
|
-
* @param {string} baseUrl - The base URL of the API.
|
|
53
|
-
* @param {string} customerToken - The customer's authentication token.
|
|
54
|
-
* @param {string} secureToken - Token generated by secure-token endpoint.
|
|
55
|
-
* @param {string} skyflowId - The Skyflow ID of the card to be removed.
|
|
56
|
-
* @param {string} businessId - The business ID.
|
|
57
|
-
* @returns {Promise<string>} The result of the card removal operation.
|
|
58
|
-
*
|
|
59
|
-
* @throws {import("../../types").IApiError} Throws an error object if the operation fails.
|
|
60
|
-
*/
|
|
61
|
-
export async function removeCustomerCard(
|
|
62
|
-
baseUrl,
|
|
63
|
-
customerToken,
|
|
64
|
-
secureToken,
|
|
65
|
-
skyflowId = "",
|
|
66
|
-
businessId,
|
|
67
|
-
) {
|
|
68
|
-
try {
|
|
69
|
-
const url = `${baseUrl}/api/v1/business/${businessId}/cards/${skyflowId}`;
|
|
70
|
-
|
|
71
|
-
const response = await fetch(url, {
|
|
72
|
-
method: "DELETE",
|
|
73
|
-
headers: {
|
|
74
|
-
Authorization: `Bearer ${secureToken}`,
|
|
75
|
-
"Content-Type": "application/json",
|
|
76
|
-
"User-Token": customerToken,
|
|
77
|
-
},
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
if (response.status === 204) return MESSAGES.cardSaved;
|
|
81
|
-
if (response.ok && "json" in response) return await response.json();
|
|
82
|
-
const res_json = await response.json();
|
|
83
|
-
|
|
84
|
-
throw await buildErrorResponse(response, res_json);
|
|
85
|
-
} catch (error) {
|
|
86
|
-
throw buildErrorResponseFromCatch(error);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Fetches a customer's saved cards.
|
|
92
|
-
* @param {string} baseUrl - The base URL of the API.
|
|
93
|
-
* @param {string} customerToken - The customer's authentication token.
|
|
94
|
-
* @param {string} secureToken - Token generated by secure-token endpoint.
|
|
95
|
-
* @param {string} businessId - The business ID.
|
|
96
|
-
* @param {AbortSignal} signal - The abort signal to cancel the request.
|
|
97
|
-
* @returns {Promise<import("../../types").ICustomerCardsResponse>} The customer's saved cards.
|
|
98
|
-
*
|
|
99
|
-
* @throws {import("../../types").IApiError} Throws an error object if the operation fails.
|
|
100
|
-
*/
|
|
101
|
-
export async function fetchCustomerCards(
|
|
102
|
-
baseUrl,
|
|
103
|
-
customerToken,
|
|
104
|
-
secureToken,
|
|
105
|
-
businessId,
|
|
106
|
-
signal = null,
|
|
107
|
-
) {
|
|
108
|
-
try {
|
|
109
|
-
const url = `${baseUrl}/api/v1/business/${businessId}/cards/`;
|
|
110
|
-
const response = await fetch(url, {
|
|
111
|
-
method: "GET",
|
|
112
|
-
headers: {
|
|
113
|
-
Authorization: `Bearer ${secureToken}`,
|
|
114
|
-
"User-Token": customerToken,
|
|
115
|
-
},
|
|
116
|
-
signal,
|
|
117
|
-
});
|
|
118
|
-
if (response.ok) return await response.json();
|
|
119
|
-
if (response.status === 401) {
|
|
120
|
-
return {
|
|
121
|
-
code: 401,
|
|
122
|
-
body: {},
|
|
123
|
-
name: "",
|
|
124
|
-
message: "Unauthorized",
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
const res_json = await response.json();
|
|
129
|
-
|
|
130
|
-
throw await buildErrorResponse(response, res_json, MESSAGES.getCardsError);
|
|
131
|
-
} catch (error) {
|
|
132
|
-
throw buildErrorResponseFromCatch(error, MESSAGES.getCardsError);
|
|
133
|
-
}
|
|
134
|
-
}
|
package/src/data/checkoutApi.js
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Creates a new order in the system.
|
|
3
|
-
* @param {string} baseUrl - The base URL of the API.
|
|
4
|
-
* @param {string} apiKey - The API key for authentication.
|
|
5
|
-
* @param {Object} orderItems - The items to be included in the order.
|
|
6
|
-
* @returns {Promise<Object>} The created order data.
|
|
7
|
-
*/
|
|
8
|
-
export async function createOrder(baseUrl, apiKey, orderItems) {
|
|
9
|
-
const url = `${baseUrl}/api/v1/orders/`;
|
|
10
|
-
const data = orderItems;
|
|
11
|
-
const response = await fetch(url, {
|
|
12
|
-
method: "POST",
|
|
13
|
-
headers: {
|
|
14
|
-
"Content-Type": "application/json",
|
|
15
|
-
Authorization: `Token ${apiKey}`,
|
|
16
|
-
},
|
|
17
|
-
body: JSON.stringify(data),
|
|
18
|
-
});
|
|
19
|
-
if (response.status === 201) {
|
|
20
|
-
const jsonResponse = await response.json();
|
|
21
|
-
return jsonResponse;
|
|
22
|
-
} else {
|
|
23
|
-
throw new Error(`Error: ${response.statusText}`);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Creates a new payment in the system.
|
|
29
|
-
* @param {string} baseUrl - The base URL of the API.
|
|
30
|
-
* @param {string} apiKey - The API key for authentication.
|
|
31
|
-
* @param {Object} paymentItems - The payment details.
|
|
32
|
-
* @returns {Promise<Object>} The created payment data.
|
|
33
|
-
*/
|
|
34
|
-
export async function createPayment(baseUrl, apiKey, paymentItems) {
|
|
35
|
-
const url = `${baseUrl}/api/v1/business/${paymentItems.business_pk}/payments/`;
|
|
36
|
-
const data = paymentItems;
|
|
37
|
-
const response = await fetch(url, {
|
|
38
|
-
method: "POST",
|
|
39
|
-
headers: {
|
|
40
|
-
"Content-Type": "application/json",
|
|
41
|
-
Authorization: `Token ${apiKey}`,
|
|
42
|
-
},
|
|
43
|
-
body: JSON.stringify(data),
|
|
44
|
-
});
|
|
45
|
-
if (response.status >= 200 && response.status <= 299) {
|
|
46
|
-
const jsonResponse = await response.json();
|
|
47
|
-
return jsonResponse;
|
|
48
|
-
} else {
|
|
49
|
-
throw new Error(`Error: ${response.statusText}`);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Initiates the checkout process.
|
|
55
|
-
*
|
|
56
|
-
* This function sends a POST request to the checkout router API with the provided
|
|
57
|
-
* checkout details. If the request is successful, it returns the response data.
|
|
58
|
-
* If the request fails, it throws an error that includes the status and details of the failure.
|
|
59
|
-
*
|
|
60
|
-
* @param {string} baseUrl - The base URL of the API.
|
|
61
|
-
* @param {string} apiKey - The API key for authentication.
|
|
62
|
-
* @param {import("../../types").IStartCheckoutRequest | import("../../types").IStartCheckoutIdRequest} routerItems - The checkout details to be sent in the request body.
|
|
63
|
-
* @returns {Promise<import("../../types").IStartCheckoutResponse>} The checkout process result.
|
|
64
|
-
*
|
|
65
|
-
* @throws {Error} Throws an error if the checkout process fails. The error object contains
|
|
66
|
-
* additional `details` property with the response from the server if available.
|
|
67
|
-
* @property {import("../../types").IStartCheckoutErrorResponse} error.details - The response body from the server when an error occurs.
|
|
68
|
-
*/
|
|
69
|
-
export async function startCheckoutRouter(baseUrl, apiKey, routerItems) {
|
|
70
|
-
try {
|
|
71
|
-
const url = `${baseUrl}/api/v1/checkout-router/`;
|
|
72
|
-
const data = routerItems;
|
|
73
|
-
const response = await fetch(url, {
|
|
74
|
-
method: "POST",
|
|
75
|
-
headers: {
|
|
76
|
-
"Content-Type": "application/json",
|
|
77
|
-
Authorization: `Token ${apiKey}`,
|
|
78
|
-
},
|
|
79
|
-
body: JSON.stringify(data),
|
|
80
|
-
});
|
|
81
|
-
if (response.status >= 200 && response.status <= 299) {
|
|
82
|
-
return await response.json();
|
|
83
|
-
} else {
|
|
84
|
-
const errorResponse = await response.json();
|
|
85
|
-
const error = new Error("Failed to start checkout router");
|
|
86
|
-
error.details = errorResponse;
|
|
87
|
-
throw error;
|
|
88
|
-
}
|
|
89
|
-
} catch (error) {
|
|
90
|
-
throw error;
|
|
91
|
-
}
|
|
92
|
-
}
|
package/src/data/customerApi.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Registers a new customer or fetches an existing customer.
|
|
3
|
-
* @param {string} baseUrl - The base URL of the API.
|
|
4
|
-
* @param {string} apiKey - The API key for authentication.
|
|
5
|
-
* @param {Object} customer - The customer data.
|
|
6
|
-
* @param {AbortSignal} signal - The abort signal to cancel the request.
|
|
7
|
-
* @returns {Promise<Object>} The registered or fetched customer data.
|
|
8
|
-
*/
|
|
9
|
-
export async function registerOrFetchCustomer(baseUrl, apiKey, customer, signal = null) {
|
|
10
|
-
const url = `${baseUrl}/api/v1/customer/`;
|
|
11
|
-
const data = {
|
|
12
|
-
email: customer.email,
|
|
13
|
-
first_name: customer?.firstName,
|
|
14
|
-
last_name: customer?.lastName,
|
|
15
|
-
phone: customer?.phone,
|
|
16
|
-
};
|
|
17
|
-
const response = await fetch(url, {
|
|
18
|
-
method: "POST",
|
|
19
|
-
headers: {
|
|
20
|
-
"Content-Type": "application/json",
|
|
21
|
-
Authorization: `Token ${apiKey}`,
|
|
22
|
-
},
|
|
23
|
-
signal: signal,
|
|
24
|
-
body: JSON.stringify(data),
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
if (response.status === 201) {
|
|
28
|
-
return await response.json();
|
|
29
|
-
} else {
|
|
30
|
-
throw new Error(`Error: ${response.statusText}`);
|
|
31
|
-
}
|
|
32
|
-
}
|
package/src/data/index.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { fetchBusiness } from "./businessApi";
|
|
2
|
-
import { registerOrFetchCustomer } from "./customerApi";
|
|
3
|
-
import { createOrder } from "./checkoutApi";
|
|
4
|
-
import { saveCustomerCard, removeCustomerCard, fetchCustomerCards } from "./cardApi";
|
|
5
|
-
import { fetchCustomerAPMs } from "./apmApi";
|
|
6
|
-
import { getOpenpayDeviceSessionID } from "./openPayApi";
|
|
7
|
-
|
|
8
|
-
export {
|
|
9
|
-
registerOrFetchCustomer,
|
|
10
|
-
createOrder,
|
|
11
|
-
saveCustomerCard,
|
|
12
|
-
removeCustomerCard,
|
|
13
|
-
fetchCustomerCards,
|
|
14
|
-
fetchBusiness,
|
|
15
|
-
fetchCustomerAPMs,
|
|
16
|
-
getOpenpayDeviceSessionID,
|
|
17
|
-
};
|
package/src/data/openPayApi.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generates an Openpay device session ID.
|
|
3
|
-
* @param {string} merchant_id - The Openpay merchant ID.
|
|
4
|
-
* @param {string} public_key - The Openpay public key.
|
|
5
|
-
* @param {AbortSignal} signal - The abort signal to cancel the request.
|
|
6
|
-
* @returns {Promise<string>} The generated device session ID.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
export async function getOpenpayDeviceSessionID(merchant_id, public_key, signal) {
|
|
10
|
-
let openpay = await window.OpenPay;
|
|
11
|
-
openpay.setId(merchant_id);
|
|
12
|
-
openpay.setApiKey(public_key);
|
|
13
|
-
openpay.setSandboxMode(true);
|
|
14
|
-
var response = await openpay.deviceData.setup({ signal });
|
|
15
|
-
return response;
|
|
16
|
-
}
|
package/src/data/skyflowApi.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export async function getVaultToken(baseUrl, apiKey, signal = null) {
|
|
2
|
-
const response = await fetch(`${baseUrl}/api/v1/vault-token/`, {
|
|
3
|
-
method: "GET",
|
|
4
|
-
headers: {
|
|
5
|
-
Authorization: `Token ${apiKey}`,
|
|
6
|
-
},
|
|
7
|
-
signal: signal,
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
if (response.ok) {
|
|
11
|
-
const responseBody = await response.json();
|
|
12
|
-
return responseBody.token;
|
|
13
|
-
} else {
|
|
14
|
-
throw new Error("Failed to retrieve bearer token");
|
|
15
|
-
}
|
|
16
|
-
}
|