@tonder.io/ionic-lite-sdk 1.0.1 → 1.0.2-beta.TEC-1207.53fb846
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 +38 -3
- package/dist/classes/3dsHandler.d.ts +26 -2
- package/dist/classes/BaseInlineCheckout.d.ts +12 -9
- package/dist/classes/liteCheckout.d.ts +1 -1
- package/dist/data/businessApi.d.ts +1 -1
- package/dist/data/coreApi.d.ts +15 -0
- package/dist/helpers/corePayment.d.ts +60 -0
- package/dist/helpers/safeUrl.d.ts +15 -0
- package/dist/helpers/sanitize3dsMarkup.d.ts +18 -0
- package/dist/helpers/utils.d.ts +1 -0
- package/dist/helpers/validations.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/shared/constants/apiEndpoints.d.ts +2 -0
- package/dist/shared/utils/appError.d.ts +9 -0
- package/dist/types/commons.d.ts +5 -0
- package/dist/types/core.d.ts +28 -0
- package/jest.config.ts +11 -1
- package/package.json +1 -1
- package/src/classes/3dsHandler.ts +134 -30
- package/src/classes/BaseInlineCheckout.ts +128 -16
- package/src/classes/liteCheckout.ts +9 -2
- package/src/data/businessApi.ts +13 -6
- package/src/data/coreApi.ts +47 -0
- package/src/helpers/corePayment.ts +211 -0
- package/src/helpers/safeUrl.ts +26 -0
- package/src/helpers/sanitize3dsMarkup.ts +133 -0
- package/src/helpers/utils.ts +4 -0
- package/src/helpers/validations.ts +9 -0
- package/src/shared/constants/apiEndpoints.ts +2 -0
- package/src/shared/constants/messages.ts +4 -4
- package/src/shared/utils/appError.ts +28 -11
- package/src/types/commons.ts +5 -0
- package/src/types/core.ts +30 -0
- package/tests/coreBusinessConfig.test.ts +100 -0
- package/tests/corePayment.test.ts +393 -0
- package/tests/corePaymentCheckout.test.ts +668 -0
- package/tests/coreStartupFailure.test.ts +70 -0
- package/tests/redirectToChallenge.test.ts +149 -0
- package/tests/sanitize3dsMarkup.test.ts +248 -0
- package/tests/secureTokenBoundary.test.ts +81 -0
- package/tests/threeDsApiKey.test.ts +41 -0
- package/tests/threeDsCore.test.ts +444 -0
- package/tests/threeDsPolling.test.ts +45 -0
package/README.md
CHANGED
|
@@ -21,6 +21,7 @@ Card data is collected through **Skyflow secure iframes** — raw card values ne
|
|
|
21
21
|
- [6.2 Pay with a saved card](#62-pay-with-a-saved-card)
|
|
22
22
|
- [6.3 Alternative Payment Method (APM)](#63-alternative-payment-method-apm)
|
|
23
23
|
- [6.4 Payment response reference](#64-payment-response-reference)
|
|
24
|
+
- [6.5 Payments API](#65-payments-api)
|
|
24
25
|
7. [3DS Handling](#7-3ds-handling)
|
|
25
26
|
8. [Managing Saved Cards](#8-managing-saved-cards)
|
|
26
27
|
- [8.1 List saved cards](#81-list-saved-cards)
|
|
@@ -105,11 +106,14 @@ export class CheckoutComponent implements OnInit {
|
|
|
105
106
|
// If this page load is a return from a 3DS challenge, the SDK verifies the
|
|
106
107
|
// transaction and, if routing is configured, may automatically retry with
|
|
107
108
|
// the next payment route. Await the result before deciding what to do next.
|
|
109
|
+
// It rejects when the payments API cannot be read: wrap it in try/catch (see verify3dsTransaction()).
|
|
108
110
|
const tdsResult = await this.liteCheckout.verify3dsTransaction();
|
|
109
111
|
if (tdsResult) {
|
|
110
112
|
const status = (tdsResult as any).transaction_status;
|
|
111
113
|
if (status === 'Success' ) {
|
|
112
114
|
// navigate to order confirmation
|
|
115
|
+
} else if (status === 'Pending' || status === 'Processing') {
|
|
116
|
+
// the payments API has not finished: verify again later
|
|
113
117
|
} else {
|
|
114
118
|
// show error to the user
|
|
115
119
|
}
|
|
@@ -160,7 +164,6 @@ npm install @tonder.io/ionic-lite-sdk
|
|
|
160
164
|
# or
|
|
161
165
|
yarn add @tonder.io/ionic-lite-sdk
|
|
162
166
|
```
|
|
163
|
-
|
|
164
167
|
---
|
|
165
168
|
|
|
166
169
|
## 3. Constructor & Configuration
|
|
@@ -299,6 +302,17 @@ The SDK must be initialized in this exact order before any other method is calle
|
|
|
299
302
|
| `'stage'` | `https://stage.tonder.io` |
|
|
300
303
|
| `'production'` | `https://app.tonder.io` |
|
|
301
304
|
|
|
305
|
+
**Start-up configuration.** `injectCheckout()` reads the business configuration (vault, processors' public keys, `core_payments_enabled`) from Tonder's payments API, for every merchant, with your `apiKey` in the `Authorization` header. The payments API base URL also depends on `mode`:
|
|
306
|
+
|
|
307
|
+
| `mode` | Payments API base URL |
|
|
308
|
+
|--------|-------------------|
|
|
309
|
+
| `'stage'`, `'sandbox'`, `'development'` | `https://api-stage.tonder.io` |
|
|
310
|
+
| `'production'` | `https://api.tonder.io` |
|
|
311
|
+
|
|
312
|
+
If the configuration cannot be read (a refusal, a server error, a network failure or an unreadable answer), `injectCheckout()` and `mountCardFields()` reject with `FETCH_BUSINESS_ERROR` and the SDK does not fall back to another source; the next call asks again.
|
|
313
|
+
|
|
314
|
+
The SDK needs to reach this host from the WebView. Contact Tonder to have your app's origin (for example `capacitor://localhost`) allowed for your business.
|
|
315
|
+
|
|
302
316
|
---
|
|
303
317
|
|
|
304
318
|
### Fetching the secure token
|
|
@@ -363,14 +377,23 @@ Only relevant when `redirectOnComplete: true` (the default). When using `redirec
|
|
|
363
377
|
|
|
364
378
|
When using the default mode, call this on **every page load**. If the page was loaded as a return from a 3DS redirect, it verifies the transaction and — if the merchant has routing configured and the transaction was declined — **automatically retries with the next payment route**. Resolves with the final transaction result, or `void` on a normal (non-3DS) page load.
|
|
365
379
|
|
|
380
|
+
For a payment charged by the payments API ([6.5](#65-payments-api)) it resolves with the same body `payment()` resolves with, whose `transaction_status` is the payments API's status: `Pending` or `Processing` while the payments API has not finished, so check for a final status before concluding. When the payments API cannot be read it **rejects** with `FETCH_TRANSACTION_ERROR` (the HTTP status is in `error.statusCode`). The 3DS state is kept after a 5xx, 429 or network failure, so the call can be repeated on the next load; a 401 or 404 clears it. Wrap the call in `try/catch` so an outage of the payments API does not stop your page from initializing.
|
|
381
|
+
|
|
366
382
|
```typescript
|
|
367
|
-
|
|
383
|
+
let result;
|
|
384
|
+
try {
|
|
385
|
+
result = await liteCheckout.verify3dsTransaction();
|
|
386
|
+
} catch (error) {
|
|
387
|
+
// The payments API could not be read (FETCH_TRANSACTION_ERROR): show a retry message
|
|
388
|
+
}
|
|
368
389
|
|
|
369
390
|
if (result) {
|
|
370
391
|
// Returning from 3DS — routing may have been applied automatically
|
|
371
392
|
const status = (result as any).transaction_status;
|
|
372
393
|
if (status === 'Success') {
|
|
373
394
|
// navigate to confirmation
|
|
395
|
+
} else if (status === 'Pending' || status === 'Processing') {
|
|
396
|
+
// not final yet: verify again later
|
|
374
397
|
} else {
|
|
375
398
|
// show error
|
|
376
399
|
}
|
|
@@ -734,6 +757,18 @@ interface IStartCheckoutResponse {
|
|
|
734
757
|
|
|
735
758
|
> **Note:** 3DS authentication is handled automatically by the SDK. You do not need to handle redirection yourself.
|
|
736
759
|
|
|
760
|
+
### 6.5 Payments API
|
|
761
|
+
|
|
762
|
+
When the business configuration the SDK reads at start-up says `core_payments_enabled: true` for your business, card payments (new card and saved card) are charged by Tonder's payments API instead of the legacy flow. Nothing changes in your integration: same key, same `payment()` arguments, same resolved object, same `callBack`, same rejection details, same statuses.
|
|
763
|
+
|
|
764
|
+
- The payment is sent to `POST /transactions/v1/process` with `Authorization: Token <apiKey>` and the header `X-App-Origin: sdk/ionic`, and one `X-Request-Id` per `payment()` call. Cart `items` and `metadata` travel in that request. No `orders` or `business/<id>/payments` request is made.
|
|
765
|
+
- The payments API's answer is turned back into the `checkout-router` body described in [6.4](#64-payment-response-reference), so `payment()` resolves, or rejects with `error.details`, exactly as before.
|
|
766
|
+
- Card On File payments go to the payments API like any saved card: the payments API decides the subscription charge itself. A `payment_method` of `CARD` (any case) is a card payment on the payments API path; alternative payment methods keep using the legacy flow whatever the flag says. A failed verification of a payment charged by the payments API rejects with `FETCH_TRANSACTION_ERROR`, and for such a payment `verify3dsTransaction()` never follows its challenge again.
|
|
767
|
+
- The request also carries the customer's `phone` and `identification` and the browser information (`browser_info`) the legacy flow sent.
|
|
768
|
+
- The engine is chosen once per payment and kept with the 3DS state in `localStorage`: a payment started on the payments API is verified against the payments API after the challenge, even if the flag changes meanwhile. The payments API continues its own route after the 3DS challenge, so for such a payment `verify3dsTransaction()` does no routing work: it reads `GET /transactions/v1/{id}` once and returns the same body `payment()` resolves with, keeping the 3DS state while the payment is still `Pending` or `Processing`, and after a server error, a throttle or a network failure, so the verification can be tried again; only a refusal such as 401 or 404 clears it. Whether a payment charged by the payments API is open or final is the payments API's `status`, not the payment processor's.
|
|
769
|
+
- If the payments API refuses to create the payment because operations are disabled (HTTP 503, `operations_disabled`), the SDK retries that payment once on the legacy flow.
|
|
770
|
+
- **Declared difference:** the `refund_transaction` entry of `actions` points at the payments API refund (`POST <payments API base URL>/transactions/v1/process`, authorized with the same API key) instead of the legacy refund route, and `verify_transaction_status` points at the payments API's `GET <payments API base URL>/transactions/v1/{id}` instead of the legacy per-provider verify route (the verify of such a payment no longer answers the legacy per-provider verify body). The action also carries a `body` hint, `{ operation_type: 'refund', original_transaction_id }`; send it with your `amount` and optional `reason`.
|
|
771
|
+
|
|
737
772
|
---
|
|
738
773
|
|
|
739
774
|
## 7. 3DS Handling
|
|
@@ -1264,7 +1299,7 @@ customization: {
|
|
|
1264
1299
|
| Property | Replacement | Notes |
|
|
1265
1300
|
|----------|-------------|-------|
|
|
1266
1301
|
| `apiKeyTonder` | `apiKey` | Renamed for clarity |
|
|
1267
|
-
| `baseUrlTonder` | `mode` | Replaced by environment enum (`'stage'` \| `'production'` \| ...) |
|
|
1302
|
+
| `baseUrlTonder` | `mode` | Replaced by environment enum (`'stage'` \| `'production'` \| ...). It still overrides the legacy API host, but the payments API host (start-up configuration and payments API) is always derived from `mode` and ignores it |
|
|
1268
1303
|
| `signal` | (removed) | AbortController signal is no longer needed |
|
|
1269
1304
|
|
|
1270
1305
|
### Deprecated methods
|
|
@@ -1,7 +1,16 @@
|
|
|
1
|
+
import { ICoreTransactionResponse, PaymentEngine } from "../types/core";
|
|
2
|
+
type CoreResultBuilder = (transaction: ICoreTransactionResponse) => Record<string, any>;
|
|
3
|
+
type StoredVerification = {
|
|
4
|
+
url: string;
|
|
5
|
+
expires: number;
|
|
6
|
+
engine?: PaymentEngine;
|
|
7
|
+
};
|
|
1
8
|
type ThreeDSHandlerContructor = {
|
|
2
9
|
payload?: any;
|
|
3
10
|
apiKey?: string;
|
|
4
11
|
baseUrl?: string;
|
|
12
|
+
coreBaseUrl?: string;
|
|
13
|
+
buildCoreResult?: CoreResultBuilder;
|
|
5
14
|
redirectOnComplete?: boolean;
|
|
6
15
|
tdsIframeId?: string;
|
|
7
16
|
tonderPayButtonId?: string;
|
|
@@ -10,30 +19,45 @@ type ThreeDSHandlerContructor = {
|
|
|
10
19
|
export declare class ThreeDSHandler {
|
|
11
20
|
callBack?: (params: any) => any;
|
|
12
21
|
baseUrl?: string;
|
|
22
|
+
coreBaseUrl?: string;
|
|
23
|
+
buildCoreResult: CoreResultBuilder;
|
|
24
|
+
engine: PaymentEngine;
|
|
13
25
|
apiKey?: string;
|
|
14
26
|
payload?: any;
|
|
15
27
|
localStorageKey: string;
|
|
16
28
|
redirectOnComplete?: boolean;
|
|
17
29
|
tdsIframeId?: string;
|
|
18
30
|
tonderPayButtonId?: string;
|
|
19
|
-
constructor({ payload, apiKey, baseUrl, redirectOnComplete, tdsIframeId, tonderPayButtonId, callBack }: ThreeDSHandlerContructor);
|
|
31
|
+
constructor({ payload, apiKey, baseUrl, coreBaseUrl, buildCoreResult, redirectOnComplete, tdsIframeId, tonderPayButtonId, callBack }: ThreeDSHandlerContructor);
|
|
20
32
|
setStorageItem(data: any): void;
|
|
21
33
|
getStorageItem(): string | null;
|
|
22
34
|
removeStorageItem(): void;
|
|
23
35
|
saveVerifyTransactionUrl(): void;
|
|
36
|
+
setEngine(engine: PaymentEngine): void;
|
|
24
37
|
saveUrlWithExpiration(url: string): void;
|
|
25
|
-
|
|
38
|
+
getStoredVerification(): StoredVerification | null | undefined;
|
|
39
|
+
getUrlWithExpiration(): string | null | undefined;
|
|
40
|
+
getStoredEngine(): PaymentEngine;
|
|
26
41
|
removeVerifyTransactionUrl(): void;
|
|
27
42
|
getVerifyTransactionUrl(): string | null;
|
|
28
43
|
loadIframe(): Promise<unknown> | undefined;
|
|
29
44
|
getRedirectUrl(): any;
|
|
30
45
|
redirectToChallenge(): void;
|
|
46
|
+
fetchVerification(item: StoredVerification): Promise<Response>;
|
|
31
47
|
requestTransactionStatus(): Promise<any>;
|
|
48
|
+
keepPolling(): {
|
|
49
|
+
status: string;
|
|
50
|
+
transaction_status: string;
|
|
51
|
+
};
|
|
32
52
|
getURLParameters(): any;
|
|
33
53
|
handleSuccessTransaction(response: any): any;
|
|
34
54
|
handleDeclinedTransaction(response: any): any;
|
|
35
55
|
handle3dsChallenge(response_json: any): Promise<void>;
|
|
36
56
|
handleTransactionResponse(response: any): Promise<any>;
|
|
57
|
+
isCoreOpen(transaction: ICoreTransactionResponse): boolean;
|
|
58
|
+
handleCoreTransaction(response: Response): Promise<Record<string, any>>;
|
|
59
|
+
isVerificationFinal(result: any): boolean;
|
|
60
|
+
isTransientCoreFailure(item: StoredVerification, status?: number): boolean;
|
|
37
61
|
verifyTransactionStatus(): Promise<any>;
|
|
38
62
|
setPayload: (payload: any) => void;
|
|
39
63
|
}
|
|
@@ -8,9 +8,18 @@ import { ITransaction } from "../types/transaction";
|
|
|
8
8
|
import { GetSecureTokenResponse } from "../types/responses";
|
|
9
9
|
import { CardOnFile } from "../helpers/card_on_file";
|
|
10
10
|
import { SdkTelemetryClient } from "../helpers/SdkTelemetryClient";
|
|
11
|
+
type CheckoutRequest = {
|
|
12
|
+
card?: Record<string, any>;
|
|
13
|
+
payment_method?: string;
|
|
14
|
+
customer: Record<string, any>;
|
|
15
|
+
isSandbox?: boolean;
|
|
16
|
+
returnUrl?: string;
|
|
17
|
+
enable_card_on_file?: boolean;
|
|
18
|
+
};
|
|
11
19
|
export declare class BaseInlineCheckout<T extends CustomizationOptions = CustomizationOptions> {
|
|
12
20
|
#private;
|
|
13
21
|
baseUrl: string;
|
|
22
|
+
coreBaseUrl: string;
|
|
14
23
|
cartTotal: string | number;
|
|
15
24
|
process3ds: ThreeDSHandler;
|
|
16
25
|
mode?: "production" | "sandbox" | "stage" | "development" | undefined;
|
|
@@ -53,15 +62,8 @@ export declare class BaseInlineCheckout<T extends CustomizationOptions = Customi
|
|
|
53
62
|
_checkout(data: any): Promise<any>;
|
|
54
63
|
_setCartTotal(total: string | number): void;
|
|
55
64
|
_getCustomer(signal?: AbortSignal | null): Promise<Record<string, any>>;
|
|
56
|
-
_handleCheckout(
|
|
57
|
-
|
|
58
|
-
payment_method?: string;
|
|
59
|
-
customer: Record<string, any>;
|
|
60
|
-
isSandbox?: boolean;
|
|
61
|
-
returnUrl?: string;
|
|
62
|
-
enable_card_on_file?: boolean;
|
|
63
|
-
}): Promise<any>;
|
|
64
|
-
_fetchMerchantData(): Promise<Business | undefined>;
|
|
65
|
+
_handleCheckout(request: CheckoutRequest): Promise<any>;
|
|
66
|
+
_fetchMerchantData(): Promise<Business>;
|
|
65
67
|
_getCustomerCards(authToken: string, businessId: string | number): Promise<ICustomerCardsResponse>;
|
|
66
68
|
_saveCustomerCard(authToken: string, businessId: string | number, skyflowTokens: ISaveCardSkyflowRequest, appOrigin?: boolean): Promise<ISaveCardInternalResponse>;
|
|
67
69
|
_removeCustomerCard(authToken: string, businessId: string | number, skyflowId: string): Promise<string>;
|
|
@@ -70,3 +72,4 @@ export declare class BaseInlineCheckout<T extends CustomizationOptions = Customi
|
|
|
70
72
|
protected _initializeCardOnFile(): Promise<CardOnFile>;
|
|
71
73
|
_handle3dsRedirect(response: ITransaction | IStartCheckoutResponse | void): Promise<void | IStartCheckoutResponse | ITransaction>;
|
|
72
74
|
}
|
|
75
|
+
export {};
|
|
@@ -58,7 +58,7 @@ export declare class LiteCheckout extends BaseInlineCheckout implements ILiteChe
|
|
|
58
58
|
getOpenpayDeviceSessionID(merchant_id: string, public_key: string, is_sandbox: boolean): Promise<string | ErrorResponse>;
|
|
59
59
|
getSkyflowTokens({ vault_id, vault_url, data, }: TokensRequest): Promise<any | ErrorResponse>;
|
|
60
60
|
_setCartTotal(total: string): void;
|
|
61
|
-
_checkout({ card, payment_method, isSandbox, returnUrl: returnUrlData }: {
|
|
61
|
+
_checkout({ card, payment_method: requestedPaymentMethod, isSandbox, returnUrl: returnUrlData }: {
|
|
62
62
|
card?: string;
|
|
63
63
|
payment_method?: string;
|
|
64
64
|
isSandbox?: boolean;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { GetBusinessResponse } from "../types/responses";
|
|
2
|
-
export declare function fetchBusiness(
|
|
2
|
+
export declare function fetchBusiness(coreBaseUrl: string, apiKey: string, signal: AbortSignal): Promise<GetBusinessResponse>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { buildCoreProcessBody } from "../helpers/corePayment";
|
|
2
|
+
export declare const SDK_APP_ORIGIN = "sdk/ionic";
|
|
3
|
+
export type CoreAnswer = {
|
|
4
|
+
status: number;
|
|
5
|
+
statusText?: string;
|
|
6
|
+
body: any;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Creates a card payment in the core and answers whatever the core answered, a refusal
|
|
10
|
+
* included: turning an answer into what the merchant sees is `rebuildCheckoutResult`'s job.
|
|
11
|
+
*/
|
|
12
|
+
export declare function createCorePayment(coreBaseUrl: string, apiKey: string, payment: ReturnType<typeof buildCoreProcessBody>, requestId: string): Promise<CoreAnswer>;
|
|
13
|
+
/** The kill switch refused the create: nothing was created, so the legacy flow may take over. */
|
|
14
|
+
export declare function isOperationsDisabled(error: unknown): boolean;
|
|
15
|
+
export declare function isOperationsDisabledAnswer(answer: Pick<CoreAnswer, "status" | "body">): boolean;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { IItem } from "../types/checkout";
|
|
2
|
+
export type CoreCheckoutInput = {
|
|
3
|
+
amount: number;
|
|
4
|
+
currency?: string;
|
|
5
|
+
reference: string | number;
|
|
6
|
+
customer: Record<string, any> | undefined;
|
|
7
|
+
/** The vault field tokens of a new card, or `{ skyflow_id }` for a saved one. */
|
|
8
|
+
card: Record<string, any>;
|
|
9
|
+
metadata?: Record<string, any>;
|
|
10
|
+
returnUrl?: string;
|
|
11
|
+
items?: IItem[];
|
|
12
|
+
browserInfo?: Record<string, any>;
|
|
13
|
+
};
|
|
14
|
+
export type CoreResultContext = {
|
|
15
|
+
coreBaseUrl: string;
|
|
16
|
+
};
|
|
17
|
+
export type RebuiltResult = {
|
|
18
|
+
outcome: "resolve" | "reject";
|
|
19
|
+
/** The HTTP status `checkout-router` answered with. */
|
|
20
|
+
status: number;
|
|
21
|
+
statusText?: string;
|
|
22
|
+
body: Record<string, any>;
|
|
23
|
+
};
|
|
24
|
+
export declare function newRequestId(): string;
|
|
25
|
+
/** The `/process` body Direct API takes, from what the legacy flow put in orders, payments and checkout-router. */
|
|
26
|
+
export declare function buildCoreProcessBody(input: CoreCheckoutInput): {
|
|
27
|
+
operation_type: string;
|
|
28
|
+
amount: number;
|
|
29
|
+
currency: string | undefined;
|
|
30
|
+
client_reference: string;
|
|
31
|
+
customer: {
|
|
32
|
+
name: string;
|
|
33
|
+
email: string;
|
|
34
|
+
phone: undefined;
|
|
35
|
+
identification: undefined;
|
|
36
|
+
};
|
|
37
|
+
payment_method: {
|
|
38
|
+
type: string;
|
|
39
|
+
token?: undefined;
|
|
40
|
+
} | {
|
|
41
|
+
type: string;
|
|
42
|
+
token: any;
|
|
43
|
+
};
|
|
44
|
+
metadata: Record<string, any> | undefined;
|
|
45
|
+
return_url: string | undefined;
|
|
46
|
+
items: IItem[] | undefined;
|
|
47
|
+
browser_info: Record<string, any> | undefined;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Rebuilds what `checkout-router` answered for the same payment, from the core's answer:
|
|
51
|
+
* a body to resolve `payment()` with, or the 4xx body it rejected with.
|
|
52
|
+
*/
|
|
53
|
+
export declare function rebuildCheckoutResult(httpStatus: number, body: any, ctx: CoreResultContext, statusText?: string): RebuiltResult;
|
|
54
|
+
/** What support needs to match a refusal with the core's own log; it never reaches the merchant. */
|
|
55
|
+
export declare function describeCoreRefusal(httpStatus: number, body: any): {
|
|
56
|
+
status: number;
|
|
57
|
+
code: any;
|
|
58
|
+
type: any;
|
|
59
|
+
request_id: any;
|
|
60
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scheme check shared by every sink a URL from the 3DS payload can reach: the
|
|
3
|
+
* attributes of the ACS markup and the challenge redirect.
|
|
4
|
+
*
|
|
5
|
+
* Resolution goes through the platform's URL parser rather than a prefix match. The
|
|
6
|
+
* parser strips the leading whitespace and the embedded tabs and newlines a crafted
|
|
7
|
+
* string uses to hide its scheme, and lowercases the result, so "JavaScript:" and a
|
|
8
|
+
* scheme followed by a comment that merely contains the word http are both classified
|
|
9
|
+
* on what they actually are.
|
|
10
|
+
*
|
|
11
|
+
* https only. A production ACS is always https — the card schemes require it — so
|
|
12
|
+
* allowing http would only add a downgrade path for someone on the network to serve
|
|
13
|
+
* the challenge. If a local sandbox over http is ever needed, widen this deliberately.
|
|
14
|
+
*/
|
|
15
|
+
export declare function isHttpsUrl(value: unknown): boolean;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The 3DS Method step cannot be rendered as text: the ACS sends back a hidden form
|
|
3
|
+
* and the iframe it targets, and the flow submits that form by id. So the markup has
|
|
4
|
+
* to reach the DOM as markup, and the only safe handling is to strip what the step
|
|
5
|
+
* never needs — script execution, event handlers, CSS, beacons and non-https URLs —
|
|
6
|
+
* before insertion.
|
|
7
|
+
*
|
|
8
|
+
* Parsing happens in a document with no browsing context, so nothing loads, navigates
|
|
9
|
+
* or executes while the markup is being inspected. That inertness does not survive the
|
|
10
|
+
* move: a script carried out of a parsed document into a live one has not been marked
|
|
11
|
+
* already-started, so insertion runs it. Removal is the protection, never inertness.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Parses 3DS markup and returns a fragment owned by the current document, with every
|
|
15
|
+
* executable construct removed. Throws nothing: unparseable markup yields an empty
|
|
16
|
+
* fragment, which the caller treats as a missing redirection.
|
|
17
|
+
*/
|
|
18
|
+
export declare function sanitize3dsMarkup(markup: string): DocumentFragment;
|
package/dist/helpers/utils.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export declare const getBrowserInfo: () => {
|
|
|
8
8
|
user_agent: string;
|
|
9
9
|
};
|
|
10
10
|
export declare const getBusinessId: (merchantData: any) => any;
|
|
11
|
+
export declare const isCardPaymentMethod: (paymentMethod?: string) => boolean;
|
|
11
12
|
declare const clearSpace: (text: string) => string;
|
|
12
13
|
declare const getCardType: (scheme: string, mode?: "production" | "sandbox" | "stage" | "development") => string;
|
|
13
14
|
export { getCardType, clearSpace, };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export declare function validateSecureToken(secureToken: unknown): secureToken is string;
|
|
1
2
|
export declare function validateCardNumber(cardNumber: string): boolean;
|
|
2
3
|
export declare function validateCardholderName(name: string): boolean;
|
|
3
4
|
export declare function validateCVV(cvv: string): boolean;
|