Documentation
¶
Index ¶
- func ConfigureRouter(router chi.Router, cfg *config.Config, paywallSvc *paywall.Service, ...)
- func NewRPCProxyHandlers(cfg *config.Config) *rpcProxyHandlers
- type A2AAgentCard
- type A2AAuthentication
- type A2APaymentMethod
- type CouponSummary
- type MCPError
- type MCPResource
- type MCPResourcesListRequest
- type MCPResourcesListResponse
- type MCPResourcesListResult
- type ProductResponse
- type ProductsListResponse
- type QuoteRequest
- type Server
- type ValidateCouponRequest
- type ValidateCouponResponse
- type VerifyRequest
- type WellKnownCryptoPrice
- type WellKnownFiatPrice
- type WellKnownPaymentInfo
- type WellKnownPaymentOptions
- type WellKnownPriceInfo
- type WellKnownResourceEntry
- type X402Config
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConfigureRouter ¶
func ConfigureRouter(router chi.Router, cfg *config.Config, paywallSvc *paywall.Service, stripeClient *stripesvc.Client, verifier x402.Verifier, rpcProxy *rpcProxyHandlers, cartService *stripesvc.CartService, couponRepo coupons.Repository, idempotencyStore idempotency.Store, metricsCollector *metrics.Metrics, subscriptionsSvc *subscriptions.Service, appLogger zerolog.Logger)
ConfigureRouter attaches Cedros routes to an existing router.
func NewRPCProxyHandlers ¶
NewRPCProxyHandlers creates handlers for RPC proxy endpoints.
Types ¶
type A2AAgentCard ¶
type A2AAgentCard struct {
Name string `json:"name"`
Version string `json:"version"`
Description string `json:"description"`
ServiceEndpoint string `json:"service_endpoint"`
Capabilities []string `json:"capabilities"`
Authentication A2AAuthentication `json:"authentication"`
PaymentMethods []A2APaymentMethod `json:"payment_methods"`
Metadata map[string]string `json:"metadata,omitempty"`
}
A2AAgentCard represents the Google Agent2Agent protocol agent card Published at /.well-known/agent.json for agent discovery
Specification: https://a2a-protocol.org/
type A2AAuthentication ¶
A2AAuthentication describes supported authentication methods
type A2APaymentMethod ¶
type A2APaymentMethod struct {
Type string `json:"type"`
Protocol string `json:"protocol"`
Network string `json:"network,omitempty"`
Description string `json:"description"`
}
A2APaymentMethod describes supported payment options
type CouponSummary ¶
type CouponSummary struct {
Code string `json:"code"`
DiscountType string `json:"discountType"` // "percentage", "fixed", "free"
DiscountValue float64 `json:"discountValue"` // Percentage (e.g., 20.0 for 20%) or fixed amount
Currency string `json:"currency,omitempty"`
Description string `json:"description,omitempty"`
}
CouponSummary represents a checkout-level coupon.
type MCPError ¶
type MCPError struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data,omitempty"`
}
MCPError represents a JSON-RPC 2.0 error
type MCPResource ¶
type MCPResource struct {
URI string `json:"uri"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
MimeType string `json:"mimeType,omitempty"`
}
MCPResource represents a single MCP resource
type MCPResourcesListRequest ¶
type MCPResourcesListRequest struct {
JSONRPC string `json:"jsonrpc"`
ID interface{} `json:"id"`
Method string `json:"method"`
Params map[string]interface{} `json:"params,omitempty"`
}
MCPResourcesListRequest represents a JSON-RPC 2.0 request for resources/list
type MCPResourcesListResponse ¶
type MCPResourcesListResponse struct {
JSONRPC string `json:"jsonrpc"`
ID interface{} `json:"id"`
Result *MCPResourcesListResult `json:"result,omitempty"`
Error *MCPError `json:"error,omitempty"`
}
MCPResourcesListResponse represents a JSON-RPC 2.0 response for resources/list
type MCPResourcesListResult ¶
type MCPResourcesListResult struct {
Resources []MCPResource `json:"resources"`
}
MCPResourcesListResult contains the list of available resources
type ProductResponse ¶
type ProductResponse struct {
ID string `json:"id"`
Description string `json:"description"`
FiatAmount float64 `json:"fiatAmount"`
EffectiveFiatAmount float64 `json:"effectiveFiatAmount"` // Price after catalog-level auto-apply coupon for Stripe
FiatCurrency string `json:"fiatCurrency"`
StripePriceID string `json:"stripePriceId,omitempty"`
CryptoAmount float64 `json:"cryptoAmount"`
EffectiveCryptoAmount float64 `json:"effectiveCryptoAmount"` // Price after catalog-level auto-apply coupon for x402
CryptoToken string `json:"cryptoToken"`
HasStripeCoupon bool `json:"hasStripeCoupon"` // True if Stripe catalog-level auto-apply coupon exists
HasCryptoCoupon bool `json:"hasCryptoCoupon"` // True if x402 catalog-level auto-apply coupon exists
StripeCouponCode string `json:"stripeCouponCode,omitempty"` // Stripe catalog-level auto-apply coupon code
CryptoCouponCode string `json:"cryptoCouponCode,omitempty"` // x402 catalog-level auto-apply coupon code
StripeDiscountPercent float64 `json:"stripeDiscountPercent"` // Percentage off for Stripe (catalog-level)
CryptoDiscountPercent float64 `json:"cryptoDiscountPercent"` // Percentage off for x402 (catalog-level)
Metadata map[string]string `json:"metadata,omitempty"`
}
ProductResponse represents the JSON structure returned to the frontend.
type ProductsListResponse ¶
type ProductsListResponse struct {
Products []ProductResponse `json:"products"`
CheckoutStripeCoupons []CouponSummary `json:"checkoutStripeCoupons"` // Auto-apply coupons for Stripe at checkout
CheckoutCryptoCoupons []CouponSummary `json:"checkoutCryptoCoupons"` // Auto-apply coupons for x402 at checkout
}
ProductsListResponse wraps the product list with checkout-level coupons.
type QuoteRequest ¶
type QuoteRequest struct {
Resource string `json:"resource"`
CouponCode *string `json:"couponCode,omitempty"`
}
QuoteRequest represents a request to generate a payment quote.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server wires handlers, middleware, and dependencies.
func New ¶
func New(cfg *config.Config, paywallSvc *paywall.Service, stripeClient *stripesvc.Client, cartService *stripesvc.CartService, verifier x402.Verifier, couponRepo coupons.Repository, idempotencyStore idempotency.Store, metricsCollector *metrics.Metrics, subscriptionsSvc *subscriptions.Service, appLogger zerolog.Logger) *Server
New builds the HTTP server with configured router.
func (*Server) ListenAndServe ¶
ListenAndServe starts the HTTP server.
type ValidateCouponRequest ¶
type ValidateCouponRequest struct {
Code string `json:"code"`
ProductIDs []string `json:"productIds,omitempty"` // Optional: products to validate against
PaymentMethod string `json:"paymentMethod,omitempty"` // Optional: "stripe", "x402", or empty for any
}
ValidateCouponRequest represents the request body for coupon validation.
type ValidateCouponResponse ¶
type ValidateCouponResponse struct {
Valid bool `json:"valid"`
Code string `json:"code,omitempty"`
DiscountType string `json:"discountType,omitempty"`
DiscountValue float64 `json:"discountValue,omitempty"`
Scope string `json:"scope,omitempty"` // "all" or "specific"
ApplicableProducts []string `json:"applicableProducts,omitempty"` // Only relevant when scope="specific"
PaymentMethod string `json:"paymentMethod,omitempty"` // Payment method restriction: "", "stripe", or "x402"
ExpiresAt *string `json:"expiresAt,omitempty"` // RFC3339 timestamp
RemainingUses *int `json:"remainingUses,omitempty"`
ErrorMessage string `json:"error,omitempty"`
}
ValidateCouponResponse represents the response for coupon validation.
type VerifyRequest ¶
type VerifyRequest struct {
}
VerifyRequest represents the internal structure for verify endpoint. The resource and resourceType are extracted from the X-PAYMENT header payload.
type WellKnownCryptoPrice ¶
WellKnownCryptoPrice contains crypto pricing
type WellKnownFiatPrice ¶
WellKnownFiatPrice contains fiat pricing
type WellKnownPaymentInfo ¶
type WellKnownPaymentInfo struct {
Methods []string `json:"methods"` // e.g., ["stripe", "x402-solana-spl-transfer"]
X402 *X402Config `json:"x402,omitempty"`
}
WellKnownPaymentInfo describes supported payment methods
type WellKnownPaymentOptions ¶
type WellKnownPaymentOptions struct {
Version string `json:"version"` // x402 protocol version
Server string `json:"server"` // Server identifier
Resources []WellKnownResourceEntry `json:"resources"` // Available paid resources
Payment WellKnownPaymentInfo `json:"payment"` // Payment configuration
}
WellKnownPaymentOptions represents the /.well-known/payment-options response This follows the RFC 8615 well-known URI standard for service discovery
type WellKnownPriceInfo ¶
type WellKnownPriceInfo struct {
Fiat *WellKnownFiatPrice `json:"fiat,omitempty"`
Crypto *WellKnownCryptoPrice `json:"crypto,omitempty"`
}
WellKnownPriceInfo contains pricing information
type WellKnownResourceEntry ¶
type WellKnownResourceEntry struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Endpoint string `json:"endpoint"`
Price WellKnownPriceInfo `json:"price"`
Metadata map[string]string `json:"metadata,omitempty"`
}
WellKnownResourceEntry represents a single resource in the discovery response
type X402Config ¶
type X402Config struct {
Network string `json:"network"` // e.g., "mainnet-beta"
PaymentAddress string `json:"paymentAddress"` // Recipient address
TokenMint string `json:"tokenMint"` // Token contract address
}
X402Config describes x402 payment configuration
Source Files
¶
- handlers_a2a.go
- handlers_cart.go
- handlers_cart_quote.go
- handlers_cart_verify.go
- handlers_coupons.go
- handlers_gasless.go
- handlers_mcp.go
- handlers_openapi.go
- handlers_paywall.go
- handlers_paywall_quote.go
- handlers_products.go
- handlers_refund.go
- handlers_refund_verify.go
- handlers_stripe.go
- handlers_subscription_mgmt.go
- handlers_subscriptions.go
- handlers_wellknown.go
- middleware_metrics.go
- middleware_security.go
- response_helpers.go
- rpc_proxy.go
- server.go
- util.go