T402 API Reference - v2.8.0
    Preparing search index...

    Class ExactDirectNearServer

    NEAR server implementation for the Exact-Direct payment scheme. Handles price parsing and converts user-friendly amounts to token amounts.

    Implements

    Index

    Constructors

    Properties

    scheme: "exact-direct" = SCHEME_EXACT_DIRECT

    Methods

    • Register a custom money parser in the parser chain. Multiple parsers can be registered - they will be tried in registration order. Each parser receives a decimal amount (e.g., 1.50 for $1.50). If a parser returns null, the next parser in the chain will be tried. The default parser is always the final fallback.

      Parameters

      • parser: MoneyParser

        Custom function to convert amount to AssetAmount (or null to skip)

      Returns ExactDirectNearServer

      The server instance for chaining

    • Parses a price into an asset amount. If price is already an AssetAmount, returns it directly. If price is Money (string | number), parses to decimal and tries custom parsers. Falls back to default conversion if all custom parsers return null.

      Parameters

      • price: Price

        The price to parse

      • network: Network

        The network to use

      Returns Promise<AssetAmount>

      Promise that resolves to the parsed asset amount

    • Build payment requirements for this scheme/network combination.

      Parameters

      • paymentRequirements: PaymentRequirements

        Base payment requirements with amount/asset already set

      • supportedKind: {
            t402Version: number;
            scheme: string;
            network: Network;
            extra?: Record<string, unknown>;
        }

        The supported kind from facilitator's /supported endpoint

      • extensionKeys: string[]

        Extensions supported by the facilitator

      Returns Promise<PaymentRequirements>

      Enhanced payment requirements ready to be sent to clients