Documentation
¶
Overview ¶
Package nakopay is the official Go SDK for the NakoPay API.
Create a client with nakopay.New(apiKey) and call resources via the returned *Client (e.g. client.Invoices.Create).
All money values are decimal strings; do not use float64.
Index ¶
- Constants
- type APIError
- type APIKey
- type APIKeyList
- type Client
- type ConnectionError
- type CreditBalance
- type CreditsResource
- type Customer
- type CustomerCreateParams
- type CustomerList
- type CustomersResource
- func (r *CustomersResource) Create(ctx context.Context, p *CustomerCreateParams, opts ...RequestOption) (*Customer, error)
- func (r *CustomersResource) List(ctx context.Context, limit int, startingAfter string, opts ...RequestOption) (*CustomerList, error)
- func (r *CustomersResource) Retrieve(ctx context.Context, id string, opts ...RequestOption) (*Customer, error)
- type Event
- type EventList
- type EventListParams
- type EventsResource
- type Invoice
- type InvoiceCreateParams
- type InvoiceList
- type InvoiceListParams
- type InvoicesResource
- func (r *InvoicesResource) Cancel(ctx context.Context, id string, opts ...RequestOption) (*Invoice, error)
- func (r *InvoicesResource) Create(ctx context.Context, p *InvoiceCreateParams, opts ...RequestOption) (*Invoice, error)
- func (r *InvoicesResource) Each(ctx context.Context, p *InvoiceListParams, fn func(*Invoice) bool) error
- func (r *InvoicesResource) List(ctx context.Context, p *InvoiceListParams, opts ...RequestOption) (*InvoiceList, error)
- func (r *InvoicesResource) Retrieve(ctx context.Context, id string, opts ...RequestOption) (*Invoice, error)
- type KeyCreateParams
- type KeysResource
- func (r *KeysResource) Create(ctx context.Context, p *KeyCreateParams, opts ...RequestOption) (*APIKey, error)
- func (r *KeysResource) List(ctx context.Context, opts ...RequestOption) (*APIKeyList, error)
- func (r *KeysResource) Revoke(ctx context.Context, id string, opts ...RequestOption) error
- func (r *KeysResource) Rotate(ctx context.Context, id string, opts ...RequestOption) (*APIKey, error)
- type LogEntry
- type LogList
- type LogListParams
- type LogsResource
- type Option
- type PaymentLink
- type PaymentLinkCreateParams
- type PaymentLinksResource
- type PaymentMethod
- type Rates
- type RatesResource
- type Refund
- type RefundCreateParams
- type RefundList
- type RefundListParams
- type RefundsResource
- func (r *RefundsResource) Cancel(ctx context.Context, id string, opts ...RequestOption) (*Refund, error)
- func (r *RefundsResource) Create(ctx context.Context, p *RefundCreateParams, opts ...RequestOption) (*Refund, error)
- func (r *RefundsResource) List(ctx context.Context, p *RefundListParams, opts ...RequestOption) (*RefundList, error)
- func (r *RefundsResource) Retrieve(ctx context.Context, id string, opts ...RequestOption) (*Refund, error)
- type RequestOption
- type SandboxResource
- type SandboxSeedParams
- type SandboxSeedResult
- type SignatureVerificationError
- type Subscription
- type SubscriptionList
- type SubscriptionListParams
- type SubscriptionPauseResult
- type SubscriptionPlan
- type SubscriptionPlanList
- type SubscriptionPlansResource
- type SubscriptionPortalResult
- type SubscriptionResumeResult
- type SubscriptionsResource
- func (r *SubscriptionsResource) Cancel(ctx context.Context, id string, atPeriodEnd bool, opts ...RequestOption) (*Subscription, error)
- func (r *SubscriptionsResource) List(ctx context.Context, p *SubscriptionListParams, opts ...RequestOption) (*SubscriptionList, error)
- func (r *SubscriptionsResource) Pause(ctx context.Context, id, token string, opts ...RequestOption) (*SubscriptionPauseResult, error)
- func (r *SubscriptionsResource) Portal(ctx context.Context, id string, opts ...RequestOption) (*SubscriptionPortalResult, error)
- func (r *SubscriptionsResource) Resume(ctx context.Context, id, token string, opts ...RequestOption) (*SubscriptionResumeResult, error)
- func (r *SubscriptionsResource) Retrieve(ctx context.Context, id string, opts ...RequestOption) (*Subscription, error)
- type Topup
- type TopupCreateParams
- type TopupsResource
- type WebhookCreateParams
- type WebhookEndpoint
- type WebhookReplayResult
- type WebhooksResource
- func (r *WebhooksResource) Create(ctx context.Context, p *WebhookCreateParams, opts ...RequestOption) (*WebhookEndpoint, error)
- func (r *WebhooksResource) Delete(ctx context.Context, id string, opts ...RequestOption) error
- func (r *WebhooksResource) Replay(ctx context.Context, id, deliveryID string, opts ...RequestOption) (*WebhookReplayResult, error)
- func (r *WebhooksResource) Test(ctx context.Context, id string, opts ...RequestOption) error
Constants ¶
const DefaultAPIVersion = "2025-04-20"
DefaultAPIVersion is the API contract this SDK is pinned to.
const DefaultBaseURL = "https://api.nakopay.com/v1"
DefaultBaseURL is the production NakoPay API root.
DefaultWebhookTolerance is the +/- window allowed between the signed timestamp and the verifier's local clock. Default is 5 minutes.
const Version = "0.2.0"
Version of this SDK.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIError ¶
type APIError struct {
Code string `json:"code"`
Type string `json:"type,omitempty"`
Message string `json:"message"`
Param string `json:"param,omitempty"`
DocURL string `json:"doc_url,omitempty"`
RequestID string `json:"request_id,omitempty"`
StatusCode int `json:"-"`
}
APIError is returned for any non-2xx response from the NakoPay API.
func (*APIError) IsAuthentication ¶
IsAuthentication returns true if this is a 401 / authentication error.
func (*APIError) IsIdempotency ¶
IsIdempotency returns true if this is an idempotency conflict.
func (*APIError) IsRateLimit ¶
IsRateLimit returns true if this is a 429 / rate limit error.
type APIKey ¶
type APIKey struct {
ID string `json:"id"`
Object string `json:"object"`
Name string `json:"name,omitempty"`
Prefix string `json:"prefix"`
Scopes []string `json:"scopes"`
Livemode bool `json:"livemode"`
Created int64 `json:"created"`
LastUsed int64 `json:"last_used,omitempty"`
Revoked bool `json:"revoked"`
Secret string `json:"secret,omitempty"` // only on create/rotate
}
APIKey is a NakoPay API key record.
type APIKeyList ¶
APIKeyList is a page of API keys.
type Client ¶
type Client struct {
Invoices *InvoicesResource
Customers *CustomersResource
PaymentLinks *PaymentLinksResource
Webhooks *WebhooksResource
Events *EventsResource
Rates *RatesResource
Credits *CreditsResource
Keys *KeysResource
Subscriptions *SubscriptionsResource
SubscriptionPlans *SubscriptionPlansResource
Refunds *RefundsResource
Logs *LogsResource
Sandbox *SandboxResource
// contains filtered or unexported fields
}
Client is the entry point for all NakoPay API calls.
Construct one with New() and reuse it across goroutines (it is safe for concurrent use).
type ConnectionError ¶
type ConnectionError struct {
Err error
}
ConnectionError wraps any transport-level failure (DNS, refused, timeout).
func (*ConnectionError) Error ¶
func (e *ConnectionError) Error() string
func (*ConnectionError) Unwrap ¶
func (e *ConnectionError) Unwrap() error
type CreditBalance ¶
type CreditBalance struct {
BalanceSats string `json:"balance_sats"`
}
CreditBalance is the merchant's prepaid balance in sats.
type CreditsResource ¶
type CreditsResource struct {
Topups *TopupsResource
// contains filtered or unexported fields
}
CreditsResource bundles prepaid-credit endpoints.
func (*CreditsResource) Balance ¶
func (r *CreditsResource) Balance(ctx context.Context, opts ...RequestOption) (*CreditBalance, error)
Balance returns the current prepaid credit balance.
type Customer ¶
type Customer struct {
ID string `json:"id"`
Object string `json:"object"`
Email string `json:"email,omitempty"`
Name string `json:"name,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
Created int64 `json:"created"`
}
Customer is a stored merchant customer.
type CustomerCreateParams ¶
type CustomerCreateParams struct {
Email string `json:"email,omitempty"`
Name string `json:"name,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
}
CustomerCreateParams is the body for POST /customers.
type CustomerList ¶
type CustomerList struct {
Object string `json:"object"`
Data []Customer `json:"data"`
HasMore bool `json:"has_more"`
NextCursor string `json:"next_cursor,omitempty"`
}
CustomerList is a page of customers.
type CustomersResource ¶
type CustomersResource struct {
// contains filtered or unexported fields
}
CustomersResource exposes /customers endpoints.
func (*CustomersResource) Create ¶
func (r *CustomersResource) Create(ctx context.Context, p *CustomerCreateParams, opts ...RequestOption) (*Customer, error)
func (*CustomersResource) List ¶
func (r *CustomersResource) List(ctx context.Context, limit int, startingAfter string, opts ...RequestOption) (*CustomerList, error)
func (*CustomersResource) Retrieve ¶
func (r *CustomersResource) Retrieve(ctx context.Context, id string, opts ...RequestOption) (*Customer, error)
type Event ¶
type Event struct {
ID string `json:"id"`
Object string `json:"object"`
Type string `json:"type"`
APIVersion string `json:"api_version"`
Created int64 `json:"created"`
Livemode bool `json:"livemode"`
Data json.RawMessage `json:"data"`
}
Event is the parsed webhook payload.
func ConstructEvent ¶
ConstructEvent verifies the signature header and returns the parsed event.
Header format: t=<unix>,v1=<hex_hmac> Signed payload: <t>.<rawBody>
Use the default tolerance via ConstructEvent; pass ConstructEventWithTolerance for a custom one.
type EventList ¶
type EventList struct {
Object string `json:"object"`
Data []Event `json:"data"`
HasMore bool `json:"has_more"`
NextCursor string `json:"next_cursor,omitempty"`
}
EventList is a page of events.
type EventListParams ¶
EventListParams filters listEvent calls.
type EventsResource ¶
type EventsResource struct {
// contains filtered or unexported fields
}
EventsResource exposes /events-list.
func (*EventsResource) Each ¶
func (r *EventsResource) Each(ctx context.Context, p *EventListParams, fn func(*Event) bool) error
Each iterates every event across pages.
func (*EventsResource) List ¶
func (r *EventsResource) List(ctx context.Context, p *EventListParams, opts ...RequestOption) (*EventList, error)
type Invoice ¶
type Invoice struct {
ID string `json:"id"`
Object string `json:"object"`
Amount string `json:"amount"`
Currency string `json:"currency"`
// Coin is empty on multi-method invoices until the buyer picks / pays.
Coin string `json:"coin,omitempty"`
AmountCrypto string `json:"amount_crypto,omitempty"`
Address string `json:"address,omitempty"`
Status string `json:"status"`
CheckoutURL string `json:"checkout_url"`
Description string `json:"description,omitempty"`
CustomerEmail string `json:"customer_email,omitempty"`
CustomerID string `json:"customer,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
// PaymentMethods lists every (coin, network) option offered to the buyer.
// Nil/empty on single-coin invoices.
PaymentMethods []PaymentMethod `json:"payment_methods,omitempty"`
// SettledCoin/SettledNetwork record what the buyer actually paid with.
SettledCoin string `json:"settled_coin,omitempty"`
SettledNetwork string `json:"settled_network,omitempty"`
Created int64 `json:"created"`
ExpiresAt int64 `json:"expires_at,omitempty"`
PaidAt int64 `json:"paid_at,omitempty"`
Livemode bool `json:"livemode"`
}
Invoice represents a payment invoice.
type InvoiceCreateParams ¶
type InvoiceCreateParams struct {
Amount string `json:"amount"`
Currency string `json:"currency"`
// Coin is optional. Omit to create a multi-method invoice where the
// customer picks any enabled coin/network at checkout. Pass a coin code
// to lock the invoice to a single coin (legacy single-coin flow).
Coin string `json:"coin,omitempty"`
Description string `json:"description,omitempty"`
CustomerEmail string `json:"customer_email,omitempty"`
CustomerID string `json:"customer,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
SuccessURL string `json:"success_url,omitempty"`
CancelURL string `json:"cancel_url,omitempty"`
}
InvoiceCreateParams is the request body for creating an invoice.
type InvoiceList ¶
type InvoiceList struct {
Object string `json:"object"`
Data []Invoice `json:"data"`
HasMore bool `json:"has_more"`
NextCursor string `json:"next_cursor,omitempty"`
}
InvoiceList is one page of invoices.
type InvoiceListParams ¶
type InvoiceListParams struct {
Limit int `json:"limit,omitempty"`
StartingAfter string `json:"starting_after,omitempty"`
Status string `json:"status,omitempty"`
}
InvoiceListParams filters listInvoice calls.
type InvoicesResource ¶
type InvoicesResource struct {
// contains filtered or unexported fields
}
InvoicesResource exposes /invoices-* endpoints.
func (*InvoicesResource) Cancel ¶
func (r *InvoicesResource) Cancel(ctx context.Context, id string, opts ...RequestOption) (*Invoice, error)
func (*InvoicesResource) Create ¶
func (r *InvoicesResource) Create(ctx context.Context, p *InvoiceCreateParams, opts ...RequestOption) (*Invoice, error)
func (*InvoicesResource) Each ¶
func (r *InvoicesResource) Each(ctx context.Context, p *InvoiceListParams, fn func(*Invoice) bool) error
Each iterates every invoice across pages, calling fn with each one. Stop by returning false from fn, or by cancelling ctx.
func (*InvoicesResource) List ¶
func (r *InvoicesResource) List(ctx context.Context, p *InvoiceListParams, opts ...RequestOption) (*InvoiceList, error)
List returns one page of invoices. Use the returned NextCursor to paginate.
func (*InvoicesResource) Retrieve ¶
func (r *InvoicesResource) Retrieve(ctx context.Context, id string, opts ...RequestOption) (*Invoice, error)
type KeyCreateParams ¶
type KeyCreateParams struct {
Name string `json:"name,omitempty"`
Scopes []string `json:"scopes,omitempty"`
Livemode bool `json:"livemode,omitempty"`
}
KeyCreateParams is the body for POST /keys-create.
type KeysResource ¶
type KeysResource struct {
// contains filtered or unexported fields
}
KeysResource exposes /keys-* endpoints.
func (*KeysResource) Create ¶
func (r *KeysResource) Create(ctx context.Context, p *KeyCreateParams, opts ...RequestOption) (*APIKey, error)
func (*KeysResource) List ¶
func (r *KeysResource) List(ctx context.Context, opts ...RequestOption) (*APIKeyList, error)
func (*KeysResource) Revoke ¶
func (r *KeysResource) Revoke(ctx context.Context, id string, opts ...RequestOption) error
func (*KeysResource) Rotate ¶
func (r *KeysResource) Rotate(ctx context.Context, id string, opts ...RequestOption) (*APIKey, error)
type LogEntry ¶
type LogEntry struct {
ID string `json:"id"`
Object string `json:"object"`
Method string `json:"method"`
Path string `json:"path"`
Status int `json:"status"`
Duration int `json:"duration_ms"`
IPAddress string `json:"ip_address,omitempty"`
UserAgent string `json:"user_agent,omitempty"`
RequestID string `json:"request_id,omitempty"`
Created int64 `json:"created"`
Metadata map[string]string `json:"metadata,omitempty"`
}
LogEntry is a single API request log row.
type LogList ¶
type LogList struct {
Object string `json:"object"`
Data []LogEntry `json:"data"`
HasMore bool `json:"has_more"`
NextCursor string `json:"next_cursor,omitempty"`
}
LogList is one page of log entries.
type LogListParams ¶
type LogListParams struct {
Limit int `json:"limit,omitempty"`
StartingAfter string `json:"starting_after,omitempty"`
Method string `json:"method,omitempty"`
Path string `json:"path,omitempty"`
Status string `json:"status,omitempty"`
}
LogListParams filters list calls.
type LogsResource ¶
type LogsResource struct {
// contains filtered or unexported fields
}
LogsResource exposes /logs-* endpoints.
func (*LogsResource) List ¶
func (r *LogsResource) List(ctx context.Context, p *LogListParams, opts ...RequestOption) (*LogList, error)
List returns one page of API request logs.
type Option ¶
type Option func(*config)
Option customises a Client at construction time.
func WithAPIVersion ¶
WithAPIVersion pins to a specific API contract version.
func WithBaseURL ¶
WithBaseURL overrides the API root (useful for testing against a mock).
func WithHTTPClient ¶
WithHTTPClient swaps the underlying http.Client.
func WithHeader ¶
WithHeader sets a default header sent on every request.
func WithMaxRetries ¶
WithMaxRetries sets the retry budget for 429/5xx responses (default 3).
type PaymentLink ¶
type PaymentLink struct {
ID string `json:"id"`
Object string `json:"object"`
URL string `json:"url"`
Amount string `json:"amount,omitempty"`
Currency string `json:"currency,omitempty"`
Description string `json:"description,omitempty"`
Active bool `json:"active"`
Created int64 `json:"created"`
}
PaymentLink is a reusable hosted checkout link.
type PaymentLinkCreateParams ¶
type PaymentLinkCreateParams struct {
Amount string `json:"amount,omitempty"`
Currency string `json:"currency,omitempty"`
Description string `json:"description,omitempty"`
}
PaymentLinkCreateParams is the body for POST /payment-links.
type PaymentLinksResource ¶
type PaymentLinksResource struct {
// contains filtered or unexported fields
}
PaymentLinksResource exposes /payment-links endpoints.
func (*PaymentLinksResource) Create ¶
func (r *PaymentLinksResource) Create(ctx context.Context, p *PaymentLinkCreateParams, opts ...RequestOption) (*PaymentLink, error)
func (*PaymentLinksResource) Retrieve ¶
func (r *PaymentLinksResource) Retrieve(ctx context.Context, id string, opts ...RequestOption) (*PaymentLink, error)
type PaymentMethod ¶
type PaymentMethod struct {
Coin string `json:"coin"`
Network string `json:"network"`
BtcpayMethod string `json:"btcpay_method,omitempty"`
Address string `json:"address,omitempty"`
Bolt11 string `json:"bolt11,omitempty"`
AmountCrypto string `json:"amount_crypto"`
BestChoice bool `json:"best_choice,omitempty"`
}
PaymentMethod is one concrete (coin, network) option offered on a multi-method invoice.
type Rates ¶
type Rates struct {
Object string `json:"object"`
Base string `json:"base"`
Quotes map[string]string `json:"quotes"`
TTLSeconds int `json:"ttl_seconds"`
FetchedAt string `json:"fetched_at"`
}
Rates is a fiat-quote response from /rates-get.
type RatesResource ¶
type RatesResource struct {
// contains filtered or unexported fields
}
RatesResource exposes /rates-get.
func (*RatesResource) Retrieve ¶
func (r *RatesResource) Retrieve(ctx context.Context, base string, quotes []string, opts ...RequestOption) (*Rates, error)
Retrieve fetches FX quotes for base into one or more quote currencies.
type Refund ¶
type Refund struct {
ID string `json:"id"`
Object string `json:"object"`
Livemode bool `json:"livemode"`
Invoice string `json:"invoice"`
Amount string `json:"amount"`
AmountFiat string `json:"amount_fiat,omitempty"`
Currency string `json:"currency,omitempty"`
Coin string `json:"coin"`
Destination string `json:"destination,omitempty"`
Reason string `json:"reason,omitempty"`
Status string `json:"status"`
TxHash string `json:"tx_hash,omitempty"`
Fee string `json:"fee"`
Metadata map[string]string `json:"metadata,omitempty"`
FailureReason string `json:"failure_reason,omitempty"`
CreatedAt string `json:"created_at"`
BroadcastAt string `json:"broadcast_at,omitempty"`
SucceededAt string `json:"succeeded_at,omitempty"`
FailedAt string `json:"failed_at,omitempty"`
}
Refund represents a merchant-initiated refund against a paid invoice.
type RefundCreateParams ¶
type RefundCreateParams struct {
InvoiceID string `json:"invoice_id"`
Amount string `json:"amount,omitempty"`
Destination string `json:"destination,omitempty"`
Reason string `json:"reason,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
}
RefundCreateParams is the body for POST /refunds-create.
type RefundList ¶
type RefundList struct {
Object string `json:"object"`
Data []Refund `json:"data"`
HasMore bool `json:"has_more"`
NextCursor string `json:"next_cursor,omitempty"`
}
RefundList is one page of refunds.
type RefundListParams ¶
type RefundListParams struct {
Limit int `json:"limit,omitempty"`
StartingAfter string `json:"starting_after,omitempty"`
InvoiceID string `json:"invoice_id,omitempty"`
Status string `json:"status,omitempty"`
}
RefundListParams filters /refunds-list.
type RefundsResource ¶
type RefundsResource struct {
// contains filtered or unexported fields
}
RefundsResource exposes /refunds-* endpoints.
func (*RefundsResource) Cancel ¶
func (r *RefundsResource) Cancel(ctx context.Context, id string, opts ...RequestOption) (*Refund, error)
func (*RefundsResource) Create ¶
func (r *RefundsResource) Create(ctx context.Context, p *RefundCreateParams, opts ...RequestOption) (*Refund, error)
func (*RefundsResource) List ¶
func (r *RefundsResource) List(ctx context.Context, p *RefundListParams, opts ...RequestOption) (*RefundList, error)
func (*RefundsResource) Retrieve ¶
func (r *RefundsResource) Retrieve(ctx context.Context, id string, opts ...RequestOption) (*Refund, error)
type RequestOption ¶
type RequestOption func(*requestOptions)
RequestOption tweaks a single API call.
func WithIdempotencyKey ¶
func WithIdempotencyKey(k string) RequestOption
WithIdempotencyKey sets the Idempotency-Key header for one call. If omitted, the SDK auto-generates one for every POST.
func WithRequestHeader ¶
func WithRequestHeader(k, v string) RequestOption
WithRequestHeader adds an extra header to one call.
type SandboxResource ¶
type SandboxResource struct {
// contains filtered or unexported fields
}
SandboxResource exposes test-mode-only helpers. Requires sk_test_* key.
func (*SandboxResource) Seed ¶
func (r *SandboxResource) Seed(ctx context.Context, p *SandboxSeedParams, opts ...RequestOption) (*SandboxSeedResult, error)
Seed creates demo customers + invoices in the sandbox.
type SandboxSeedParams ¶
type SandboxSeedParams struct {
Invoices int `json:"invoices,omitempty"`
Customers int `json:"customers,omitempty"`
Coins []string `json:"coins,omitempty"`
Reset bool `json:"reset,omitempty"`
}
SandboxSeedParams configures /sandbox-seed (all fields optional).
type SandboxSeedResult ¶
type SandboxSeedResult struct {
Object string `json:"object"`
CustomerIDs []string `json:"customer_ids"`
InvoiceIDs []string `json:"invoice_ids"`
}
SandboxSeedResult is the response from POST /sandbox-seed.
type SignatureVerificationError ¶
SignatureVerificationError is returned by ConstructEvent when verification fails.
func (*SignatureVerificationError) Error ¶
func (e *SignatureVerificationError) Error() string
type Subscription ¶
type Subscription struct {
ID string `json:"id"`
Object string `json:"object"`
Status string `json:"status"` // active, past_due, canceled, paused
Amount string `json:"amount"`
Currency string `json:"currency"`
Coin string `json:"coin"`
Interval string `json:"interval"` // week, month, year
IntervalCount int `json:"interval_count"`
CustomerID string `json:"customer_id,omitempty"`
CurrentPeriodStart int64 `json:"current_period_start"`
CurrentPeriodEnd int64 `json:"current_period_end"`
CancelAtPeriodEnd bool `json:"cancel_at_period_end"`
Metadata map[string]string `json:"metadata,omitempty"`
Created int64 `json:"created"`
Livemode bool `json:"livemode"`
}
Subscription represents a crypto subscription.
type SubscriptionList ¶
type SubscriptionList struct {
Object string `json:"object"`
Data []Subscription `json:"data"`
HasMore bool `json:"has_more"`
NextCursor string `json:"next_cursor,omitempty"`
}
SubscriptionList is one page of subscriptions.
type SubscriptionListParams ¶
type SubscriptionListParams struct {
Limit int `json:"limit,omitempty"`
StartingAfter string `json:"starting_after,omitempty"`
Status string `json:"status,omitempty"`
CustomerID string `json:"customer_id,omitempty"`
}
SubscriptionListParams filters list calls.
type SubscriptionPauseResult ¶
type SubscriptionPauseResult struct {
ID string `json:"id"`
Status string `json:"status"`
PausedAt int64 `json:"paused_at"`
}
SubscriptionPauseResult is the response from POST /subscriptions-pause.
type SubscriptionPlan ¶
type SubscriptionPlan struct {
ID string `json:"id"`
Object string `json:"object"`
Name string `json:"name"`
Amount string `json:"amount"`
Coin string `json:"coin"`
AcceptedCoins []string `json:"accepted_coins"`
Interval string `json:"interval"` // weekly, monthly, yearly
Active bool `json:"active"`
Metadata map[string]string `json:"metadata,omitempty"`
Created int64 `json:"created"`
}
SubscriptionPlan represents a subscription plan.
type SubscriptionPlanList ¶
type SubscriptionPlanList struct {
Object string `json:"object"`
Data []SubscriptionPlan `json:"data"`
HasMore bool `json:"has_more"`
NextCursor string `json:"next_cursor,omitempty"`
}
SubscriptionPlanList is one page of subscription plans.
type SubscriptionPlansResource ¶
type SubscriptionPlansResource struct {
// contains filtered or unexported fields
}
SubscriptionPlansResource exposes /subscription-plans-* endpoints.
func (*SubscriptionPlansResource) List ¶
func (r *SubscriptionPlansResource) List(ctx context.Context, opts ...RequestOption) (*SubscriptionPlanList, error)
List returns subscription plans.
type SubscriptionPortalResult ¶
type SubscriptionPortalResult struct {
PortalURL string `json:"portal_url"`
Token string `json:"token"`
ExpiresAt int64 `json:"expires_at,omitempty"`
}
SubscriptionPortalResult is the response from POST /subscriptions-portal.
type SubscriptionResumeResult ¶
type SubscriptionResumeResult struct {
ID string `json:"id"`
Status string `json:"status"`
CurrentPeriodEnd int64 `json:"current_period_end"`
}
SubscriptionResumeResult is the response from POST /subscriptions-resume.
type SubscriptionsResource ¶
type SubscriptionsResource struct {
// contains filtered or unexported fields
}
SubscriptionsResource exposes /subscriptions-* endpoints.
func (*SubscriptionsResource) Cancel ¶
func (r *SubscriptionsResource) Cancel(ctx context.Context, id string, atPeriodEnd bool, opts ...RequestOption) (*Subscription, error)
Cancel cancels a subscription (at period end by default).
func (*SubscriptionsResource) List ¶
func (r *SubscriptionsResource) List(ctx context.Context, p *SubscriptionListParams, opts ...RequestOption) (*SubscriptionList, error)
List returns one page of subscriptions.
func (*SubscriptionsResource) Pause ¶
func (r *SubscriptionsResource) Pause(ctx context.Context, id, token string, opts ...RequestOption) (*SubscriptionPauseResult, error)
Pause pauses an active subscription. Pass empty token when authenticating with an API key.
func (*SubscriptionsResource) Portal ¶
func (r *SubscriptionsResource) Portal(ctx context.Context, id string, opts ...RequestOption) (*SubscriptionPortalResult, error)
Portal generates a customer portal URL for the subscription.
func (*SubscriptionsResource) Resume ¶
func (r *SubscriptionsResource) Resume(ctx context.Context, id, token string, opts ...RequestOption) (*SubscriptionResumeResult, error)
Resume resumes a paused subscription.
func (*SubscriptionsResource) Retrieve ¶
func (r *SubscriptionsResource) Retrieve(ctx context.Context, id string, opts ...RequestOption) (*Subscription, error)
type Topup ¶
type Topup struct {
ID string `json:"id"`
Object string `json:"object"`
AmountSats string `json:"amount_sats"`
Status string `json:"status"`
Address string `json:"address,omitempty"`
Bolt11 string `json:"bolt11,omitempty"`
Created int64 `json:"created"`
}
Topup is a prepaid-credit top-up invoice.
type TopupCreateParams ¶
type TopupCreateParams struct {
AmountSats string `json:"amount_sats"`
}
TopupCreateParams is the body for POST /credits-topup-create.
type TopupsResource ¶
type TopupsResource struct {
// contains filtered or unexported fields
}
TopupsResource exposes /credits-topup-* endpoints.
func (*TopupsResource) Create ¶
func (r *TopupsResource) Create(ctx context.Context, p *TopupCreateParams, opts ...RequestOption) (*Topup, error)
func (*TopupsResource) Retrieve ¶
func (r *TopupsResource) Retrieve(ctx context.Context, id string, opts ...RequestOption) (*Topup, error)
type WebhookCreateParams ¶
type WebhookCreateParams struct {
URL string `json:"url"`
EnabledEvents []string `json:"enabled_events,omitempty"`
}
WebhookCreateParams is the body for POST /webhooks-create.
type WebhookEndpoint ¶
type WebhookEndpoint struct {
ID string `json:"id"`
Object string `json:"object"`
URL string `json:"url"`
EnabledEvents []string `json:"enabled_events"`
Status string `json:"status"`
Secret string `json:"secret,omitempty"` // only on create
Created int64 `json:"created"`
}
WebhookEndpoint is a registered webhook destination.
type WebhookReplayResult ¶
type WebhookReplayResult struct {
ID string `json:"id"`
Event string `json:"event"`
ReplayedFrom string `json:"replayed_from"`
Status string `json:"status"`
}
WebhookReplayResult is the response from POST /webhooks-replay.
type WebhooksResource ¶
type WebhooksResource struct {
// contains filtered or unexported fields
}
WebhooksResource exposes /webhooks-* endpoints. Use the package-level ConstructEvent helper to verify incoming signatures.
func (*WebhooksResource) Create ¶
func (r *WebhooksResource) Create(ctx context.Context, p *WebhookCreateParams, opts ...RequestOption) (*WebhookEndpoint, error)
func (*WebhooksResource) Delete ¶
func (r *WebhooksResource) Delete(ctx context.Context, id string, opts ...RequestOption) error
func (*WebhooksResource) Replay ¶
func (r *WebhooksResource) Replay(ctx context.Context, id, deliveryID string, opts ...RequestOption) (*WebhookReplayResult, error)
Replay re-delivers a previously sent event to a webhook endpoint. Pass an empty deliveryID to replay the most recent failed delivery.
func (*WebhooksResource) Test ¶
func (r *WebhooksResource) Test(ctx context.Context, id string, opts ...RequestOption) error
Source Files
¶
- credits.go
- customers.go
- errors.go
- events.go
- http.go
- invoices.go
- keys.go
- logs.go
- nakopay.go
- payment_links.go
- rates.go
- refunds.go
- sandbox.go
- subscriptions.go
- webhook.go
- webhooks.go