@miguelmorales13/nestkit 0.26.0 → 0.29.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 +69 -0
- package/dist/alerts/alert-on-failure.decorator.d.ts +5 -0
- package/dist/alerts/alert-sinks.d.ts +29 -0
- package/dist/alerts/alerts.module.d.ts +19 -0
- package/dist/alerts/alerts.options.d.ts +1 -0
- package/dist/alerts/alerts.service.d.ts +28 -0
- package/dist/alerts/alerts.types.d.ts +66 -0
- package/dist/alerts/index.cjs +276 -0
- package/dist/alerts/index.d.ts +10 -0
- package/dist/alerts/index.js +276 -0
- package/dist/alerts/logger-with-alerts.d.ts +18 -0
- package/dist/alerts/process-guards.d.ts +21 -0
- package/dist/alerts/runtime.d.ts +4 -0
- package/dist/audit/index.cjs +13 -13
- package/dist/audit/index.js +2 -2
- package/dist/auth/index.cjs +21 -21
- package/dist/auth/index.js +3 -3
- package/dist/auth/oauth/index.cjs +101 -101
- package/dist/auth/oauth/index.js +3 -3
- package/dist/bootstrap/apply-defaults.d.ts +9 -0
- package/dist/bootstrap/index.cjs +7 -6
- package/dist/bootstrap/index.js +6 -5
- package/dist/chunk-33KFVAUZ.cjs +151 -0
- package/dist/chunk-3TUMVLPJ.js +14 -0
- package/dist/{chunk-PA24P76K.js → chunk-45SW7FBE.js} +1 -1
- package/dist/{chunk-RF75KC63.cjs → chunk-47IYXZHW.cjs} +2 -2
- package/dist/{chunk-TUNDBBQF.js → chunk-4WWOKZIO.js} +4 -4
- package/dist/{chunk-2DUEQKOI.js → chunk-5LVGCTJ3.js} +4 -4
- package/dist/chunk-A6YGIZCQ.cjs +14 -0
- package/dist/chunk-A7FI6HXV.js +40 -0
- package/dist/chunk-CU4FUIVJ.cjs +8 -0
- package/dist/{chunk-FH5UNWWW.cjs → chunk-D35TBVRO.cjs} +4 -4
- package/dist/{chunk-4MGIQFAJ.js → chunk-D3DDJWUD.js} +5 -0
- package/dist/chunk-DVGPEBUL.js +8 -0
- package/dist/{chunk-VKOPDDCC.js → chunk-ENZ7LQRE.js} +1 -1
- package/dist/{chunk-3AUOOEQO.cjs → chunk-F77X4QUN.cjs} +2 -2
- package/dist/chunk-FBNV5X6C.js +61 -0
- package/dist/{chunk-APUFKA4K.cjs → chunk-FDZQCLLK.cjs} +6 -6
- package/dist/{chunk-DYHSOULW.js → chunk-IGSNB5BX.js} +1 -1
- package/dist/chunk-IVWPA6QH.cjs +90 -0
- package/dist/{chunk-LSDY6ETG.cjs → chunk-JJKGQNGD.cjs} +5 -5
- package/dist/{chunk-ALIKVFOV.cjs → chunk-JRFE7NSO.cjs} +12 -4
- package/dist/{chunk-HVHYZXBB.cjs → chunk-KNU5RN3O.cjs} +3 -3
- package/dist/{chunk-52IOOHNX.cjs → chunk-KQPJCVN3.cjs} +26 -26
- package/dist/chunk-LGFHLAY3.cjs +61 -0
- package/dist/{chunk-2REOCMUD.cjs → chunk-LRX7AMSS.cjs} +6 -1
- package/dist/chunk-LU3HO7B3.js +151 -0
- package/dist/{chunk-4PFAKLT3.js → chunk-MUWHGBIB.js} +1 -1
- package/dist/{chunk-ZJMLEP5H.js → chunk-NJYLQDB3.js} +1 -1
- package/dist/{chunk-IFNYRZP2.js → chunk-OSRH6KYZ.js} +4 -4
- package/dist/{chunk-6RAPVLJM.js → chunk-OTE77ONL.js} +1 -1
- package/dist/chunk-UDACUMLO.cjs +40 -0
- package/dist/{chunk-PFHHLB7B.js → chunk-UGAAJRPO.js} +10 -2
- package/dist/{chunk-SPTDXUED.cjs → chunk-URLDTS2Q.cjs} +2 -2
- package/dist/{chunk-W2T2VFLC.cjs → chunk-VALDHJOO.cjs} +5 -5
- package/dist/chunk-WFCQDOSN.js +90 -0
- package/dist/consent/consent.interceptor.d.ts +20 -0
- package/dist/consent/consent.module.d.ts +25 -0
- package/dist/consent/consent.options.d.ts +30 -0
- package/dist/consent/consent.port.d.ts +17 -0
- package/dist/consent/consent.service.d.ts +44 -0
- package/dist/consent/guard/index.cjs +13 -0
- package/dist/consent/guard/index.d.ts +31 -0
- package/dist/consent/guard/index.js +13 -0
- package/dist/consent/index.cjs +271 -0
- package/dist/consent/index.d.ts +13 -0
- package/dist/consent/index.js +271 -0
- package/dist/consent/memory.store.d.ts +7 -0
- package/dist/consent/shared/index.cjs +11 -0
- package/dist/consent/shared/index.d.ts +19 -0
- package/dist/consent/shared/index.js +11 -0
- package/dist/consent/typeorm.store.d.ts +22 -0
- package/dist/crud/index.cjs +4 -4
- package/dist/crud/index.js +3 -3
- package/dist/database/postgres/index.cjs +3 -3
- package/dist/database/postgres/index.js +2 -2
- package/dist/database/supabase/index.cjs +3 -3
- package/dist/database/supabase/index.js +2 -2
- package/dist/database/typeorm/index.cjs +2 -2
- package/dist/database/typeorm/index.js +1 -1
- package/dist/devices/device-check.interceptor.d.ts +20 -0
- package/dist/devices/devices.module.d.ts +28 -0
- package/dist/devices/devices.options.d.ts +53 -0
- package/dist/devices/devices.port.d.ts +62 -0
- package/dist/devices/devices.service.d.ts +58 -0
- package/dist/devices/index.cjs +327 -0
- package/dist/devices/index.d.ts +8 -0
- package/dist/devices/index.js +327 -0
- package/dist/devices/memory.store.d.ts +12 -0
- package/dist/email/index.cjs +2 -2
- package/dist/email/index.js +1 -1
- package/dist/email/nodemailer/index.cjs +2 -2
- package/dist/email/nodemailer/index.js +1 -1
- package/dist/email/resend/index.cjs +2 -2
- package/dist/email/resend/index.js +1 -1
- package/dist/entities/index.cjs +1 -1
- package/dist/entities/index.js +1 -1
- package/dist/errors/index.cjs +7 -7
- package/dist/errors/index.js +7 -7
- package/dist/events/buses.d.ts +27 -0
- package/dist/events/events.controller.d.ts +15 -0
- package/dist/events/events.module.d.ts +29 -0
- package/dist/events/events.options.d.ts +50 -0
- package/dist/events/events.service.d.ts +49 -0
- package/dist/events/events.types.d.ts +77 -0
- package/dist/events/index.cjs +557 -0
- package/dist/events/index.d.ts +10 -0
- package/dist/events/index.js +557 -0
- package/dist/events/memory-ticket.store.d.ts +9 -0
- package/dist/google-business/google-business-http.d.ts +41 -0
- package/dist/google-business/google-business.errors.d.ts +75 -0
- package/dist/google-business/google-business.mappers.d.ts +52 -0
- package/dist/google-business/google-business.module.d.ts +26 -0
- package/dist/google-business/google-business.options.d.ts +40 -0
- package/dist/google-business/google-business.ports.d.ts +18 -0
- package/dist/google-business/google-business.service.d.ts +120 -0
- package/dist/google-business/google-business.types.d.ts +155 -0
- package/dist/google-business/index.cjs +1025 -0
- package/dist/google-business/index.d.ts +15 -0
- package/dist/google-business/index.js +1025 -0
- package/dist/google-business/testing/google-simulator.d.ts +61 -0
- package/dist/hardening/body-limits.d.ts +24 -0
- package/dist/hardening/http.types.d.ts +26 -0
- package/dist/hardening/index.cjs +179 -0
- package/dist/hardening/index.d.ts +19 -0
- package/dist/hardening/index.js +179 -0
- package/dist/hardening/memory-rate-limit.store.d.ts +10 -0
- package/dist/hardening/origin-secret.d.ts +29 -0
- package/dist/hardening/rate-limit.decorator.d.ts +8 -0
- package/dist/hardening/rate-limit.guard.d.ts +18 -0
- package/dist/hardening/rate-limit.module.d.ts +23 -0
- package/dist/hardening/rate-limit.options.d.ts +35 -0
- package/dist/hardening/rate-limit.port.d.ts +11 -0
- package/dist/hardening/redis-rate-limit.store.d.ts +23 -0
- package/dist/hardening/trust-proxy.d.ts +22 -0
- package/dist/health/health.controller.d.ts +32 -0
- package/dist/health/health.module.d.ts +15 -0
- package/dist/health/health.options.d.ts +24 -0
- package/dist/health/index.cjs +103 -0
- package/dist/health/index.d.ts +5 -0
- package/dist/health/index.js +103 -0
- package/dist/i18n/index.cjs +3 -3
- package/dist/i18n/index.js +2 -2
- package/dist/idempotency/idempotency.interceptor.d.ts +1 -0
- package/dist/idempotency/idempotency.options.d.ts +15 -0
- package/dist/idempotency/index.cjs +214 -7
- package/dist/idempotency/index.d.ts +5 -0
- package/dist/idempotency/index.js +210 -3
- package/dist/idempotency/no-idempotency.decorator.d.ts +8 -0
- package/dist/idempotency/postgres.store.d.ts +49 -0
- package/dist/idempotency/redis.store.d.ts +59 -0
- package/dist/index.cjs +21 -20
- package/dist/index.js +33 -32
- package/dist/invoicing/index.cjs +2 -2
- package/dist/invoicing/index.js +1 -1
- package/dist/jobs/defer-job.d.ts +10 -0
- package/dist/jobs/index.cjs +318 -0
- package/dist/jobs/index.d.ts +8 -0
- package/dist/jobs/index.js +318 -0
- package/dist/jobs/jobs-admin.controller.d.ts +18 -0
- package/dist/jobs/jobs.module.d.ts +33 -0
- package/dist/jobs/jobs.options.d.ts +62 -0
- package/dist/jobs/jobs.service.d.ts +53 -0
- package/dist/jobs/jobs.sql.d.ts +11 -0
- package/dist/media/index.cjs +14 -14
- package/dist/media/index.js +1 -1
- package/dist/meta/index.cjs +3 -3
- package/dist/meta/index.js +1 -1
- package/dist/notifications/index.cjs +375 -0
- package/dist/notifications/index.d.ts +8 -0
- package/dist/notifications/index.js +375 -0
- package/dist/notifications/memory.stores.d.ts +23 -0
- package/dist/notifications/notifications.controller.d.ts +11 -0
- package/dist/notifications/notifications.module.d.ts +31 -0
- package/dist/notifications/notifications.options.d.ts +33 -0
- package/dist/notifications/notifications.port.d.ts +97 -0
- package/dist/notifications/notifier.service.d.ts +31 -0
- package/dist/payments/connect/credentials-cipher.d.ts +14 -0
- package/dist/payments/connect/mercadopago-refund.d.ts +118 -0
- package/dist/payments/connect/mercadopago-signature.d.ts +6 -0
- package/dist/payments/connect/online-checkout.d.ts +69 -0
- package/dist/payments/connect/rejection.d.ts +7 -0
- package/dist/payments/connect/status.d.ts +20 -0
- package/dist/payments/connect/terminal-connections.d.ts +291 -0
- package/dist/payments/index.cjs +908 -10
- package/dist/payments/index.d.ts +10 -0
- package/dist/payments/index.js +900 -2
- package/dist/pinterest/index.cjs +3 -3
- package/dist/pinterest/index.js +1 -1
- package/dist/privacy/anonymizer.d.ts +14 -0
- package/dist/privacy/index.cjs +768 -0
- package/dist/privacy/index.d.ts +13 -0
- package/dist/privacy/index.js +768 -0
- package/dist/privacy/memory.store.d.ts +15 -0
- package/dist/privacy/privacy.module.d.ts +30 -0
- package/dist/privacy/privacy.options.d.ts +43 -0
- package/dist/privacy/privacy.port.d.ts +25 -0
- package/dist/privacy/privacy.service.d.ts +69 -0
- package/dist/privacy/privacy.types.d.ts +125 -0
- package/dist/privacy/sql.d.ts +7 -0
- package/dist/privacy/sql.store.d.ts +21 -0
- package/dist/privacy/zip.d.ts +23 -0
- package/dist/push/index.cjs +13 -13
- package/dist/push/index.js +5 -5
- package/dist/resilience/alert-channels.d.ts +39 -0
- package/dist/resilience/alert-errors.interceptor.d.ts +10 -0
- package/dist/resilience/alert-on-failure.decorator.d.ts +10 -0
- package/dist/resilience/alert.service.d.ts +77 -0
- package/dist/resilience/index.cjs +863 -0
- package/dist/resilience/index.d.ts +18 -0
- package/dist/resilience/index.js +863 -0
- package/dist/resilience/memory-alert-store.d.ts +26 -0
- package/dist/resilience/provider-health.controller.d.ts +14 -0
- package/dist/resilience/provider-unavailable.exception.d.ts +11 -0
- package/dist/resilience/resilience.module.d.ts +34 -0
- package/dist/resilience/resilience.options.d.ts +28 -0
- package/dist/resilience/resilience.types.d.ts +167 -0
- package/dist/resilience/resilient-fetch.d.ts +38 -0
- package/dist/resilience/runtime.d.ts +24 -0
- package/dist/resilience/typeorm/alert.entity.d.ts +21 -0
- package/dist/resilience/typeorm/index.cjs +102 -0
- package/dist/resilience/typeorm/index.d.ts +3 -0
- package/dist/resilience/typeorm/index.js +102 -0
- package/dist/resilience/typeorm/typeorm-alert-store.d.ts +39 -0
- package/dist/resilience/validate-destination.d.ts +63 -0
- package/dist/response/index.cjs +3 -3
- package/dist/response/index.js +2 -2
- package/dist/scheduling/cron-lock.service.d.ts +36 -0
- package/dist/scheduling/cron-unico.decorator.d.ts +27 -0
- package/dist/scheduling/fallback.store.d.ts +34 -0
- package/dist/scheduling/index.cjs +392 -0
- package/dist/scheduling/index.d.ts +18 -0
- package/dist/scheduling/index.js +392 -0
- package/dist/scheduling/lock-store.port.d.ts +19 -0
- package/dist/scheduling/memory.store.d.ts +15 -0
- package/dist/scheduling/redis.module.d.ts +31 -0
- package/dist/scheduling/redis.store.d.ts +24 -0
- package/dist/scheduling/scheduling.module.d.ts +24 -0
- package/dist/scheduling/scheduling.options.d.ts +27 -0
- package/dist/scheduling/sql.store.d.ts +26 -0
- package/dist/secrets/index.cjs +274 -0
- package/dist/secrets/index.d.ts +8 -0
- package/dist/secrets/index.js +274 -0
- package/dist/secrets/secrets.errors.d.ts +6 -0
- package/dist/secrets/secrets.module.d.ts +21 -0
- package/dist/secrets/secrets.options.d.ts +32 -0
- package/dist/secrets/secrets.service.d.ts +54 -0
- package/dist/secrets/secrets.transformer.d.ts +33 -0
- package/dist/security/hash.d.ts +8 -0
- package/dist/security/index.cjs +27 -35
- package/dist/security/index.d.ts +5 -0
- package/dist/security/index.js +24 -32
- package/dist/security/mask.d.ts +22 -0
- package/dist/security/signed-grant.d.ts +30 -0
- package/dist/storage/index.cjs +2 -2
- package/dist/storage/index.js +1 -1
- package/dist/stripe/index.cjs +7 -7
- package/dist/stripe/index.js +1 -1
- package/dist/telegram/index.cjs +2 -2
- package/dist/telegram/index.js +1 -1
- package/dist/tenancy/app-role.d.ts +24 -0
- package/dist/tenancy/db-helpers.d.ts +12 -0
- package/dist/tenancy/index.cjs +205 -0
- package/dist/tenancy/index.d.ts +14 -0
- package/dist/tenancy/index.js +205 -0
- package/dist/tenancy/pg/index.cjs +34 -0
- package/dist/tenancy/pg/index.d.ts +2 -0
- package/dist/tenancy/pg/index.js +34 -0
- package/dist/tenancy/pg/with-tenant.d.ts +23 -0
- package/dist/tenancy/request-context.d.ts +18 -0
- package/dist/tenancy/rls-guardrail.d.ts +38 -0
- package/dist/tenancy/scope.d.ts +5 -0
- package/dist/tenancy/tenancy.errors.d.ts +5 -0
- package/dist/tenancy/tenancy.middleware.d.ts +8 -0
- package/dist/tenancy/tenancy.module.d.ts +37 -0
- package/dist/tenancy/tenancy.options.d.ts +34 -0
- package/dist/tenancy/typeorm/index.cjs +41 -0
- package/dist/tenancy/typeorm/index.d.ts +2 -0
- package/dist/tenancy/typeorm/index.js +41 -0
- package/dist/tenancy/typeorm/with-tenant.d.ts +23 -0
- package/dist/tiktok/index.cjs +3 -3
- package/dist/tiktok/index.js +1 -1
- package/dist/tracking/index.cjs +3 -3
- package/dist/tracking/index.js +2 -2
- package/dist/umami/index.cjs +4 -4
- package/dist/umami/index.js +1 -1
- package/dist/whatsapp/index.cjs +2 -2
- package/dist/whatsapp/index.js +1 -1
- package/package.json +108 -3
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Card refunds through Mercado Pago's Orders API (`POST /v1/orders/{id}/refund`) with a stable `X-Idempotency-Key` per
|
|
3
|
+
* refund. Mercado Pago remembers a key's answer for 24 h: retrying with the SAME key returns the same refund, never a
|
|
4
|
+
* new one. Only the pure part (reading the order, deciding the status) and the HTTP call live here; who stores what is
|
|
5
|
+
* up to the app. Never mark something "refunded" without Mercado Pago confirming it.
|
|
6
|
+
*/
|
|
7
|
+
/** What Mercado Pago says about ONE refund of ours. */
|
|
8
|
+
export type RefundStatus = 'confirmed' | 'pending' | 'rejected';
|
|
9
|
+
export interface RefundResult {
|
|
10
|
+
status: RefundStatus;
|
|
11
|
+
/** The refund id at Mercado Pago, once known. */
|
|
12
|
+
providerRefundId: string | null;
|
|
13
|
+
/** Why it is still pending or why it was rejected (text for a person, no internals). */
|
|
14
|
+
detail: string | null;
|
|
15
|
+
}
|
|
16
|
+
/** Window in which Mercado Pago remembers an idempotency key (24 h); a margin is left. */
|
|
17
|
+
export declare const IDEMPOTENCY_WINDOW_MS: number;
|
|
18
|
+
interface OrderRefund {
|
|
19
|
+
id?: unknown;
|
|
20
|
+
amount?: unknown;
|
|
21
|
+
status?: unknown;
|
|
22
|
+
}
|
|
23
|
+
export interface MercadoPagoOrder {
|
|
24
|
+
id?: string;
|
|
25
|
+
status?: string;
|
|
26
|
+
status_detail?: string;
|
|
27
|
+
total_amount?: string;
|
|
28
|
+
transactions?: {
|
|
29
|
+
payments?: {
|
|
30
|
+
id?: string;
|
|
31
|
+
amount?: string;
|
|
32
|
+
paid_amount?: string;
|
|
33
|
+
status?: string;
|
|
34
|
+
}[];
|
|
35
|
+
refunds?: OrderRefund[];
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/** A Mercado Pago amount (`"10.00"`) in integer cents. */
|
|
39
|
+
export declare const centsOf: (v: unknown) => number;
|
|
40
|
+
/** What the order collected (cents) and the payment id a partial refund is made against. */
|
|
41
|
+
export declare function paymentOfOrder(o: MercadoPagoOrder): {
|
|
42
|
+
paymentId: string | null;
|
|
43
|
+
collectedCents: number;
|
|
44
|
+
};
|
|
45
|
+
/** Texts shown to people. Override any of them (e.g. to translate); the defaults are Spanish. */
|
|
46
|
+
export interface RefundMessages {
|
|
47
|
+
notYetListed: string;
|
|
48
|
+
processing: string;
|
|
49
|
+
rejected: string;
|
|
50
|
+
rejectedWith: (reason: string) => string;
|
|
51
|
+
}
|
|
52
|
+
export declare const DEFAULT_REFUND_MESSAGES: RefundMessages;
|
|
53
|
+
/**
|
|
54
|
+
* Finds OUR refund inside the order and tells its status. With `providerRefundId` it looks it up by id; without it
|
|
55
|
+
* (the answer was lost) it takes the latest refund of that amount that no other refund of ours already claimed.
|
|
56
|
+
* If it is not found it stays `pending`: nothing is ever assumed.
|
|
57
|
+
*/
|
|
58
|
+
export declare function interpretOrder(o: MercadoPagoOrder, wanted: {
|
|
59
|
+
providerRefundId: string | null;
|
|
60
|
+
amountCents: number;
|
|
61
|
+
claimed: string[];
|
|
62
|
+
}, messages?: RefundMessages): RefundResult;
|
|
63
|
+
/** Readable message of a Mercado Pago 4xx body (its `message` or the first error's), trimmed. */
|
|
64
|
+
export declare function refundErrorMessage(body: unknown, messages?: RefundMessages): string;
|
|
65
|
+
/** Stable code of a Mercado Pago error (`errors[0].code`, or flat `error`/`code`). */
|
|
66
|
+
export declare function refundErrorCode(body: unknown): string | null;
|
|
67
|
+
/**
|
|
68
|
+
* Codes from Point's official refund-error table that are FINAL (the refund will not happen as asked) and what to tell
|
|
69
|
+
* the person. Source: mercadopago.com.mx/developers/es/docs/mp-point/resources/refund-errors.
|
|
70
|
+
*/
|
|
71
|
+
export declare const DEFINITIVE_REFUND_REJECTIONS: Record<string, string>;
|
|
72
|
+
/** An HTTP status from Mercado Pago that is not final: stays pending (the key makes retrying safe). */
|
|
73
|
+
export declare const isTransientStatus: (status: number) => boolean;
|
|
74
|
+
/**
|
|
75
|
+
* What to do with an error response of the refund POST. The official code first; with no code, the HTTP status:
|
|
76
|
+
* 408/425/429/5xx and any unknown 409 stay pending.
|
|
77
|
+
*/
|
|
78
|
+
export declare function classifyRefundError(status: number, body: unknown, messages?: RefundMessages): {
|
|
79
|
+
transient: true;
|
|
80
|
+
} | {
|
|
81
|
+
transient: false;
|
|
82
|
+
detail: string;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Minimal client over a merchant's access token. `fetchImpl` should add a timeout and retries: a POST with an
|
|
86
|
+
* idempotency key is safe to retry.
|
|
87
|
+
*/
|
|
88
|
+
export declare class MercadoPagoRefunds {
|
|
89
|
+
private readonly o;
|
|
90
|
+
constructor(o: {
|
|
91
|
+
accessToken: string;
|
|
92
|
+
baseUrl?: string;
|
|
93
|
+
fetchImpl?: typeof fetch;
|
|
94
|
+
});
|
|
95
|
+
private get base();
|
|
96
|
+
private get http();
|
|
97
|
+
private headers;
|
|
98
|
+
/** The order, or `null` if it does not exist in this account (404). Throws if Mercado Pago does not answer. */
|
|
99
|
+
order(orderId: string): Promise<{
|
|
100
|
+
status: number;
|
|
101
|
+
order: MercadoPagoOrder | null;
|
|
102
|
+
}>;
|
|
103
|
+
/**
|
|
104
|
+
* Asks for the refund. `amountCents` equal to everything collected = total refund (empty body, as documented);
|
|
105
|
+
* less = partial with `transactions: [{ id, amount }]`. Returns the HTTP status and raw body: the caller decides.
|
|
106
|
+
*/
|
|
107
|
+
refund(a: {
|
|
108
|
+
orderId: string;
|
|
109
|
+
key: string;
|
|
110
|
+
total: boolean;
|
|
111
|
+
paymentId: string | null;
|
|
112
|
+
amountCents: number;
|
|
113
|
+
}): Promise<{
|
|
114
|
+
status: number;
|
|
115
|
+
body: unknown;
|
|
116
|
+
}>;
|
|
117
|
+
}
|
|
118
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Verifies a Mercado Pago webhook. Header `x-signature: ts=…,v1=…`; the signed manifest is
|
|
3
|
+
* `id:<data.id lowercased>;request-id:<x-request-id>;ts:<ts>;` (absent parts are left out).
|
|
4
|
+
* Timing-safe. A notification is only a trigger: still read the order from the API, never from the body.
|
|
5
|
+
*/
|
|
6
|
+
export declare function verifyMercadoPagoSignature(secret: string, dataId: string | null, xSignature: string | undefined, xRequestId: string | undefined): boolean;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { I18nMessage } from '../../i18n/message.js';
|
|
2
|
+
export type OnlineCheckoutProvider = 'mercadopago' | 'clip';
|
|
3
|
+
export type OnlineCheckoutCredentials = {
|
|
4
|
+
provider: 'mercadopago';
|
|
5
|
+
accessToken: string;
|
|
6
|
+
} | {
|
|
7
|
+
provider: 'clip';
|
|
8
|
+
apiKey: string;
|
|
9
|
+
secretKey: string;
|
|
10
|
+
};
|
|
11
|
+
export interface CreateOnlineCheckout {
|
|
12
|
+
/** Your id for the sale; comes back on lookup and prevents charging the same thing twice. */
|
|
13
|
+
reference: string;
|
|
14
|
+
description: string;
|
|
15
|
+
/** Integer cents (converted to pesos at the edge). */
|
|
16
|
+
amountCents: number;
|
|
17
|
+
/** Where the buyer lands afterwards. */
|
|
18
|
+
returnUrl: string;
|
|
19
|
+
/** Where the provider notifies (your public API). */
|
|
20
|
+
noticeUrl: string;
|
|
21
|
+
/** Minutes the payment link lives. */
|
|
22
|
+
validForMinutes: number;
|
|
23
|
+
}
|
|
24
|
+
export interface OnlineCheckout {
|
|
25
|
+
provider: OnlineCheckoutProvider;
|
|
26
|
+
/** Provider id (Mercado Pago preference or Clip `payment_request_id`). */
|
|
27
|
+
ref: string;
|
|
28
|
+
url: string;
|
|
29
|
+
}
|
|
30
|
+
export type OnlinePaymentState = 'paid' | 'pending' | 'failed';
|
|
31
|
+
export interface OnlineCheckoutLookup {
|
|
32
|
+
state: OnlinePaymentState;
|
|
33
|
+
/** What the provider says was collected, in cents (null while it has not). */
|
|
34
|
+
paidCents: number | null;
|
|
35
|
+
}
|
|
36
|
+
/** Error messages. Override to translate; defaults are Spanish. */
|
|
37
|
+
export interface OnlineCheckoutMessages {
|
|
38
|
+
mercadoPagoNotOpened: string | I18nMessage;
|
|
39
|
+
mercadoPagoNoAnswer: string | I18nMessage;
|
|
40
|
+
clipNotOpened: string | I18nMessage;
|
|
41
|
+
clipNoAnswer: string | I18nMessage;
|
|
42
|
+
}
|
|
43
|
+
export interface OnlineCheckoutOptions {
|
|
44
|
+
/** Pass the fetch you use for each provider (timeouts, retries). Defaults to global `fetch`. */
|
|
45
|
+
fetchImpl?: (provider: OnlineCheckoutProvider) => typeof fetch;
|
|
46
|
+
mercadoPagoBaseUrl?: string;
|
|
47
|
+
clipBaseUrl?: string;
|
|
48
|
+
messages?: Partial<OnlineCheckoutMessages>;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Online payment link of a merchant: Mercado Pago Checkout Pro or Clip Checkout, always with the MERCHANT's own
|
|
52
|
+
* credentials (the money goes to their account). Creates the link and looks its state up; the state is ALWAYS read
|
|
53
|
+
* from the provider, never from what the buyer or a notification body says.
|
|
54
|
+
*/
|
|
55
|
+
export declare class OnlineCheckoutClient {
|
|
56
|
+
private readonly o;
|
|
57
|
+
private readonly msg;
|
|
58
|
+
constructor(o?: OnlineCheckoutOptions);
|
|
59
|
+
private http;
|
|
60
|
+
private get mpBase();
|
|
61
|
+
private get clipBase();
|
|
62
|
+
private clipAuth;
|
|
63
|
+
create(cred: OnlineCheckoutCredentials, c: CreateOnlineCheckout): Promise<OnlineCheckout>;
|
|
64
|
+
/**
|
|
65
|
+
* Current state of the payment according to the provider (`ref` = preference or payment_request_id).
|
|
66
|
+
* `since`: when the current link was opened — a rejection older than that belongs to an earlier attempt.
|
|
67
|
+
*/
|
|
68
|
+
lookup(cred: OnlineCheckoutCredentials, reference: string, ref: string, since?: Date): Promise<OnlineCheckoutLookup>;
|
|
69
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One-line summary of a provider rejection (`TERMINAL_PAYMENT_PROVIDER_ERROR`) for the log: provider, HTTP status and
|
|
3
|
+
* the body it answered with (trimmed). The exception already carries that body in `details`, but a log that only says
|
|
4
|
+
* "clip rejected the request (HTTP 400)" cannot diagnose a production rejection. Provider bodies never carry your
|
|
5
|
+
* secrets (credentials travel in headers). Returns `null` when the error is not a provider error.
|
|
6
|
+
*/
|
|
7
|
+
export declare function summarizeProviderRejection(error: unknown, limit?: number): string | null;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { TerminalPayment, TerminalPaymentStatus } from '../payments.port.js';
|
|
2
|
+
/**
|
|
3
|
+
* The Clip adapter only recognises PENDING / COMPLETED / FAILED; any other value arrives as `unknown`, which a
|
|
4
|
+
* point of sale can never treat as final, so the screen keeps saying "waiting" after the card already went through.
|
|
5
|
+
* This reads the raw `status` with more synonyms and, failing that, the paid amount: Clip only sends `amount_paid`
|
|
6
|
+
* once the charge completed. Returns the same status when the adapter already recognised it.
|
|
7
|
+
*/
|
|
8
|
+
export declare function clipStatus(p: TerminalPayment): TerminalPaymentStatus;
|
|
9
|
+
/**
|
|
10
|
+
* Mercado Pago (Orders): the adapter knows created / action_required / at_terminal / processed / failed / canceled /
|
|
11
|
+
* expired / refunded; anything else (`processing`, `partially_refunded`) arrived as `unknown`. `processing` means the
|
|
12
|
+
* card already went through the reader and is being credited; `partially_refunded` and credited payments inside the
|
|
13
|
+
* order mean the charge did happen.
|
|
14
|
+
*/
|
|
15
|
+
export declare function mercadoPagoStatus(p: TerminalPayment): TerminalPaymentStatus;
|
|
16
|
+
/**
|
|
17
|
+
* The status a point of sale should act on: the adapter's when it recognised it, otherwise the provider-specific
|
|
18
|
+
* reading above. Call this on every `TerminalPayment` you get back from `charge`/`get`/`cancel`.
|
|
19
|
+
*/
|
|
20
|
+
export declare function resolveTerminalStatus(p: TerminalPayment): TerminalPaymentStatus;
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
import { Logger } from '@nestjs/common';
|
|
2
|
+
import type { I18nMessage } from '../../i18n/message.js';
|
|
3
|
+
import { MercadoPagoConnect } from '../adapters/mercadopago-connect.js';
|
|
4
|
+
import type { TerminalPayment, TerminalPaymentStatus, TerminalPaymentsPort } from '../payments.port.js';
|
|
5
|
+
import type { CredentialsCipher } from './credentials-cipher.js';
|
|
6
|
+
import { type RefundMessages, type RefundResult } from './mercadopago-refund.js';
|
|
7
|
+
import type { OnlineCheckoutCredentials } from './online-checkout.js';
|
|
8
|
+
export type ConnectionProvider = 'mercadopago' | 'clip';
|
|
9
|
+
/**
|
|
10
|
+
* Credentials of a merchant's Mercado Pago account, as stored (encrypted JSON). The field names are the persisted
|
|
11
|
+
* format — keep them if you already have rows.
|
|
12
|
+
*/
|
|
13
|
+
export interface MercadoPagoCredentials {
|
|
14
|
+
accessToken: string;
|
|
15
|
+
refreshToken: string;
|
|
16
|
+
mpUserId: string;
|
|
17
|
+
/** ISO. Refreshed on its own 5 minutes before it expires. */
|
|
18
|
+
expira: string;
|
|
19
|
+
/** Store / POS that Mercado Pago requires before accepting an order — filled when a terminal is chosen. */
|
|
20
|
+
mpStoreId?: string;
|
|
21
|
+
mpPosId?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface ClipCredentials {
|
|
24
|
+
apiKey: string;
|
|
25
|
+
secretKey: string;
|
|
26
|
+
}
|
|
27
|
+
export type ConnectionCredentials = MercadoPagoCredentials | ClipCredentials;
|
|
28
|
+
/** One connected terminal account of a tenant (a store, a branch…). What your database row looks like. */
|
|
29
|
+
export interface ConnectionRecord {
|
|
30
|
+
id: string;
|
|
31
|
+
/** The tenant that owns it. Every call is scoped by this. */
|
|
32
|
+
scopeId: string;
|
|
33
|
+
provider: ConnectionProvider;
|
|
34
|
+
encryptedCredentials: string;
|
|
35
|
+
/** Mercado Pago `terminal_id` or the Clip reader's serial number. */
|
|
36
|
+
terminalId: string | null;
|
|
37
|
+
terminalName: string | null;
|
|
38
|
+
/** Hand-written name to tell two terminals of one provider apart. */
|
|
39
|
+
alias: string | null;
|
|
40
|
+
/** Clip only: goes in the webhook URL (Clip does not sign its notices). Unique. */
|
|
41
|
+
webhookToken: string | null;
|
|
42
|
+
active: boolean;
|
|
43
|
+
primary: boolean;
|
|
44
|
+
createdAt: Date;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Where connections live. Implement it over any table; `scopeId` is your tenant (store, branch, company). Services
|
|
48
|
+
* that also run without a tenant in context (webhooks) need an implementation that is allowed to cross tenants for
|
|
49
|
+
* `findByWebhookToken` and `listActiveByProvider`.
|
|
50
|
+
*/
|
|
51
|
+
export interface TerminalConnectionStore {
|
|
52
|
+
/** Every connection of the tenant, oldest first. */
|
|
53
|
+
list(scopeId: string): Promise<ConnectionRecord[]>;
|
|
54
|
+
find(id: string): Promise<ConnectionRecord | null>;
|
|
55
|
+
insert(data: Omit<ConnectionRecord, 'id' | 'createdAt'>): Promise<ConnectionRecord>;
|
|
56
|
+
update(id: string, patch: Partial<Omit<ConnectionRecord, 'id' | 'scopeId' | 'createdAt'>>): Promise<void>;
|
|
57
|
+
/** `false` when nothing matched `id` inside `scopeId`. */
|
|
58
|
+
delete(scopeId: string, id: string): Promise<boolean>;
|
|
59
|
+
/** Exactly one primary per tenant: turn the others off and `id` on, atomically. `false` if `id` is not the tenant's. */
|
|
60
|
+
setPrimary(scopeId: string, id: string): Promise<boolean>;
|
|
61
|
+
findByWebhookToken(token: string): Promise<ConnectionRecord | null>;
|
|
62
|
+
/** Active connections of a provider across ALL tenants (to map a Mercado Pago notice to its tenants). */
|
|
63
|
+
listActiveByProvider(provider: ConnectionProvider): Promise<ConnectionRecord[]>;
|
|
64
|
+
}
|
|
65
|
+
/** A connection without its secrets, ready to show. */
|
|
66
|
+
export interface ConnectionView {
|
|
67
|
+
id: string;
|
|
68
|
+
provider: ConnectionProvider;
|
|
69
|
+
terminalId: string | null;
|
|
70
|
+
terminalName: string | null;
|
|
71
|
+
alias: string | null;
|
|
72
|
+
active: boolean;
|
|
73
|
+
primary: boolean;
|
|
74
|
+
/** Connected and with a terminal chosen: a point of sale can send charges. */
|
|
75
|
+
ready: boolean;
|
|
76
|
+
/** Clip only, and only if asked for: the URL to paste in Clip's Postback Webhook. */
|
|
77
|
+
webhookUrl?: string;
|
|
78
|
+
}
|
|
79
|
+
export interface TerminalSummary {
|
|
80
|
+
id: string;
|
|
81
|
+
name: string;
|
|
82
|
+
online: boolean | null;
|
|
83
|
+
mode: 'pdv' | 'standalone' | 'unknown' | null;
|
|
84
|
+
}
|
|
85
|
+
export interface TerminalCharge {
|
|
86
|
+
id: string;
|
|
87
|
+
provider: string;
|
|
88
|
+
status: TerminalPaymentStatus;
|
|
89
|
+
amountCents: number;
|
|
90
|
+
paidCents: number | null;
|
|
91
|
+
}
|
|
92
|
+
export type ConnectionMessageKey = 'missingAccessToken' | 'missingCredentials' | 'minimumAmount';
|
|
93
|
+
type Message = string | I18nMessage;
|
|
94
|
+
export interface TerminalConnectionsOptions {
|
|
95
|
+
store: TerminalConnectionStore;
|
|
96
|
+
/** Without it the whole feature reports `available === false`. Build it with `CredentialsCipher.fromHex`. */
|
|
97
|
+
cipher: CredentialsCipher | null | (() => CredentialsCipher | null);
|
|
98
|
+
/**
|
|
99
|
+
* The `fetch` for each provider (timeouts, retries, alerts). Cobrar sends an idempotency key for Mercado Pago, so
|
|
100
|
+
* retrying is safe there; Clip's charge is not idempotent, so retry only reads and cancellations.
|
|
101
|
+
*/
|
|
102
|
+
fetchImpl?: (provider: ConnectionProvider, scopeId?: string) => typeof fetch;
|
|
103
|
+
/** Test doubles / sandboxes. */
|
|
104
|
+
mercadoPagoBaseUrl?: string;
|
|
105
|
+
clipBaseUrl?: string;
|
|
106
|
+
/** Mercado Pago marketplace OAuth for this scope; `null` when the app is not configured. */
|
|
107
|
+
mercadoPagoConnect?: (scopeId?: string) => MercadoPagoConnect | null;
|
|
108
|
+
/** Secret that verifies Mercado Pago webhooks (`x-signature`). Without it notices are ignored. */
|
|
109
|
+
mercadoPagoWebhookSecret?: string | (() => string | undefined);
|
|
110
|
+
/** Secret that signs the OAuth `state`. */
|
|
111
|
+
stateSecret?: string | (() => string | undefined);
|
|
112
|
+
/** Public URL of your API, for the Clip webhook URL. */
|
|
113
|
+
publicWebhookUrl?: (webhookToken: string) => string;
|
|
114
|
+
/** Name for the Mercado Pago Store/POS created when the terminal has none. */
|
|
115
|
+
describeScope?: (scopeId: string) => Promise<{
|
|
116
|
+
name: string;
|
|
117
|
+
}>;
|
|
118
|
+
/** Mercado Pago requires a location to create a Store. Defaults to Mexico City. */
|
|
119
|
+
storeLocation?: (name: string) => Record<string, unknown>;
|
|
120
|
+
/** Minimum charge per provider, in cents. Defaults: Mercado Pago 500, Clip 100. */
|
|
121
|
+
minimumCents?: Partial<Record<ConnectionProvider, number>>;
|
|
122
|
+
/** What the Mercado Pago terminal displays for the charge. */
|
|
123
|
+
chargeDescription?: string;
|
|
124
|
+
providerNames?: Partial<Record<ConnectionProvider, string>>;
|
|
125
|
+
/** Override the texts people read (translate them, e.g. with nestkit's `t()`). */
|
|
126
|
+
messages?: Partial<{
|
|
127
|
+
missingAccessToken: () => Message;
|
|
128
|
+
missingCredentials: () => Message;
|
|
129
|
+
minimumAmount: (p: {
|
|
130
|
+
provider: string;
|
|
131
|
+
minimum: string;
|
|
132
|
+
}) => Message;
|
|
133
|
+
}>;
|
|
134
|
+
refundMessages?: Partial<RefundMessages>;
|
|
135
|
+
/** Called, de-duplicated, when a provider notice moved a charge to a status you have not seen. */
|
|
136
|
+
onPaymentChanged?: (scopeId: string, paymentId: string, charge: TerminalCharge) => void;
|
|
137
|
+
/** Called for every verified Mercado Pago order notice, before it is looked up (someone may be waiting on a refund). */
|
|
138
|
+
onMercadoPagoOrder?: (scopeId: string, orderId: string) => void;
|
|
139
|
+
logger?: Pick<Logger, 'log' | 'warn' | 'debug' | 'error'>;
|
|
140
|
+
}
|
|
141
|
+
/** Open all day, every day: a sensible default so a merchant is not asked for hours just to connect a terminal. */
|
|
142
|
+
export declare const ALWAYS_OPEN: {
|
|
143
|
+
[k: string]: {
|
|
144
|
+
open: string;
|
|
145
|
+
close: string;
|
|
146
|
+
}[];
|
|
147
|
+
};
|
|
148
|
+
/** Mexico City, for stores that give no address. */
|
|
149
|
+
export declare const defaultStoreLocation: (name: string) => {
|
|
150
|
+
streetNumber: string;
|
|
151
|
+
streetName: string;
|
|
152
|
+
cityName: string;
|
|
153
|
+
stateName: string;
|
|
154
|
+
latitude: number;
|
|
155
|
+
longitude: number;
|
|
156
|
+
};
|
|
157
|
+
export interface OAuthStatePayload {
|
|
158
|
+
scopeId: string;
|
|
159
|
+
actorId: string;
|
|
160
|
+
/** Binds the callback to the browser that started the flow (cookie value). */
|
|
161
|
+
csrf: string;
|
|
162
|
+
destination?: string;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Everything a point of sale needs to take card payments on a merchant's own Mercado Pago / Clip terminals:
|
|
166
|
+
* connect (Clip keys, Mercado Pago OAuth), choose and provision the terminal, charge, look up, cancel, react to
|
|
167
|
+
* provider notices, refund, and hand out the merchant's credentials for online checkout. Storage-agnostic: bring a
|
|
168
|
+
* {@link TerminalConnectionStore}. Plain class, no Nest dependency: wrap it in your own service for plan checks,
|
|
169
|
+
* audit and events.
|
|
170
|
+
*/
|
|
171
|
+
export declare class TerminalConnections {
|
|
172
|
+
private readonly o;
|
|
173
|
+
private readonly log;
|
|
174
|
+
private readonly lastStatus;
|
|
175
|
+
private mpCache;
|
|
176
|
+
constructor(o: TerminalConnectionsOptions);
|
|
177
|
+
/** Resolved on every use so a key set after construction (env, secret manager) is picked up. */
|
|
178
|
+
private get cipher();
|
|
179
|
+
get available(): boolean;
|
|
180
|
+
private requireCipher;
|
|
181
|
+
private name;
|
|
182
|
+
private fetchFor;
|
|
183
|
+
private sorted;
|
|
184
|
+
view(r: ConnectionRecord, includeWebhook?: boolean): ConnectionView;
|
|
185
|
+
list(scopeId: string, includeWebhook?: boolean): Promise<ConnectionView[]>;
|
|
186
|
+
/** Providers with an active account: which one the merchant can charge online with. */
|
|
187
|
+
connectedProviders(scopeId: string): Promise<ConnectionProvider[]>;
|
|
188
|
+
private one;
|
|
189
|
+
/** Connects Clip (API key + secret key) after checking them; adds a new terminal row. */
|
|
190
|
+
connectClip(scopeId: string, credentials: ClipCredentials): Promise<{
|
|
191
|
+
id: string;
|
|
192
|
+
terminals: TerminalSummary[];
|
|
193
|
+
}>;
|
|
194
|
+
/**
|
|
195
|
+
* URL to send the owner to so they authorize. `state` binds the callback to this tenant, and `csrf` (to be set as an
|
|
196
|
+
* httpOnly cookie by your controller) binds it to the browser that started the flow (OAuth CSRF, RFC 6749 §10.12).
|
|
197
|
+
* Check your plan/permissions BEFORE calling this: the public callback cannot tell the original tab anything.
|
|
198
|
+
*/
|
|
199
|
+
mercadoPagoAuthorizationUrl(scopeId: string, actorId: string, destination?: string): {
|
|
200
|
+
url: string;
|
|
201
|
+
csrf: string;
|
|
202
|
+
};
|
|
203
|
+
private stateSecret;
|
|
204
|
+
private readOAuthState;
|
|
205
|
+
/** Where to go back after the callback. An unreadable `state` goes back to `fallback`. */
|
|
206
|
+
oauthDestination(state: string | undefined, fallback?: string): string;
|
|
207
|
+
/**
|
|
208
|
+
* The Mercado Pago callback (no session: only `code`/`state` plus the cookie set at the start). Exchanges the code,
|
|
209
|
+
* adds a new terminal row with the encrypted credentials and says which tenant/user/row it ended in.
|
|
210
|
+
* `cookieOptional` for native apps, whose system browser does not hold the cookie of the app's HTTP session: there
|
|
211
|
+
* the signed `state` (tenant, user, validity) is all that binds the return.
|
|
212
|
+
*/
|
|
213
|
+
completeMercadoPagoOAuth(code: string, state: string | undefined, nonceCookie: string | undefined, isCookieOptional?: (destination: string | undefined) => boolean): Promise<{
|
|
214
|
+
scopeId: string;
|
|
215
|
+
actorId: string;
|
|
216
|
+
id: string;
|
|
217
|
+
terminals: number;
|
|
218
|
+
}>;
|
|
219
|
+
/** Inserts a new row (never overwrites); the tenant's first terminal becomes primary on its own. */
|
|
220
|
+
private save;
|
|
221
|
+
terminals(scopeId: string, id: string): Promise<TerminalSummary[]>;
|
|
222
|
+
/**
|
|
223
|
+
* The owner picks, from the real list, which terminal it is. For Mercado Pago it also makes sure the Store→POS
|
|
224
|
+
* hierarchy its Point API requires exists and switches the terminal to PDV mode — without blocking if any of that
|
|
225
|
+
* fails (uncertified account, freshly paired terminal): the choice is saved anyway.
|
|
226
|
+
*/
|
|
227
|
+
chooseTerminal(scopeId: string, id: string, terminalId: string, name?: string): Promise<ConnectionView>;
|
|
228
|
+
rename(scopeId: string, id: string, alias: string): Promise<ConnectionView>;
|
|
229
|
+
setPrimary(scopeId: string, id: string): Promise<void>;
|
|
230
|
+
disconnect(scopeId: string, id: string): Promise<void>;
|
|
231
|
+
private provisionMercadoPago;
|
|
232
|
+
/** Sends the charge to the chosen terminal. Returns once queued, not once paid. */
|
|
233
|
+
charge(scopeId: string, id: string, amountCents: number, reference: string): Promise<TerminalCharge>;
|
|
234
|
+
get(scopeId: string, id: string, paymentId: string): Promise<TerminalCharge>;
|
|
235
|
+
cancel(scopeId: string, id: string, paymentId: string): Promise<TerminalCharge>;
|
|
236
|
+
/** The status a point of sale should act on, with the adapter's `unknown` resolved (and logged). */
|
|
237
|
+
normalize(p: TerminalPayment): TerminalCharge;
|
|
238
|
+
/** Clip: `token` identifies the terminal (and the tenant). Never throws: a webhook always answers 200. */
|
|
239
|
+
handleClipNotice(token: string, paymentId: unknown): Promise<void>;
|
|
240
|
+
/** Mercado Pago: verifies `x-signature` and finds the tenant(s) by `user_id`. Never throws. */
|
|
241
|
+
handleMercadoPagoNotice(a: {
|
|
242
|
+
dataIdQuery: string | null;
|
|
243
|
+
xSignature: string | undefined;
|
|
244
|
+
xRequestId: string | undefined;
|
|
245
|
+
body: unknown;
|
|
246
|
+
}): Promise<void>;
|
|
247
|
+
/** One active row per tenant whose Mercado Pago account is `mpUserId`. Short cache. */
|
|
248
|
+
private mercadoPagoRows;
|
|
249
|
+
private lookupAndNotify;
|
|
250
|
+
/**
|
|
251
|
+
* Credentials of the tenant's own account for online checkout (the money goes to them). With no `provider` it takes
|
|
252
|
+
* the primary terminal's. Mercado Pago refreshes its access token here.
|
|
253
|
+
*/
|
|
254
|
+
checkoutCredentials(scopeId: string, provider?: ConnectionProvider | null): Promise<OnlineCheckoutCredentials>;
|
|
255
|
+
/** There is something to ask with: encryption key and an active Mercado Pago account. */
|
|
256
|
+
canRefundMercadoPago(scopeId: string): Promise<boolean>;
|
|
257
|
+
/**
|
|
258
|
+
* The account (among those connected to the tenant) where the order exists. `no_answer` if one did not answer and
|
|
259
|
+
* none had it: it cannot be concluded the order does not exist.
|
|
260
|
+
*/
|
|
261
|
+
private accountOfOrder;
|
|
262
|
+
/**
|
|
263
|
+
* Asks (or asks again with the SAME key) for the refund of `amountCents` of the order, or just looks it up.
|
|
264
|
+
* - `key`: stable per refund; Mercado Pago remembers it 24 h, so retrying never creates a second refund.
|
|
265
|
+
* - `providerRefundId` known or `onlyLookup` (past the key's window): the order is only read, nothing is sent.
|
|
266
|
+
* - `firstAttempt`: if the order is not in the connected account it is rejected; on a retry it stays pending (the
|
|
267
|
+
* first attempt may have gone through).
|
|
268
|
+
* - `claimed`: ids of refunds of that order that already belong to OTHER records (not to be mistaken for this one).
|
|
269
|
+
* Never throws because of the provider: no answer = `pending`.
|
|
270
|
+
*/
|
|
271
|
+
refundMercadoPago(scopeId: string, a: {
|
|
272
|
+
orderId: string;
|
|
273
|
+
amountCents: number;
|
|
274
|
+
key: string;
|
|
275
|
+
providerRefundId: string | null;
|
|
276
|
+
claimed: string[];
|
|
277
|
+
onlyLookup?: boolean;
|
|
278
|
+
firstAttempt?: boolean;
|
|
279
|
+
}): Promise<RefundResult>;
|
|
280
|
+
/** The row, its decrypted (and, for Mercado Pago, refreshed) credentials and a ready adapter. */
|
|
281
|
+
adapterOf(scopeId: string, id: string): Promise<{
|
|
282
|
+
config: ConnectionRecord;
|
|
283
|
+
credentials: ConnectionCredentials;
|
|
284
|
+
adapter: TerminalPaymentsPort;
|
|
285
|
+
}>;
|
|
286
|
+
/** Renews the Mercado Pago access token 5 minutes before it expires; Mercado Pago rotates the refresh token too. */
|
|
287
|
+
private refreshed;
|
|
288
|
+
private mercadoPagoTerminals;
|
|
289
|
+
private adapter;
|
|
290
|
+
}
|
|
291
|
+
export {};
|