Skip to main content
Version: v0.12.4

Payment Rails

PEAC records what happened during commerce flows. Each rail mapping extracts upstream artifacts, preserves them as-is, and produces a PEAC receipt with typed commerce extensions. PEAC never executes payments, coordinates checkout, or manages wallets.

Supported rails

RailPackageWhat it recordsStatus
Paymentauth / MPP@peac/mappings-paymentauthHTTP 402 challenges, credentials, upstream receiptsStable
x402@peac/adapter-x402Offer/receipt verification, v1/v2 headers, upstream artifact separationStable
Stripe@peac/rails-stripePayment intent observation, SPT delegation lifecycleStable
Razorpay@peac/rails-razorpayUPI, cards, netbanking, walletsStable
Card networks@peac/rails-cardVisa, Mastercard, Amex authorizationStable

Paymentauth / MPP

Envelope-first parsing for the HTTP Payment authentication scheme (draft-ryan-httpauth-payment). Extracts Challenge, Credential, and Receipt envelopes with raw artifact preservation.

Terminal
pnpm add @peac/mappings-paymentauth
paymentauth-evidence.ts
import { parseChallenge, parseReceipt } from '@peac/mappings-paymentauth';

// Parse 402 challenge from WWW-Authenticate header
const challenge = parseChallenge(wwwAuthenticateHeader);

// Parse upstream receipt from Payment-Receipt header
const receipt = parseReceipt(paymentReceiptHeader);

Carrier coexistence: PEAC-Receipt (PEAC compact JWS) and Payment-Receipt (upstream receipt) coexist without conflict. JSON-RPC error helpers (-32042, -32043) and MCP extraction functions included.


x402

Four-layer adapter architecture (A1/A2/B/C) with 5-layer verification API. Reads v1 (X-PAYMENT-RESPONSE) and v2 (PAYMENT-RESPONSE) headers alongside PEAC-Receipt.

Terminal
pnpm add @peac/adapter-x402
x402-evidence.ts
import { extractReceiptArtifactFromHeaders } from '@peac/adapter-x402';

const artifact = extractReceiptArtifactFromHeaders(headers);
// artifact.receipt_jws: PEAC compact JWS only
// artifact.upstreamArtifact: raw upstream data (preserved as-is)
// artifact.artifactFormat: 'peac' | 'x402-v1' | 'x402-v2'

Stripe

Payment intent observation and SPT delegation evidence. Commerce event fields are set only when the upstream PaymentIntent explicitly proves the claimed payment state.

Terminal
pnpm add @peac/rails-stripe

Payment intent observation

stripe-observation.ts
import { fromStripePaymentIntentObservation } from '@peac/rails-stripe';

const evidence = fromStripePaymentIntentObservation(paymentIntent);
// succeeded -> commerce event: settlement
// requires_capture -> commerce event: authorization
// processing, canceled -> no commerce event

SPT delegation lifecycle

Delegation events record token lifecycle, not payment finality:

EventTypeCommerce event
delegated_payment_grantedDelegation lifecycleNone
delegated_payment_presentedDelegation lifecycleNone
delegated_payment_deactivatedDelegation lifecycleNone

Razorpay

India payment adapter supporting UPI, cards, netbanking, and wallet payments.

Terminal
pnpm add @peac/rails-razorpay
razorpay-evidence.ts
import { fromRazorpayPayment } from '@peac/rails-razorpay';

const evidence = fromRazorpayPayment({
paymentId: 'pay_abc123',
orderId: 'order_xyz789',
method: 'upi',
amount: 1000,
currency: 'INR',
});

Card networks

Generic card billing bridge for Visa, Mastercard, and Amex.

Terminal
pnpm add @peac/rails-card
card-evidence.ts
import { fromCardPayment } from '@peac/rails-card';

const evidence = fromCardPayment({
network: 'visa',
authorizationCode: 'AUTH123',
last4: '4242',
amount: 1999,
currency: 'USD',
});

Commerce extension (Wire 0.2)

All commerce evidence uses the org.peacprotocol/commerce extension group:

issue-commerce-receipt.ts
import { issueWire02 } from '@peac/protocol';

const receipt = await issueWire02({
privateKey: process.env.PEAC_PRIVATE_KEY,
kid: 'peac-2026-03',
claims: {
iss: 'https://api.example.com',
kind: 'evidence',
type: 'org.peacprotocol/payment',
pillars: ['commerce'],
extensions: {
'org.peacprotocol/commerce': {
payment_rail: 'stripe',
amount_minor: '2500',
currency: 'USD',
event: 'settlement',
},
},
},
});

The event field is a 6-value closed enum (authorization, settlement, void, refund, chargeback, observation) and is observational metadata only. It records what the upstream system reported, not more.


Semantic boundary

PEAC mappings preserve raw upstream artifacts and never synthesize payment finality:

  • An ACP session "completed" does not prove payment settled
  • An SPT "grant" does not prove payment authorized
  • A paymentauth receipt proves what the upstream server attested, not more
  • event fields are set only when the upstream artifact explicitly proves the claimed state