tempest-react-sdk 0.83.0 → 0.84.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/README.md +1 -0
- package/dist/auth/create-tempest-auth.cjs +1 -1
- package/dist/auth/create-tempest-auth.cjs.map +1 -1
- package/dist/auth/create-tempest-auth.js +150 -105
- package/dist/auth/create-tempest-auth.js.map +1 -1
- package/dist/http/resumable-upload.cjs +1 -1
- package/dist/http/resumable-upload.cjs.map +1 -1
- package/dist/http/resumable-upload.js +1 -1
- package/dist/http/resumable-upload.js.map +1 -1
- package/dist/http/upload-with-progress.cjs +1 -1
- package/dist/http/upload-with-progress.cjs.map +1 -1
- package/dist/http/upload-with-progress.js +47 -39
- package/dist/http/upload-with-progress.js.map +1 -1
- package/dist/payments/PixCheckout.cjs +2 -0
- package/dist/payments/PixCheckout.cjs.map +1 -0
- package/dist/payments/PixCheckout.js +171 -0
- package/dist/payments/PixCheckout.js.map +1 -0
- package/dist/payments/PixCheckout.module.cjs +3 -0
- package/dist/payments/PixCheckout.module.cjs.map +1 -0
- package/dist/payments/PixCheckout.module.js +22 -0
- package/dist/payments/PixCheckout.module.js.map +1 -0
- package/dist/payments/format.cjs +2 -0
- package/dist/payments/format.cjs.map +1 -0
- package/dist/payments/format.js +9 -0
- package/dist/payments/format.js.map +1 -0
- package/dist/payments/mercado-pago.cjs +2 -0
- package/dist/payments/mercado-pago.cjs.map +1 -0
- package/dist/payments/mercado-pago.js +27 -0
- package/dist/payments/mercado-pago.js.map +1 -0
- package/dist/payments/outcome.cjs +2 -0
- package/dist/payments/outcome.cjs.map +1 -0
- package/dist/payments/outcome.js +108 -0
- package/dist/payments/outcome.js.map +1 -0
- package/dist/payments/types.cjs +2 -0
- package/dist/payments/types.cjs.map +1 -0
- package/dist/payments/types.js +16 -0
- package/dist/payments/types.js.map +1 -0
- package/dist/payments/use-mercado-pago-card.cjs +2 -0
- package/dist/payments/use-mercado-pago-card.cjs.map +1 -0
- package/dist/payments/use-mercado-pago-card.js +120 -0
- package/dist/payments/use-mercado-pago-card.js.map +1 -0
- package/dist/payments/use-pix-charge.cjs +2 -0
- package/dist/payments/use-pix-charge.cjs.map +1 -0
- package/dist/payments/use-pix-charge.js +63 -0
- package/dist/payments/use-pix-charge.js.map +1 -0
- package/dist/query/offline-persistence.cjs +1 -1
- package/dist/query/offline-persistence.cjs.map +1 -1
- package/dist/query/offline-persistence.js +3 -3
- package/dist/query/offline-persistence.js.map +1 -1
- package/dist/styles/PixCheckout.css +2 -0
- package/dist/styles/component/PixCheckout.css +18 -0
- package/dist/styles/manifest.json +6 -0
- package/dist/styles/payments.css +18 -0
- package/dist/styles.css +1 -1
- package/dist/sw/cache.cjs +1 -1
- package/dist/sw/cache.cjs.map +1 -1
- package/dist/sw/cache.js +1 -1
- package/dist/sw/cache.js.map +1 -1
- package/dist/tempest-react-sdk.cjs +1 -1
- package/dist/tempest-react-sdk.d.ts +677 -23
- package/dist/tempest-react-sdk.js +104 -97
- package/package.json +1 -1
|
@@ -3138,8 +3138,96 @@ export declare function capitalize(value: string): string;
|
|
|
3138
3138
|
*/
|
|
3139
3139
|
export declare function Card({ title, actions, footer, flush, interactive, elevation, className, children, ...props }: CardProps): JSX.Element;
|
|
3140
3140
|
|
|
3141
|
+
/**
|
|
3142
|
+
* PT-BR text for every `status_detail` Mercado Pago's Orders API documents.
|
|
3143
|
+
*
|
|
3144
|
+
* Ported from Mercado Pago's "Status da transação" table
|
|
3145
|
+
* (`developers/pt/docs/checkout-api-orders/payment-management/status/transaction-status`,
|
|
3146
|
+
* read on 2026-11-14), rewritten for the payer: the provider's descriptions are
|
|
3147
|
+
* addressed to the integrator. `rejected_by_issuer` is the decline the backend
|
|
3148
|
+
* pinned in the sandbox (holder `OTHE`, HTTP 402); the others come from the
|
|
3149
|
+
* table. `high_risk` deliberately does not say "fraud" — telling the payer the
|
|
3150
|
+
* anti-fraud system flagged them helps exactly the person it should not.
|
|
3151
|
+
*
|
|
3152
|
+
* A test pins every key, so a code dropped or renamed here fails instead of
|
|
3153
|
+
* silently falling back to the generic text.
|
|
3154
|
+
*/
|
|
3155
|
+
export declare const CARD_STATUS_DETAIL_MESSAGES: Readonly<Record<string, string>>;
|
|
3156
|
+
|
|
3157
|
+
/** A card charge — `CardCharge` in the backend. */
|
|
3158
|
+
export declare interface CardCharge {
|
|
3159
|
+
/** Provider that owns the charge. */
|
|
3160
|
+
provider: string;
|
|
3161
|
+
/** The charge's id at the provider. */
|
|
3162
|
+
provider_charge_id: string;
|
|
3163
|
+
/** The service's own identifier. */
|
|
3164
|
+
reference: string;
|
|
3165
|
+
/** Amount charged, in cents. */
|
|
3166
|
+
amount_cents: number;
|
|
3167
|
+
/** How much went back to the payer, in cents. A partial refund keeps `status` at `paid`. */
|
|
3168
|
+
refunded_cents: number;
|
|
3169
|
+
/** ISO 4217 code. */
|
|
3170
|
+
currency: string;
|
|
3171
|
+
/**
|
|
3172
|
+
* Canonical state. A declined card is `"failed"` — returned, not raised: the
|
|
3173
|
+
* backend answers the decline as a charge, with the reason in `status_detail`.
|
|
3174
|
+
*/
|
|
3175
|
+
status: PaymentStatus;
|
|
3176
|
+
/** The provider's raw state. */
|
|
3177
|
+
provider_status: string;
|
|
3178
|
+
/** The provider's reason — `rejected_by_issuer`, `waiting_capture`, `accredited`. */
|
|
3179
|
+
status_detail: string | null;
|
|
3180
|
+
/** Card brand. */
|
|
3181
|
+
payment_method_id: string | null;
|
|
3182
|
+
/** Installments charged. */
|
|
3183
|
+
installments: number | null;
|
|
3184
|
+
/** Each installment, interest included, in cents. */
|
|
3185
|
+
installment_amount_cents: number | null;
|
|
3186
|
+
/** What the payer owes with interest, in cents. Not proof of payment — read `status`. */
|
|
3187
|
+
payer_total_cents: number | null;
|
|
3188
|
+
/** The provider's payload as decoded. */
|
|
3189
|
+
raw?: Record<string, unknown>;
|
|
3190
|
+
}
|
|
3191
|
+
|
|
3192
|
+
/**
|
|
3193
|
+
* The body a service needs to charge a tokenized card — `CardChargeRequest` in
|
|
3194
|
+
* the backend, minus nothing: `card_token`, `payment_method_id` and
|
|
3195
|
+
* `installments` are exactly what {@link useMercadoPagoCard}'s `tokenize`
|
|
3196
|
+
* returns, and the card number is never part of it.
|
|
3197
|
+
*/
|
|
3198
|
+
export declare interface CardChargeRequest {
|
|
3199
|
+
/** The price in cents. With installments, still the price: the provider adds the interest. */
|
|
3200
|
+
amount_cents: number;
|
|
3201
|
+
/** The service's own identifier — also the create's idempotency key. */
|
|
3202
|
+
reference: string;
|
|
3203
|
+
/** Single-use token produced in the browser. */
|
|
3204
|
+
card_token: string;
|
|
3205
|
+
/** Card brand as the provider names it (`visa`, `master`, …). */
|
|
3206
|
+
payment_method_id: string;
|
|
3207
|
+
/** Installments the payer chose. Default `1` on the backend. */
|
|
3208
|
+
installments?: number;
|
|
3209
|
+
/** `false` only authorizes; the charge comes back `authorized`. Default `true`. */
|
|
3210
|
+
capture?: boolean;
|
|
3211
|
+
/** Free text, where the provider supports it. */
|
|
3212
|
+
description?: string | null;
|
|
3213
|
+
/** Who is paying. */
|
|
3214
|
+
payer?: PaymentPayer | null;
|
|
3215
|
+
}
|
|
3216
|
+
|
|
3141
3217
|
export declare type CardElevation = "flat" | "default" | "raised" | "elevated";
|
|
3142
3218
|
|
|
3219
|
+
/** One installment choice, in the shape a `<Select>` needs. */
|
|
3220
|
+
export declare interface CardInstallmentOption {
|
|
3221
|
+
/** Number of installments — the value to submit. */
|
|
3222
|
+
installments: number;
|
|
3223
|
+
/** The provider's own text, e.g. `"2 parcelas de R$ 54,82 (R$ 109,64)"`. Show it verbatim. */
|
|
3224
|
+
recommendedMessage: string;
|
|
3225
|
+
/** Each installment, interest included, in cents. */
|
|
3226
|
+
installmentAmountCents: number;
|
|
3227
|
+
/** What the payer owes in total, interest included, in cents. */
|
|
3228
|
+
totalAmountCents: number;
|
|
3229
|
+
}
|
|
3230
|
+
|
|
3143
3231
|
export declare interface CardProps extends Omit<HTMLAttributes<HTMLDivElement>, "title"> {
|
|
3144
3232
|
title?: ReactNode;
|
|
3145
3233
|
actions?: ReactNode;
|
|
@@ -3151,6 +3239,34 @@ export declare interface CardProps extends Omit<HTMLAttributes<HTMLDivElement>,
|
|
|
3151
3239
|
elevation?: CardElevation;
|
|
3152
3240
|
}
|
|
3153
3241
|
|
|
3242
|
+
/** What the non-card part of the form supplies when tokenizing. */
|
|
3243
|
+
export declare interface CardTokenizeInput {
|
|
3244
|
+
/** Name printed on the card. */
|
|
3245
|
+
cardholderName: string;
|
|
3246
|
+
/** Installments chosen from {@link UseMercadoPagoCardResult.installmentOptions}. */
|
|
3247
|
+
installments: number;
|
|
3248
|
+
/** Document type (`"CPF"`, `"CNPJ"`). */
|
|
3249
|
+
identificationType?: string;
|
|
3250
|
+
/** Document number, digits only. */
|
|
3251
|
+
identificationNumber?: string;
|
|
3252
|
+
}
|
|
3253
|
+
|
|
3254
|
+
/**
|
|
3255
|
+
* Everything the backend needs to charge the card — and nothing more.
|
|
3256
|
+
*
|
|
3257
|
+
* Maps onto the backend's `CardChargeRequest` as `card_token: token` plus the
|
|
3258
|
+
* other two fields unchanged. No card number, expiry or CVV: those never left
|
|
3259
|
+
* Mercado Pago's iframes.
|
|
3260
|
+
*/
|
|
3261
|
+
export declare interface CardTokenResult {
|
|
3262
|
+
/** Single-use card token. */
|
|
3263
|
+
token: string;
|
|
3264
|
+
/** Card brand as Mercado Pago names it (`visa`, `master`, …). */
|
|
3265
|
+
payment_method_id: string;
|
|
3266
|
+
/** Installments chosen. */
|
|
3267
|
+
installments: number;
|
|
3268
|
+
}
|
|
3269
|
+
|
|
3154
3270
|
/**
|
|
3155
3271
|
* Horizontal content slider showing one slide at a time.
|
|
3156
3272
|
*
|
|
@@ -4933,6 +5049,10 @@ export declare function createLinkStatsSampler(options?: LinkStatsSamplerOptions
|
|
|
4933
5049
|
* `clear()` forgets every record under the prefix. Call it from
|
|
4934
5050
|
* `onSessionEnd`: a record outlives the session that wrote it, and only
|
|
4935
5051
|
* completing the upload or `abort({ discard: true })` removes it otherwise.
|
|
5052
|
+
* It also ends every handle built over a storage with the same prefix: a run
|
|
5053
|
+
* in flight stops with {@link ResumableUploadSupersededError} (`"cleared"`),
|
|
5054
|
+
* and a paused one's next `resume()` starts a new upload with a fresh
|
|
5055
|
+
* `Idempotency-Key` (since 0.84.0, #528).
|
|
4936
5056
|
*
|
|
4937
5057
|
* @param prefix - Key prefix. Default `"tempest-upload:"`.
|
|
4938
5058
|
* @returns A storage that no-ops when `localStorage` is unavailable.
|
|
@@ -7255,6 +7375,35 @@ export declare interface DescribeApiErrorOptions extends Partial<ApiErrorStrings
|
|
|
7255
7375
|
*/
|
|
7256
7376
|
export declare function describeAppError(error: unknown, context?: Record<string, unknown>): AppErrorDescription;
|
|
7257
7377
|
|
|
7378
|
+
/**
|
|
7379
|
+
* Turn a card charge from the backend into what the payer should read.
|
|
7380
|
+
*
|
|
7381
|
+
* The **status** decides the outcome; `status_detail` only refines the sentence.
|
|
7382
|
+
* That ordering is the point: `waiting_capture` arrives as `authorized` and
|
|
7383
|
+
* reads as "reserved, not charged", never as paid, and a detail this table does
|
|
7384
|
+
* not know falls back to the status's generic text instead of guessing. A
|
|
7385
|
+
* decline reason only refines a `failed` charge, and a pending reason only a
|
|
7386
|
+
* charge that is not `failed`, so a detail that contradicts its status cannot
|
|
7387
|
+
* put "recusado" and "reservado" on the same screen.
|
|
7388
|
+
*
|
|
7389
|
+
* A decline is data here, not an exception. The backend returns a declined card
|
|
7390
|
+
* as a `CardCharge` with `status: "failed"` — Mercado Pago answers it with HTTP
|
|
7391
|
+
* 402 and the backend reads that as a result — so the checkout renders the
|
|
7392
|
+
* reason the same way it renders an approval. If your own endpoint chooses to
|
|
7393
|
+
* answer a decline with a non-2xx status, parse its body and pass it here; do
|
|
7394
|
+
* not show it as a network error, because it is not one.
|
|
7395
|
+
*
|
|
7396
|
+
* @param charge - The charge, or just its `status` and `status_detail`.
|
|
7397
|
+
* @param messages - Overrides per `status_detail`, merged over
|
|
7398
|
+
* {@link CARD_STATUS_DETAIL_MESSAGES} — for another language or tone.
|
|
7399
|
+
* @returns Tone, title, message and whether the payer can retry.
|
|
7400
|
+
*
|
|
7401
|
+
* @example
|
|
7402
|
+
* const outcome = describeCardCharge(charge);
|
|
7403
|
+
* <Alert variant={outcome.tone} title={outcome.title} description={outcome.message} />
|
|
7404
|
+
*/
|
|
7405
|
+
export declare function describeCardCharge(charge: Pick<CardCharge, "status" | "status_detail">, messages?: Readonly<Record<string, string>>): PaymentOutcome;
|
|
7406
|
+
|
|
7258
7407
|
/**
|
|
7259
7408
|
* One filter, in words: `"Status é Pago"`.
|
|
7260
7409
|
*
|
|
@@ -8666,6 +8815,21 @@ export declare interface FormatPhoneOptions {
|
|
|
8666
8815
|
mobile?: boolean;
|
|
8667
8816
|
}
|
|
8668
8817
|
|
|
8818
|
+
/**
|
|
8819
|
+
* `mm:ss` under an hour, `h:mm:ss` above — a Pix can live for 24 h.
|
|
8820
|
+
*
|
|
8821
|
+
* The default countdown format of `PixCheckout`, exported so an app that
|
|
8822
|
+
* renders its own Pix screen shows the same clock.
|
|
8823
|
+
*
|
|
8824
|
+
* @param ms - Milliseconds left. Rounded up, so the last second reads `00:01`.
|
|
8825
|
+
* @returns The formatted remaining time.
|
|
8826
|
+
*
|
|
8827
|
+
* @example
|
|
8828
|
+
* formatPixRemaining(65_000); // "01:05"
|
|
8829
|
+
* formatPixRemaining(3_725_000); // "1:02:05"
|
|
8830
|
+
*/
|
|
8831
|
+
export declare function formatPixRemaining(ms: number): string;
|
|
8832
|
+
|
|
8669
8833
|
export declare function FormField<TValues extends FieldValues = FieldValues, TName extends FieldPath<TValues> = FieldPath<TValues>>({ name, label, helperText, required, control, children }: FormFieldProps<TValues, TName>): JSX.Element;
|
|
8670
8834
|
|
|
8671
8835
|
export declare interface FormFieldChildProps {
|
|
@@ -9944,6 +10108,23 @@ export declare function isDefined<T>(value: T | null | undefined): value is T;
|
|
|
9944
10108
|
*/
|
|
9945
10109
|
export declare function isEmpty(value: unknown): boolean;
|
|
9946
10110
|
|
|
10111
|
+
/**
|
|
10112
|
+
* Whether a checkout has nothing left to wait for.
|
|
10113
|
+
*
|
|
10114
|
+
* `paid`, `expired`, `cancelled`, `refunded`, `charged_back` and `failed` end the
|
|
10115
|
+
* flow the payer is looking at, so a status poll stops there. `pending`,
|
|
10116
|
+
* `authorized`, `in_analysis` and `unknown` do not: each is a state the backend
|
|
10117
|
+
* will still move. `paid` can later become `refunded`, but that is no longer
|
|
10118
|
+
* something the checkout screen waits for.
|
|
10119
|
+
*
|
|
10120
|
+
* @param status - The charge's canonical state.
|
|
10121
|
+
* @returns `true` when following the charge further is pointless.
|
|
10122
|
+
*
|
|
10123
|
+
* @example
|
|
10124
|
+
* if (isFinalPaymentStatus(charge.status)) stopPolling();
|
|
10125
|
+
*/
|
|
10126
|
+
export declare function isFinalPaymentStatus(status: PaymentStatus): boolean;
|
|
10127
|
+
|
|
9947
10128
|
/**
|
|
9948
10129
|
* Whether this environment can present anything fullscreen at all.
|
|
9949
10130
|
*
|
|
@@ -10807,6 +10988,33 @@ export { LoaderFunction }
|
|
|
10807
10988
|
|
|
10808
10989
|
export { LoaderFunctionArgs }
|
|
10809
10990
|
|
|
10991
|
+
/**
|
|
10992
|
+
* Load MercadoPago.js once per document and resolve its constructor.
|
|
10993
|
+
*
|
|
10994
|
+
* Concurrent and repeated calls share one `<script>` tag and one promise, so a
|
|
10995
|
+
* checkout that remounts never injects the script twice. A failed load is
|
|
10996
|
+
* forgotten instead of cached — the next call tries again, which is what a
|
|
10997
|
+
* payer on a flaky connection needs — and the dead tag is removed.
|
|
10998
|
+
*
|
|
10999
|
+
* @param options - Script URL and target document.
|
|
11000
|
+
* @returns The `MercadoPago` constructor.
|
|
11001
|
+
* @throws {Error} When the script fails to load, or loads without defining
|
|
11002
|
+
* `window.MercadoPago`.
|
|
11003
|
+
*
|
|
11004
|
+
* @example
|
|
11005
|
+
* const MercadoPago = await loadMercadoPago();
|
|
11006
|
+
* const mp = new MercadoPago(import.meta.env.VITE_MP_PUBLIC_KEY, { locale: "pt-BR" });
|
|
11007
|
+
*/
|
|
11008
|
+
export declare function loadMercadoPago(options?: LoadMercadoPagoOptions): Promise<MercadoPagoConstructor>;
|
|
11009
|
+
|
|
11010
|
+
/** Options for {@link loadMercadoPago}. */
|
|
11011
|
+
export declare interface LoadMercadoPagoOptions {
|
|
11012
|
+
/** Script URL. Default {@link MERCADO_PAGO_SCRIPT_URL}; override only for a proxy you control. */
|
|
11013
|
+
src?: string;
|
|
11014
|
+
/** Document to inject into. Default the global `document`. */
|
|
11015
|
+
document?: Document;
|
|
11016
|
+
}
|
|
11017
|
+
|
|
10810
11018
|
export declare type LocalStorageOptions<T> = {
|
|
10811
11019
|
serialize?: (value: T) => string;
|
|
10812
11020
|
deserialize?: (raw: string) => T;
|
|
@@ -11306,6 +11514,107 @@ export declare interface MenubarProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
11306
11514
|
portal?: boolean;
|
|
11307
11515
|
}
|
|
11308
11516
|
|
|
11517
|
+
/**
|
|
11518
|
+
* The official MercadoPago.js v2 script.
|
|
11519
|
+
*
|
|
11520
|
+
* Loaded from Mercado Pago's own host, never bundled or vendored: the PCI DSS
|
|
11521
|
+
* self-assessment that keeps a merchant in the lightest scope (SAQ A) requires
|
|
11522
|
+
* the card fields to come straight from the processor, and Mercado Pago ships
|
|
11523
|
+
* the script unversioned so fixes reach every merchant without a rebuild. It is
|
|
11524
|
+
* also why this is not an npm dependency — there is no package to pin.
|
|
11525
|
+
*
|
|
11526
|
+
* A Content-Security-Policy needs `script-src https://sdk.mercadopago.com` and,
|
|
11527
|
+
* for the Secure Fields iframes and the API calls the script makes,
|
|
11528
|
+
* `frame-src https://secure-fields.mercadopago.com https://api-static.mercadopago.com`
|
|
11529
|
+
* plus `connect-src https://api.mercadopago.com https://api.mercadolibre.com`
|
|
11530
|
+
* (hosts read from the script itself, `js_version` 2.83.6, on 2026-11-14).
|
|
11531
|
+
*/
|
|
11532
|
+
export declare const MERCADO_PAGO_SCRIPT_URL = "https://sdk.mercadopago.com/js/v2";
|
|
11533
|
+
|
|
11534
|
+
/** Element ids the three Secure Fields mount into. */
|
|
11535
|
+
export declare interface MercadoPagoCardContainers {
|
|
11536
|
+
cardNumber: string;
|
|
11537
|
+
expirationDate: string;
|
|
11538
|
+
securityCode: string;
|
|
11539
|
+
}
|
|
11540
|
+
|
|
11541
|
+
/** Lifecycle of the Secure Fields. */
|
|
11542
|
+
export declare type MercadoPagoCardStatus = "loading" | "ready" | "error";
|
|
11543
|
+
|
|
11544
|
+
/** Non-card data the token is bound to. */
|
|
11545
|
+
export declare interface MercadoPagoCardTokenData {
|
|
11546
|
+
cardholderName: string;
|
|
11547
|
+
identificationType?: string;
|
|
11548
|
+
identificationNumber?: string;
|
|
11549
|
+
}
|
|
11550
|
+
|
|
11551
|
+
/** The `MercadoPago` global the script defines. */
|
|
11552
|
+
export declare type MercadoPagoConstructor = new (publicKey: string, options?: {
|
|
11553
|
+
locale?: string;
|
|
11554
|
+
}) => MercadoPagoLike;
|
|
11555
|
+
|
|
11556
|
+
/** One mounted Secure Field — the subset of MercadoPago.js this module calls. */
|
|
11557
|
+
export declare interface MercadoPagoFieldLike {
|
|
11558
|
+
/** Mounts the iframe into the element with this id. */
|
|
11559
|
+
mount(containerId: string): unknown;
|
|
11560
|
+
/** Removes the iframe. */
|
|
11561
|
+
unmount(): unknown;
|
|
11562
|
+
/** Subscribes to a field event (`binChange`, `validityChange`, `error`, …). */
|
|
11563
|
+
on(event: string, listener: (payload: unknown) => void): unknown;
|
|
11564
|
+
}
|
|
11565
|
+
|
|
11566
|
+
/** Options for one Secure Field, as MercadoPago.js accepts them. */
|
|
11567
|
+
export declare interface MercadoPagoFieldOptions {
|
|
11568
|
+
/** Placeholder shown inside the iframe. */
|
|
11569
|
+
placeholder?: string;
|
|
11570
|
+
/** Inline style applied inside the iframe (font, colour, size). */
|
|
11571
|
+
style?: Record<string, string>;
|
|
11572
|
+
}
|
|
11573
|
+
|
|
11574
|
+
/** The Secure Fields this module mounts. */
|
|
11575
|
+
export declare type MercadoPagoFieldType = "cardNumber" | "expirationDate" | "securityCode";
|
|
11576
|
+
|
|
11577
|
+
/** One entry of the `getInstallments` answer. */
|
|
11578
|
+
export declare interface MercadoPagoInstallmentsEntry {
|
|
11579
|
+
payment_method_id: string;
|
|
11580
|
+
payment_type_id?: string;
|
|
11581
|
+
issuer?: {
|
|
11582
|
+
id?: string | number | null;
|
|
11583
|
+
} | null;
|
|
11584
|
+
payer_costs: MercadoPagoPayerCost[];
|
|
11585
|
+
}
|
|
11586
|
+
|
|
11587
|
+
/**
|
|
11588
|
+
* The subset of a `new MercadoPago(publicKey)` instance this module calls.
|
|
11589
|
+
*
|
|
11590
|
+
* Declared here instead of depending on `@mercadopago/sdk-js`, matching how the
|
|
11591
|
+
* SDK treats every injected provider: tests pass a fake with this shape, and an
|
|
11592
|
+
* app never pays for typings it does not use.
|
|
11593
|
+
*/
|
|
11594
|
+
export declare interface MercadoPagoLike {
|
|
11595
|
+
fields: {
|
|
11596
|
+
create(type: MercadoPagoFieldType, options?: MercadoPagoFieldOptions): MercadoPagoFieldLike;
|
|
11597
|
+
createCardToken(data: MercadoPagoCardTokenData): Promise<{
|
|
11598
|
+
id: string;
|
|
11599
|
+
}>;
|
|
11600
|
+
};
|
|
11601
|
+
getInstallments(params: {
|
|
11602
|
+
amount: string;
|
|
11603
|
+
bin: string;
|
|
11604
|
+
paymentTypeId?: string;
|
|
11605
|
+
}): Promise<MercadoPagoInstallmentsEntry[]>;
|
|
11606
|
+
}
|
|
11607
|
+
|
|
11608
|
+
/** One installment option, as `getInstallments` returns it. */
|
|
11609
|
+
export declare interface MercadoPagoPayerCost {
|
|
11610
|
+
installments: number;
|
|
11611
|
+
installment_rate: number;
|
|
11612
|
+
installment_amount: number;
|
|
11613
|
+
total_amount: number;
|
|
11614
|
+
/** Ready-made text, e.g. `"2 parcelas de R$ 54,82 (R$ 109,64)"`. */
|
|
11615
|
+
recommended_message: string;
|
|
11616
|
+
}
|
|
11617
|
+
|
|
11309
11618
|
/**
|
|
11310
11619
|
* A point projected onto the unit Web Mercator plane. Both axes are in `[0, 1]`
|
|
11311
11620
|
* — `x` grows east, `y` grows south (screen convention).
|
|
@@ -12225,9 +12534,9 @@ export declare interface OfflineQueryPersistenceOptions {
|
|
|
12225
12534
|
/**
|
|
12226
12535
|
* Who is signed in right now — a stable, non-secret id such as the user id;
|
|
12227
12536
|
* `null`/`undefined` when nobody is. Read on every write, which stamps the
|
|
12228
|
-
* snapshot with a one-way fingerprint of it (never the id itself),
|
|
12537
|
+
* snapshot with a one-way fingerprint of it (never the id itself), on
|
|
12229
12538
|
* `restore()`, which hydrates only a snapshot stamped with the same
|
|
12230
|
-
* fingerprint.
|
|
12539
|
+
* fingerprint, and on cache changes until the handle is bound.
|
|
12231
12540
|
*
|
|
12232
12541
|
* `clear()` on logout already deletes the snapshot; this covers the session
|
|
12233
12542
|
* that ends without it — a token that expired, a crash, a tab closed while
|
|
@@ -12240,11 +12549,14 @@ export declare interface OfflineQueryPersistenceOptions {
|
|
|
12240
12549
|
* the principal after a `/me` round trip would otherwise wipe its own cache
|
|
12241
12550
|
* on every cold start. The next write replaces it.
|
|
12242
12551
|
*
|
|
12243
|
-
* The handle is bound to the first signed-in owner it
|
|
12244
|
-
*
|
|
12245
|
-
*
|
|
12246
|
-
*
|
|
12247
|
-
* the
|
|
12552
|
+
* The handle is bound to the first signed-in owner it sees on a cache
|
|
12553
|
+
* change, a write or a restore — the cache change is what pins the owner of
|
|
12554
|
+
* data that a throttled write would otherwise stamp with whoever is signed
|
|
12555
|
+
* in a second later (#580). Once bound, a write under another owner —
|
|
12556
|
+
* nobody, because the token expired without `clear()`, or a second account
|
|
12557
|
+
* on the same tab — deletes the snapshot instead of stamping the bound
|
|
12558
|
+
* owner's cached responses with the new owner (#563); the same owner coming
|
|
12559
|
+
* back writes again. Writes
|
|
12248
12560
|
* before anyone signs in stay anonymous and are restored while nobody is,
|
|
12249
12561
|
* so an app that persists logged-out data keeps doing so. An anonymous
|
|
12250
12562
|
* snapshot written by 0.82.0 is not restored (it may hold an expired
|
|
@@ -13213,6 +13525,57 @@ export { PathMatch }
|
|
|
13213
13525
|
|
|
13214
13526
|
export { PathPattern }
|
|
13215
13527
|
|
|
13528
|
+
/** What a card charge means to the payer, ready to render. */
|
|
13529
|
+
export declare interface PaymentOutcome {
|
|
13530
|
+
/** The canonical state the outcome was derived from. */
|
|
13531
|
+
status: PaymentStatus;
|
|
13532
|
+
/** Tone for the surrounding `Alert`/`Badge`. */
|
|
13533
|
+
tone: PaymentOutcomeTone;
|
|
13534
|
+
/** Short headline. */
|
|
13535
|
+
title: string;
|
|
13536
|
+
/** One sentence telling the payer what happened and what to do. */
|
|
13537
|
+
message: string;
|
|
13538
|
+
/** Whether the payer can fix it from the checkout (another card, other data). */
|
|
13539
|
+
canRetry: boolean;
|
|
13540
|
+
}
|
|
13541
|
+
|
|
13542
|
+
/** Visual tone of an outcome, matching `Alert`'s variants. */
|
|
13543
|
+
export declare type PaymentOutcomeTone = "success" | "info" | "warning" | "danger" | "neutral";
|
|
13544
|
+
|
|
13545
|
+
/** Who is paying — `PixPayer` in the backend, shared by Pix and card requests. */
|
|
13546
|
+
export declare interface PaymentPayer {
|
|
13547
|
+
/** Full name. */
|
|
13548
|
+
name?: string | null;
|
|
13549
|
+
/** CPF or CNPJ, digits or formatted. */
|
|
13550
|
+
tax_id?: string | null;
|
|
13551
|
+
/** E-mail. Mercado Pago requires it on a card charge (`payer.email`). */
|
|
13552
|
+
email?: string | null;
|
|
13553
|
+
/** Phone number. */
|
|
13554
|
+
phone?: string | null;
|
|
13555
|
+
}
|
|
13556
|
+
|
|
13557
|
+
/**
|
|
13558
|
+
* The payment contract as the `tempest-fastapi-sdk` backend serialises it.
|
|
13559
|
+
*
|
|
13560
|
+
* Every shape here is the JSON a service built on that SDK answers with — the
|
|
13561
|
+
* Pydantic schemas in `tempest_fastapi_sdk/integrations/payment/base.py`, dumped
|
|
13562
|
+
* with `model_dump(mode="json")`. The field names stay in snake_case because
|
|
13563
|
+
* `BaseSchema` declares no alias generator, so that is what crosses the wire;
|
|
13564
|
+
* renaming them here would make every app write a mapper that can drift.
|
|
13565
|
+
*
|
|
13566
|
+
* Datetimes arrive as ISO 8601 strings and money as integer cents, never as a
|
|
13567
|
+
* float: the backend refuses floats for money on purpose, and so does this side.
|
|
13568
|
+
*/
|
|
13569
|
+
/**
|
|
13570
|
+
* The canonical state of a charge — `PaymentStatusEnum` in the backend.
|
|
13571
|
+
*
|
|
13572
|
+
* `"unknown"` is a real state, not a fallback: the backend uses it for a
|
|
13573
|
+
* provider state its version does not classify, keeping the provider's own
|
|
13574
|
+
* string in `provider_status`. A screen should show it as "we are checking",
|
|
13575
|
+
* never as paid or failed.
|
|
13576
|
+
*/
|
|
13577
|
+
export declare type PaymentStatus = "pending" | "authorized" | "paid" | "expired" | "cancelled" | "refunded" | "charged_back" | "in_analysis" | "failed" | "unknown";
|
|
13578
|
+
|
|
13216
13579
|
/** Raw PCM ready to be wrapped in a RIFF container. */
|
|
13217
13580
|
export declare interface PcmAudio {
|
|
13218
13581
|
/** One `Float32Array` per channel, samples in −1…1. */
|
|
@@ -13512,6 +13875,100 @@ export declare type PinInputSize = "sm" | "md" | "lg";
|
|
|
13512
13875
|
|
|
13513
13876
|
export declare type PinInputType = "numeric" | "alphanumeric";
|
|
13514
13877
|
|
|
13878
|
+
/** A Pix charge — `PixCharge` in the backend. */
|
|
13879
|
+
export declare interface PixCharge {
|
|
13880
|
+
/** Provider that owns the charge (`"mercado_pago"`, `"openpix"`, …). */
|
|
13881
|
+
provider: string;
|
|
13882
|
+
/** The charge's id at the provider. */
|
|
13883
|
+
provider_charge_id: string;
|
|
13884
|
+
/** The service's own identifier for the charge. */
|
|
13885
|
+
reference: string;
|
|
13886
|
+
/** Amount in cents. */
|
|
13887
|
+
amount_cents: number;
|
|
13888
|
+
/** ISO 4217 code; `"BRL"` for Pix. */
|
|
13889
|
+
currency: string;
|
|
13890
|
+
/** Canonical state — the only field a screen branches on. */
|
|
13891
|
+
status: PaymentStatus;
|
|
13892
|
+
/** The provider's raw state, for support and logs. */
|
|
13893
|
+
provider_status: string;
|
|
13894
|
+
/** EMV copia-e-cola string. */
|
|
13895
|
+
br_code: string | null;
|
|
13896
|
+
/** QR as a Base64 PNG, without the `data:` prefix (Mercado Pago fills it). */
|
|
13897
|
+
qr_code_base64: string | null;
|
|
13898
|
+
/** QR as a URL (OpenPix fills it instead of the Base64). */
|
|
13899
|
+
qr_code_image_url: string | null;
|
|
13900
|
+
/** Pix end-to-end id, once the provider reports one. */
|
|
13901
|
+
end_to_end_id: string | null;
|
|
13902
|
+
/** When the charge stops being payable, ISO 8601. */
|
|
13903
|
+
expires_at: string | null;
|
|
13904
|
+
/** When it settled, ISO 8601. */
|
|
13905
|
+
paid_at: string | null;
|
|
13906
|
+
/** The provider's payload as decoded. A screen should not read it. */
|
|
13907
|
+
raw?: Record<string, unknown>;
|
|
13908
|
+
}
|
|
13909
|
+
|
|
13910
|
+
/**
|
|
13911
|
+
* The payer's Pix screen: amount, QR, copia-e-cola, countdown and the state the
|
|
13912
|
+
* backend reports.
|
|
13913
|
+
*
|
|
13914
|
+
* Presentational and controlled. It renders `charge` and never changes it, so
|
|
13915
|
+
* the decision that a Pix was paid stays where it can be made — on the backend,
|
|
13916
|
+
* re-reading the order. Feed it from {@link usePixCharge} or from your own
|
|
13917
|
+
* stream.
|
|
13918
|
+
*
|
|
13919
|
+
* The QR comes from `qr_code_base64` when the provider sent one (Mercado Pago),
|
|
13920
|
+
* and is otherwise drawn locally from `br_code` (OpenPix sends a URL instead,
|
|
13921
|
+
* and fetching it would hand the payload to an image host for nothing). The
|
|
13922
|
+
* copia-e-cola line is always next to it: a QR cannot be scanned by the phone
|
|
13923
|
+
* that is showing it, which is where a mobile checkout puts it.
|
|
13924
|
+
*
|
|
13925
|
+
* When the countdown reaches zero while the backend still says `pending`, the
|
|
13926
|
+
* screen hides the QR and says it is **confirming** — not "expired". A payment
|
|
13927
|
+
* sent in the last second can still settle, and only the backend knows.
|
|
13928
|
+
*
|
|
13929
|
+
* @example
|
|
13930
|
+
* const { charge } = usePixCharge(created, { refresh: (signal) => readCharge(created.provider_charge_id, signal) });
|
|
13931
|
+
* <PixCheckout charge={charge} />
|
|
13932
|
+
*/
|
|
13933
|
+
export declare function PixCheckout({ charge, qrSize, labels, formatRemaining, onCopied, footer, className, ...rest }: PixCheckoutProps): JSX.Element;
|
|
13934
|
+
|
|
13935
|
+
/** Strings the screen renders, so an app can translate them. */
|
|
13936
|
+
export declare interface PixCheckoutLabels {
|
|
13937
|
+
/** Accessible name of the QR. */
|
|
13938
|
+
qr: string;
|
|
13939
|
+
/** Heading over the copia-e-cola line. */
|
|
13940
|
+
copyHint: string;
|
|
13941
|
+
/** Copy button, idle. */
|
|
13942
|
+
copy: string;
|
|
13943
|
+
/** Copy button, just clicked. */
|
|
13944
|
+
copied: string;
|
|
13945
|
+
/** Prefix of the countdown, e.g. "Expira em". */
|
|
13946
|
+
expiresIn: string;
|
|
13947
|
+
/** Shown when the deadline passed but the backend has not said "expired" yet. */
|
|
13948
|
+
confirming: string;
|
|
13949
|
+
/** Title and description per terminal or waiting state. */
|
|
13950
|
+
states: Record<PaymentStatus, {
|
|
13951
|
+
title: string;
|
|
13952
|
+
description: string;
|
|
13953
|
+
}>;
|
|
13954
|
+
}
|
|
13955
|
+
|
|
13956
|
+
export declare interface PixCheckoutProps extends Omit<HTMLAttributes<HTMLDivElement>, "children"> {
|
|
13957
|
+
/** The charge as the backend reports it — pair with {@link usePixCharge} to follow it. */
|
|
13958
|
+
charge: PixCharge;
|
|
13959
|
+
/** Rendered side of the QR in px. Default `220`. */
|
|
13960
|
+
qrSize?: number;
|
|
13961
|
+
labels?: Partial<Omit<PixCheckoutLabels, "states">> & {
|
|
13962
|
+
states?: Partial<PixCheckoutLabels["states"]>;
|
|
13963
|
+
};
|
|
13964
|
+
/** Formats the countdown. Default {@link formatPixRemaining}. */
|
|
13965
|
+
formatRemaining?: (ms: number) => string;
|
|
13966
|
+
/** Called after the copia-e-cola reaches the clipboard. */
|
|
13967
|
+
onCopied?: () => void;
|
|
13968
|
+
/** Rendered under the status, e.g. a "gerar novo Pix" button for a final state. */
|
|
13969
|
+
footer?: ReactNode;
|
|
13970
|
+
}
|
|
13971
|
+
|
|
13515
13972
|
/** A pixel coordinate inside the plotting viewport. */
|
|
13516
13973
|
export declare interface PixelPoint {
|
|
13517
13974
|
x: number;
|
|
@@ -14911,8 +15368,11 @@ export declare interface ResumableUploadOptions {
|
|
|
14911
15368
|
* It is read again before every chunk and every record write: when it
|
|
14912
15369
|
* names someone else mid-run, the run stops with
|
|
14913
15370
|
* {@link ResumableUploadSupersededError} (`"principal"`) before the new
|
|
14914
|
-
* account's token reaches the previous one's upload URL. Without it,
|
|
14915
|
-
* `
|
|
15371
|
+
* account's token reaches the previous one's upload URL. Without it,
|
|
15372
|
+
* `createLocalUploadStorage().clear()` from `onSessionEnd` stops the runs in
|
|
15373
|
+
* flight and, since 0.84.0, makes a paused handle start over with a fresh
|
|
15374
|
+
* `Idempotency-Key`; with a custom `storage`, call `abort()` on the uploads
|
|
15375
|
+
* in progress there instead.
|
|
14916
15376
|
*/
|
|
14917
15377
|
getPrincipal?: () => string | number | null | undefined;
|
|
14918
15378
|
/**
|
|
@@ -17356,10 +17816,45 @@ export declare interface TempestAuth<TUser, TCredentials> {
|
|
|
17356
17816
|
/**
|
|
17357
17817
|
* Refresh the access token (deduplicated across concurrent callers).
|
|
17358
17818
|
*
|
|
17819
|
+
* When both the access token held and the one redeemed are JWTs with a
|
|
17820
|
+
* `sub` claim and the subjects differ, the redeemed credential — a refresh
|
|
17821
|
+
* cookie another sign-in replaced — belongs to another account. That is
|
|
17822
|
+
* an account switch, not a rotation: the held session ends with
|
|
17823
|
+
* `onSessionEnd` `"switch"`, the new one gets a lineage of its own and its
|
|
17824
|
+
* user is loaded, exactly as `login()` would; `refresh()` resolves with it
|
|
17825
|
+
* installed, and a `401` replay of the previous account's request rejects
|
|
17826
|
+
* with {@link SessionSupersededError} instead of going out as the new one
|
|
17827
|
+
* (#579). With opaque tokens there is no subject to compare, and the
|
|
17828
|
+
* redemption counts as a rotation — call `restore()` where a sign-in may
|
|
17829
|
+
* have happened outside `login()`.
|
|
17830
|
+
*
|
|
17359
17831
|
* @throws {SessionSupersededError} When the session ended or changed while
|
|
17360
17832
|
* the refresh was in flight; its tokens were discarded.
|
|
17361
17833
|
*/
|
|
17362
17834
|
refresh: () => Promise<void>;
|
|
17835
|
+
/**
|
|
17836
|
+
* Redeem the refresh credential as a **new sign-in**: whatever it signs in
|
|
17837
|
+
* replaces the session installed now, like `login()` with no credentials.
|
|
17838
|
+
*
|
|
17839
|
+
* For the point where the app knows a sign-in happened outside `login()`
|
|
17840
|
+
* — the OAuth or magic-link callback that set the refresh cookie. The
|
|
17841
|
+
* session held, if any, ends with `onSessionEnd` `"switch"` only once the
|
|
17842
|
+
* redemption succeeded, the new one gets a lineage of its own, and the
|
|
17843
|
+
* user is loaded (`parseUser`, then `mePath`). A failed redemption leaves
|
|
17844
|
+
* the held session untouched.
|
|
17845
|
+
*
|
|
17846
|
+
* `refresh()` cannot make that call on its own when tokens are opaque: a
|
|
17847
|
+
* rotation of the same account and another account's cookie look alike,
|
|
17848
|
+
* and comparing `mePath` users would cost a request per rotation and
|
|
17849
|
+
* reopen #544. So the boot keeps `refresh()` — a reload must not end the
|
|
17850
|
+
* session — and the callback uses this. Called where no sign-in happened,
|
|
17851
|
+
* it costs a needless switch: an upload bound to the session starts over.
|
|
17852
|
+
*
|
|
17853
|
+
* @returns The user of the new session, or null.
|
|
17854
|
+
* @throws {SessionSupersededError} When a `logout()` or `login()` moved
|
|
17855
|
+
* the session while it was in flight; the new tokens are discarded.
|
|
17856
|
+
*/
|
|
17857
|
+
restore: () => Promise<TUser | null>;
|
|
17363
17858
|
/** The current access token, or null. */
|
|
17364
17859
|
getToken: () => string | null;
|
|
17365
17860
|
/**
|
|
@@ -17382,6 +17877,11 @@ export declare interface TempestAuth<TUser, TCredentials> {
|
|
|
17382
17877
|
* answered one constant for every account, and an upload bound by
|
|
17383
17878
|
* `getToken: auth.getToken` was resumed by the next account restored the
|
|
17384
17879
|
* same way.
|
|
17880
|
+
*
|
|
17881
|
+
* A `refresh()` that redeems another account while a session is installed
|
|
17882
|
+
* changes the key too, when JWT subjects tell the accounts apart; with
|
|
17883
|
+
* opaque tokens `restore()` is the call that does (#579). Until 0.83.0 such
|
|
17884
|
+
* a redemption kept the previous account's key.
|
|
17385
17885
|
*/
|
|
17386
17886
|
sessionKey: () => string | null;
|
|
17387
17887
|
/**
|
|
@@ -18517,8 +19017,9 @@ export declare interface UploadProgressEvent {
|
|
|
18517
19017
|
*
|
|
18518
19018
|
* An `XMLHttpRequest` cannot refuse a redirect; see
|
|
18519
19019
|
* {@link UploadWithProgressOptions.redirect} for what follows one, what the
|
|
18520
|
-
* helper still refuses,
|
|
18521
|
-
* following
|
|
19020
|
+
* helper still refuses, the `fetch` path that trades progress for never
|
|
19021
|
+
* following, and when that path is the default (fixed headers and no
|
|
19022
|
+
* `onProgress`, since 0.84.0).
|
|
18522
19023
|
*
|
|
18523
19024
|
* @returns The parsed JSON response, or the raw text when the response is not JSON.
|
|
18524
19025
|
*/
|
|
@@ -18574,30 +19075,41 @@ export declare interface UploadWithProgressOptions {
|
|
|
18574
19075
|
*/
|
|
18575
19076
|
requestId?: () => string;
|
|
18576
19077
|
/**
|
|
18577
|
-
* What to do when the server answers with a redirect.
|
|
19078
|
+
* What to do when the server answers with a redirect. When unset, the
|
|
19079
|
+
* helper picks: `"error"` when {@link headers} carry anything besides the
|
|
19080
|
+
* headers it exempts (`Authorization`, `X-Request-ID`, `Content-Type` and
|
|
19081
|
+
* `X-CSRF-Token`) **and** no {@link onProgress} was given, `"follow"`
|
|
19082
|
+
* otherwise (since 0.84.0). A value passed here always wins.
|
|
18578
19083
|
*
|
|
18579
19084
|
* - `"follow"` — the `XMLHttpRequest` path, with byte-level progress. The
|
|
18580
19085
|
* browser follows every redirect and offers no way to stop it: measured
|
|
18581
|
-
* in Chrome 150
|
|
18582
|
-
*
|
|
18583
|
-
*
|
|
18584
|
-
* the
|
|
18585
|
-
*
|
|
18586
|
-
*
|
|
19086
|
+
* in Chrome 150, and again in Chromium 153, Firefox 155 and WebKit 26.6
|
|
19087
|
+
* (#570), a same-origin upload answered `301`/`302`/`303`/`307`/`308`
|
|
19088
|
+
* towards another origin delivered `X-Api-Key` from {@link headers} and
|
|
19089
|
+
* the SDK's own `X-CSRF-Token` there on all five, and the body on
|
|
19090
|
+
* `307`/`308`; only `Authorization` was stripped. What this path does
|
|
19091
|
+
* enforce (since 0.83.0): an answer from another origin than the one the
|
|
19092
|
+
* request was sent to is never the result — it rejects with
|
|
18587
19093
|
* `code: "REDIRECT_REFUSED"`, so that host cannot hand the app a URL to
|
|
18588
19094
|
* store. Until 0.82.0 it resolved with the other host's body.
|
|
18589
19095
|
* - `"error"` — goes out over `fetch` with `redirect: "manual"`, and a
|
|
18590
19096
|
* redirect rejects with `code: "REDIRECT_REFUSED"` before anything is
|
|
18591
19097
|
* sent to the other host. The cost: `fetch` reports no upload progress,
|
|
18592
|
-
* so `onProgress` fires once, when the server confirms the whole body
|
|
19098
|
+
* so `onProgress` fires once, when the server confirms the whole body,
|
|
19099
|
+
* and a same-origin redirect (FastAPI's trailing-slash `307`) is refused
|
|
19100
|
+
* too — a browser hands it back opaque, with no readable `Location`. A
|
|
18593
19101
|
* streamed `fetch` body would report progress, but Chrome refuses one
|
|
18594
19102
|
* over HTTP/1.1 (`TypeError: Failed to fetch`, measured) and Firefox and
|
|
18595
19103
|
* Safari do not support it.
|
|
18596
19104
|
*
|
|
18597
|
-
*
|
|
18598
|
-
* the
|
|
18599
|
-
*
|
|
18600
|
-
* `
|
|
19105
|
+
* Why the default depends on `onProgress`: progress is the only thing the
|
|
19106
|
+
* XHR path buys, and the leak is its price. A caller that asked for no
|
|
19107
|
+
* progress paid that price for nothing, so its fixed headers get the
|
|
19108
|
+
* treatment `createApiClient` (#560) and `createResumableUpload` (#568)
|
|
19109
|
+
* give theirs. A caller that wants progress keeps it, and the guarantee is
|
|
19110
|
+
* one `redirect: "error"` away. Sending the bearer through
|
|
19111
|
+
* {@link getToken} keeps `"follow"` safe for it, because the browser
|
|
19112
|
+
* strips `Authorization` on a cross-origin redirect.
|
|
18601
19113
|
*/
|
|
18602
19114
|
redirect?: "follow" | "error";
|
|
18603
19115
|
}
|
|
@@ -20030,6 +20542,95 @@ export declare interface UseMediaPermissionResult {
|
|
|
20030
20542
|
*/
|
|
20031
20543
|
export declare function useMediaQuery(query: string): boolean;
|
|
20032
20544
|
|
|
20545
|
+
/**
|
|
20546
|
+
* Card tokenization with MercadoPago.js **Secure Fields**, plus installments by BIN.
|
|
20547
|
+
*
|
|
20548
|
+
* The card number, expiry and CVV are typed into iframes served by Mercado Pago,
|
|
20549
|
+
* so they never exist in this page's DOM, in React state, in a callback argument
|
|
20550
|
+
* or in a log line — not even transiently. That is the property the PCI DSS
|
|
20551
|
+
* scoping depends on: a page that renders its own `<input>` for the number and
|
|
20552
|
+
* calls `createCardToken` with it has handled cardholder data and is in the
|
|
20553
|
+
* heavier SAQ A-EP scope, however quickly it discards the value. The backend
|
|
20554
|
+
* never sees the card either: it receives the token, the brand and the
|
|
20555
|
+
* installments, which is exactly `CardChargeRequest`.
|
|
20556
|
+
*
|
|
20557
|
+
* The only digits the hook learns are the BIN (first 6–8), which Mercado Pago's
|
|
20558
|
+
* `binChange` event exposes precisely so the page can quote installments; it is
|
|
20559
|
+
* used for the lookup and not returned. Installment options come from the
|
|
20560
|
+
* provider with its own `recommended_message`, because interest starts at 2x
|
|
20561
|
+
* (measured in the sandbox) and the total the payer sees has to be the
|
|
20562
|
+
* provider's number, not one recomputed here.
|
|
20563
|
+
*
|
|
20564
|
+
* The containers must be in the DOM when the hook's effect runs — render the
|
|
20565
|
+
* three empty elements in the same component. The fields are created once per
|
|
20566
|
+
* `publicKey`; changing the containers, locale or loader afterwards does not
|
|
20567
|
+
* remount them.
|
|
20568
|
+
*
|
|
20569
|
+
* @tempest-limits empty-catch — `unmount()` throws when MercadoPago.js already
|
|
20570
|
+
* tore the iframe down (a container removed by React first). The cleanup has
|
|
20571
|
+
* nothing left to undo in that case and nowhere useful to report it.
|
|
20572
|
+
*
|
|
20573
|
+
* @param options - Public key, amount, container ids and an injectable loader.
|
|
20574
|
+
* @returns Field status, brand, installment options and `tokenize`.
|
|
20575
|
+
*
|
|
20576
|
+
* @example
|
|
20577
|
+
* const card = useMercadoPagoCard({
|
|
20578
|
+
* publicKey: import.meta.env.VITE_MP_PUBLIC_KEY,
|
|
20579
|
+
* amountCents: 10964,
|
|
20580
|
+
* containers: { cardNumber: "mp-number", expirationDate: "mp-expiry", securityCode: "mp-cvv" },
|
|
20581
|
+
* });
|
|
20582
|
+
* const { token, payment_method_id, installments } = await card.tokenize({
|
|
20583
|
+
* cardholderName: "APRO",
|
|
20584
|
+
* installments: 1,
|
|
20585
|
+
* identificationType: "CPF",
|
|
20586
|
+
* identificationNumber: "12345678909",
|
|
20587
|
+
* });
|
|
20588
|
+
*/
|
|
20589
|
+
export declare function useMercadoPagoCard(options: UseMercadoPagoCardOptions): UseMercadoPagoCardResult;
|
|
20590
|
+
|
|
20591
|
+
/** Options for {@link useMercadoPagoCard}. */
|
|
20592
|
+
export declare interface UseMercadoPagoCardOptions {
|
|
20593
|
+
/**
|
|
20594
|
+
* The application's **Public Key** — never the access token. It is meant to
|
|
20595
|
+
* be public: it can only tokenize, and the token is useless without the
|
|
20596
|
+
* access token that stays on the backend.
|
|
20597
|
+
*/
|
|
20598
|
+
publicKey: string;
|
|
20599
|
+
/** The price in cents, used to quote installments. */
|
|
20600
|
+
amountCents: number;
|
|
20601
|
+
/** Ids of the empty elements the card number, expiry and CVV iframes mount into. */
|
|
20602
|
+
containers: MercadoPagoCardContainers;
|
|
20603
|
+
/** MercadoPago.js locale. Default `"pt-BR"`. */
|
|
20604
|
+
locale?: string;
|
|
20605
|
+
/** Per-field options (placeholder, inline style). */
|
|
20606
|
+
fieldOptions?: Partial<Record<MercadoPagoFieldType, MercadoPagoFieldOptions>>;
|
|
20607
|
+
/** Loads the constructor. Default {@link loadMercadoPago}; tests pass a fake. */
|
|
20608
|
+
load?: () => Promise<MercadoPagoConstructor>;
|
|
20609
|
+
}
|
|
20610
|
+
|
|
20611
|
+
/** Return value of {@link useMercadoPagoCard}. */
|
|
20612
|
+
export declare interface UseMercadoPagoCardResult {
|
|
20613
|
+
/** `"ready"` once all three fields are mounted. */
|
|
20614
|
+
status: MercadoPagoCardStatus;
|
|
20615
|
+
/** Why loading or mounting failed. */
|
|
20616
|
+
error: Error | null;
|
|
20617
|
+
/** Brand detected from the BIN, or `null` until the payer types enough digits. */
|
|
20618
|
+
paymentMethodId: string | null;
|
|
20619
|
+
/** Installment choices for the current BIN and amount; empty until known. */
|
|
20620
|
+
installmentOptions: CardInstallmentOption[];
|
|
20621
|
+
/** `true` while the installments for a new BIN are being fetched. */
|
|
20622
|
+
installmentsLoading: boolean;
|
|
20623
|
+
/** Why the installment lookup failed, if it did. */
|
|
20624
|
+
installmentsError: Error | null;
|
|
20625
|
+
/**
|
|
20626
|
+
* Ask Mercado Pago for a card token. Throws when the fields are not ready,
|
|
20627
|
+
* the BIN has not been identified, or `installments` is not one of the
|
|
20628
|
+
* offered options — each of which would otherwise surface later as an
|
|
20629
|
+
* opaque `400` from the backend.
|
|
20630
|
+
*/
|
|
20631
|
+
tokenize: (input: CardTokenizeInput) => Promise<CardTokenResult>;
|
|
20632
|
+
}
|
|
20633
|
+
|
|
20033
20634
|
/**
|
|
20034
20635
|
* Acquire a microphone `MediaStream`, classified errors included, and release it
|
|
20035
20636
|
* properly.
|
|
@@ -20663,6 +21264,59 @@ export declare interface UsePasskeySignInResult<TResult> extends PasskeyCapabili
|
|
|
20663
21264
|
reset: () => void;
|
|
20664
21265
|
}
|
|
20665
21266
|
|
|
21267
|
+
/**
|
|
21268
|
+
* Follow a Pix charge until the backend says it is final.
|
|
21269
|
+
*
|
|
21270
|
+
* The browser never decides that a Pix was paid: there is no client-side signal
|
|
21271
|
+
* that could prove it, and a screen that infers "paid" from a countdown or a
|
|
21272
|
+
* copy click is a screen that ships goods for free. This hook only relays what
|
|
21273
|
+
* the app's `refresh`/`subscribe` report, and stops polling once the status is
|
|
21274
|
+
* final (`paid`, `expired`, `cancelled`, `refunded`, `charged_back`, `failed`).
|
|
21275
|
+
*
|
|
21276
|
+
* Polling is sequential — the next request starts `intervalMs` after the
|
|
21277
|
+
* previous one settled — so a slow backend is never hit by overlapping reads.
|
|
21278
|
+
* A failed read keeps the last good charge and is exposed as `error`; the poll
|
|
21279
|
+
* goes on, because a dropped request is not a payment state.
|
|
21280
|
+
*
|
|
21281
|
+
* Passing a charge with a different `provider_charge_id` restarts the follow.
|
|
21282
|
+
*
|
|
21283
|
+
* @param initial - The charge as created.
|
|
21284
|
+
* @param options - `refresh`, `subscribe` and the poll period.
|
|
21285
|
+
* @returns The latest charge and the last read error.
|
|
21286
|
+
*
|
|
21287
|
+
* @example
|
|
21288
|
+
* const { charge } = usePixCharge(created, {
|
|
21289
|
+
* refresh: (signal) => api.get<PixCharge>(`/api/pix/${created.provider_charge_id}`, { signal }),
|
|
21290
|
+
* });
|
|
21291
|
+
* return <PixCheckout charge={charge} />;
|
|
21292
|
+
*/
|
|
21293
|
+
export declare function usePixCharge(initial: PixCharge, options?: UsePixChargeOptions): UsePixChargeResult;
|
|
21294
|
+
|
|
21295
|
+
/** Options for {@link usePixCharge}. */
|
|
21296
|
+
export declare interface UsePixChargeOptions {
|
|
21297
|
+
/**
|
|
21298
|
+
* Re-reads the charge from **your backend** — which re-reads it from the
|
|
21299
|
+
* provider. Called every `intervalMs` until the charge is final. The signal
|
|
21300
|
+
* aborts when the component unmounts or the charge changes.
|
|
21301
|
+
*/
|
|
21302
|
+
refresh?: (signal: AbortSignal) => Promise<PixCharge>;
|
|
21303
|
+
/**
|
|
21304
|
+
* Pushes updates instead of polling — an SSE stream, a WebSocket. Receives
|
|
21305
|
+
* the emitter and returns its own cleanup. Can be combined with `refresh`.
|
|
21306
|
+
*/
|
|
21307
|
+
subscribe?: (emit: (charge: PixCharge) => void) => () => void;
|
|
21308
|
+
/** Poll period in ms. Default `5000`. */
|
|
21309
|
+
intervalMs?: number;
|
|
21310
|
+
}
|
|
21311
|
+
|
|
21312
|
+
/** Return value of {@link usePixCharge}. */
|
|
21313
|
+
export declare interface UsePixChargeResult {
|
|
21314
|
+
/** The latest charge the backend reported. */
|
|
21315
|
+
charge: PixCharge;
|
|
21316
|
+
/** The last `refresh` failure, cleared by the next success. Polling continues after it. */
|
|
21317
|
+
error: Error | null;
|
|
21318
|
+
}
|
|
21319
|
+
|
|
20666
21320
|
/**
|
|
20667
21321
|
* Poll an async factory on a fixed interval. Skips overlapping requests if a
|
|
20668
21322
|
* prior call has not finished. Pause via `disabled` or `stopWhen`.
|