manza

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: MIT Imports: 15 Imported by: 0

README

manza-go

Go SDK for the Manza API.

go get github.com/getmanza/manza-go
import manza "github.com/getmanza/manza-go"

client, err := manza.New(manza.WithAPIKey(os.Getenv("MANZA_API_KEY")))
if err != nil { ... }

entity, err := client.Entity.Get(ctx)

page, err := client.Accounts.List(ctx, manza.AccountListParams{})
for _, account := range page.Data {
    fmt.Println(account["id"], account["name"])
}

// Initiate a transfer — it lands in your workspace's in-app approval
// queue; the API never executes a transfer itself.
draft, err := client.TransferDrafts.Create(ctx, manza.Attributes{
    "account_id":        accountID,
    "beneficiary_id":    beneficiaryID,
    "amount":            "150.00",
    "payment_reference": "INV-000042",
})

Response shape

Response bodies are returned as-is from the API — snake_case keys in a map[string]any (resp.Body). The same shape ships across every Manza SDK (Ruby, TypeScript, Python, Go, ...) so the cassette contract is one-to-one.

For typed access, decode the raw body onto a model from types.go (TransferDraft, Beneficiary, ExternalAccount, PayeeTrustRequest, CheckoutSession, PaymentLink, Customer, Invoice, Authorization):

var draft manza.TransferDraft
if err := resp.Decode(&draft); err != nil { ... }

Market-gated keys (tax_id, ice_number, delivery_date) are absent outside Morocco, so they are pointers and nil there.

Hosts

Market Base URL
Morocco (default) https://ma.manza.finance
South Africa https://za.manza.finance

Override with manza.WithBaseURL(...) or MANZA_BASE_URL (the legacy ZAZU_BASE_URL still works, with a one-time deprecation warning). The replay cassettes were recorded against https://ma.manza.dev (the staging host).

Resources

Service Methods
Accounts List, Get, ListTransactions, GetTransaction
Beneficiaries List, Get, Create, ListExternalAccounts, GetExternalAccount, CreateExternalAccount
CheckoutSessions Create, Get
Customers List, Get, Create, Update, Delete
Entity Get
Invoices List, Get, Create, Update, Send, MarkAsPaid, Cancel, CreditNote, Delete, CreatePaymentLink
PayeeTrustRequests Create(ctx, externalAccountIDs), Get
PaymentLinks List, Get, Create, Cancel
TransferDrafts Create, Get, Authorize, Decline
WebhookEndpoints List, Get, Create, Update, Delete, Test, RegenerateSecret, Enable, Disable

Machine-authorizing transfers

