@gpmpay/sdk
Version:
Official Node.js SDK for GPM Pay — VietQR codes, transaction webhooks, and payment reconciliation.
68 lines (65 loc) • 2.75 kB
text/typescript
/**
* String-literal unions mirroring the backend's Prisma enums and
* `apps/backend/src/modules/api-tokens/api-token.types.ts`.
*
* These are deliberately vendored rather than imported from `@repo/shared-types`
* (that package is unpublishable). `src/types/__compat__.ts` asserts they stay
* in sync at compile time.
*/
/** Scopes an API token can carry. */
type ApiTokenScope = 'transactions:read' | 'bank-accounts:read' | 'webhooks:manage';
declare const ALL_API_SCOPES: readonly ApiTokenScope[];
/** `ACTIVE` = usable. `PENDING` = temporarily blocked by the owner. */
type ApiTokenStatus = 'ACTIVE' | 'PENDING';
type TransactionType = 'IN' | 'OUT';
type TransactionSource = 'REAL' | 'SIMULATED';
type BankAccountStatus = 'ACTIVE' | 'SUSPENDED' | 'DELETED' | 'PENDING_VERIFICATION';
type WebhookDriver = 'HTTP' | 'TELEGRAM' | 'WORDPRESS' | 'GOOGLE_SHEETS';
type WebhookAuthType = 'NONE' | 'API_KEY' | 'HMAC';
type WebhookScope = 'ALL' | 'SPECIFIC';
type WebhookDeliveryStatus = 'PENDING' | 'DELIVERED' | 'RETRYING' | 'FAILED';
/**
* Delivery retry backoff used by the GPM Pay webhook dispatcher, in seconds.
* Mirrors `apps/backend/src/modules/webhook-delivery/backoff.util.ts`.
*
* Your endpoint will be called up to {@link WEBHOOK_MAX_ATTEMPTS} times for the
* same transaction — make it idempotent on `payload.id`.
*/
declare const WEBHOOK_RETRY_SCHEDULE_SECONDS: readonly number[];
declare const WEBHOOK_MAX_ATTEMPTS = 6;
/**
* The HTTP delivery driver aborts after this long. Respond within it or the
* delivery is recorded as failed and retried.
*/
declare const WEBHOOK_DELIVERY_TIMEOUT_MS = 5000;
interface Bank {
id: string;
code: string;
/** NAPAS BIN — the identifier VietQR payloads are built from. */
bin: string;
name: string;
shortName: string;
logoUrl: string | null;
isActive: boolean;
}
interface BankAccount {
id: string;
userId: string;
bankId: string;
accountNumber: string;
ownerName: string;
reminiscentName: string | null;
status: BankAccountStatus;
expiresAt: string | null;
createdAt: string;
updatedAt?: string;
bank?: Bank;
}
interface ListBankAccountsParams {
page?: number;
limit?: number;
search?: string;
status?: BankAccountStatus;
bankId?: string;
}
export { type ApiTokenScope as A, type BankAccount as B, type ListBankAccountsParams as L, type TransactionType as T, WEBHOOK_DELIVERY_TIMEOUT_MS as W, type Bank as a, type TransactionSource as b, ALL_API_SCOPES as c, type ApiTokenStatus as d, type BankAccountStatus as e, WEBHOOK_MAX_ATTEMPTS as f, WEBHOOK_RETRY_SCHEDULE_SECONDS as g, type WebhookAuthType as h, type WebhookDeliveryStatus as i, type WebhookDriver as j, type WebhookScope as k };