openpayments

package module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 12, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

README

Development

Requires:

  • go1.22+

OpenAPI Specs

This repository contains a Git submodule, which contains the Open Payments OpenAPI specifications. After cloning, make sure to initialize and update it:

git submodule update --init

Alternatively, clone the repository with submodules in one step:

git clone --recurse-submodules https://github.com/interledger/open-payments-go.git

The SDK depends on types generated from the specs. To generate types from the specs:

go generate ./generated

Commands

Run tests

From root:

go test ./...

Note, this runs all tests including integration, which requires the Rafiki localenv.

Integration tests can be run against a local or testnet Rafiki environment:

go test ./test/integration -env=testnet

Or to run test from a specific package:

go test ./httpsignatureutils

To include all logs for debugging or development:

go test -v ./...

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthenticatedClient

type AuthenticatedClient struct {
	WalletAddress   *WalletAddressService
	Grant           *GrantService
	IncomingPayment *IncomingPaymentService
	Quote           *QuoteService
	Token           *TokenService
	OutgoingPayment *OutgoingPaymentService
	// contains filtered or unexported fields
}

func NewAuthenticatedClient

func NewAuthenticatedClient(walletAddressUrl string, privateKey string, keyId string, opts ...AuthenticatedClientOption) (*AuthenticatedClient, error)

func (*AuthenticatedClient) DoSigned

func (c *AuthenticatedClient) DoSigned(req *http.Request) (*http.Response, error)

type AuthenticatedClientOption

type AuthenticatedClientOption func(*AuthenticatedClient)

AuthenticatedClientOption is used to configure optional behavior for the authenticated client.

func WithHTTPClientAuthed

func WithHTTPClientAuthed(c *http.Client) AuthenticatedClientOption

WithHTTPClientAuthed allows setting a custom HTTP client.

WARNING: Use with care. Replacing the internal http.Client could break built-in behavior.

func WithPostSignHook

func WithPostSignHook(hook func(req *http.Request)) AuthenticatedClientOption

func WithPreSignHook

func WithPreSignHook(hook func(req *http.Request)) AuthenticatedClientOption

type Client

type Client struct {
	WalletAddress   *WalletAddressService
	IncomingPayment *PublicIncomingPaymentService
	// contains filtered or unexported fields
}

func NewClient

func NewClient(opts ...ClientOption) *Client

type ClientOption

type ClientOption func(*Client)

ClientOption is used to configure optional behavior for the Open Payments client.

func WithHTTPClientUnauthed

func WithHTTPClientUnauthed(c *http.Client) ClientOption

WithHTTPClientUnauthed allows setting a custom HTTP client.

WARNING: Use with care. Replacing the internal http.Client could break built-in behavior.

type Grant

type Grant struct {
	Interact    *as.InteractResponse `json:"interact,omitempty"`
	AccessToken *as.AccessToken      `json:"access_token,omitempty"`
	Subject     *as.Subject          `json:"subject,omitempty"`
	Continue    as.Continue          `json:"continue"`
}

TODO: Address missing grant request type in generated types. This re-constructs from the generated types therefore is prone to drift from OpenAPI spec.

func (*Grant) IsGranted deprecated

func (gr *Grant) IsGranted() bool

IsGranted reports whether the grant contains an access token.

Deprecated: use IsGrantedWithAccessToken instead.

func (*Grant) IsGrantedWithAccessToken

func (gr *Grant) IsGrantedWithAccessToken() bool

IsGrantedWithAccessToken reports whether the grant contains an access token.

func (*Grant) IsGrantedWithSubject

func (gr *Grant) IsGrantedWithSubject() bool

IsGrantedWithSubject reports whether the grant contains subject information.

func (*Grant) IsInteractive

func (gr *Grant) IsInteractive() bool

type GrantCancelParams

type GrantCancelParams struct {
	URL         string // continue URI
	AccessToken string
}

type GrantContinueParams

type GrantContinueParams struct {
	URL         string
	AccessToken string
	InteractRef string
}

type GrantRequestParams

type GrantRequestParams struct {
	URL         string // Auth server URL
	RequestBody as.GrantRequest
	// ClientOverride, when set, replaces the default wallet-address client
	// identification with a JWK (directed identity). Per spec, only valid for
	// non-interactive grants (e.g. incoming payments).
	ClientOverride *as.ClientDirectedIdentity
}

type GrantService

type GrantService struct {
	DoSigned RequestDoer
	// contains filtered or unexported fields
}

func (*GrantService) Cancel

func (gs *GrantService) Cancel(ctx context.Context, params GrantCancelParams) error

func (*GrantService) Continue

func (gs *GrantService) Continue(ctx context.Context, params GrantContinueParams) (Grant, error)

func (*GrantService) Request

func (gs *GrantService) Request(ctx context.Context, params GrantRequestParams) (Grant, error)

type IncomingPaymentCompleteParams

type IncomingPaymentCompleteParams struct {
	URL         string // The incoming payment url
	AccessToken string
}

type IncomingPaymentCreateParams

type IncomingPaymentCreateParams struct {
	BaseURL     string // The base URL for creating an incoming payment
	AccessToken string
	Payload     rs.CreateIncomingPaymentRequest
}

type IncomingPaymentGetParams

type IncomingPaymentGetParams struct {
	URL         string // The full URL of the incoming payment resource.
	AccessToken string
}

type IncomingPaymentGetPublicParams

type IncomingPaymentGetPublicParams struct {
	URL string // The full URL of the public incoming payment resource.
}

type IncomingPaymentListParams

