@prudra/payments
v0.2.2
Published
Prudra payments SDK — dual protocol payment middleware (MPP, x402), receipts, logs, verification
Downloads
60
Readme
@prudra/payments
Prudra payments SDK — Dual-protocol payment middleware (x402 + MPP), read receipts and payment logs, parse dual 402 challenges.
Installation
npm install @prudra/paymentsPrerequisites
Call initialise() from @prudra/core before using server-side helpers (getReceipt, verifyReceipt, listPaymentLogs, getPaymentSummary, submitRouteSnapshot). Pure parsers (parseChallenge, parseMPPChallenge, parseX402Requirement) work without initialise().
1 — API servers
import { initialise } from '@prudra/core';
import {
getReceipt,
verifyReceipt,
listPaymentLogs,
getPaymentSummary,
} from '@prudra/payments';
initialise({ apiKey: process.env.PRUDRA_API_KEY! });
const receipt = await getReceipt('pay_abc');
const { valid } = await verifyReceipt(receipt.receipt);
const logs = await listPaymentLogs({
routePath: '/analyse',
limit: 50,
withSnapshot: true,
});
const summary = await getPaymentSummary({ from: '2026-01-01T00:00:00Z' });2 — Calling agents (402 parsing)
import { parseChallenge } from '@prudra/payments';
const dual = parseChallenge(response.headers);
if (dual.mpp) {
console.log(dual.mpp.request.amount, dual.mpp.request.recipient);
}
if (dual.x402) {
console.log(dual.x402.price, dual.x402.network);
}3 — Route registry
After a successful payment, @prudra/express payMiddleware() captures the request, normalises it, and submits a snapshot to the registry. For tests or custom integrations you can call normaliseSnapshot() and submitRouteSnapshot() from this package.
payMiddleware() is implemented in @prudra/express, not here. Import it from @prudra/express when Step 4 ships.
Further documentation: docs.prudra.dev/docs/payments
