@payconductor/react 1.2.6 → 1.3.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/dist/index.cjs.js +3 -3
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.es.js +618 -487
- package/dist/index.es.js.map +1 -1
- package/dist/payconductor/hooks/use-three-ds.d.ts +6 -3
- package/dist/payconductor/three-ds/api.d.ts +14 -2
- package/dist/payconductor/three-ds/handler.d.ts +26 -0
- package/dist/payconductor/three-ds/index.d.ts +2 -2
- package/dist/payconductor/three-ds/types.d.ts +56 -15
- package/package.json +1 -1
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import { ThreeDSecureInit, ThreeDSecureResult } from '../three-ds/types';
|
|
1
|
+
import { ThreeDSecureInit, ThreeDSecurePollingOptions, ThreeDSecureResult } from '../three-ds/types';
|
|
2
2
|
|
|
3
3
|
export type UseThreeDSOptions = {
|
|
4
4
|
onChallenge?: () => void;
|
|
5
|
-
onComplete?: () => void;
|
|
5
|
+
onComplete?: (result: ThreeDSecureResult) => void;
|
|
6
6
|
onError?: (error: Error) => void;
|
|
7
7
|
onTimeout?: () => void;
|
|
8
|
+
complete?: boolean;
|
|
9
|
+
poll?: boolean;
|
|
10
|
+
polling?: ThreeDSecurePollingOptions;
|
|
8
11
|
};
|
|
9
12
|
export type UseThreeDSReturn = {
|
|
10
|
-
|
|
13
|
+
authenticate: (threeDSecure: ThreeDSecureInit) => Promise<ThreeDSecureResult>;
|
|
11
14
|
destroy: () => void;
|
|
12
15
|
};
|
|
13
16
|
export declare function useThreeDS(options?: UseThreeDSOptions): UseThreeDSReturn;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PaymentResult } from '../iframe/types';
|
|
2
|
+
import { ThreeDSMode, ThreeDSecureCompletionPayload, ThreeDSecureData, ThreeDSecurePollingOptions } from './types';
|
|
2
3
|
|
|
3
4
|
export declare class PayConductorThreeDSApiError extends Error {
|
|
4
5
|
readonly title?: unknown | undefined;
|
|
@@ -7,7 +8,18 @@ export declare class PayConductorThreeDSApiError extends Error {
|
|
|
7
8
|
export declare class PayConductorThreeDSApi {
|
|
8
9
|
private readonly publicKey;
|
|
9
10
|
constructor(publicKey: string);
|
|
10
|
-
|
|
11
|
+
completeChallenge(orderId: string, body: ThreeDSecureCompletionPayload): Promise<void>;
|
|
12
|
+
getOrderStatus(orderId: string): Promise<PaymentResult>;
|
|
13
|
+
/**
|
|
14
|
+
* Aguarda o pedido sair de `ThreeDsAwaitingChallenge`.
|
|
15
|
+
* No modo `Auto` não existe `statusDetail`; a espera é enquanto o pedido seguir `Pending`.
|
|
16
|
+
*/
|
|
17
|
+
pollOrderStatus(orderId: string, { maxAttempts, intervalMs, mode }?: ThreeDSecurePollingOptions & {
|
|
18
|
+
mode?: ThreeDSMode;
|
|
19
|
+
}): Promise<{
|
|
20
|
+
order: PaymentResult | null;
|
|
21
|
+
timedOut: boolean;
|
|
22
|
+
}>;
|
|
11
23
|
getThreeDSecureData(orderId: string): Promise<ThreeDSecureData>;
|
|
12
24
|
private parseResponseError;
|
|
13
25
|
private get headers();
|
|
@@ -7,6 +7,32 @@ export declare class PayConductor3DSSDK {
|
|
|
7
7
|
constructor(threeDSecure: ThreeDSecureInit);
|
|
8
8
|
get needsChallenge(): boolean;
|
|
9
9
|
get acquirer(): string | undefined;
|
|
10
|
+
/** Indica se o pedido precisa de autenticação 3DS. */
|
|
11
|
+
static requiresChallenge(order: {
|
|
12
|
+
statusDetail?: string | null;
|
|
13
|
+
threeDSecure?: {
|
|
14
|
+
status?: string;
|
|
15
|
+
} | null;
|
|
16
|
+
creditCard?: {
|
|
17
|
+
threeDSecure?: {
|
|
18
|
+
status?: string;
|
|
19
|
+
};
|
|
20
|
+
} | null;
|
|
21
|
+
}): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Executa o fluxo completo de 3DS: carrega os dados, resolve o provedor,
|
|
24
|
+
* conduz o desafio, envia o `complete` (só no modo `Manual`) e faz o polling
|
|
25
|
+
* do pedido. O integrador não precisa ramificar por modo.
|
|
26
|
+
*/
|
|
10
27
|
authenticate(options?: Omit<ThreeDSecureOptions, "threeDSecure">): Promise<ThreeDSecureResult>;
|
|
11
28
|
destroy(): void;
|
|
29
|
+
/** Mensagem amigável da falha do desafio (pt-BR). */
|
|
30
|
+
private deriveFailureReason;
|
|
31
|
+
/**
|
|
32
|
+
* Payload do `complete`. `failureReason` só vai quando é falha técnica
|
|
33
|
+
* (sem `transStatus` do emissor nem cancelamento) — string vazia quebra o backend.
|
|
34
|
+
*/
|
|
35
|
+
private buildCompletionPayload;
|
|
36
|
+
private finish;
|
|
37
|
+
private toError;
|
|
12
38
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { PayConductor3DSSDK } from './handler';
|
|
2
|
-
export { ThreeDSecureResultStatus, ThreeDSTransStatus } from './types';
|
|
3
|
-
export type { ThreeDSecureData, ThreeDSecureInit, ThreeDSecureResult } from './types';
|
|
2
|
+
export { ThreeDSMode, ThreeDSecureResultStatus, ThreeDSTransStatus } from './types';
|
|
3
|
+
export type { ThreeDSecureData, ThreeDSecureInit, ThreeDSecureResult, ThreeDSecureChallengeOutcome, ThreeDSecureCompletionPayload, ThreeDSecurePollingOptions, ThreeDSecureOptions } from './types';
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { IntegrationProvider, OrganizationEnvironment } from '../iframe/types';
|
|
1
|
+
import { IntegrationProvider, OrganizationEnvironment, PaymentResult } from '../iframe/types';
|
|
2
2
|
|
|
3
3
|
export type ThreeDSecureData = {
|
|
4
4
|
orderId: string;
|
|
5
5
|
publicKey: string;
|
|
6
6
|
status?: string;
|
|
7
7
|
statusDetail?: string;
|
|
8
|
+
/** Modo do 3DS resolvido pelo backend. Uso interno do SDK. */
|
|
9
|
+
mode?: ThreeDSMode;
|
|
8
10
|
acquirer?: IntegrationProvider | "PayConductor" | string;
|
|
9
11
|
environment?: OrganizationEnvironment;
|
|
10
12
|
authToken?: string;
|
|
@@ -15,9 +17,11 @@ export type ThreeDSecureData = {
|
|
|
15
17
|
version?: string;
|
|
16
18
|
card?: {
|
|
17
19
|
number: string;
|
|
18
|
-
expMonth: string;
|
|
19
|
-
expYear: string;
|
|
20
20
|
holderName: string;
|
|
21
|
+
expiration: {
|
|
22
|
+
month: number;
|
|
23
|
+
year: number;
|
|
24
|
+
};
|
|
21
25
|
};
|
|
22
26
|
customer?: {
|
|
23
27
|
name: string;
|
|
@@ -51,14 +55,12 @@ export type ThreeDSecureData = {
|
|
|
51
55
|
* pela API através do `orderId` ao chamar `authenticate`.
|
|
52
56
|
*/
|
|
53
57
|
export type ThreeDSecureInit = Pick<ThreeDSecureData, "orderId" | "publicKey" | "card">;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
timeoutMs?: number;
|
|
61
|
-
};
|
|
58
|
+
/** Modo de condução do desafio 3DS, resolvido pelo backend. */
|
|
59
|
+
export declare enum ThreeDSMode {
|
|
60
|
+
Auto = "Auto",
|
|
61
|
+
Manual = "Manual",
|
|
62
|
+
Agnostic = "Agnostic"
|
|
63
|
+
}
|
|
62
64
|
export declare enum ThreeDSecureResultStatus {
|
|
63
65
|
Success = "Success",
|
|
64
66
|
Failed = "Failed",
|
|
@@ -73,14 +75,53 @@ export declare enum ThreeDSTransStatus {
|
|
|
73
75
|
Rejected = "R",
|
|
74
76
|
InformationOnly = "I"
|
|
75
77
|
}
|
|
76
|
-
|
|
78
|
+
/** Corpo de `POST /api/v1/sdk/three-ds/complete/:orderId`. */
|
|
79
|
+
export type ThreeDSecureCompletionPayload = {
|
|
80
|
+
providerTransactionId?: string;
|
|
81
|
+
transStatus?: ThreeDSTransStatus;
|
|
82
|
+
challengeCanceled?: boolean;
|
|
83
|
+
failureReason?: string;
|
|
84
|
+
};
|
|
85
|
+
/** Resultado normalizado do desafio, independente do provedor. */
|
|
86
|
+
export type ThreeDSecureChallengeOutcome = {
|
|
77
87
|
status: ThreeDSecureResultStatus;
|
|
78
88
|
error?: Error;
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
89
|
+
/** Mensagem amigável (pt-BR) da falha do desafio. Ausente em sucesso. */
|
|
90
|
+
failureReason?: string;
|
|
91
|
+
/** `transStatus` bruto do emissor (EMVCo), quando o provedor devolver. */
|
|
82
92
|
transStatus?: ThreeDSTransStatus;
|
|
93
|
+
/** Identificador da transação no provedor/adquirente (fallback de `dsTransactionId`). */
|
|
94
|
+
providerTransactionId?: string;
|
|
95
|
+
/** O portador fechou/cancelou o desafio. */
|
|
83
96
|
challengeCanceled?: boolean;
|
|
97
|
+
/** Mantido para o fallback de `providerTransactionId` e uso interno dos provedores. */
|
|
98
|
+
dsTransactionId?: string;
|
|
99
|
+
authToken?: string;
|
|
100
|
+
};
|
|
101
|
+
export type ThreeDSecurePollingOptions = {
|
|
102
|
+
/** Default: 30 */
|
|
103
|
+
maxAttempts?: number;
|
|
104
|
+
/** Default: 2000 */
|
|
105
|
+
intervalMs?: number;
|
|
106
|
+
};
|
|
107
|
+
export type ThreeDSecureResult = ThreeDSecureChallengeOutcome & {
|
|
108
|
+
/** Último status conhecido do pedido. Presente quando `poll` (ou `complete`) rodou. */
|
|
109
|
+
order?: PaymentResult;
|
|
110
|
+
/** `true` quando o polling esgotou as tentativas sem sair de `ThreeDsAwaitingChallenge`. */
|
|
111
|
+
timedOut?: boolean;
|
|
112
|
+
};
|
|
113
|
+
export type ThreeDSecureOptions = {
|
|
114
|
+
threeDSecure: ThreeDSecureData;
|
|
115
|
+
onChallenge?: () => void;
|
|
116
|
+
onComplete?: (result: ThreeDSecureResult) => void;
|
|
117
|
+
onError?: (error: Error) => void;
|
|
118
|
+
onTimeout?: () => void;
|
|
119
|
+
timeoutMs?: number;
|
|
120
|
+
/** Envia o resultado ao backend (`POST /three-ds/complete/:orderId`). Default: `true`. */
|
|
121
|
+
complete?: boolean;
|
|
122
|
+
/** Faz polling de `GET /orders/:id/status`. Default: `true`. */
|
|
123
|
+
poll?: boolean;
|
|
124
|
+
polling?: ThreeDSecurePollingOptions;
|
|
84
125
|
};
|
|
85
126
|
export declare abstract class AbstractThreeDSProvider {
|
|
86
127
|
protected readonly data: ThreeDSecureData;
|