type IncomingPaymentListParams struct {
	BaseURL       string // The base URL for the incoming payments collection.
	AccessToken   string
	WalletAddress string
	Pagination    Pagination
}

type IncomingPaymentListResponse

type IncomingPaymentListResponse struct {
	Pagination rs.PageInfo                     `json:"pagination"`
	Result     []rs.IncomingPaymentWithMethods `json:"result"`
}

type IncomingPaymentService

type IncomingPaymentService struct {
	DoUnsigned RequestDoer
	DoSigned   RequestDoer
}

func (*IncomingPaymentService) Complete

func (*IncomingPaymentService) Create

TODO: should Create handle adding /incoming-paymnets or nah? php and rust do, ts doesnt

func (*IncomingPaymentService) Get

func (*IncomingPaymentService) GetPublic

func (*IncomingPaymentService) List

type OpenPaymentsClientError

type OpenPaymentsClientError struct {
	Description      string
	Status           int
	Code             string
	ValidationErrors []string
	Details          map[string]any
	Method           string
	URL              string
}

func (*OpenPaymentsClientError) Error

func (e *OpenPaymentsClientError) Error() string

type OutgoingPaymentCreateParams

type OutgoingPaymentCreateParams struct {
	BaseURL     string // The base URL for creating an outgoing payment
	AccessToken string
	Payload     rs.CreateOutgoingPaymentRequest
}

type OutgoingPaymentGetParams

type OutgoingPaymentGetParams struct {
	URL         string // The full URL of the outgoing payment resource.
	AccessToken string
}

type OutgoingPaymentGrantGetParams

type OutgoingPaymentGrantGetParams struct {
	BaseURL     string // The base URL of the wallet address.
	AccessToken string
}

type OutgoingPaymentGrantSpentAmounts

type OutgoingPaymentGrantSpentAmounts struct {
	SpentReceiveAmount *rs.Amount `json:"spentReceiveAmount"`
	SpentDebitAmount   *rs.Amount `json:"spentDebitAmount"`
}

type OutgoingPaymentListParams

type OutgoingPaymentListParams struct {
	BaseURL       string // The base URL for the outgoing payments collection.
	AccessToken   string
	WalletAddress string
	Pagination    Pagination
}

type OutgoingPaymentListResponse

type OutgoingPaymentListResponse struct {
	Pagination rs.PageInfo          `json:"pagination"`
	Result     []rs.OutgoingPayment `json:"result"`
}

type OutgoingPaymentService

type OutgoingPaymentService struct {
	DoSigned RequestDoer
}

func (*OutgoingPaymentService) Create

TODO: ensure this works with/without quoteId in the params.payload

func (*OutgoingPaymentService) Get

func (*OutgoingPaymentService) GetGrantSpentAmounts

func (*OutgoingPaymentService) List

type Pagination

type Pagination struct {
	First  string
	Last   string
	Cursor string
}

type PublicIncomingPaymentService

type PublicIncomingPaymentService struct {
	DoUnsigned RequestDoer
}

func (*PublicIncomingPaymentService) GetPublic

type QuoteCreateParams

type QuoteCreateParams struct {
	BaseURL     string // The base URL for creating a quote (e.g., wallet address URL).
	AccessToken string
	// TODO: cant use rs.CreateQuoteRequest (unexported `union`). Consumers should pass one of
	// the named variants directly: rs.CreateQuoteRequestByReceiver, rs.CreateQuoteRequestWithReceiveAmount,
	// or rs.CreateQuoteRequestWithDebitAmount.
	Payload any
}

type QuoteGetParams

type QuoteGetParams struct {
	URL         string // The full URL of the quote resource.
	AccessToken string
}

type QuoteService

type QuoteService struct {
	DoUnsigned RequestDoer
	DoSigned   RequestDoer
}

func (*QuoteService) Create

func (qs *QuoteService) Create(ctx context.Context, params QuoteCreateParams) (rs.Quote, error)

func (*QuoteService) Get

func (qs *QuoteService) Get(ctx context.Context, params QuoteGetParams) (rs.Quote, error)

type RequestDoer

type RequestDoer func(req *http.Request) (*http.Response, error)

type TokenRevokeParams

type TokenRevokeParams struct {
	URL         string // The full URL of the token resource to revoke
	AccessToken string
}

type TokenRotateParams

type TokenRotateParams struct {
	URL         string // The full URL of the token resource to rotate
	AccessToken string
}

type TokenService

type TokenService struct {
	DoSigned RequestDoer
}

func (*TokenService) Revoke

func (ts *TokenService) Revoke(ctx context.Context, params TokenRevokeParams) error

func (*TokenService) Rotate

func (ts *TokenService) Rotate(ctx context.Context, params TokenRotateParams) (as.AccessToken, error)

type WalletAddressGetKeysParams

type WalletAddressGetKeysParams struct {
	URL string // The full URL of the wallet address resource.
}

type WalletAddressGetParams

type WalletAddressGetParams struct {
	URL string // The full URL of the wallet address resource.
}

type WalletAddressService

type WalletAddressService struct {
	DoUnsigned RequestDoer
}

func (*WalletAddressService) Get

func (*WalletAddressService) GetKeys

Directories

Path Synopsis
authserver
Package api provides primitives to interact with the openapi HTTP API.
Package api provides primitives to interact with the openapi HTTP API.
resourceserver
Package api provides primitives to interact with the openapi HTTP API.
Package api provides primitives to interact with the openapi HTTP API.
walletaddressserver
Package api provides primitives to interact with the openapi HTTP API.
Package api provides primitives to interact with the openapi HTTP API.
TODO ts client has key and jwk files.
TODO ts client has key and jwk files.
internal
scripts/release command
test

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL