Package tech.mogami.java.client
Class X402V2Client
java.lang.Object
tech.mogami.java.client.X402V2Client
Mogami Java client X402 V2.
All public APIs in this package are non-null by default.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuildPaymentHeader(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.PaymentPayloadbuildPaymentPayload(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.PaymentRequired> extractPaymentRequired(Map<String, String> headers) Extract the PaymentRequired from the given headers.Optional<tech.mogami.commons.api.facilitator.settle.SettlementResponse> extractSettlementResponse(Map<String, String> headers) Extract the SettlementResponse from the given headers.
-
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
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.
-
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.
-