Elixir implementation of the Machine Payments Protocol (MPP).

MPP enables machine-to-machine payments via HTTP 402. This library provides Plug middleware that adds pay-per-call billing to any Phoenix or Plug application.

How it works

  1. Client requests a protected resource
  2. Server responds with 402 Payment Required and a payment challenge
  3. Client fulfills payment (Stripe, stablecoins, or on-chain)
  4. Client retries with payment credential in Authorization: Payment header
  5. Server verifies payment and returns the resource with a Payment-Receipt header

No user accounts. No API keys. No signup flow. Payment is authentication.

Protocol

Built on the MPP specification — an IETF draft co-developed by Stripe and Tempo Labs. Also supports x402 for on-chain payments.

Modules

Discovery

Use MPP.describe/0-2 for progressive API discovery:

MPP.describe()                          # Level 1: all modules
MPP.describe(:challenge)                # Level 2: functions in Challenge
MPP.describe(:challenge, :create)       # Level 3: full contract for create/2

Summary

Functions

Return the list of modules registered with this library.

Return a Level 1 overview of all modules in this library.

Return Level 2 function list for a module (by full atom or short name).

Return Level 3 function detail (or nil if not found).

Functions

__descripex_modules__()

@spec __descripex_modules__() :: [module()]

Return the list of modules registered with this library.

describe()

@spec describe() :: [map()]

Return a Level 1 overview of all modules in this library.

describe(mod_or_short)

@spec describe(module() | atom()) :: [map()]

Return Level 2 function list for a module (by full atom or short name).

describe(mod_or_short, func_name)

@spec describe(module() | atom(), atom()) :: map() | nil

Return Level 3 function detail (or nil if not found).