@hook-sdk/template 0.18.0 → 0.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +13 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15 -1
- package/dist/index.d.ts +15 -1
- package/dist/index.js +13 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -723,7 +723,21 @@ declare function shouldBlockInstall(state: InstallState, now?: number): boolean;
|
|
|
723
723
|
*/
|
|
724
724
|
declare function shouldShowPermanentOption(state: InstallState): boolean;
|
|
725
725
|
|
|
726
|
-
|
|
726
|
+
/**
|
|
727
|
+
* Map Asaas error → PT-BR user-facing message.
|
|
728
|
+
*
|
|
729
|
+
* Two inputs because backend folds Asaas's specific error code into a
|
|
730
|
+
* compound code (`payments.capture_card.tokenize_failed:invalid_holderInfo`)
|
|
731
|
+
* and only the *description* string ("O CEP informado é inválido.")
|
|
732
|
+
* distinguishes between sub-cases of `invalid_holderInfo` (CEP, phone, name).
|
|
733
|
+
*
|
|
734
|
+
* Asaas keeps a snapshot of Correios CEPs that lags real registrations by
|
|
735
|
+
* months — CEPs of recently-cadastrated streets (ex: bairros novos) get
|
|
736
|
+
* rejected even though they're valid in ViaCEP/BrasilAPI. We don't suggest
|
|
737
|
+
* a fictitious CEP (would mess up nota fiscal/comms); we explain the issue
|
|
738
|
+
* is on the processor's side and ask user to try a nearby street's CEP.
|
|
739
|
+
*/
|
|
740
|
+
declare function asaasErrorMessage(code: string, description?: string): string;
|
|
727
741
|
|
|
728
742
|
type RouteBoundaryProps = {
|
|
729
743
|
children: ReactNode;
|
package/dist/index.d.ts
CHANGED
|
@@ -723,7 +723,21 @@ declare function shouldBlockInstall(state: InstallState, now?: number): boolean;
|
|
|
723
723
|
*/
|
|
724
724
|
declare function shouldShowPermanentOption(state: InstallState): boolean;
|
|
725
725
|
|
|
726
|
-
|
|
726
|
+
/**
|
|
727
|
+
* Map Asaas error → PT-BR user-facing message.
|
|
728
|
+
*
|
|
729
|
+
* Two inputs because backend folds Asaas's specific error code into a
|
|
730
|
+
* compound code (`payments.capture_card.tokenize_failed:invalid_holderInfo`)
|
|
731
|
+
* and only the *description* string ("O CEP informado é inválido.")
|
|
732
|
+
* distinguishes between sub-cases of `invalid_holderInfo` (CEP, phone, name).
|
|
733
|
+
*
|
|
734
|
+
* Asaas keeps a snapshot of Correios CEPs that lags real registrations by
|
|
735
|
+
* months — CEPs of recently-cadastrated streets (ex: bairros novos) get
|
|
736
|
+
* rejected even though they're valid in ViaCEP/BrasilAPI. We don't suggest
|
|
737
|
+
* a fictitious CEP (would mess up nota fiscal/comms); we explain the issue
|
|
738
|
+
* is on the processor's side and ask user to try a nearby street's CEP.
|
|
739
|
+
*/
|
|
740
|
+
declare function asaasErrorMessage(code: string, description?: string): string;
|
|
727
741
|
|
|
728
742
|
type RouteBoundaryProps = {
|
|
729
743
|
children: ReactNode;
|
package/dist/index.js
CHANGED
|
@@ -196,7 +196,16 @@ var MAP = {
|
|
|
196
196
|
pix_expired: "QR Code do PIX expirou. Gere um novo.",
|
|
197
197
|
pix_not_paid_yet: "PIX ainda n\xE3o foi pago. Aguardando confirma\xE7\xE3o."
|
|
198
198
|
};
|
|
199
|
-
function asaasErrorMessage(code) {
|
|
199
|
+
function asaasErrorMessage(code, description) {
|
|
200
|
+
if (description) {
|
|
201
|
+
const lower = description.toLowerCase();
|
|
202
|
+
if (lower.includes("cep")) {
|
|
203
|
+
return "Nosso processador de pagamentos n\xE3o reconheceu esse CEP \u2014 a base deles pode estar desatualizada. Tente outro CEP.";
|
|
204
|
+
}
|
|
205
|
+
if (lower.includes("telefone") || lower.includes("contato com ddd")) {
|
|
206
|
+
return "Telefone inv\xE1lido. Confira o n\xFAmero com DDD e tente novamente.";
|
|
207
|
+
}
|
|
208
|
+
}
|
|
200
209
|
return MAP[code] ?? "Ocorreu um erro inesperado. Tente novamente em instantes.";
|
|
201
210
|
}
|
|
202
211
|
|
|
@@ -325,7 +334,9 @@ function usePaywallState() {
|
|
|
325
334
|
(code, fallbackMessage) => ({
|
|
326
335
|
code,
|
|
327
336
|
message: fallbackMessage,
|
|
328
|
-
|
|
337
|
+
// fallbackMessage carries Asaas's PT-BR description ("O CEP informado é inválido.")
|
|
338
|
+
// that distinguishes invalid_holderInfo sub-cases (CEP vs phone vs name).
|
|
339
|
+
userMessage: useDefaultMessages ? asaasErrorMessage(code, fallbackMessage) : fallbackMessage
|
|
329
340
|
}),
|
|
330
341
|
[useDefaultMessages]
|
|
331
342
|
);
|