A draft inside your machine-authorization envelope (trusted payee, within limits) is sent to your enrolled transfer authorizer as a payment.authorization_requested webhook carrying authorization_id and a one-time nonce. Build the signature input from your own record of the transfer (not the webhook's signature_input), sign it with the authorizer endpoint's signing secret, and answer with a key other than the one that created the draft:

// draft is a manza.TransferDraft (decoded via resp.Decode) or your own record.
// Its ExternalAccountID, DestinationAccountID and ClientReference are *string:
// exactly one of the first two is set, and ClientReference is nil for a
// transfer without a client_reference.
externalAccountID, destinationAccountID := "", ""
if draft.ExternalAccountID != nil {
    externalAccountID = *draft.ExternalAccountID
}
if draft.DestinationAccountID != nil {
    destinationAccountID = *draft.DestinationAccountID
}
payee, err := manza.PayeeFor(externalAccountID, destinationAccountID)
if err != nil {
    return err
}
clientReference := ""
if draft.ClientReference != nil {
    clientReference = *draft.ClientReference
}
input := manza.SignatureInput(manza.TransferAuthorizationFields{
    PaymentID:       draft.ID,
    Nonce:           nonce,
    Amount:          draft.Amount, // the API's string verbatim, e.g. "2500.0"
    CurrencyCode:    draft.CurrencyCode,
    AccountID:       draft.AccountID,
    Payee:           payee,
    ClientReference: clientReference, // "" when the transfer has none
})
signature := manza.Sign(signingSecret, input) // lowercase hex HMAC-SHA256

resp, err := authorizerClient.TransferDrafts.Authorize(ctx, draft.ID, authorizationID, signature)
// or: authorizerClient.TransferDrafts.Decline(ctx, draft.ID, authorizationID, "reason") // "" omits reason

Authorize refuses a blank signature locally (*manza.ArgumentError) because the API counts a missing signature as a failed attempt. Create accepts an optional client_reference (at most 128 characters, unique per entity); a duplicate returns a conflict error carrying the existing draft's PaymentID.

Errors

Non-2xx responses come back as *manza.Error with Status, Kind (manza.KindAuthentication, KindForbidden, KindNotFound, KindValidation for 400 and 422, KindConflict for 409, KindRateLimit, KindServer, KindAPI), the API's Type/Message/Param, and the RequestID. A conflict also carries PaymentID. Discriminate on Kind, not on status codes:

var apiErr *manza.Error
if errors.As(err, &apiErr) && apiErr.Kind == manza.KindConflict {
    fmt.Println("already created as", apiErr.PaymentID)
}

Transport failures are *manza.ConnectionError, a misconfigured client is *manza.ConfigurationError, and a value the SDK refuses to send is *manza.ArgumentError.

Tests

Tests replay the canonical cassettes recorded by manza-ruby. The cassettes are downloaded from the Ruby SDK's release tarball and served from an httptest.Server. Same interactions, same assertions, every language.

scripts/fetch-cassettes.sh
go test ./...

The SDK family

Documentation

Overview

Package manza is the Go SDK for the Manza API.

Response bodies are returned as-is from the API — snake_case keys in a map. The same shape ships across every Manza SDK (Ruby, TypeScript, Python, Go, ...) so the cassette contract is one-to-one. Response.Decode maps a body onto the typed models in types.go when you want structs.

Index

Constants

View Source
const (
	KindAuthentication = "authentication" // 401
	KindForbidden      = "forbidden"      // 403
	KindNotFound       = "not_found"      // 404
	KindValidation     = "validation"     // 400, 422
	KindConflict       = "conflict"       // 409
	KindRateLimit      = "rate_limit"     // 429
	KindServer         = "server"         // 5xx
	KindAPI            = "api"            // any other non-2xx
)

Error kinds, mirroring the shared Manza SDK error hierarchy. Together with ConfigurationError, ConnectionError and ArgumentError they make up the ten classes every SDK exposes.

View Source
const (
	BeneficiaryTypeIndividual = "individual"
	BeneficiaryTypeBusiness   = "business"
)

BeneficiaryType values.

View Source
const MaxPerPage = 100

MaxPerPage is the API's hard page-size cap.

View Source
const StatusClearing = "clearing"

StatusClearing is the checkout-session and payment-link status between a customer's payment and settlement; settled_at is set once it clears.

View Source
const (
	// Version is the SDK version, sent in the User-Agent header.
	Version = "1.0.0"
)

Variables

This section is empty.

Functions

func PayeeFor

func PayeeFor(externalAccountID, destinationAccountID string) (string, error)

PayeeFor returns the payee token: `ext:<id>` for a beneficiary's bank account, `own:<id>` for one of the entity's own accounts. Pass exactly one id; the other must be empty.

func Sign

func Sign(secret, signatureInput string) string

Sign returns the lowercase hex HMAC-SHA256 of signatureInput under the authorizer endpoint's signing secret. Pass the result to TransferDraftsService.Authorize.

func SignatureInput

func SignatureInput(f TransferAuthorizationFields) string

SignatureInput builds the pipe-joined, versioned string that Sign signs:

manza.transfer-authorization.v1|<payment_id>|<nonce>|<amount>|<currency_code>|<account_id>|<payee>|<client_reference or "">

Amount must be the API's decimal string verbatim ("2500.0", not "2500.00" or a formatted float), otherwise the server's signature will not match.

Types

type AccountListParams

type AccountListParams struct {
	ListParams
	Status       string
	CurrencyCode string
}

AccountListParams filters GET /api/accounts.

type AccountsService

type AccountsService struct {
	// contains filtered or unexported fields
}

AccountsService — accounts and their transactions.

func (*AccountsService) Get

func (s *AccountsService) Get(ctx context.Context, id string) (*Response, error)

Get calls GET /api/accounts/:id.

func (*AccountsService) GetTransaction

func (s *AccountsService) GetTransaction(ctx context.Context, accountID, transactionID string) (*Response, error)

GetTransaction calls GET /api/accounts/:account_id/transactions/:id.

func (*AccountsService) List

func (s *AccountsService) List(ctx context.Context, params AccountListParams) (*Page, error)

List calls GET /api/accounts.

func (*AccountsService) ListTransactions

func (s *AccountsService) ListTransactions(ctx context.Context, accountID string, params TransactionListParams) (*Page, error)

ListTransactions calls GET /api/accounts/:account_id/transactions.

type ArgumentError

type ArgumentError struct{ Message string }

ArgumentError is returned when the caller passes a value the SDK refuses to send (e.g. a blank signature). Distinct from *Error with KindValidation, which is the server rejecting a request. No HTTP call was made.

func (*ArgumentError) Error

func (e *ArgumentError) Error() string

type Attributes

type Attributes map[string]any

Attributes is a request body for create/update calls — snake_case keys, exactly what the API accepts (see the per-endpoint docs).

type Authorization

type Authorization struct {
	ID           string  `json:"id"`
	Status       string  `json:"status"` // pending, authorized, declined, ...
	ExpiresAt    string  `json:"expires_at"`
	AuthorizedAt *string `json:"authorized_at,omitempty"`
	DeclinedAt   *string `json:"declined_at,omitempty"`
}

Authorization is a machine-authorization challenge on a transfer draft, and the response of TransferDraftsService.Decline.

type BeneficiariesService

type BeneficiariesService struct {
	// contains filtered or unexported fields
}

BeneficiariesService — saved transfer recipients. Each beneficiary embeds its bank accounts; the one flagged `default` is used when a transfer names only the beneficiary_id. There is no update or delete via the API.

func (*BeneficiariesService) Create

func (s *BeneficiariesService) Create(ctx context.Context, attributes Attributes) (*Response, error)

Create calls POST /api/beneficiaries. Attributes: beneficiary_type ("individual" | "business"; inferred from person_name / company_name when omitted), person_name, company_name, email, phone_number. Values must be strings. Shares a 10/minute limit with CreateExternalAccount.

func (*BeneficiariesService) CreateExternalAccount

func (s *BeneficiariesService) CreateExternalAccount(ctx context.Context, beneficiaryID string, attributes Attributes) (*Response, error)

CreateExternalAccount calls POST /api/beneficiaries/:beneficiary_id/external_accounts. Required: account_number. Optional: name, country_code, currency_code, account_type ("bank" only), bank_identifier (required in ZA, rejected in MA, where it is derived from the RIB).

func (*BeneficiariesService) Get

Get calls GET /api/beneficiaries/:id.

func (*BeneficiariesService) GetExternalAccount

func (s *BeneficiariesService) GetExternalAccount(ctx context.Context, beneficiaryID, id string) (*Response, error)

GetExternalAccount calls GET /api/beneficiaries/:beneficiary_id/external_accounts/:id.

func (*BeneficiariesService) List

func (s *BeneficiariesService) List(ctx context.Context, params ListParams) (*Page, error)

List calls GET /api/beneficiaries.

func (*BeneficiariesService) ListExternalAccounts

func (s *BeneficiariesService) ListExternalAccounts(ctx context.Context, beneficiaryID string, params ListParams) (*Page, error)

ListExternalAccounts calls GET /api/beneficiaries/:beneficiary_id/external_accounts.

type Beneficiary

type Beneficiary struct {
	ID               string            `json:"id"`
	BeneficiaryType  string            `json:"beneficiary_type"` // individual | business
	Name             string            `json:"name"`
	Email            *string           `json:"email"`
	PhoneNumber      *string           `json:"phone_number"`
	ExternalAccounts []ExternalAccount `json:"external_accounts"`
	CreatedAt        string            `json:"created_at"`
}

Beneficiary is a saved transfer recipient.

type CheckoutSession

type CheckoutSession struct {
	ID                    string         `json:"id"`
	URL                   string         `json:"url"`
	Status                string         `json:"status"`
	Amount                string         `json:"amount"`
	CurrencyCode          string         `json:"currency_code"`
	Description           *string        `json:"description"`
	CustomerEmail         *string        `json:"customer_email"`
	CustomerName          *string        `json:"customer_name"`
	CollectBillingAddress *bool          `json:"collect_billing_address"`
	BillingAddress        map[string]any `json:"billing_address"`
	SuccessURL            string         `json:"success_url"`
	CancelURL             *string        `json:"cancel_url"`
	Metadata              map[string]any `json:"metadata"`
	ExpiresAt             string         `json:"expires_at"`
	CompletedAt           *string        `json:"completed_at"`
	SettledAt             *string        `json:"settled_at"`
	CreatedAt             string         `json:"created_at"`
	Transaction           map[string]any `json:"transaction"`
}

CheckoutSession is a one-off hosted checkout session. Status is open, clearing (StatusClearing), or a terminal state.

type CheckoutSessionsService

type CheckoutSessionsService struct {
	// contains filtered or unexported fields
}

CheckoutSessionsService — one-off hosted checkout sessions. No list, update, or delete; sessions are created and inspected by id.

func (*CheckoutSessionsService) Create

func (s *CheckoutSessionsService) Create(ctx context.Context, attributes Attributes) (*Response, error)

Create calls POST /api/checkout_sessions. Required attributes: account_id, amount, success_url. Optional: cancel_url, description, customer_email, customer_name, metadata, collect_billing_address, billing_address. The response carries settled_at and transaction once the session has cleared (status "clearing" → "complete").

func (*CheckoutSessionsService) Get

Get calls GET /api/checkout_sessions/:id.

type Client

type Client struct {
	Accounts           *AccountsService
	Beneficiaries      *BeneficiariesService
	CheckoutSessions   *CheckoutSessionsService
	Customers          *CustomersService
	Entity             *EntityService
	Invoices           *InvoicesService
	PayeeTrustRequests *PayeeTrustRequestsService
	PaymentLinks       *PaymentLinksService
	TransferDrafts     *TransferDraftsService
	WebhookEndpoints   *WebhookEndpointsService
	// contains filtered or unexported fields
}

Client is the SDK entry point. Resources hang off it as fields.

client, err := manza.New(manza.WithAPIKey("sk_live_..."))
page, err := client.Accounts.List(ctx, manza.ListParams{})

func New

func New(opts ...Option) (*Client, error)

New builds a Client. An API key is required — pass WithAPIKey or set MANZA_API_KEY.

func (*Client) Request

func (c *Client) Request(ctx context.Context, method, path string, params url.Values, body any) (*Response, error)

Request performs an HTTP request against the API. Non-2xx responses are returned as *Error. Body (when non-nil) is JSON-encoded.

type ConfigurationError

type ConfigurationError struct{ Message string }

ConfigurationError is returned by New when the client can't be built.

func (*ConfigurationError) Error

func (e *ConfigurationError) Error() string

type ConnectionError

type ConnectionError struct{ Message string }

ConnectionError wraps transport-level failures (timeouts, DNS, refused).

func (*ConnectionError) Error

func (e *ConnectionError) Error() string

type Customer

type Customer struct {
	ID                 string  `json:"id"`
	CustomerType       string  `json:"customer_type"`
	Name               string  `json:"name"`
	PersonName         *string `json:"person_name"`
	CompanyName        *string `json:"company_name"`
	Email              *string `json:"email"`
	Phone              *string `json:"phone"`
	RegistrationNumber *string `json:"registration_number,omitempty"`
	VATNumber          *string `json:"vat_number,omitempty"`
	TaxID              *string `json:"tax_id,omitempty"`
	ICENumber          *string `json:"ice_number,omitempty"`
	CreatedAt          string  `json:"created_at"`
	UpdatedAt          string  `json:"updated_at"`
}

Customer is an individual or business the entity invoices. TaxID and ICENumber are market-gated (absent outside Morocco); RegistrationNumber and VATNumber are absent where the entity's market does not collect them.

type CustomerListParams

type CustomerListParams struct {
	ListParams
	Query string // matches company name, person name, email
}

CustomerListParams filters GET /api/customers.

type CustomersService

type CustomersService struct {
	// contains filtered or unexported fields
}

CustomersService — individuals or businesses the entity invoices.

func (*CustomersService) Create

func (s *CustomersService) Create(ctx context.Context, attributes Attributes) (*Response, error)

Create calls POST /api/customers.

func (*CustomersService) Delete

func (s *CustomersService) Delete(ctx context.Context, id string) (*Response, error)

Delete calls DELETE /api/customers/:id.

func (*CustomersService) Get

func (s *CustomersService) Get(ctx context.Context, id string) (*Response, error)

Get calls GET /api/customers/:id.

func (*CustomersService) List

func (s *CustomersService) List(ctx context.Context, params CustomerListParams) (*Page, error)

List calls GET /api/customers.

func (*CustomersService) Update

func (s *CustomersService) Update(ctx context.Context, id string, attributes Attributes) (*Response, error)

Update calls PATCH /api/customers/:id.

type EntityService

type EntityService struct {
	// contains filtered or unexported fields
}

EntityService — the current entity (the tenant the API key belongs to).

func (*EntityService) Get

func (s *EntityService) Get(ctx context.Context) (*Response, error)

Get calls GET /api/entity.

type Error

type Error struct {
	Status     int
	Kind       string // one of the Kind* constants
	Type       string // the API's error.type field
	Message    string
	Param      string
	PaymentID  string // only set for conflict: the draft already holding a duplicate client_reference
	RequestID  string
	RetryAfter int // seconds; only set for rate_limit
	Body       map[string]any
}

Error is the API error envelope, mirroring the other Manza SDKs' hierarchy: { "error": { "type": ..., "message": ..., "param": ..., "payment_id": ... } }. Discriminate on Kind (errors.As to *Error, then compare against the Kind* constants) instead of matching status codes.

func (*Error) Error

func (e *Error) Error() string

type ExternalAccount

type ExternalAccount struct {
	ID             string `json:"id"`
	Name           string `json:"name"`
	AccountNumber  string `json:"account_number"`
	BankIdentifier string `json:"bank_identifier"`
	CurrencyCode   string `json:"currency_code"`
	Default        bool   `json:"default"`
}

ExternalAccount is a beneficiary's bank account.

type Invoice

type Invoice struct {
	ID           string  `json:"id"`
	Number       string  `json:"number"`
	Status       string  `json:"status"`
	CurrencyCode string  `json:"currency_code"`
	IssueDate    string  `json:"issue_date"`
	DueDate      string  `json:"due_date"`
	DeliveryDate *string `json:"delivery_date,omitempty"`
	Total        string  `json:"total"`
}

Invoice carries the headline fields; use Response.Body for the rest. DeliveryDate is market-gated: the key is absent outside Morocco.

type InvoiceListParams

type InvoiceListParams struct {
	ListParams
	Status     string
	CustomerID string
}

InvoiceListParams filters GET /api/invoices.

type InvoicesService

type InvoicesService struct {
	// contains filtered or unexported fields
}

InvoicesService — invoices and their lifecycle actions.

func (*InvoicesService) Cancel

func (s *InvoicesService) Cancel(ctx context.Context, id string) (*Response, error)

Cancel calls POST /api/invoices/:id/cancel.

func (*InvoicesService) Create

func (s *InvoicesService) Create(ctx context.Context, attributes Attributes) (*Response, error)

Create calls POST /api/invoices.

func (s *InvoicesService) CreatePaymentLink(ctx context.Context, invoiceID, accountID string) (*Response, error)

CreatePaymentLink calls POST /api/invoices/:invoice_id/payment_link.

func (*InvoicesService) CreditNote

func (s *InvoicesService) CreditNote(ctx context.Context, id string) (*Response, error)

CreditNote calls POST /api/invoices/:id/credit_note.

func (*InvoicesService) Delete

func (s *InvoicesService) Delete(ctx context.Context, id string) (*Response, error)

Delete calls DELETE /api/invoices/:id.

func (*InvoicesService) Get

func (s *InvoicesService) Get(ctx context.Context, id string) (*Response, error)

Get calls GET /api/invoices/:id.

func (*InvoicesService) List

func (s *InvoicesService) List(ctx context.Context, params InvoiceListParams) (*Page, error)

List calls GET /api/invoices.

func (*InvoicesService) MarkAsPaid

func (s *InvoicesService) MarkAsPaid(ctx context.Context, id string) (*Response, error)

MarkAsPaid calls POST /api/invoices/:id/mark_as_paid.

func (*InvoicesService) Send

func (s *InvoicesService) Send(ctx context.Context, id string) (*Response, error)

Send calls POST /api/invoices/:id/send.

func (*InvoicesService) Update

func (s *InvoicesService) Update(ctx context.Context, id string, attributes Attributes) (*Response, error)

Update calls PATCH /api/invoices/:id.

type ListParams

type ListParams struct {
	Limit  int
	Cursor string
}

ListParams are the shared cursor-pagination inputs. Limit 0 means MaxPerPage.

type Option

type Option func(*Client)

Option configures a Client.

func WithAPIKey

func WithAPIKey(key string) Option

WithAPIKey sets the API key (default: MANZA_API_KEY, falling back to the deprecated ZAZU_API_KEY).

func WithAPIVersion

func WithAPIVersion(v string) Option

WithAPIVersion pins the Manza-Version request header (default: MANZA_API_VERSION).

func WithBaseURL

func WithBaseURL(u string) Option

WithBaseURL sets the API base URL (default: MANZA_BASE_URL or https://ma.manza.finance). South Africa is https://za.manza.finance.

func WithHTTPClient

func WithHTTPClient(h *http.Client) Option

WithHTTPClient swaps the underlying *http.Client (default: 30s timeout).

type Page

type Page struct {
	Data       []map[string]any
	HasMore    bool
	NextCursor string
	Response   *Response
	// contains filtered or unexported fields
}

Page is one page of a cursor-paginated list endpoint: { "data": [...], "has_more": bool, "next_cursor": string|null }.

func (*Page) Next

func (p *Page) Next(ctx context.Context) (*Page, error)

Next fetches the following page, or returns nil when this is the last one.

type PayeeTrustRequest

type PayeeTrustRequest struct {
	ID                 string   `json:"id"`
	Status             string   `json:"status"` // pending, approved, declined, cancelled
	ExternalAccountIDs []string `json:"external_account_ids"`
	CreatedAt          string   `json:"created_at"`
	ResolvedAt         *string  `json:"resolved_at"`
}

PayeeTrustRequest is a request to trust payees for machine-authorized transfers.

type PayeeTrustRequestsService

type PayeeTrustRequestsService struct {
	// contains filtered or unexported fields
}

PayeeTrustRequestsService — requests to trust payees for machine-authorized transfers. The API key can only ask: a member holding payment-authorize permission approves the request in the Manza app. Status: pending → approved / declined / cancelled. No list, update, or delete.

func (*PayeeTrustRequestsService) Create

func (s *PayeeTrustRequestsService) Create(ctx context.Context, externalAccountIDs []string) (*Response, error)

Create calls POST /api/payee_trust_requests with at most 100 bank account ids.

func (*PayeeTrustRequestsService) Get

Get calls GET /api/payee_trust_requests/:id.

type PaymentLink struct {
	ID                    string         `json:"id"`
	Slug                  string         `json:"slug"`
	LinkType              string         `json:"link_type"`
	Status                string         `json:"status"`
	Amount                *string        `json:"amount"`
	CurrencyCode          string         `json:"currency_code"`
	Title                 *string        `json:"title"`
	Description           *string        `json:"description"`
	PaymentReference      *string        `json:"payment_reference"`
	PaymentsCount         int            `json:"payments_count"`
	MaxPayments           *int           `json:"max_payments"`
	RedirectURL           *string        `json:"redirect_url"`
	InvoiceID             *string        `json:"invoice_id"`
	CollectBillingAddress *bool          `json:"collect_billing_address"`
	BillingAddress        map[string]any `json:"billing_address"`
	URL                   string         `json:"url"`
	ExpiresAt             *string        `json:"expires_at"`
	PaidAt                *string        `json:"paid_at"`
	SettledAt             *string        `json:"settled_at"`
	CreatedAt             string         `json:"created_at"`
	UpdatedAt             string         `json:"updated_at"`
}

PaymentLink is a standalone payment link. Status is active, clearing (StatusClearing), or a terminal state.

type PaymentLinkListParams

type PaymentLinkListParams struct {
	ListParams
	Status   string
	LinkType string
}

PaymentLinkListParams filters GET /api/payment_links.

type PaymentLinksService

type PaymentLinksService struct {
	// contains filtered or unexported fields
}

PaymentLinksService — standalone payment links (not attached to an invoice).

func (*PaymentLinksService) Cancel

func (s *PaymentLinksService) Cancel(ctx context.Context, id string) (*Response, error)

Cancel calls POST /api/payment_links/:id/cancel.

func (*PaymentLinksService) Create

func (s *PaymentLinksService) Create(ctx context.Context, attributes Attributes) (*Response, error)

Create calls POST /api/payment_links.

func (*PaymentLinksService) Get

Get calls GET /api/payment_links/:id.

func (*PaymentLinksService) List

List calls GET /api/payment_links.

type Response

type Response struct {
	Status    int
	RequestID string
	Body      map[string]any
	Raw       []byte
}

Response is a successful (2xx) API response.

func (*Response) Decode

func (r *Response) Decode(v any) error

Decode unmarshals the raw response body into v, typically one of the models in types.go (TransferDraft, CheckoutSession, ...).

type TransactionListParams

type TransactionListParams struct {
	ListParams
	Operation    string
	PostedAfter  string // ISO-8601
	PostedBefore string // ISO-8601
}

TransactionListParams filters GET /api/accounts/:id/transactions.

type TransferAuthorizationFields

type TransferAuthorizationFields struct {
	PaymentID    string
	Nonce        string // one-time, from the payment.authorization_requested webhook
	Amount       string // the API's decimal string verbatim, e.g. "2500.0"
	CurrencyCode string
	AccountID    string
	Payee        string // see PayeeFor
	// ClientReference is empty when the transfer has none.
	ClientReference string
}

TransferAuthorizationFields are the inputs to a machine-authorization signature. Build them from your OWN record of the transfer, not from the webhook's `signature_input` (which is there only to compare against).

type TransferDraft

type TransferDraft struct {
	ID                   string         `json:"id"`
	Status               string         `json:"status"`
	CurrencyCode         string         `json:"currency_code"`
	PaymentReference     *string        `json:"payment_reference"`
	ClientReference      *string        `json:"client_reference"`
	AccountID            string         `json:"account_id"`
	BeneficiaryID        *string        `json:"beneficiary_id"`
	ExternalAccountID    *string        `json:"external_account_id"`
	DestinationAccountID *string        `json:"destination_account_id"`
	Amount               string         `json:"amount"`
	Transfer             *TransferRef   `json:"transfer"`
	Authorization        *Authorization `json:"authorization"`
	CreatedAt            string         `json:"created_at"`
	UpdatedAt            string         `json:"updated_at"`
}

TransferDraft is an API-initiated transfer.

type TransferDraftsService

type TransferDraftsService struct {
	// contains filtered or unexported fields
}

TransferDraftsService — API-initiated transfers. Creating a draft never executes a transfer by itself. A draft inside the entity's machine-authorization envelope (trusted payee, within limits) is sent to the enrolled transfer authorizer as a `payment.authorization_requested` webhook; answer it with Authorize or Decline, using an API key other than the one that created the draft. Every other draft goes to the in-app approval flow, where a manager or legal representative approves it. Poll Get (status: requested → processing → completed / failed) or subscribe to the `transfer.executed` webhook to follow execution.

func (*TransferDraftsService) Authorize

func (s *TransferDraftsService) Authorize(ctx context.Context, id, authorizationID, signature string) (*Response, error)

Authorize calls POST /api/transfer_drafts/:id/authorize.

Executes the draft. authorizationID comes from the `payment.authorization_requested` webhook; build signature with SignatureInput and Sign. Requires the `transfers:authorize` scope on a key other than the draft's creator (otherwise a forbidden *Error of type `same_key_forbidden`). A blank signature is refused locally with *ArgumentError: the API counts it as a failed attempt, and five fail the challenge.

func (*TransferDraftsService) Create

func (s *TransferDraftsService) Create(ctx context.Context, attributes Attributes) (*Response, error)

Create calls POST /api/transfer_drafts. Required: account_id, amount, and exactly one of beneficiary_id (external transfer) or destination_account_id (own-account move). Optional: external_account_id, currency_code, payment_reference, internal_notes, client_reference (unique per entity, at most 128 characters; a duplicate returns a conflict *Error whose PaymentID names the existing draft).

func (*TransferDraftsService) Decline

func (s *TransferDraftsService) Decline(ctx context.Context, id, authorizationID, reason string) (*Response, error)

Decline calls POST /api/transfer_drafts/:id/decline.

Declines the challenge and deletes the draft; the response is the authorization (status "declined"). An empty reason is omitted from the request.

func (*TransferDraftsService) Get

Get calls GET /api/transfer_drafts/:id.

type TransferRef

type TransferRef struct {
	ID     string `json:"id"`
	Status string `json:"status"` // e.g. submitted
}

TransferRef is the executed transfer attached to an authorized draft.

type WebhookEndpointsService

type WebhookEndpointsService struct {
	// contains filtered or unexported fields
}

WebhookEndpointsService — webhook endpoint management.

func (*WebhookEndpointsService) Create

func (s *WebhookEndpointsService) Create(ctx context.Context, attributes Attributes) (*Response, error)

Create calls POST /api/webhook_endpoints.

func (*WebhookEndpointsService) Delete

Delete calls DELETE /api/webhook_endpoints/:id.

func (*WebhookEndpointsService) Disable

func (s *WebhookEndpointsService) Disable(ctx context.Context, id string) (*Response, error)

Disable calls POST /api/webhook_endpoints/:id/disable.

func (*WebhookEndpointsService) Enable

Enable calls POST /api/webhook_endpoints/:id/enable.

func (*WebhookEndpointsService) Get

Get calls GET /api/webhook_endpoints/:id.

func (*WebhookEndpointsService) List

func (s *WebhookEndpointsService) List(ctx context.Context, params ListParams) (*Page, error)

List calls GET /api/webhook_endpoints.

func (*WebhookEndpointsService) RegenerateSecret

func (s *WebhookEndpointsService) RegenerateSecret(ctx context.Context, id string) (*Response, error)

RegenerateSecret calls POST /api/webhook_endpoints/:id/regenerate_secret.

func (*WebhookEndpointsService) Test

Test calls POST /api/webhook_endpoints/:id/test.

func (*WebhookEndpointsService) Update

func (s *WebhookEndpointsService) Update(ctx context.Context, id string, attributes Attributes) (*Response, error)

Update calls PATCH /api/webhook_endpoints/:id.

Jump to

Keyboard shortcuts

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