npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@maib/rtp

v0.3.2

Published

TypeScript SDK for the maib Request to Pay (RTP) API — bank-initiated payment requests

Readme

@maib/rtp

TypeScript SDK for the maib Request to Pay (RTP) API — bank-initiated payment requests.

Install

npm install @maib/rtp

Or use the umbrella package @maib/merchants:

npm install @maib/merchants

Usage

import { RtpClient, Currency } from "@maib/rtp";

const client = new RtpClient({
  clientId: process.env.MAIB_CLIENT_ID,
  clientSecret: process.env.MAIB_CLIENT_SECRET,
  signatureKey: process.env.MAIB_SIGNATURE_KEY, // for callback verification
});

Create a payment request

const rtp = await client.create({
  alias: "+37360123456",
  amount: 100,
  currency: Currency.MDL,
  description: "Invoice #456",
  expiresAt: "2026-12-31T23:59:59Z",
  callbackUrl: "https://example.com/callback",
  redirectUrl: "https://example.com/redirect",
});

console.log(rtp.rtpId);

Get status

const status = await client.getStatus(rtp.rtpId);

List payment requests

const { items, totalCount } = await client.list({
  count: 20,
  offset: 0,
  status: RtpStatus.ACTIVE,
});

Cancel a payment request

await client.cancel(rtp.rtpId, { reason: "No longer needed" });

Refund a completed payment

const refund = await client.refund(payId, { reason: "Customer request" });

Sandbox testing

import { RtpClient, Environment } from "@maib/rtp";

const client = new RtpClient({
  clientId: process.env.MAIB_CLIENT_ID,
  clientSecret: process.env.MAIB_CLIENT_SECRET,
  environment: Environment.SANDBOX,
});

// Simulate customer accepting the payment
const accepted = await client.testAccept(rtp.rtpId, {
  amount: 100,
  currency: Currency.MDL,
});

// Simulate customer rejecting the payment
const rejected = await client.testReject(rtp.rtpId);

Verify callback signature

// In your webhook handler
const isValid = client.verifyCallback(callbackPayload);
// callbackPayload = { result: { ... }, signature: "..." }

Enums

import { RtpStatus } from "@maib/rtp";

RtpStatus.CREATED; // "Created"
RtpStatus.ACTIVE; // "Active"
RtpStatus.ACCEPTED; // "Accepted"
RtpStatus.REJECTED; // "Rejected"
RtpStatus.CANCELLED; // "Cancelled"
RtpStatus.EXPIRED; // "Expired"

Documentation

This package ships documentation in dist/docs/ for AI coding agents and tooling:

Runtime validation (optional)

@maib/rtp ships JSON Schema files for every wire-format type plus a tiny validator-agnostic helper. Use Zod, Valibot, ArkType, or any other Standard-Schema-compatible validator – once converted, the parser plugs into TanStack Form, tRPC, hono validators, the AI SDK, and the rest of the Standard Schema ecosystem. Zod is the runnable example.

Typed wrapper (preferred)

Import from @maib/rtp/schemas/<TypeName> (no .json suffix) – the wrapper carries the SDK type, so buildSchema infers ParsingValidator<T> without an explicit generic.

import { z } from "zod";
import { buildSchema } from "@maib/rtp/schemas";
import CreateRtpRequestDef from "@maib/rtp/schemas/CreateRtpRequest";

export const CreateRtpRequestSchema = buildSchema(z.fromJSONSchema, CreateRtpRequestDef);
// → ParsingValidator<CreateRtpRequest> (inferred)

CreateRtpRequestSchema.parse({
  alias: "37360000000",
  amount: 25,
  expiresAt: "2029-01-01T00:00:00Z",
  currency: "MDL",
  description: "Loan repayment",
});

Raw JSON (explicit generic)

Backwards-compatible pattern for the with { type: "json" } import style:

import { z } from "zod";
import type { RtpCallbackPayload } from "@maib/rtp";
import { buildSchema } from "@maib/rtp/schemas";
import RtpCallbackPayloadDef from "@maib/rtp/schemas/RtpCallbackPayload.json" with { type: "json" };

export const RtpCallbackPayloadSchema = buildSchema<RtpCallbackPayload>(
  z.fromJSONSchema,
  RtpCallbackPayloadDef,
);

See docs/schemas.md for the full guide and bulk import pattern.

AI / agent coding

  • Canonical references: ./docs/sdk-reference.md (TypeScript surface) and ./docs/schemas.md (runtime validation). Read these before generating code against this package.
  • Prefer the typed-wrapper pattern – import Def from "@maib/rtp/schemas/<TypeName>" plus buildSchema(z.fromJSONSchema, Def). No explicit generic, no separate import type.
  • The convert callback signature is (schema: _JSONSchema) => unknown, matching z.fromJSONSchema.
  • JSON Schema artifacts are shipped at @maib/rtp/schemas/bundle.json and @maib/rtp/schemas/<TypeName>.json (draft-2020-12). @maib/rtp/schemas re-exports JSONSchema, _JSONSchema, and the back-compat alias JSONSchemaDef.
  • Client methods live on RtpClient (see src/index.ts): create, getStatus, list, cancel, refund, testAccept, testReject, verifyCallback, computeCallbackSignature. RTP stands for "Request to Pay".
  • @maib/rtp depends on @maib/core for Currency, Environment, MaibError, MaibNetworkError, and signature verification helpers. Callback signatures here use SHA-256 over sorted leaf values joined with : plus signatureKey – not HMAC (that's @maib/checkout).
  • Prefer the documented public types (CreateRtpRequest, RtpCallbackPayload, RtpStatusResult, etc.) over inferring shapes from runtime payloads.
  • For sandbox flows use testAccept / testReject; the returned payId (not rtpId) is what refund consumes.

License

MIT