Class X402V2Client

java.lang.Object
tech.mogami.java.client.X402V2Client

public class X402V2Client extends Object
Mogami Java client X402 V2. All public APIs in this package are non-null by default.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    buildPaymentHeader(tech.mogami.commons.payment.PaymentPayload signedPaymentPayload)
    Builds a payment header from the given signed PaymentPayload.
    buildPaymentHeaders(tech.mogami.commons.payment.PaymentPayload signedPaymentPayload)
    Builds payment headers from the given signed PaymentPayload.
    tech.mogami.commons.payment.PaymentPayload
    buildPaymentPayload(tech.mogami.commons.payment.PaymentRequired paymentRequired, tech.mogami.commons.payment.PaymentRequirements paymentRequirementsSelected, org.web3j.crypto.Credentials credentials)
    Build a signed payment payload based on the given PaymentRequirements and fromAddress.
    Optional<tech.mogami.commons.payment.extensions.bazaar.BazaarExtension>
    extractBazaarExtension(tech.mogami.commons.payment.PaymentRequired paymentRequired)
    Extract the BazaarExtension from the given PaymentRequired.
    Optional<tech.mogami.commons.payment.PaymentRequired>
    Extract the PaymentRequired from the given headers.
    Optional<tech.mogami.commons.api.facilitator.settle.SettlementResponse>
    Extract the SettlementResponse from the given headers.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • X402V2Client

      public X402V2Client()
  • Method Details

    • extractPaymentRequired

      public Optional<tech.mogami.commons.payment.PaymentRequired> extractPaymentRequired(Map<String,String> headers)
      Extract the PaymentRequired from the given headers.
      Parameters:
      headers - The headers to fetch the PaymentRequired from.
      Returns:
      An Optional containing the PaymentRequired if present.
      Throws:
      tech.mogami.commons.exception.InvalidX402HeaderException - if the extracted PaymentRequired has an unsupported x402 version.
    • buildPaymentPayload

      public tech.mogami.commons.payment.PaymentPayload buildPaymentPayload(tech.mogami.commons.payment.PaymentRequired paymentRequired, tech.mogami.commons.payment.PaymentRequirements paymentRequirementsSelected, org.web3j.crypto.Credentials credentials)
      Build a signed payment payload based on the given PaymentRequirements and fromAddress.
      Parameters:
      paymentRequired - The payment required.
      paymentRequirementsSelected - The payment requirements.
      credentials - The credentials to derive the fromAddress.
      Returns:
      A PaymentPayload object.
    • buildPaymentHeader

      public String buildPaymentHeader(tech.mogami.commons.payment.PaymentPayload signedPaymentPayload)
      Builds a payment header from the given signed PaymentPayload.
      Parameters:
      signedPaymentPayload - The signed payment payload.
      Returns:
      The payment header as a String.
    • buildPaymentHeaders

      public Map<String,String> buildPaymentHeaders(tech.mogami.commons.payment.PaymentPayload signedPaymentPayload)
      Builds payment headers from the given signed PaymentPayload.
      Parameters:
      signedPaymentPayload - The signed payment payload.
      Returns:
      A map of payment headers.
    • extractBazaarExtension

      public Optional<tech.mogami.commons.payment.extensions.bazaar.BazaarExtension> extractBazaarExtension(tech.mogami.commons.payment.PaymentRequired paymentRequired)
      Extract the BazaarExtension from the given PaymentRequired.
      Parameters:
      paymentRequired - The PaymentRequired containing potential bazaar extension data.
      Returns:
      An Optional containing the BazaarExtension if present.
    • extractSettlementResponse

      public Optional<tech.mogami.commons.api.facilitator.settle.SettlementResponse> extractSettlementResponse(Map<String,String> headers)
      Extract the SettlementResponse from the given headers.
      Parameters:
      headers - The headers to retrieve the SettlementResponse from.
      Returns:
      An Optional containing the SettlementResponse if present.