Skip to Content
Developer ToolsSDKsMerchant SDKs

Merchant SDKs

Description and purpose

The Merchant SDK is a library that intercepts your route handlers, manages the 402 challenge-and-response cycle and verifies the onchain payment, all in a few lines of code.

Available languages

  • TypeScript
  • Python (coming soon)

How to download the Merchant SDK

  1. Create an account in the Merchant Portal.
  2. Create API keys.
  3. Download the SDK in your preferred language (TypeScript for now).

Integrating the SDK into the resource server

The merchant is responsible for the integration. It uses the Merchant SDK directly in the code base of its resource server, and uses it to guide the agent step by step through the payment flow:

  1. Integrate the SDK. Wrap your endpoint or checkout route with the Merchant SDK.
  2. Send dynamic instructions (HTTP 402). When the agent requests access or attempts to check out, the middleware intercepts the call and builds a standardized 402 Payment Required response. The PAYMENT-REQUIRED header carries machine-readable instructions: the price, the asset (for example USDC or USD8), the recipient address and the payment scheme required (exact, upto, batch and so on).
  3. Guide the next step. The agent reads the header and learns which scheme the merchant expects. It signs the corresponding payment payload with its session key and attaches it as PAYMENT-SIGNATURE in the retry.
  4. Verify automatically. The Merchant SDK on the merchant’s server receives the signed payload and routes it to the Facilitator for verification and settlement. When the Facilitator confirms the payment, the SDK unlocks the service and returns PAYMENT-RESPONSE.