main
go 64 lines 2.14 KB
Raw
1 package types
2
3 import (
4 "net/http"
5 "time"
6
7 facilitatortypes "github.com/gosuda/x402-facilitator/types"
8 )
9
10 // X402FacilitatorInfo describes relay-owned x402 control-plane facilitator settings exposed by the API.
11 type X402FacilitatorInfo struct {
12 Enabled bool `json:"enabled"`
13 URL string `json:"url,omitempty"`
14 Network string `json:"network,omitempty"`
15 NetworkName string `json:"network_name,omitempty"`
16 SupportedURL string `json:"supported_url,omitempty"`
17 PayTo string `json:"pay_to,omitempty"`
18 }
19
20 // X402Payment is the stable x402 payment contract shared by SDK helpers and payment apps.
21 type X402Payment struct {
22 Testnet bool
23 Network string
24 NetworkName string
25 Asset string
26 PayTo string
27 Amount string
28 MaxTimeoutSeconds int
29 RequestTimeout time.Duration
30 Endpoints []string
31 ResourcePath string
32 ResourceDescription string
33 ResourceMimeType string
34 }
35
36 // X402PaymentResult is the successful settlement data passed to protected handlers.
37 type X402PaymentResult struct {
38 TransactionID string
39 Network string
40 Payer string
41 }
42
43 // X402PaymentHandlerFunc handles a request after its x402 payment has settled.
44 type X402PaymentHandlerFunc func(http.ResponseWriter, *http.Request, X402PaymentResult)
45
46 // X402PreparePaymentRequest is the shared prepare endpoint request body.
47 type X402PreparePaymentRequest struct {
48 Sender string `json:"sender"`
49 Method string `json:"method,omitempty"`
50 Path string `json:"path,omitempty"`
51 }
52
53 // X402PreparePaymentResponse is the wallet transaction payload returned by a payment prepare endpoint.
54 type X402PreparePaymentResponse struct {
55 X402Version int `json:"x402Version"`
56 PaymentRequirements facilitatortypes.PaymentRequirements `json:"paymentRequirements"`
57 Resource *facilitatortypes.ResourceInfo `json:"resource,omitempty"`
58 PrepareTransaction *struct {
59 Transaction string `json:"transaction"`
60 } `json:"prepareTransaction,omitempty"`
61 PaymentTransaction struct {
62 Transaction string `json:"transaction"`
63 } `json:"paymentTransaction"`
64 }