@nevermined-io/payments
    Preparing search index...

    Function buildPaymentRequired

    • Build an X402PaymentRequired object for verify/settle operations.

      This helper simplifies the creation of payment requirement objects that are needed for the facilitator API.

      Parameters

      • planId: string

        The Nevermined plan identifier (required)

      • Optionaloptions: {
            agentId?: string;
            description?: string;
            endpoint?: string;
            environment?: EnvironmentName;
            httpVerb?: string;
            mimeType?: string;
            network?: string;
            scheme?: X402SchemeType;
        }

        Optional configuration with endpoint, agentId, httpVerb, network, description

      Returns X402PaymentRequired

      X402PaymentRequired object ready to use with verifyPermissions/settlePermissions

      import { buildPaymentRequired } from '@nevermined-io/payments'

      const paymentRequired = buildPaymentRequired('123456789', {
      endpoint: '/api/v1/agents/task',
      agentId: '987654321',
      httpVerb: 'POST'
      })

      const result = await payments.facilitator.verifyPermissions({
      paymentRequired,
      x402AccessToken: token,
      maxAmount: 2n
      })