Documentation
¶
Overview ¶
Package walletd is the first-party Go SDK for the WalletD API: contract types generated from the published OpenAPI document, one HTTP client that carries credentials, idempotency keys and retries, RFC 7807 problems decoded into errors callers can errors.Is against, and webhook signature verification.
Package walletd provides primitives to interact with the openapi HTTP API.
Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.8.0 DO NOT EDIT.
Example ¶
Example is the quickstart in SDK form, and is the same code the README shows. It is compiled by `go test`, so the documented sample cannot rot past a contract change without the build saying so.
package main
import (
"context"
"errors"
"fmt"
"log"
"os"
"github.com/walletd-io/walletd-go"
)
func main() {
ctx := context.Background()
client, err := walletd.New(os.Getenv("WALLETD_API"), walletd.APIKey(os.Getenv("WALLETD_API_KEY")),
walletd.WithUserAgent("acme-billing/2.1"))
if err != nil {
log.Fatal(err)
}
// 1. Create a wallet user. external_id is yours and unique per tenant.
name := "Ada Lovelace"
handle := "ada"
ada, err := client.CreateUser(ctx, walletd.CreateUserRequest{
ExternalId: "user-42",
DisplayName: &name,
Handle: &handle,
})
if err != nil {
log.Fatal(err)
}
// 2. Put money in. This does NOT credit the wallet: it opens an intent
// at the gateway. The balance rises when the processor confirms, which
// arrives as a topup.succeeded webhook.
topup, err := client.CreateTopup(ctx, "topup-user-42-first", walletd.CreateTopupRequest{
UserId: ada.Id,
Amount: 5000, // minor units: $50.00
Gateway: "stripe",
})
if err != nil {
log.Fatal(err)
}
fmt.Println("hand this to your checkout UI:", topup.NextAction)
// 3. Read the balance. Show Available, not Balance: the difference is
// money held by an uncaptured authorization.
balances, err := client.UserBalances(ctx, ada.Id)
if err != nil {
log.Fatal(err)
}
for _, b := range balances {
fmt.Printf("%s %s: %d available\n", b.Purpose, b.Commodity, b.Available)
}
// 4. Send money. The idempotency key is a parameter, not an option, so
// a transfer without one does not compile. It comes from your order, so
// retrying after a timeout still sends once.
bob, err := client.CreateUser(ctx, walletd.CreateUserRequest{ExternalId: "user-43"})
if err != nil {
log.Fatal(err)
}
transfer, err := client.CreateTransfer(ctx, "transfer-order-8891", walletd.CreateTransferRequest{
FromUser: ada.Id,
ToUser: &bob.Id,
Amount: 1500,
})
switch {
case errors.Is(err, walletd.ErrInsufficientFunds):
fmt.Println("not enough money")
case errors.Is(err, walletd.ErrTierLimitExceeded):
fmt.Println("a tier cap would be breached; nothing reached the processor")
case err != nil:
log.Fatal(err)
default:
fmt.Println("sent", transfer.Id)
}
// 5. Read the history. The iterator pages for you.
for row, err := range client.UserTransactions(ada.Id).All(ctx) {
if err != nil {
log.Fatal(err)
}
fmt.Printf("%s %s %d %s\n", row.CreatedAt.Format("2006-01-02"), row.TxnType, row.Amount, row.Direction)
}
}
Output:
Index ¶
- Constants
- Variables
- func CodeOf(err error) string
- func VerifySignature(header string, body []byte, secret string, tolerance time.Duration) error
- type AddVariantJSONRequestBody
- type AdjustStockJSONRequestBody
- type Alias
- type AuditEntry
- type CapturePaymentJSONBody
- type CapturePaymentJSONRequestBody
- type CapturePaymentParams
- type CatalogClient
- type CatalogClientStatus
- type CatalogImport
- type CatalogImportRow
- type CatalogImportRowAction
- type CatalogImportStatus
- type Category
- type CategoryId
- type CategoryInput
- type Client
- func (c *Client) CancelSubscription(ctx context.Context, subscriptionID uuid.UUID) (Subscription, error)
- func (c *Client) CapturePayment(ctx context.Context, paymentID uuid.UUID, key IdempotencyKey, amount *int64) (Payment, error)
- func (c *Client) ClientOfferings(clientID uuid.UUID, filter OfferingFilter) *PageIterator[Offering]
- func (c *Client) ConvertPoints(ctx context.Context, key IdempotencyKey, req ConvertPointsJSONRequestBody) (Conversion, error)
- func (c *Client) CreatePayment(ctx context.Context, key IdempotencyKey, req CreatePaymentRequest) (Payment, error)
- func (c *Client) CreateRefund(ctx context.Context, key IdempotencyKey, req CreateRefundRequest) (Refund, error)
- func (c *Client) CreateSubscription(ctx context.Context, key IdempotencyKey, req CreateSubscriptionRequest) (Subscription, error)
- func (c *Client) CreateTopup(ctx context.Context, key IdempotencyKey, req CreateTopupRequest) (Topup, error)
- func (c *Client) CreateTransfer(ctx context.Context, key IdempotencyKey, req CreateTransferRequest) (Transfer, error)
- func (c *Client) CreateUser(ctx context.Context, req CreateUserRequest) (User, error)
- func (c *Client) CreateWebhookEndpoint(ctx context.Context, req CreateWebhookEndpointRequest) (WebhookEndpoint, error)
- func (c *Client) ExploreClient(ctx context.Context, clientID uuid.UUID) (ExploreClientDetail, error)
- func (c *Client) ExploreClients(query, category string) *Iterator[CatalogClient]
- func (c *Client) ExploreOffering(ctx context.Context, offeringID uuid.UUID) (ExploreOfferingDetail, error)
- func (c *Client) GetClient(ctx context.Context, clientID uuid.UUID) (CatalogClient, error)
- func (c *Client) GetClientOffering(ctx context.Context, clientID, offeringID uuid.UUID) (Offering, error)
- func (c *Client) GetOrder(ctx context.Context, orderID uuid.UUID) (Order, error)
- func (c *Client) GetPayment(ctx context.Context, paymentID uuid.UUID) (Payment, error)
- func (c *Client) GetSubscription(ctx context.Context, subscriptionID uuid.UUID) (Subscription, error)
- func (c *Client) GetTopup(ctx context.Context, topupID uuid.UUID) (Topup, error)
- func (c *Client) GetUser(ctx context.Context, userID uuid.UUID) (User, error)
- func (c *Client) ListClientOfferings(ctx context.Context, clientID uuid.UUID, filter OfferingFilter, ...) (OfferingPage, error)
- func (c *Client) ListClients(ctx context.Context, status CatalogClientStatus, limit int) ([]CatalogClient, error)
- func (c *Client) ListExploreClients(ctx context.Context, query, category string, cursor uuid.UUID, limit int) ([]CatalogClient, error)
- func (c *Client) ListOrders(ctx context.Context, cursor uuid.UUID, limit int) ([]Order, error)
- func (c *Client) ListSubscriptions(ctx context.Context, userID *uuid.UUID, status SubscriptionStatus, ...) ([]Subscription, error)
- func (c *Client) ListTopupMethods(ctx context.Context) ([]TopupMethod, error)
- func (c *Client) ListTransactions(ctx context.Context, txnType string, cursor uuid.UUID, limit int) ([]Transaction, error)
- func (c *Client) ListUserRewards(ctx context.Context, userID uuid.UUID, limit int) ([]RewardGrant, error)
- func (c *Client) ListUserTransactions(ctx context.Context, userID, cursor uuid.UUID, limit int) ([]UserTransaction, error)
- func (c *Client) ListUsers(ctx context.Context, query string, cursor uuid.UUID, limit int) ([]User, error)
- func (c *Client) ListWebhookDeliveries(ctx context.Context, endpointID *uuid.UUID, cursor uuid.UUID, limit int) ([]WebhookDelivery, error)
- func (c *Client) ListWebhookEndpoints(ctx context.Context) ([]WebhookEndpoint, error)
- func (c *Client) ListWebhookEvents(ctx context.Context, eventType string, since time.Time, limit int) ([]WebhookEvent, error)
- func (c *Client) Me(ctx context.Context) (User, error)
- func (c *Client) Orders() *Iterator[Order]
- func (c *Client) PauseSubscription(ctx context.Context, subscriptionID uuid.UUID) (Subscription, error)
- func (c *Client) RedeliverWebhookEvent(ctx context.Context, eventID uuid.UUID) (int, error)
- func (c *Client) RefreshTopup(ctx context.Context, topupID uuid.UUID) (Topup, error)
- func (c *Client) ResumeSubscription(ctx context.Context, subscriptionID uuid.UUID) (Subscription, error)
- func (c *Client) SetUserCreditLimit(ctx context.Context, userID uuid.UUID, req SetCreditLimitRequest) (CreditLine, error)
- func (c *Client) Subscriptions(userID *uuid.UUID, status SubscriptionStatus) *Iterator[Subscription]
- func (c *Client) Transactions(txnType string) *Iterator[Transaction]
- func (c *Client) UserBalances(ctx context.Context, userID uuid.UUID) ([]UserBalance, error)
- func (c *Client) UserTransactions(userID uuid.UUID) *Iterator[UserTransaction]
- func (c *Client) Users(query string) *Iterator[User]
- func (c *Client) VoidPayment(ctx context.Context, paymentID uuid.UUID) (Payment, error)
- func (c *Client) WebhookDeliveries(endpointID *uuid.UUID) *Iterator[WebhookDelivery]
- type ClientId
- type ClientProfileRequest
- type ClientRewardRuleRequest
- type ClientRewardRuleRequestKind
- type ClientSale
- type ClientSales
- type ClientSalesSummary
- type CommissionMode
- type Conversion
- type ConvertPointsJSONBody
- type ConvertPointsJSONRequestBody
- type ConvertPointsParams
- type CreateCategoryJSONRequestBody
- type CreateClientRewardRuleJSONRequestBody
- type CreateMerchantJSONRequestBody
- type CreateMerchantRequest
- type CreateMerchantWebhookEndpointJSONRequestBody
- type CreateOfferingJSONRequestBody
- type CreateOfferingRequest
- type CreateOfferingRequestInterval
- type CreateOfferingRequestKind
- type CreateOrderJSONRequestBody
- type CreateOrderParams
- type CreateOrderRequest
- type CreatePaymentJSONRequestBody
- type CreatePaymentParams
- type CreatePaymentRequest
- type CreatePaymentRequestMode
- type CreateRefundJSONRequestBody
- type CreateRefundParams
- type CreateRefundRequest
- type CreateRewardRuleJSONRequestBody
- type CreateRewardRuleRequest
- type CreateRewardRuleRequestKind
- type CreateSubscriptionJSONRequestBody
- type CreateSubscriptionParams
- type CreateSubscriptionRequest
- type CreateSupportAccessGrantJSONRequestBody
- type CreateSupportAccessGrantRequest
- type CreateTenantJSONRequestBody
- type CreateTenantRequest
- type CreateTopupJSONRequestBody
- type CreateTopupParams
- type CreateTopupRequest
- type CreateTransferJSONRequestBody
- type CreateTransferParams
- type CreateTransferRequest
- type CreateUserJSONRequestBody
- type CreateUserRequest
- type CreateWebhookEndpointJSONRequestBody
- type CreateWebhookEndpointRequest
- type Credential
- type CreditLine
- type Cursor
- type EndpointId
- type EntryDirection
- type Event
- type ExploreClientDetail
- type ExploreClientsParams
- type ExploreOfferingDetail
- type FeePlan
- type FeeRule
- type FeeSchedule
- type FlowRow
- type FundClientMarketingJSONRequestBody
- type FundClientMarketingParams
- type FundMarketingRequest
- type FundMarketingResult
- type GetLedgerMetricsParams
- type GetLedgerMetricsParamsWindow
- type GetMerchantStatementParams
- type Health
- type HealthStatus
- type IdempotencyKey
- type IdempotencyKeyHeader
- type ImportId
- type InventoryMovement
- type InventoryMovementKind
- type IssueMerchantApiKeyJSONRequestBody
- type IssueMerchantApiKeyRequest
- type IssueMerchantApiKeyRequestEnv
- type IssuedMerchantApiKey
- type Iterator
- func (it *Iterator[T]) All(ctx context.Context) iter.Seq2[T, error]
- func (it *Iterator[T]) Collect(ctx context.Context) ([]T, error)
- func (it *Iterator[T]) Err() error
- func (it *Iterator[T]) Item() T
- func (it *Iterator[T]) Next(ctx context.Context) bool
- func (it *Iterator[T]) PageSize(n int) *Iterator[T]
- type KeyId
- type LedgerMetrics
- type LedgerMetricsBucket
- type LedgerSummary
- type Limit
- type LineItem
- type ListAuditLogParams
- type ListCatalogImportRowsParams
- type ListCatalogImportRowsParamsAction
- type ListCatalogImportsParams
- type ListClientOfferingsParams
- type ListClientOfferingsParamsStatus
- type ListClientOrdersParams
- type ListClientOrdersParamsStatus
- type ListClientPayoutsParams
- type ListClientSalesParams
- type ListClientsParams
- type ListInventoryMovementsParams
- type ListMerchantWebhookDeliveriesParams
- type ListOrdersParams
- type ListPlatformClientsParams
- type ListPlatformSubscriptionsParams
- type ListPlatformTransactionsParams
- type ListPlatformUsersParams
- type ListPriceHistoryParams
- type ListSubscriptionsParams
- type ListSupportAccessGrantsParams
- type ListTransactionsParams
- type ListUserRewardsParams
- type ListUserTransactionsParams
- type ListUsersParams
- type ListWebhookDeliveriesParams
- type ListWebhookEventsParams
- type MarketingView
- type Markup
- type MarkupKind
- type Merchant
- type MerchantApiKey
- type MerchantApiKeyEnv
- type MerchantApiKeyStatus
- type MerchantId
- type MerchantVolume
- type Offering
- type OfferingFilter
- type OfferingId
- type OfferingInterval
- type OfferingKind
- type OfferingPage
- type OfferingStatus
- type OnboardClientJSONRequestBody
- type OnboardClientRequest
- type OperationsSummary
- type Option
- type Order
- type OrderId
- type OrderLine
- type OrderLineInput
- type OrderPayment
- type OrderStatus
- type PageIterator
- func (p *PageIterator[T]) All(ctx context.Context) iter.Seq2[T, error]
- func (p *PageIterator[T]) Collect(ctx context.Context) ([]T, error)
- func (p *PageIterator[T]) Err() error
- func (p *PageIterator[T]) Item() T
- func (p *PageIterator[T]) Next(ctx context.Context) bool
- func (p *PageIterator[T]) PageSize(n int) *PageIterator[T]
- type Payment
- type PaymentId
- type PaymentStatus
- type Payout
- type PayoutStatus
- type PlatformClient
- type PlatformOverview
- type PlatformSubscription
- type PlatformTenantRow
- type PlatformTotal
- type PlatformTransaction
- type PlatformUser
- type PositionSummary
- type PriceChange
- type PriceChangeSource
- type Pricing
- type Problem
- type PurchaseOfferingParams
- type ReconciliationRow
- type Refund
- type RetryPolicy
- type RevenueSummary
- type RewardGrant
- type RewardRule
- type Rounding
- type RunClientPayoutJSONBody
- type RunClientPayoutJSONRequestBody
- type RunClientPayoutParams
- type SeriesPoint
- type SetClientCommissionJSONRequestBody
- type SetClientCommissionRequest
- type SetClientPricingJSONRequestBody
- type SetCreditLimitRequest
- type SetTierLimitsJSONRequestBody
- type SetTierLimitsRequest
- type SetUserCreditLimitJSONRequestBody
- type SetUserTierJSONBody
- type SetUserTierJSONRequestBody
- type StartCatalogImportMultipartBody
- type StartCatalogImportMultipartRequestBody
- type StatementEntry
- type StatementEntryDirection
- type StockAdjustmentRequest
- type StockAdjustmentResult
- type SubscribeOfferingParams
- type Subscription
- type SubscriptionId
- type SubscriptionInterval
- type SubscriptionStatus
- type SummaryRow
- type SupportAccessGrant
- type Tenant
- type TenantFilter
- type TenantSummary
- type TierLimits
- type Topup
- type TopupMethod
- type TopupMethodFlow
- type TopupNextAction
- type TopupNextActionKind
- type TopupStatus
- type Transaction
- type TransactionLeg
- type Transfer
- type UpdateCategoryJSONRequestBody
- type UpdateClientProfileJSONRequestBody
- type UpdateFeePlanJSONRequestBody
- type UpdateFeePlanRequest
- type UpdateOfferingJSONRequestBody
- type UpdateOfferingRequest
- type UpdateVariantJSONRequestBody
- type User
- type UserBalance
- type UserId
- type UserKind
- type UserTransaction
- type Variant
- type VariantId
- type VariantInput
- type VariantInputPricingMode
- type VariantInventory
- type VariantPricingMode
- type VariantStatus
- type WebhookDelivery
- type WebhookEndpoint
- type WebhookEvent
Examples ¶
Constants ¶
const ( // Version is this SDK's version. Version = "0.1.0" // APIVersion is the version of the WalletD contract types.gen.go was // generated from. A server on a different minor version may return // fields this SDK does not know; it will never return a field shape // this SDK decodes wrongly, because unknown fields are ignored. APIVersion = "0.8.0" )
const ( CodeUnauthenticated = "unauthenticated" CodeUnknownTenant = "unknown_tenant" CodeTenantSuspended = "tenant_suspended" CodeInsufficientScope = "insufficient_scope" CodeForbidden = "forbidden" CodeUserTokenRequired = "user_token_required" CodeConsumerTokenRequired = "consumer_token_required" CodePlatformScopeOnly = "platform_scope_only" CodeNotClientMember = "not_client_member" CodeInvalidRequest = "invalid_request" CodeSelfTransfer = "self_transfer" CodeIdempotencyKeyReuse = "idempotency_key_reuse" CodeUserExists = "user_exists" CodeMerchantExists = "merchant_exists" CodeRuleExists = "rule_exists" CodeInsufficientFunds = "insufficient_funds" CodeInsufficientPoints = "insufficient_points" CodeTierLimitExceeded = "tier_limit_exceeded" CodeNoConversionRule = "no_conversion_rule" CodeNothingToPay = "nothing_to_pay" CodeNotAnItem = "not_an_item" CodeNotAPlan = "not_a_plan" CodeUserNotBusiness = "user_not_business" CodeCreditLimitBelowBalance = "credit_limit_below_balance" CodeUserNotFound = "user_not_found" CodeSenderNotFound = "sender_not_found" CodeRecipientNotFound = "recipient_not_found" CodePayerNotFound = "payer_not_found" CodeMerchantNotFound = "merchant_not_found" CodePaymentNotFound = "payment_not_found" CodeTopupNotFound = "topup_not_found" CodeSubscriptionNotFound = "subscription_not_found" CodeClientNotFound = "client_not_found" CodeOfferingNotFound = "offering_not_found" CodeRuleNotFound = "rule_not_found" CodeEventNotFound = "event_not_found" CodeTenantNotFound = "tenant_not_found" CodeRateLimited = "rate_limited" CodeBulkheadFull = "bulkhead_full" CodeGatewayUnreachable = "gateway_unreachable" CodeReportingTimeout = "reporting_timeout" CodeInternalError = "internal_error" )
Documented problem codes. The list mirrors the errors page of the developer documentation; a code the server adds later arrives as a plain string in Problem.Code and still matches its status class.
const DefaultPageSize = 100
DefaultPageSize is the page the iterators ask for. The contract's ceiling is 100.
const DefaultTolerance = 5 * time.Minute
DefaultTolerance is the timestamp skew the platform documents: five minutes either way.
const EventIDHeader = "X-Wallet-Event-Id"
EventIDHeader carries the event id. It is the deduplication key for an at-least-once feed: record it and make reprocessing a no-op.
const SignatureHeader = "X-Wallet-Signature"
SignatureHeader is the header WalletD signs every delivery with.
Variables ¶
var ( ErrBadRequest = errors.New("bad request") ErrForbidden = errors.New("forbidden") ErrNotFound = errors.New("not found") ErrConflict = errors.New("conflict") ErrUnprocessable = errors.New("refused by a money rule") ErrRateLimited = errors.New("rate limited") ErrServer = errors.New("server error") // ErrTransport is a request that never got an answer: DNS, dial, TLS // or a read failure. Whether the call landed is unknown, which is // exactly what an idempotency key is for. ErrTransport = errors.New("transport failure") )
Status-class sentinels. Every Problem matches exactly one of these.
var ( ErrUnauthenticated = errors.New("unauthenticated") ErrUnknownTenant = errors.New("unknown tenant") ErrTenantSuspended = errors.New("tenant suspended") ErrInsufficientScope = errors.New("insufficient scope") ErrUserTokenRequired = errors.New("user token required") ErrConsumerTokenRequired = errors.New("consumer token required") ErrPlatformScopeOnly = errors.New("platform scope only") ErrNotClientMember = errors.New("not a member of that client") ErrInvalidRequest = errors.New("invalid request") ErrSelfTransfer = errors.New("sender and recipient are the same wallet") ErrIdempotencyKeyReuse = errors.New("idempotency key reused with different parameters") ErrUserExists = errors.New("user already exists") ErrMerchantExists = errors.New("merchant already exists") ErrRuleExists = errors.New("rule already exists") ErrInsufficientFunds = errors.New("insufficient funds") ErrInsufficientPoints = errors.New("insufficient points") ErrTierLimitExceeded = errors.New("tier limit exceeded") ErrNoConversionRule = errors.New("no active conversion rule") ErrNothingToPay = errors.New("nothing to pay") ErrNotAnItem = errors.New("offering is not a one-off item") ErrNotAPlan = errors.New("offering is not a plan") ErrUserNotBusiness = errors.New("user is not a business") ErrCreditLimitBelowBalance = errors.New("credit limit below drawn balance") ErrUserNotFound = errors.New("user not found") ErrSenderNotFound = errors.New("sender not found") ErrRecipientNotFound = errors.New("recipient not found") ErrPayerNotFound = errors.New("payer not found") ErrMerchantNotFound = errors.New("merchant not found") ErrPaymentNotFound = errors.New("payment not found") ErrTopupNotFound = errors.New("topup not found") ErrSubscriptionNotFound = errors.New("subscription not found") ErrClientNotFound = errors.New("client not found") ErrOfferingNotFound = errors.New("offering not found") ErrRuleNotFound = errors.New("rule not found") ErrEventNotFound = errors.New("event not found") ErrTenantNotFound = errors.New("tenant not found") ErrBulkheadFull = errors.New("gateway concurrency compartment full") ErrGatewayUnreachable = errors.New("payment gateway unreachable") ErrReportingTimeout = errors.New("reporting window too wide") ErrInternal = errors.New("internal error") )
Problem-code sentinels for the documented codes.
var ( // ErrSignatureMalformed means the header is not t=<unix>,v1=<hex>. ErrSignatureMalformed = errors.New("malformed signature header") // ErrSignatureStale means the timestamp is outside the tolerance: // either a replayed capture or a badly skewed clock. ErrSignatureStale = errors.New("signature timestamp outside tolerance") // ErrSignatureMismatch means the body, the secret, or both are not // what was signed. Treat it as a forgery. ErrSignatureMismatch = errors.New("signature does not match") )
Signature verification failures. They are deliberately separate so a receiver can alarm on a forgery and merely log a clock problem, but a receiver must reject the delivery on any of them.
var DefaultRetryPolicy = RetryPolicy{ MaxAttempts: 4, BaseDelay: 200 * time.Millisecond, MaxDelay: 5 * time.Second, }
DefaultRetryPolicy is four attempts over roughly two seconds of backoff.
var ErrPaginationStalled = errors.New("pagination stalled: the page did not advance the cursor")
ErrPaginationStalled means the server answered a full page whose last item is the cursor we just sent. Continuing would loop forever and stopping would drop whatever lies past it, so the iterator says so instead of doing either quietly.
Functions ¶
func VerifySignature ¶
VerifySignature checks one delivery against its endpoint secret.
X-Wallet-Signature: t=<unix seconds>,v1=<hex hmac_sha256(secret, "<t>.<raw body>")>
body must be the RAW bytes as received. Decoding the JSON and re-encoding it changes key order and whitespace, and therefore changes the hash: every such receiver rejects every genuine delivery. Read the body with io.ReadAll before anything else touches it.
tolerance bounds how far the timestamp may be from now, in either direction; pass DefaultTolerance unless you have a reason. Without it a captured delivery can be replayed at any time in the future, which is the attack the timestamp exists to stop.
A nil return means the delivery came from WalletD and has not been altered. It says nothing about whether you have already processed this event — that is what EventIDHeader is for.
body, err := io.ReadAll(io.LimitReader(r.Body, 1<<20))
if err != nil { ... }
if err := walletd.VerifySignature(r.Header.Get(walletd.SignatureHeader), body, secret, walletd.DefaultTolerance); err != nil {
w.WriteHeader(http.StatusUnauthorized)
return
}
One secret belongs to one endpoint of one tenant. If your receiver serves several tenants, select the secret by the delivery's tenant_id; verifying tenant A's delivery against tenant B's secret fails exactly like a forgery, which is the point.
Example ¶
ExampleVerifySignature is the README's receiver, compiled.
package main
import (
"fmt"
"io"
"net/http"
"os"
"github.com/walletd-io/walletd-go"
)
func main() {
secret := os.Getenv("WALLETD_WEBHOOK_SECRET")
http.HandleFunc("/webhooks/walletd", func(w http.ResponseWriter, r *http.Request) {
// The RAW bytes are what was signed. Decoding and re-encoding the
// JSON changes key order, and the hash with it.
body, err := io.ReadAll(io.LimitReader(r.Body, 1<<20))
if err != nil {
w.WriteHeader(http.StatusBadRequest)
return
}
if err := walletd.VerifySignature(
r.Header.Get(walletd.SignatureHeader), body, secret, walletd.DefaultTolerance,
); err != nil {
w.WriteHeader(http.StatusUnauthorized)
return
}
event, err := walletd.ParseEvent(body)
if err != nil {
w.WriteHeader(http.StatusBadRequest)
return
}
// Delivery is at-least-once: X-Wallet-Event-Id is the dedupe key.
// Answer fast and do the work elsewhere.
go func() {
switch event.Type {
case "topup.succeeded":
var topup walletd.Topup
if err := event.Into("topup", &topup); err != nil {
return
}
fmt.Println("credited", topup.UserId, topup.Amount)
default:
// New types are added without warning. Ignore, do not crash.
}
}()
w.WriteHeader(http.StatusOK)
})
}
Output:
Types ¶
type AddVariantJSONRequestBody ¶
type AddVariantJSONRequestBody = VariantInput
AddVariantJSONRequestBody defines body for AddVariant for application/json ContentType.
type AdjustStockJSONRequestBody ¶
type AdjustStockJSONRequestBody = StockAdjustmentRequest
AdjustStockJSONRequestBody defines body for AdjustStock for application/json ContentType.
type Alias ¶
type Alias struct {
Email *string `json:"email,omitempty"`
Handle *string `json:"handle,omitempty"`
Phone *string `json:"phone,omitempty"`
}
Alias defines model for Alias.
type AuditEntry ¶
type AuditEntry struct {
Action string `json:"action"`
ActorId string `json:"actor_id"`
ActorType string `json:"actor_type"`
After interface{} `json:"after,omitempty"`
Before interface{} `json:"before,omitempty"`
CreatedAt time.Time `json:"created_at"`
Id int64 `json:"id"`
ObjectId string `json:"object_id"`
ObjectType string `json:"object_type"`
}
AuditEntry defines model for AuditEntry.
type CapturePaymentJSONBody ¶
type CapturePaymentJSONBody struct {
// Amount Defaults to the full authorized amount
Amount *int64 `json:"amount,omitempty"`
}
CapturePaymentJSONBody defines parameters for CapturePayment.
type CapturePaymentJSONRequestBody ¶
type CapturePaymentJSONRequestBody CapturePaymentJSONBody
CapturePaymentJSONRequestBody defines body for CapturePayment for application/json ContentType.
type CapturePaymentParams ¶
type CapturePaymentParams struct {
IdempotencyKeyHeader IdempotencyKeyHeader `json:"Idempotency-Key"`
}
CapturePaymentParams defines parameters for CapturePayment.
type CatalogClient ¶
type CatalogClient struct {
// ApprovedAt When the platform first let this client publish. Absent while pending.
ApprovedAt *time.Time `json:"approved_at,omitempty"`
Category *string `json:"category,omitempty"`
// CommissionBps Overrides the loop's commission rate for this client. Absent means no deal here and the loop's rate applies; zero means this client sells commission-free.
CommissionBps *int `json:"commission_bps,omitempty"`
CreatedAt time.Time `json:"created_at"`
Description *string `json:"description,omitempty"`
DisplayName string `json:"display_name"`
Id openapi_types.UUID `json:"id"`
LogoUrl *string `json:"logo_url,omitempty"`
MerchantId openapi_types.UUID `json:"merchant_id"`
OrgAlias string `json:"org_alias"`
// Status A self-onboarded client starts pending: it can build its profile and draft offerings, but nothing reaches Explore until the platform approves it. Suspended hides its catalog again without touching its money.
Status CatalogClientStatus `json:"status"`
}
CatalogClient defines model for CatalogClient.
type CatalogClientStatus ¶
type CatalogClientStatus string
CatalogClientStatus A self-onboarded client starts pending: it can build its profile and draft offerings, but nothing reaches Explore until the platform approves it. Suspended hides its catalog again without touching its money.
const ( CatalogClientStatusActive CatalogClientStatus = "active" CatalogClientStatusPending CatalogClientStatus = "pending" CatalogClientStatusSuspended CatalogClientStatus = "suspended" )
Defines values for CatalogClientStatus.
func (CatalogClientStatus) Valid ¶
func (e CatalogClientStatus) Valid() bool
Valid indicates whether the value is a known member of the CatalogClientStatus enum.
type CatalogImport ¶
type CatalogImport struct {
AppliedCount int `json:"applied_count"`
ClientId openapi_types.UUID `json:"client_id"`
CommittedAt *time.Time `json:"committed_at,omitempty"`
CreateCount int `json:"create_count"`
CreatedAt time.Time `json:"created_at"`
Error *string `json:"error,omitempty"`
ErrorCount int `json:"error_count"`
FileName string `json:"file_name"`
HasImages bool `json:"has_images"`
Id openapi_types.UUID `json:"id"`
RowCount int `json:"row_count"`
Status CatalogImportStatus `json:"status"`
UpdateCount int `json:"update_count"`
UpdatedAt time.Time `json:"updated_at"`
}
CatalogImport A bulk import. validating: the file is being parsed and previewed; ready: the preview is complete and the merchant may commit or cancel; committing: the rows are being applied; done, failed and canceled are final. error is the fatal reason for failed; row problems are on the rows.
type CatalogImportRow ¶
type CatalogImportRow struct {
Action CatalogImportRowAction `json:"action"`
Applied bool `json:"applied"`
Errors []string `json:"errors"`
// ImageUrl The stored public image this row will use.
ImageUrl *string `json:"image_url,omitempty"`
// Payload The row as the parser understood it.
Payload map[string]interface{} `json:"payload"`
ProductHandle *string `json:"product_handle,omitempty"`
// RowNo The spreadsheet line, header being line 1.
RowNo int `json:"row_no"`
Sku *string `json:"sku,omitempty"`
Title *string `json:"title,omitempty"`
}
CatalogImportRow defines model for CatalogImportRow.
type CatalogImportRowAction ¶
type CatalogImportRowAction string
CatalogImportRowAction defines model for CatalogImportRow.Action.
const ( CatalogImportRowActionCreate CatalogImportRowAction = "create" CatalogImportRowActionError CatalogImportRowAction = "error" CatalogImportRowActionUpdate CatalogImportRowAction = "update" )
Defines values for CatalogImportRowAction.
func (CatalogImportRowAction) Valid ¶
func (e CatalogImportRowAction) Valid() bool
Valid indicates whether the value is a known member of the CatalogImportRowAction enum.
type CatalogImportStatus ¶
type CatalogImportStatus string
CatalogImportStatus defines model for CatalogImport.Status.
const ( CatalogImportStatusCanceled CatalogImportStatus = "canceled" CatalogImportStatusCommitting CatalogImportStatus = "committing" CatalogImportStatusDone CatalogImportStatus = "done" CatalogImportStatusFailed CatalogImportStatus = "failed" CatalogImportStatusReady CatalogImportStatus = "ready" CatalogImportStatusValidating CatalogImportStatus = "validating" )
Defines values for CatalogImportStatus.
func (CatalogImportStatus) Valid ¶
func (e CatalogImportStatus) Valid() bool
Valid indicates whether the value is a known member of the CatalogImportStatus enum.
type Category ¶
type Category struct {
CreatedAt time.Time `json:"created_at"`
Id openapi_types.UUID `json:"id"`
Name string `json:"name"`
ParentId *openapi_types.UUID `json:"parent_id,omitempty"`
Position int `json:"position"`
Slug string `json:"slug"`
}
Category defines model for Category.
type CategoryInput ¶
type CategoryInput struct {
Name string `json:"name"`
// ParentId A top-level category; trees are one level deep.
ParentId *openapi_types.UUID `json:"parent_id,omitempty"`
Position *int `json:"position,omitempty"`
}
CategoryInput defines model for CategoryInput.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to one WalletD deployment as one principal. It is safe for concurrent use and should be built once and shared.
func New ¶
func New(baseURL string, cred Credential, opts ...Option) (*Client, error)
New builds a client for baseURL — the API host, with no path, e.g. https://apigw.walletd.io.
func (*Client) CancelSubscription ¶
func (c *Client) CancelSubscription(ctx context.Context, subscriptionID uuid.UUID) (Subscription, error)
CancelSubscription ends a subscription for good.
func (*Client) CapturePayment ¶
func (c *Client) CapturePayment(ctx context.Context, paymentID uuid.UUID, key IdempotencyKey, amount *int64) (Payment, error)
CapturePayment settles an authorized payment. A nil amount captures the full authorization; a smaller one captures part and releases the rest.
func (*Client) ClientOfferings ¶
func (c *Client) ClientOfferings(clientID uuid.UUID, filter OfferingFilter) *PageIterator[Offering]
ClientOfferings iterates a client's whole catalog.
func (*Client) ConvertPoints ¶
func (c *Client) ConvertPoints(ctx context.Context, key IdempotencyKey, req ConvertPointsJSONRequestBody) (Conversion, error)
ConvertPoints turns a user's loyalty points into spendable cash at the tenant's active conversion rule.
func (*Client) CreatePayment ¶
func (c *Client) CreatePayment(ctx context.Context, key IdempotencyKey, req CreatePaymentRequest) (Payment, error)
CreatePayment charges a user for a merchant. Mode "capture" takes the money now; mode "authorize" holds it until CapturePayment or VoidPayment, or until the hold expires on its own.
func (*Client) CreateRefund ¶
func (c *Client) CreateRefund(ctx context.Context, key IdempotencyKey, req CreateRefundRequest) (Refund, error)
CreateRefund returns part or all of a captured payment. Refunds are contra postings, not reversals: the original payment stays in the books.
func (*Client) CreateSubscription ¶
func (c *Client) CreateSubscription(ctx context.Context, key IdempotencyKey, req CreateSubscriptionRequest) (Subscription, error)
CreateSubscription starts a recurring charge. The first charge happens at StartAt, or immediately when it is nil.
func (*Client) CreateTopup ¶
func (c *Client) CreateTopup(ctx context.Context, key IdempotencyKey, req CreateTopupRequest) (Topup, error)
CreateTopup opens a funding intent at a gateway. It does NOT credit the wallet: the balance rises only when the processor confirms, which arrives as a topup.succeeded webhook. Hand NextAction to your checkout UI.
func (*Client) CreateTransfer ¶
func (c *Client) CreateTransfer(ctx context.Context, key IdempotencyKey, req CreateTransferRequest) (Transfer, error)
CreateTransfer moves money between two wallets of the same tenant.
Example ¶
ExampleClient_CreateTransfer shows branching on problem codes.
package main
import (
"context"
"errors"
"fmt"
"log"
"github.com/walletd-io/walletd-go"
)
func main() {
client, err := walletd.New("https://apigw.walletd.io", walletd.APIKey("sk_sandbox_..."))
if err != nil {
log.Fatal(err)
}
// The key is the caller's order, minted once and reused on every
// attempt — including the SDK's own retries.
_, err = client.CreateTransfer(context.Background(), "transfer-order-8891",
walletd.CreateTransferRequest{Amount: 1500})
var problem *walletd.Problem
switch {
case errors.Is(err, walletd.ErrInsufficientFunds):
fmt.Println("top up first")
case errors.Is(err, walletd.ErrSelfTransfer):
fmt.Println("sender and recipient are the same wallet")
case errors.As(err, &problem):
fmt.Printf("walletd %d %s: %s\n", problem.Status, problem.Code, problem.Message())
}
}
Output:
func (*Client) CreateUser ¶
CreateUser mirrors one of your users into the wallet. ExternalId is yours and unique per tenant, so creating the same one twice is a user_exists conflict.
func (*Client) CreateWebhookEndpoint ¶
func (c *Client) CreateWebhookEndpoint(ctx context.Context, req CreateWebhookEndpointRequest) (WebhookEndpoint, error)
CreateWebhookEndpoint registers a receiver.
The signing secret is in WebhookEndpoint.Secret and is returned exactly once, here. Store it in your secret manager before this function's return value goes out of scope; it cannot be read back.
func (*Client) ExploreClient ¶
func (c *Client) ExploreClient(ctx context.Context, clientID uuid.UUID) (ExploreClientDetail, error)
ExploreClient reads one storefront as a shopper sees it.
func (*Client) ExploreClients ¶
func (c *Client) ExploreClients(query, category string) *Iterator[CatalogClient]
ExploreClients iterates the shopper-facing storefront directory.
func (*Client) ExploreOffering ¶
func (c *Client) ExploreOffering(ctx context.Context, offeringID uuid.UUID) (ExploreOfferingDetail, error)
ExploreOffering reads one offering as a shopper sees it.
func (*Client) GetClientOffering ¶
func (c *Client) GetClientOffering(ctx context.Context, clientID, offeringID uuid.UUID) (Offering, error)
GetClientOffering reads one offering with its variants.
func (*Client) GetPayment ¶
GetPayment reads one payment.
func (*Client) GetSubscription ¶
func (c *Client) GetSubscription(ctx context.Context, subscriptionID uuid.UUID) (Subscription, error)
GetSubscription reads one subscription.
func (*Client) ListClientOfferings ¶
func (c *Client) ListClientOfferings(ctx context.Context, clientID uuid.UUID, filter OfferingFilter, cursor uuid.UUID, limit int) (OfferingPage, error)
ListClientOfferings reads one page of a client's catalog. Unlike the other listings this one answers with an envelope that names the next cursor, so the last page is stated rather than inferred.
func (*Client) ListClients ¶
func (c *Client) ListClients(ctx context.Context, status CatalogClientStatus, limit int) ([]CatalogClient, error)
ListClients returns the tenant's catalog clients (merchant storefronts).
The contract gives this listing a limit but no cursor, so it returns at most limit clients, 100 at the ceiling, and cannot be paged.
func (*Client) ListExploreClients ¶
func (c *Client) ListExploreClients(ctx context.Context, query, category string, cursor uuid.UUID, limit int) ([]CatalogClient, error)
ListExploreClients reads one page of the shopper-facing directory of approved storefronts. Prefer ExploreClients.
func (*Client) ListOrders ¶
ListOrders reads one page of the calling user's orders. Prefer Orders.
func (*Client) ListSubscriptions ¶
func (c *Client) ListSubscriptions(ctx context.Context, userID *uuid.UUID, status SubscriptionStatus, cursor uuid.UUID, limit int) ([]Subscription, error)
ListSubscriptions reads one page. Prefer Subscriptions.
func (*Client) ListTopupMethods ¶
func (c *Client) ListTopupMethods(ctx context.Context) ([]TopupMethod, error)
ListTopupMethods returns the funding methods this tenant has enabled.
func (*Client) ListTransactions ¶
func (c *Client) ListTransactions(ctx context.Context, txnType string, cursor uuid.UUID, limit int) ([]Transaction, error)
ListTransactions reads one page of the tenant's ledger transactions. txnType filters to one kind ("transfer", "payment", ...); empty is all.
func (*Client) ListUserRewards ¶
func (c *Client) ListUserRewards(ctx context.Context, userID uuid.UUID, limit int) ([]RewardGrant, error)
ListUserRewards returns a user's most recent reward grants.
The contract gives this listing a limit but no cursor, so it cannot be paged: what you get is the newest limit grants, at most 100.
func (*Client) ListUserTransactions ¶
func (c *Client) ListUserTransactions(ctx context.Context, userID, cursor uuid.UUID, limit int) ([]UserTransaction, error)
ListUserTransactions reads one page of a user's history, newest first.
The limit counts TRANSACTIONS, not rows: one transaction can put several entries in this list for the same user, so a page may be longer than the limit. Use UserTransactions unless you are paging by hand, and if you are, take the cursor from the last row's TxnId and stop only when the page holds fewer than `limit` distinct TxnIds.
func (*Client) ListUsers ¶
func (c *Client) ListUsers(ctx context.Context, query string, cursor uuid.UUID, limit int) ([]User, error)
ListUsers reads one page. Prefer Users, which pages correctly on its own. query matches the display name, handle or external id.
func (*Client) ListWebhookDeliveries ¶
func (c *Client) ListWebhookDeliveries(ctx context.Context, endpointID *uuid.UUID, cursor uuid.UUID, limit int) ([]WebhookDelivery, error)
ListWebhookDeliveries reads one page of delivery attempts. Prefer WebhookDeliveries.
func (*Client) ListWebhookEndpoints ¶
func (c *Client) ListWebhookEndpoints(ctx context.Context) ([]WebhookEndpoint, error)
ListWebhookEndpoints returns the tenant's endpoints, without secrets.
func (*Client) ListWebhookEvents ¶
func (c *Client) ListWebhookEvents(ctx context.Context, eventType string, since time.Time, limit int) ([]WebhookEvent, error)
ListWebhookEvents returns recent events, newest first. History is kept for 30 days.
The contract gives this listing a since filter and a limit but no cursor, so it cannot be paged: narrow the window instead of asking for more.
func (*Client) Me ¶
Me returns the user the credential resolves to. It is the call a mobile app makes with a user token; an API key has no user and gets a problem.
func (*Client) PauseSubscription ¶
func (c *Client) PauseSubscription(ctx context.Context, subscriptionID uuid.UUID) (Subscription, error)
PauseSubscription stops charging without ending the mandate.
func (*Client) RedeliverWebhookEvent ¶
RedeliverWebhookEvent re-queues one event to every endpoint that should receive it, and returns how many deliveries were enqueued. Use it when a receiver was down past its retry window.
func (*Client) RefreshTopup ¶
RefreshTopup asks WalletD to reconcile the intent against the gateway now, instead of waiting for the processor's callback. Use it when a top-up has been pending longer than it should; it is the reconcile path, not a polling loop.
func (*Client) ResumeSubscription ¶
func (c *Client) ResumeSubscription(ctx context.Context, subscriptionID uuid.UUID) (Subscription, error)
ResumeSubscription restarts a paused subscription.
func (*Client) SetUserCreditLimit ¶
func (c *Client) SetUserCreditLimit(ctx context.Context, userID uuid.UUID, req SetCreditLimitRequest) (CreditLine, error)
SetUserCreditLimit sets the floor the user's cash balance may go below zero, absolutely — it is not a delta. A limit under what the account has already drawn is refused with credit_limit_below_balance.
This changes what the user may spend but moves no money, which is why the contract does not key it.
func (*Client) Subscriptions ¶
func (c *Client) Subscriptions(userID *uuid.UUID, status SubscriptionStatus) *Iterator[Subscription]
Subscriptions iterates subscriptions, optionally filtered by user and status.
func (*Client) Transactions ¶
func (c *Client) Transactions(txnType string) *Iterator[Transaction]
Transactions iterates the tenant's ledger transactions, newest first.
func (*Client) UserBalances ¶
UserBalances returns one balance per purpose the user holds. Show Available, not Balance: the difference is money reserved by an uncaptured authorization.
func (*Client) UserTransactions ¶
func (c *Client) UserTransactions(userID uuid.UUID) *Iterator[UserTransaction]
UserTransactions iterates a user's whole history, newest first.
func (*Client) VoidPayment ¶
VoidPayment releases an authorization without charging.
The contract does not key this call: voiding twice is the same void, so there is nothing to deduplicate. That also means the SDK will not retry it after a 5xx — read the payment back and decide.
func (*Client) WebhookDeliveries ¶
func (c *Client) WebhookDeliveries(endpointID *uuid.UUID) *Iterator[WebhookDelivery]
WebhookDeliveries iterates delivery attempts, newest first.
type ClientProfileRequest ¶
type ClientProfileRequest struct {
Category *string `json:"category,omitempty"`
Description *string `json:"description,omitempty"`
DisplayName string `json:"display_name"`
LogoUrl *string `json:"logo_url,omitempty"`
}
ClientProfileRequest defines model for ClientProfileRequest.
type ClientRewardRuleRequest ¶
type ClientRewardRuleRequest struct {
// Fixed Flat cashback added on top of the rate. Cashback only.
Fixed *int64 `json:"fixed,omitempty"`
// Kind cashback pays money back from this merchant's own marketing pot; accrual grants tenant-issued loyalty points. Defaults to cashback.
Kind *ClientRewardRuleRequestKind `json:"kind,omitempty"`
// OfferingId When set, the rule applies only to this one product of the merchant and overrides the merchant's common rule of the same kind. Absent is the common rule that applies to all of the merchant's products.
OfferingId *openapi_types.UUID `json:"offering_id,omitempty"`
PerTxnCap *int64 `json:"per_txn_cap,omitempty"`
PerUserDayCap *int64 `json:"per_user_day_cap,omitempty"`
// RateBps Cashback rate in basis points (0-10000). For accrual this is the points-per-unit rate (1-100000).
RateBps *int `json:"rate_bps,omitempty"`
}
ClientRewardRuleRequest Scope and funding are pinned to the calling merchant; the rule is either common (all products) or per-product, and either cashback or loyalty.
type ClientRewardRuleRequestKind ¶
type ClientRewardRuleRequestKind string
ClientRewardRuleRequestKind cashback pays money back from this merchant's own marketing pot; accrual grants tenant-issued loyalty points. Defaults to cashback.
const ( ClientRewardRuleRequestKindAccrual ClientRewardRuleRequestKind = "accrual" ClientRewardRuleRequestKindCashback ClientRewardRuleRequestKind = "cashback" )
Defines values for ClientRewardRuleRequestKind.
func (ClientRewardRuleRequestKind) Valid ¶
func (e ClientRewardRuleRequestKind) Valid() bool
Valid indicates whether the value is a known member of the ClientRewardRuleRequestKind enum.
type ClientSale ¶
type ClientSale struct {
Amount int64 `json:"amount"`
Commission int64 `json:"commission"`
CreatedAt time.Time `json:"created_at"`
Fee int64 `json:"fee"`
// Net What reached settlement, so amount less fee, commission and refunds.
Net int64 `json:"net"`
// OfferingId Absent when the sale did not come from the catalog.
OfferingId *openapi_types.UUID `json:"offering_id,omitempty"`
// OrderId Set when the sale came through a cart order.
OrderId *openapi_types.UUID `json:"order_id,omitempty"`
PaymentId openapi_types.UUID `json:"payment_id"`
Refunded int64 `json:"refunded"`
Status string `json:"status"`
Title *string `json:"title,omitempty"`
}
ClientSale defines model for ClientSale.
type ClientSales ¶
type ClientSales struct {
Sales []ClientSale `json:"sales"`
Summary ClientSalesSummary `json:"summary"`
}
ClientSales defines model for ClientSales.
type ClientSalesSummary ¶
type ClientSalesSummary struct {
Commission int64 `json:"commission"`
Fees int64 `json:"fees"`
Gross int64 `json:"gross"`
Net int64 `json:"net"`
Refunded int64 `json:"refunded"`
Sales int64 `json:"sales"`
// Subscribers Live mandates, counting active and past-due.
Subscribers int64 `json:"subscribers"`
}
ClientSalesSummary defines model for ClientSalesSummary.
type CommissionMode ¶
type CommissionMode string
CommissionMode Whether marketplace commission comes out of the merchant's settlement (the consumer pays the list price) or is added to what the consumer pays (the merchant nets the full list price).
const ( Add CommissionMode = "add" Deduct CommissionMode = "deduct" )
Defines values for CommissionMode.
func (CommissionMode) Valid ¶
func (e CommissionMode) Valid() bool
Valid indicates whether the value is a known member of the CommissionMode enum.
type Conversion ¶
type Conversion struct {
CashCredited int64 `json:"cash_credited"`
Id openapi_types.UUID `json:"id"`
MinorPerPoint int64 `json:"minor_per_point"`
Points int64 `json:"points"`
UserId openapi_types.UUID `json:"user_id"`
}
Conversion defines model for Conversion.
type ConvertPointsJSONBody ¶
type ConvertPointsJSONBody struct {
Points int64 `json:"points"`
UserId openapi_types.UUID `json:"user_id"`
}
ConvertPointsJSONBody defines parameters for ConvertPoints.
type ConvertPointsJSONRequestBody ¶
type ConvertPointsJSONRequestBody ConvertPointsJSONBody
ConvertPointsJSONRequestBody defines body for ConvertPoints for application/json ContentType.
type ConvertPointsParams ¶
type ConvertPointsParams struct {
IdempotencyKeyHeader IdempotencyKeyHeader `json:"Idempotency-Key"`
}
ConvertPointsParams defines parameters for ConvertPoints.
type CreateCategoryJSONRequestBody ¶
type CreateCategoryJSONRequestBody = CategoryInput
CreateCategoryJSONRequestBody defines body for CreateCategory for application/json ContentType.
type CreateClientRewardRuleJSONRequestBody ¶
type CreateClientRewardRuleJSONRequestBody = ClientRewardRuleRequest
CreateClientRewardRuleJSONRequestBody defines body for CreateClientRewardRule for application/json ContentType.
type CreateMerchantJSONRequestBody ¶
type CreateMerchantJSONRequestBody = CreateMerchantRequest
CreateMerchantJSONRequestBody defines body for CreateMerchant for application/json ContentType.
type CreateMerchantRequest ¶
type CreateMerchantRequest struct {
Category *string `json:"category,omitempty"`
ExternalId string `json:"external_id"`
Name string `json:"name"`
}
CreateMerchantRequest defines model for CreateMerchantRequest.
type CreateMerchantWebhookEndpointJSONRequestBody ¶
type CreateMerchantWebhookEndpointJSONRequestBody = CreateWebhookEndpointRequest
CreateMerchantWebhookEndpointJSONRequestBody defines body for CreateMerchantWebhookEndpoint for application/json ContentType.
type CreateOfferingJSONRequestBody ¶
type CreateOfferingJSONRequestBody = CreateOfferingRequest
CreateOfferingJSONRequestBody defines body for CreateOffering for application/json ContentType.
type CreateOfferingRequest ¶
type CreateOfferingRequest struct {
// Amount The plan price, or the price of an item's default variant when no variants are given. Ignored when variants are given.
Amount *int64 `json:"amount,omitempty"`
CategoryId *openapi_types.UUID `json:"category_id,omitempty"`
Description *string `json:"description,omitempty"`
ImageUrl *string `json:"image_url,omitempty"`
// Interval Required for plans, forbidden for items
Interval *CreateOfferingRequestInterval `json:"interval,omitempty"`
Kind CreateOfferingRequestKind `json:"kind"`
// Markup What a merchant adds to a cost to reach a sell price. percent is basis points of the cost; fixed is minor units on top. Resolves most specific wins: variant, then product, then shop.
Markup *Markup `json:"markup,omitempty"`
Metadata *map[string]string `json:"metadata,omitempty"`
// Options Variant axes; a product with options must list its variants.
Options *[]string `json:"options,omitempty"`
Title string `json:"title"`
Variants *[]VariantInput `json:"variants,omitempty"`
}
CreateOfferingRequest defines model for CreateOfferingRequest.
type CreateOfferingRequestInterval ¶
type CreateOfferingRequestInterval string
CreateOfferingRequestInterval Required for plans, forbidden for items
const ( CreateOfferingRequestIntervalMonthly CreateOfferingRequestInterval = "monthly" CreateOfferingRequestIntervalWeekly CreateOfferingRequestInterval = "weekly" )
Defines values for CreateOfferingRequestInterval.
func (CreateOfferingRequestInterval) Valid ¶
func (e CreateOfferingRequestInterval) Valid() bool
Valid indicates whether the value is a known member of the CreateOfferingRequestInterval enum.
type CreateOfferingRequestKind ¶
type CreateOfferingRequestKind string
CreateOfferingRequestKind defines model for CreateOfferingRequest.Kind.
const ( CreateOfferingRequestKindItem CreateOfferingRequestKind = "item" CreateOfferingRequestKindPlan CreateOfferingRequestKind = "plan" )
Defines values for CreateOfferingRequestKind.
func (CreateOfferingRequestKind) Valid ¶
func (e CreateOfferingRequestKind) Valid() bool
Valid indicates whether the value is a known member of the CreateOfferingRequestKind enum.
type CreateOrderJSONRequestBody ¶
type CreateOrderJSONRequestBody = CreateOrderRequest
CreateOrderJSONRequestBody defines body for CreateOrder for application/json ContentType.
type CreateOrderParams ¶
type CreateOrderParams struct {
IdempotencyKeyHeader IdempotencyKeyHeader `json:"Idempotency-Key"`
}
CreateOrderParams defines parameters for CreateOrder.
type CreateOrderRequest ¶
type CreateOrderRequest struct {
Lines []OrderLineInput `json:"lines"`
}
CreateOrderRequest Lines from one merchant. Prices come from the catalog; the buyer never sends an amount.
type CreatePaymentJSONRequestBody ¶
type CreatePaymentJSONRequestBody = CreatePaymentRequest
CreatePaymentJSONRequestBody defines body for CreatePayment for application/json ContentType.
type CreatePaymentParams ¶
type CreatePaymentParams struct {
IdempotencyKeyHeader IdempotencyKeyHeader `json:"Idempotency-Key"`
}
CreatePaymentParams defines parameters for CreatePayment.
type CreatePaymentRequest ¶
type CreatePaymentRequest struct {
Amount int64 `json:"amount"`
// HoldTtlSeconds Authorize mode only; defaults to 900
HoldTtlSeconds *int `json:"hold_ttl_seconds,omitempty"`
LineItems *[]LineItem `json:"line_items,omitempty"`
MerchantId openapi_types.UUID `json:"merchant_id"`
Metadata *map[string]string `json:"metadata,omitempty"`
Mode CreatePaymentRequestMode `json:"mode"`
PayerUserId openapi_types.UUID `json:"payer_user_id"`
}
CreatePaymentRequest defines model for CreatePaymentRequest.
type CreatePaymentRequestMode ¶
type CreatePaymentRequestMode string
CreatePaymentRequestMode defines model for CreatePaymentRequest.Mode.
const ( Authorize CreatePaymentRequestMode = "authorize" Instant CreatePaymentRequestMode = "instant" )
Defines values for CreatePaymentRequestMode.
func (CreatePaymentRequestMode) Valid ¶
func (e CreatePaymentRequestMode) Valid() bool
Valid indicates whether the value is a known member of the CreatePaymentRequestMode enum.
type CreateRefundJSONRequestBody ¶
type CreateRefundJSONRequestBody = CreateRefundRequest
CreateRefundJSONRequestBody defines body for CreateRefund for application/json ContentType.
type CreateRefundParams ¶
type CreateRefundParams struct {
IdempotencyKeyHeader IdempotencyKeyHeader `json:"Idempotency-Key"`
}
CreateRefundParams defines parameters for CreateRefund.
type CreateRefundRequest ¶
type CreateRefundRequest struct {
Amount int64 `json:"amount"`
PaymentId openapi_types.UUID `json:"payment_id"`
Reason *string `json:"reason,omitempty"`
}
CreateRefundRequest defines model for CreateRefundRequest.
type CreateRewardRuleJSONRequestBody ¶
type CreateRewardRuleJSONRequestBody = CreateRewardRuleRequest
CreateRewardRuleJSONRequestBody defines body for CreateRewardRule for application/json ContentType.
type CreateRewardRuleRequest ¶
type CreateRewardRuleRequest struct {
Caps *struct {
PerTxn *int64 `json:"per_txn,omitempty"`
PerUserDay *int64 `json:"per_user_day,omitempty"`
} `json:"caps,omitempty"`
EndsAt *time.Time `json:"ends_at,omitempty"`
Kind CreateRewardRuleRequestKind `json:"kind"`
// Params cashback: {rate_bps, fixed}; accrual: {rate_bps}; conversion: {minor_per_point, min_points, max_points}
Params map[string]interface{} `json:"params"`
Scope *struct {
Categories *[]string `json:"categories,omitempty"`
MerchantIds *[]openapi_types.UUID `json:"merchant_ids,omitempty"`
// OfferingId Narrows the rule to a single catalog product.
OfferingId *openapi_types.UUID `json:"offering_id,omitempty"`
} `json:"scope,omitempty"`
StartsAt *time.Time `json:"starts_at,omitempty"`
}
CreateRewardRuleRequest defines model for CreateRewardRuleRequest.
type CreateRewardRuleRequestKind ¶
type CreateRewardRuleRequestKind string
CreateRewardRuleRequestKind defines model for CreateRewardRuleRequest.Kind.
const ( CreateRewardRuleRequestKindAccrual CreateRewardRuleRequestKind = "accrual" CreateRewardRuleRequestKindCashback CreateRewardRuleRequestKind = "cashback" CreateRewardRuleRequestKindConversion CreateRewardRuleRequestKind = "conversion" )
Defines values for CreateRewardRuleRequestKind.
func (CreateRewardRuleRequestKind) Valid ¶
func (e CreateRewardRuleRequestKind) Valid() bool
Valid indicates whether the value is a known member of the CreateRewardRuleRequestKind enum.
type CreateSubscriptionJSONRequestBody ¶
type CreateSubscriptionJSONRequestBody = CreateSubscriptionRequest
CreateSubscriptionJSONRequestBody defines body for CreateSubscription for application/json ContentType.
type CreateSubscriptionParams ¶
type CreateSubscriptionParams struct {
IdempotencyKeyHeader IdempotencyKeyHeader `json:"Idempotency-Key"`
}
CreateSubscriptionParams defines parameters for CreateSubscription.
type CreateSubscriptionRequest ¶
type CreateSubscriptionRequest struct {
Amount int64 `json:"amount"`
Interval SubscriptionInterval `json:"interval"`
MerchantId openapi_types.UUID `json:"merchant_id"`
Metadata *map[string]string `json:"metadata,omitempty"`
PlanName string `json:"plan_name"`
// StartAt First charge time; defaults to now
StartAt *time.Time `json:"start_at,omitempty"`
UserId openapi_types.UUID `json:"user_id"`
}
CreateSubscriptionRequest defines model for CreateSubscriptionRequest.
type CreateSupportAccessGrantJSONRequestBody ¶
type CreateSupportAccessGrantJSONRequestBody = CreateSupportAccessGrantRequest
CreateSupportAccessGrantJSONRequestBody defines body for CreateSupportAccessGrant for application/json ContentType.
type CreateSupportAccessGrantRequest ¶
type CreateSupportAccessGrantRequest struct {
ExpiresAt time.Time `json:"expires_at"`
Reason string `json:"reason"`
StaffId string `json:"staff_id"`
TicketReference string `json:"ticket_reference"`
}
CreateSupportAccessGrantRequest defines model for CreateSupportAccessGrantRequest.
type CreateTenantJSONRequestBody ¶
type CreateTenantJSONRequestBody = CreateTenantRequest
CreateTenantJSONRequestBody defines body for CreateTenant for application/json ContentType.
type CreateTenantRequest ¶
CreateTenantRequest defines model for CreateTenantRequest.
type CreateTopupJSONRequestBody ¶
type CreateTopupJSONRequestBody = CreateTopupRequest
CreateTopupJSONRequestBody defines body for CreateTopup for application/json ContentType.
type CreateTopupParams ¶
type CreateTopupParams struct {
IdempotencyKeyHeader IdempotencyKeyHeader `json:"Idempotency-Key"`
}
CreateTopupParams defines parameters for CreateTopup.
type CreateTopupRequest ¶
type CreateTopupRequest struct {
Amount int64 `json:"amount"`
Gateway string `json:"gateway"`
UserId openapi_types.UUID `json:"user_id"`
}
CreateTopupRequest defines model for CreateTopupRequest.
type CreateTransferJSONRequestBody ¶
type CreateTransferJSONRequestBody = CreateTransferRequest
CreateTransferJSONRequestBody defines body for CreateTransfer for application/json ContentType.
type CreateTransferParams ¶
type CreateTransferParams struct {
IdempotencyKeyHeader IdempotencyKeyHeader `json:"Idempotency-Key"`
}
CreateTransferParams defines parameters for CreateTransfer.
type CreateTransferRequest ¶
type CreateTransferRequest struct {
Amount int64 `json:"amount"`
FromUser openapi_types.UUID `json:"from_user"`
Metadata *map[string]string `json:"metadata,omitempty"`
Note *string `json:"note,omitempty"`
ToAlias *Alias `json:"to_alias,omitempty"`
ToUser *openapi_types.UUID `json:"to_user,omitempty"`
}
CreateTransferRequest defines model for CreateTransferRequest.
type CreateUserJSONRequestBody ¶
type CreateUserJSONRequestBody = CreateUserRequest
CreateUserJSONRequestBody defines body for CreateUser for application/json ContentType.
type CreateUserRequest ¶
type CreateUserRequest struct {
DisplayName *string `json:"display_name,omitempty"`
Email *openapi_types.Email `json:"email,omitempty"`
ExternalId string `json:"external_id"`
Handle *string `json:"handle,omitempty"`
Kind *UserKind `json:"kind,omitempty"`
Phone *string `json:"phone,omitempty"`
}
CreateUserRequest defines model for CreateUserRequest.
type CreateWebhookEndpointJSONRequestBody ¶
type CreateWebhookEndpointJSONRequestBody = CreateWebhookEndpointRequest
CreateWebhookEndpointJSONRequestBody defines body for CreateWebhookEndpoint for application/json ContentType.
type CreateWebhookEndpointRequest ¶
type CreateWebhookEndpointRequest struct {
// EventFilters Event types to deliver; empty means all
EventFilters *[]string `json:"event_filters,omitempty"`
Url string `json:"url"`
}
CreateWebhookEndpointRequest defines model for CreateWebhookEndpointRequest.
type Credential ¶
Credential authorizes every request. Implementations must be safe for concurrent use; Token is called once per attempt, so a rotating credential refreshes without the client being rebuilt.
func APIKey ¶
func APIKey(key string) Credential
APIKey is a tenant API key (`sk_{env}_{id}_{secret}`). It carries the tenant's own scopes and acts for the whole loop: never ship one to an end-user device.
func CredentialFunc ¶
func CredentialFunc(f func(ctx context.Context) (string, error)) Credential
CredentialFunc adapts any token source — an OAuth2 client-credentials cache, a secret manager lookup — to Credential.
func UserToken ¶
func UserToken(token string) Credential
UserToken is a wallet user's own access token. It resolves to that user and can only reach that user's money.
type CreditLine ¶
type CreditLine struct {
AccountId openapi_types.UUID `json:"account_id"`
CreditLimit int64 `json:"credit_limit"`
Previous int64 `json:"previous"`
UserId openapi_types.UUID `json:"user_id"`
}
CreditLine defines model for CreditLine.
type EntryDirection ¶
type EntryDirection string
EntryDirection defines model for EntryDirection.
const ( EntryDirectionCredit EntryDirection = "credit" EntryDirectionDebit EntryDirection = "debit" )
Defines values for EntryDirection.
func (EntryDirection) Valid ¶
func (e EntryDirection) Valid() bool
Valid indicates whether the value is a known member of the EntryDirection enum.
type Event ¶
type Event struct {
ID uuid.UUID `json:"id"`
Type string `json:"type"`
TenantID uuid.UUID `json:"tenant_id"`
ClientID *uuid.UUID `json:"client_id,omitempty"`
CreatedAt time.Time `json:"created_at"`
Data map[string]json.RawMessage `json:"data"`
}
Event is one webhook delivery's envelope. Data holds the object the event is about, keyed by its kind ("topup", "payment", "order"); use Event.Into to decode it.
Treat an event as an observation of something that already happened, not as an instruction, and ignore a Type you do not recognise: new ones are added without warning.
func ParseEvent ¶
ParseEvent decodes a verified delivery body.
Verify the signature FIRST. An unverified body is attacker-controlled input, and this function will happily decode a forgery.
type ExploreClientDetail ¶
type ExploreClientDetail struct {
Client CatalogClient `json:"client"`
Offerings []Offering `json:"offerings"`
}
ExploreClientDetail defines model for ExploreClientDetail.
type ExploreClientsParams ¶
type ExploreClientsParams struct {
Q *string `form:"q,omitempty" json:"q,omitempty"`
Category *string `form:"category,omitempty" json:"category,omitempty"`
// Cursor Last seen id from the previous page
Cursor *Cursor `form:"cursor,omitempty" json:"cursor,omitempty"`
Limit *Limit `form:"limit,omitempty" json:"limit,omitempty"`
}
ExploreClientsParams defines parameters for ExploreClients.
type ExploreOfferingDetail ¶
type ExploreOfferingDetail struct {
Client CatalogClient `json:"client"`
Offering Offering `json:"offering"`
}
ExploreOfferingDetail defines model for ExploreOfferingDetail.
type FeePlan ¶
type FeePlan struct {
// CommissionMode Whether marketplace commission comes out of the merchant's settlement (the consumer pays the list price) or is added to what the consumer pays (the merchant nets the full list price).
CommissionMode CommissionMode `json:"commission_mode"`
// Fees A tenant's price list, one rule per money path. An absent path charges nothing, so a tenant provisioned before a path existed stays free on it. Payments and subscriptions deduct their fee from the merchant's settlement; P2P adds it on top of what the sender pays; top-up deducts it from what is credited; payout deducts it from what leaves.
Fees FeeSchedule `json:"fees"`
}
FeePlan defines model for FeePlan.
type FeeRule ¶
type FeeRule struct {
Bps int `json:"bps"`
Flat int64 `json:"flat"`
// MaxFee Absent means uncapped. A cap of zero makes the path free.
MaxFee *int64 `json:"max_fee,omitempty"`
MinFee int64 `json:"min_fee"`
}
FeeRule What one money path costs. The proportional part is basis points of the amount and rounds up; the flat part is minor units charged regardless of size; the result is then clamped into the [min_fee, max_fee] band. A fee taken out of the money never exceeds the amount it comes from.
type FeeSchedule ¶
type FeeSchedule struct {
// Commission What one money path costs. The proportional part is basis points of the amount and rounds up; the flat part is minor units charged regardless of size; the result is then clamped into the [min_fee, max_fee] band. A fee taken out of the money never exceeds the amount it comes from.
Commission *FeeRule `json:"commission,omitempty"`
// P2p What one money path costs. The proportional part is basis points of the amount and rounds up; the flat part is minor units charged regardless of size; the result is then clamped into the [min_fee, max_fee] band. A fee taken out of the money never exceeds the amount it comes from.
P2p *FeeRule `json:"p2p,omitempty"`
// Payment What one money path costs. The proportional part is basis points of the amount and rounds up; the flat part is minor units charged regardless of size; the result is then clamped into the [min_fee, max_fee] band. A fee taken out of the money never exceeds the amount it comes from.
Payment *FeeRule `json:"payment,omitempty"`
// Payout What one money path costs. The proportional part is basis points of the amount and rounds up; the flat part is minor units charged regardless of size; the result is then clamped into the [min_fee, max_fee] band. A fee taken out of the money never exceeds the amount it comes from.
Payout *FeeRule `json:"payout,omitempty"`
// Subscription What one money path costs. The proportional part is basis points of the amount and rounds up; the flat part is minor units charged regardless of size; the result is then clamped into the [min_fee, max_fee] band. A fee taken out of the money never exceeds the amount it comes from.
Subscription *FeeRule `json:"subscription,omitempty"`
// Topup What one money path costs. The proportional part is basis points of the amount and rounds up; the flat part is minor units charged regardless of size; the result is then clamped into the [min_fee, max_fee] band. A fee taken out of the money never exceeds the amount it comes from.
Topup *FeeRule `json:"topup,omitempty"`
}
FeeSchedule A tenant's price list, one rule per money path. An absent path charges nothing, so a tenant provisioned before a path existed stays free on it. Payments and subscriptions deduct their fee from the merchant's settlement; P2P adds it on top of what the sender pays; top-up deducts it from what is credited; payout deducts it from what leaves.
type FlowRow ¶
type FlowRow struct {
Amount int64 `json:"amount"`
Commodity string `json:"commodity"`
Count int64 `json:"count"`
PreviousAmount int64 `json:"previous_amount"`
PreviousCount int64 `json:"previous_count"`
Type string `json:"type"`
}
FlowRow Gross value moved by one transaction type in one commodity. Amount is the sum of the credit legs, which for a balanced posting equals the value the transaction moved (a $10 payment splitting into $9.90 settlement and $0.10 fee counts once, as $10).
type FundClientMarketingJSONRequestBody ¶
type FundClientMarketingJSONRequestBody = FundMarketingRequest
FundClientMarketingJSONRequestBody defines body for FundClientMarketing for application/json ContentType.
type FundClientMarketingParams ¶
type FundClientMarketingParams struct {
IdempotencyKeyHeader IdempotencyKeyHeader `json:"Idempotency-Key"`
}
FundClientMarketingParams defines parameters for FundClientMarketing.
type FundMarketingRequest ¶
type FundMarketingRequest struct {
Amount int64 `json:"amount"`
}
FundMarketingRequest defines model for FundMarketingRequest.
type FundMarketingResult ¶
type FundMarketingResult struct {
Amount int64 `json:"amount"`
TxnId openapi_types.UUID `json:"txn_id"`
}
FundMarketingResult defines model for FundMarketingResult.
type GetLedgerMetricsParams ¶
type GetLedgerMetricsParams struct {
// Window Reporting period ending now. The previous period of the same length is returned alongside for comparison.
Window *GetLedgerMetricsParamsWindow `form:"window,omitempty" json:"window,omitempty"`
}
GetLedgerMetricsParams defines parameters for GetLedgerMetrics.
type GetLedgerMetricsParamsWindow ¶
type GetLedgerMetricsParamsWindow string
GetLedgerMetricsParamsWindow defines parameters for GetLedgerMetrics.
const ( N24h GetLedgerMetricsParamsWindow = "24h" N30d GetLedgerMetricsParamsWindow = "30d" N7d GetLedgerMetricsParamsWindow = "7d" N90d GetLedgerMetricsParamsWindow = "90d" )
Defines values for GetLedgerMetricsParamsWindow.
func (GetLedgerMetricsParamsWindow) Valid ¶
func (e GetLedgerMetricsParamsWindow) Valid() bool
Valid indicates whether the value is a known member of the GetLedgerMetricsParamsWindow enum.
type GetMerchantStatementParams ¶
type GetMerchantStatementParams struct {
Since *time.Time `form:"since,omitempty" json:"since,omitempty"`
Limit *int `form:"limit,omitempty" json:"limit,omitempty"`
}
GetMerchantStatementParams defines parameters for GetMerchantStatement.
type Health ¶
type Health struct {
Status HealthStatus `json:"status"`
}
Health defines model for Health.
type HealthStatus ¶
type HealthStatus string
HealthStatus defines model for Health.Status.
const (
Ok HealthStatus = "ok"
)
Defines values for HealthStatus.
func (HealthStatus) Valid ¶
func (e HealthStatus) Valid() bool
Valid indicates whether the value is a known member of the HealthStatus enum.
type IdempotencyKey ¶
type IdempotencyKey string
IdempotencyKey makes one money-moving call safe to repeat. The server stores the first answer under the key and replays it byte for byte for every later call with the same key, so a timeout, a crash between the request and the response, or an SDK retry costs at most one movement.
Every method on Client that moves money takes one as an explicit parameter. That is deliberate: the only way to send a payment without a key is to not compile.
The key belongs to the caller's logical operation, not to an HTTP attempt. Derive it from something the caller already has and will still have after a restart — an order number, an invoice line, a job id:
key := walletd.IdempotencyKey("order-8891-capture")
NewIdempotencyKey is the fallback when there is no such identifier, and only then: a random key minted inside a retry loop, or regenerated after a crash, defeats the whole mechanism — the second attempt looks like a new payment and the customer is charged twice. Mint it once, persist it with the work, reuse it on every attempt.
The contract accepts 1 to 200 characters. Reusing a key with different parameters is an idempotency_key_reuse conflict, not a replay.
func NewIdempotencyKey ¶
func NewIdempotencyKey() IdempotencyKey
NewIdempotencyKey mints a random key. Use it only where no natural identifier exists, and store it before the first attempt.
func (IdempotencyKey) String ¶
func (k IdempotencyKey) String() string
type IdempotencyKeyHeader ¶
type IdempotencyKeyHeader = string
IdempotencyKeyHeader defines model for IdempotencyKey.
type InventoryMovement ¶
type InventoryMovement struct {
ActorId *string `json:"actor_id,omitempty"`
ActorType *string `json:"actor_type,omitempty"`
CreatedAt time.Time `json:"created_at"`
Id openapi_types.UUID `json:"id"`
Kind InventoryMovementKind `json:"kind"`
OnHandAfter int64 `json:"on_hand_after"`
OrderId *openapi_types.UUID `json:"order_id,omitempty"`
// Quantity Signed change to the counter the kind names.
Quantity int64 `json:"quantity"`
Reason *string `json:"reason,omitempty"`
ReservedAfter int64 `json:"reserved_after"`
VariantId openapi_types.UUID `json:"variant_id"`
}
InventoryMovement defines model for InventoryMovement.
type InventoryMovementKind ¶
type InventoryMovementKind string
InventoryMovementKind defines model for InventoryMovement.Kind.
const ( InventoryMovementKindAdjustment InventoryMovementKind = "adjustment" InventoryMovementKindImport InventoryMovementKind = "import" InventoryMovementKindRelease InventoryMovementKind = "release" InventoryMovementKindReservation InventoryMovementKind = "reservation" InventoryMovementKindRestock InventoryMovementKind = "restock" InventoryMovementKindSale InventoryMovementKind = "sale" )
Defines values for InventoryMovementKind.
func (InventoryMovementKind) Valid ¶
func (e InventoryMovementKind) Valid() bool
Valid indicates whether the value is a known member of the InventoryMovementKind enum.
type IssueMerchantApiKeyJSONRequestBody ¶
type IssueMerchantApiKeyJSONRequestBody = IssueMerchantApiKeyRequest
IssueMerchantApiKeyJSONRequestBody defines body for IssueMerchantApiKey for application/json ContentType.
type IssueMerchantApiKeyRequest ¶
type IssueMerchantApiKeyRequest struct {
Env *IssueMerchantApiKeyRequestEnv `json:"env,omitempty"`
// Name What system will hold it (e.g. "Shopify sync", "POS till 2").
Name string `json:"name"`
}
IssueMerchantApiKeyRequest defines model for IssueMerchantApiKeyRequest.
type IssueMerchantApiKeyRequestEnv ¶
type IssueMerchantApiKeyRequestEnv string
IssueMerchantApiKeyRequestEnv defines model for IssueMerchantApiKeyRequest.Env.
const ( IssueMerchantApiKeyRequestEnvLive IssueMerchantApiKeyRequestEnv = "live" IssueMerchantApiKeyRequestEnvSandbox IssueMerchantApiKeyRequestEnv = "sandbox" )
Defines values for IssueMerchantApiKeyRequestEnv.
func (IssueMerchantApiKeyRequestEnv) Valid ¶
func (e IssueMerchantApiKeyRequestEnv) Valid() bool
Valid indicates whether the value is a known member of the IssueMerchantApiKeyRequestEnv enum.
type IssuedMerchantApiKey ¶
type IssuedMerchantApiKey struct {
// Key An API key bound to one merchant. It acts as that merchant on every /v1/clients/{clientId} route and carries no tenant-wide scope. The token itself is returned once, at issuance.
Key MerchantApiKey `json:"key"`
// Token Shown once. Store it in your system's secret store now.
Token string `json:"token"`
}
IssuedMerchantApiKey defines model for IssuedMerchantApiKey.
type Iterator ¶
type Iterator[T any] struct { // contains filtered or unexported fields }
Iterator walks a cursor-paged listing one item at a time, fetching the next page only when the current one runs out.
It exists because the obvious loop is wrong. These listings answer with a bare array and no next-page marker, so the end of the list has to be inferred — and "fewer rows than I asked for means the end" is false for at least one of them: a user's transaction history pages by TRANSACTION, and one transaction can carry several rows for the same user (a conversion debits cash and credits points). A full page there can be more rows than the limit, and a short page can still have a successor. The iterator therefore counts DISTINCT cursor keys, which is the unit the server itself pages by, and it refuses to stop on anything but a page that did not fill.
it := client.UserTransactions(userID)
for it.Next(ctx) {
txn := it.Item()
}
if err := it.Err(); err != nil { ... }
An Iterator is not safe for concurrent use.
func (*Iterator[T]) All ¶
All is the range-over-func form. The loop stops at the first error, which is yielded with the zero item; Err holds it afterwards too.
for txn, err := range client.UserTransactions(userID).All(ctx) {
if err != nil { return err }
}
func (*Iterator[T]) Collect ¶
Collect walks the whole listing into a slice. Use it when the result set is known to be small; otherwise range it.
func (*Iterator[T]) Item ¶
func (it *Iterator[T]) Item() T
Item is the current item. It is only defined after Next returned true.
type LedgerMetrics ¶
type LedgerMetrics struct {
AsOf time.Time `json:"as_of"`
// Bucket Granularity of the series points.
Bucket LedgerMetricsBucket `json:"bucket"`
Currency string `json:"currency"`
Flows []FlowRow `json:"flows"`
From time.Time `json:"from"`
// Operations The queues and failure counts a wallet operator has to act on.
Operations OperationsSummary `json:"operations"`
// Position Snapshot of what the loop holds and owes right now, in the tenant's currency, plus the point liability counted separately.
Position PositionSummary `json:"position"`
Reconciliation []ReconciliationRow `json:"reconciliation"`
// Revenue What the loop earned and spent in the window, in the tenant's currency.
Revenue RevenueSummary `json:"revenue"`
Series []SeriesPoint `json:"series"`
To time.Time `json:"to"`
TopMerchants []MerchantVolume `json:"top_merchants"`
Window string `json:"window"`
}
LedgerMetrics defines model for LedgerMetrics.
type LedgerMetricsBucket ¶
type LedgerMetricsBucket string
LedgerMetricsBucket Granularity of the series points.
const ( Day LedgerMetricsBucket = "day" Hour LedgerMetricsBucket = "hour" )
Defines values for LedgerMetricsBucket.
func (LedgerMetricsBucket) Valid ¶
func (e LedgerMetricsBucket) Valid() bool
Valid indicates whether the value is a known member of the LedgerMetricsBucket enum.
type LedgerSummary ¶
type LedgerSummary struct {
Currency string `json:"currency"`
FeePlan FeePlan `json:"fee_plan"`
Rows []SummaryRow `json:"rows"`
}
LedgerSummary defines model for LedgerSummary.
type ListAuditLogParams ¶
type ListAuditLogParams struct {
Action *string `form:"action,omitempty" json:"action,omitempty"`
Cursor *int64 `form:"cursor,omitempty" json:"cursor,omitempty"`
Limit *Limit `form:"limit,omitempty" json:"limit,omitempty"`
}
ListAuditLogParams defines parameters for ListAuditLog.
type ListCatalogImportRowsParams ¶
type ListCatalogImportRowsParams struct {
Action *ListCatalogImportRowsParamsAction `form:"action,omitempty" json:"action,omitempty"`
// After Last seen row_no from the previous page
After *int `form:"after,omitempty" json:"after,omitempty"`
Limit *int `form:"limit,omitempty" json:"limit,omitempty"`
}
ListCatalogImportRowsParams defines parameters for ListCatalogImportRows.
type ListCatalogImportRowsParamsAction ¶
type ListCatalogImportRowsParamsAction string
ListCatalogImportRowsParamsAction defines parameters for ListCatalogImportRows.
const ( ListCatalogImportRowsParamsActionCreate ListCatalogImportRowsParamsAction = "create" ListCatalogImportRowsParamsActionError ListCatalogImportRowsParamsAction = "error" ListCatalogImportRowsParamsActionUpdate ListCatalogImportRowsParamsAction = "update" )
Defines values for ListCatalogImportRowsParamsAction.
func (ListCatalogImportRowsParamsAction) Valid ¶
func (e ListCatalogImportRowsParamsAction) Valid() bool
Valid indicates whether the value is a known member of the ListCatalogImportRowsParamsAction enum.
type ListCatalogImportsParams ¶
type ListCatalogImportsParams struct {
// Cursor Last seen id from the previous page
Cursor *Cursor `form:"cursor,omitempty" json:"cursor,omitempty"`
Limit *Limit `form:"limit,omitempty" json:"limit,omitempty"`
}
ListCatalogImportsParams defines parameters for ListCatalogImports.
type ListClientOfferingsParams ¶
type ListClientOfferingsParams struct {
Status *ListClientOfferingsParamsStatus `form:"status,omitempty" json:"status,omitempty"`
CategoryId *openapi_types.UUID `form:"category_id,omitempty" json:"category_id,omitempty"`
// Q Matches title, SKU or barcode
Q *string `form:"q,omitempty" json:"q,omitempty"`
// LowStock Only items with a variant at or under its low-stock threshold
LowStock *bool `form:"low_stock,omitempty" json:"low_stock,omitempty"`
// Cursor Last seen id from the previous page
Cursor *Cursor `form:"cursor,omitempty" json:"cursor,omitempty"`
Limit *Limit `form:"limit,omitempty" json:"limit,omitempty"`
}
ListClientOfferingsParams defines parameters for ListClientOfferings.
type ListClientOfferingsParamsStatus ¶
type ListClientOfferingsParamsStatus string
ListClientOfferingsParamsStatus defines parameters for ListClientOfferings.
const ( ListClientOfferingsParamsStatusArchived ListClientOfferingsParamsStatus = "archived" ListClientOfferingsParamsStatusDraft ListClientOfferingsParamsStatus = "draft" ListClientOfferingsParamsStatusPublished ListClientOfferingsParamsStatus = "published" )
Defines values for ListClientOfferingsParamsStatus.
func (ListClientOfferingsParamsStatus) Valid ¶
func (e ListClientOfferingsParamsStatus) Valid() bool
Valid indicates whether the value is a known member of the ListClientOfferingsParamsStatus enum.
type ListClientOrdersParams ¶
type ListClientOrdersParams struct {
Status *ListClientOrdersParamsStatus `form:"status,omitempty" json:"status,omitempty"`
// Cursor Last seen id from the previous page
Cursor *Cursor `form:"cursor,omitempty" json:"cursor,omitempty"`
Limit *Limit `form:"limit,omitempty" json:"limit,omitempty"`
}
ListClientOrdersParams defines parameters for ListClientOrders.
type ListClientOrdersParamsStatus ¶
type ListClientOrdersParamsStatus string
ListClientOrdersParamsStatus defines parameters for ListClientOrders.
const ( ListClientOrdersParamsStatusCanceled ListClientOrdersParamsStatus = "canceled" ListClientOrdersParamsStatusExpired ListClientOrdersParamsStatus = "expired" ListClientOrdersParamsStatusOpen ListClientOrdersParamsStatus = "open" ListClientOrdersParamsStatusPaid ListClientOrdersParamsStatus = "paid" ListClientOrdersParamsStatusPaying ListClientOrdersParamsStatus = "paying" )
Defines values for ListClientOrdersParamsStatus.
func (ListClientOrdersParamsStatus) Valid ¶
func (e ListClientOrdersParamsStatus) Valid() bool
Valid indicates whether the value is a known member of the ListClientOrdersParamsStatus enum.
type ListClientPayoutsParams ¶
type ListClientPayoutsParams struct {
Limit *Limit `form:"limit,omitempty" json:"limit,omitempty"`
}
ListClientPayoutsParams defines parameters for ListClientPayouts.
type ListClientSalesParams ¶
type ListClientSalesParams struct {
// Cursor Last seen id from the previous page
Cursor *Cursor `form:"cursor,omitempty" json:"cursor,omitempty"`
Limit *Limit `form:"limit,omitempty" json:"limit,omitempty"`
}
ListClientSalesParams defines parameters for ListClientSales.
type ListClientsParams ¶
type ListClientsParams struct {
Status *CatalogClientStatus `form:"status,omitempty" json:"status,omitempty"`
Limit *Limit `form:"limit,omitempty" json:"limit,omitempty"`
}
ListClientsParams defines parameters for ListClients.
type ListInventoryMovementsParams ¶
type ListInventoryMovementsParams struct {
VariantId *openapi_types.UUID `form:"variant_id,omitempty" json:"variant_id,omitempty"`
// Cursor Last seen id from the previous page
Cursor *Cursor `form:"cursor,omitempty" json:"cursor,omitempty"`
Limit *Limit `form:"limit,omitempty" json:"limit,omitempty"`
}
ListInventoryMovementsParams defines parameters for ListInventoryMovements.
type ListMerchantWebhookDeliveriesParams ¶
type ListMerchantWebhookDeliveriesParams struct {
EndpointId *openapi_types.UUID `form:"endpoint_id,omitempty" json:"endpoint_id,omitempty"`
// Cursor Last seen id from the previous page
Cursor *Cursor `form:"cursor,omitempty" json:"cursor,omitempty"`
Limit *Limit `form:"limit,omitempty" json:"limit,omitempty"`
}
ListMerchantWebhookDeliveriesParams defines parameters for ListMerchantWebhookDeliveries.
type ListOrdersParams ¶
type ListOrdersParams struct {
// Cursor Last seen id from the previous page
Cursor *Cursor `form:"cursor,omitempty" json:"cursor,omitempty"`
Limit *Limit `form:"limit,omitempty" json:"limit,omitempty"`
}
ListOrdersParams defines parameters for ListOrders.
type ListPlatformClientsParams ¶
type ListPlatformClientsParams struct {
// TenantId Restrict a cross-tenant listing to one tenant
TenantId *TenantFilter `form:"tenant_id,omitempty" json:"tenant_id,omitempty"`
Status *CatalogClientStatus `form:"status,omitempty" json:"status,omitempty"`
// Cursor Last seen id from the previous page
Cursor *Cursor `form:"cursor,omitempty" json:"cursor,omitempty"`
Limit *Limit `form:"limit,omitempty" json:"limit,omitempty"`
}
ListPlatformClientsParams defines parameters for ListPlatformClients.
type ListPlatformSubscriptionsParams ¶
type ListPlatformSubscriptionsParams struct {
// TenantId Restrict a cross-tenant listing to one tenant
TenantId *TenantFilter `form:"tenant_id,omitempty" json:"tenant_id,omitempty"`
Status *SubscriptionStatus `form:"status,omitempty" json:"status,omitempty"`
// Cursor Last seen id from the previous page
Cursor *Cursor `form:"cursor,omitempty" json:"cursor,omitempty"`
Limit *Limit `form:"limit,omitempty" json:"limit,omitempty"`
}
ListPlatformSubscriptionsParams defines parameters for ListPlatformSubscriptions.
type ListPlatformTransactionsParams ¶
type ListPlatformTransactionsParams struct {
// TenantId Restrict a cross-tenant listing to one tenant
TenantId *TenantFilter `form:"tenant_id,omitempty" json:"tenant_id,omitempty"`
Type *string `form:"type,omitempty" json:"type,omitempty"`
// Cursor Last seen id from the previous page
Cursor *Cursor `form:"cursor,omitempty" json:"cursor,omitempty"`
Limit *Limit `form:"limit,omitempty" json:"limit,omitempty"`
}
ListPlatformTransactionsParams defines parameters for ListPlatformTransactions.
type ListPlatformUsersParams ¶
type ListPlatformUsersParams struct {
// TenantId Restrict a cross-tenant listing to one tenant
TenantId *TenantFilter `form:"tenant_id,omitempty" json:"tenant_id,omitempty"`
Query *string `form:"query,omitempty" json:"query,omitempty"`
// Cursor Last seen id from the previous page
Cursor *Cursor `form:"cursor,omitempty" json:"cursor,omitempty"`
Limit *Limit `form:"limit,omitempty" json:"limit,omitempty"`
}
ListPlatformUsersParams defines parameters for ListPlatformUsers.
type ListPriceHistoryParams ¶
type ListPriceHistoryParams struct {
OfferingId *openapi_types.UUID `form:"offering_id,omitempty" json:"offering_id,omitempty"`
// Cursor Last seen id from the previous page
Cursor *Cursor `form:"cursor,omitempty" json:"cursor,omitempty"`
Limit *Limit `form:"limit,omitempty" json:"limit,omitempty"`
}
ListPriceHistoryParams defines parameters for ListPriceHistory.
type ListSubscriptionsParams ¶
type ListSubscriptionsParams struct {
UserId *openapi_types.UUID `form:"user_id,omitempty" json:"user_id,omitempty"`
Status *SubscriptionStatus `form:"status,omitempty" json:"status,omitempty"`
// Cursor Last seen id from the previous page
Cursor *Cursor `form:"cursor,omitempty" json:"cursor,omitempty"`
Limit *Limit `form:"limit,omitempty" json:"limit,omitempty"`
}
ListSubscriptionsParams defines parameters for ListSubscriptions.
type ListSupportAccessGrantsParams ¶
type ListSupportAccessGrantsParams struct {
Limit *Limit `form:"limit,omitempty" json:"limit,omitempty"`
}
ListSupportAccessGrantsParams defines parameters for ListSupportAccessGrants.
type ListTransactionsParams ¶
type ListTransactionsParams struct {
Type *string `form:"type,omitempty" json:"type,omitempty"`
// Cursor Last seen id from the previous page
Cursor *Cursor `form:"cursor,omitempty" json:"cursor,omitempty"`
Limit *Limit `form:"limit,omitempty" json:"limit,omitempty"`
}
ListTransactionsParams defines parameters for ListTransactions.
type ListUserRewardsParams ¶
type ListUserRewardsParams struct {
Limit *int `form:"limit,omitempty" json:"limit,omitempty"`
}
ListUserRewardsParams defines parameters for ListUserRewards.
type ListUserTransactionsParams ¶
type ListUserTransactionsParams struct {
// Cursor Last seen id from the previous page
Cursor *Cursor `form:"cursor,omitempty" json:"cursor,omitempty"`
Limit *Limit `form:"limit,omitempty" json:"limit,omitempty"`
}
ListUserTransactionsParams defines parameters for ListUserTransactions.
type ListUsersParams ¶
type ListUsersParams struct {
Query *string `form:"query,omitempty" json:"query,omitempty"`
// Cursor Last seen id from the previous page
Cursor *Cursor `form:"cursor,omitempty" json:"cursor,omitempty"`
Limit *Limit `form:"limit,omitempty" json:"limit,omitempty"`
}
ListUsersParams defines parameters for ListUsers.
type ListWebhookDeliveriesParams ¶
type ListWebhookDeliveriesParams struct {
EndpointId *openapi_types.UUID `form:"endpoint_id,omitempty" json:"endpoint_id,omitempty"`
// Cursor Last seen id from the previous page
Cursor *Cursor `form:"cursor,omitempty" json:"cursor,omitempty"`
Limit *Limit `form:"limit,omitempty" json:"limit,omitempty"`
}
ListWebhookDeliveriesParams defines parameters for ListWebhookDeliveries.
type ListWebhookEventsParams ¶
type ListWebhookEventsParams struct {
Type *string `form:"type,omitempty" json:"type,omitempty"`
Since *time.Time `form:"since,omitempty" json:"since,omitempty"`
Limit *int `form:"limit,omitempty" json:"limit,omitempty"`
}
ListWebhookEventsParams defines parameters for ListWebhookEvents.
type MarketingView ¶
type MarketingView struct {
MarketingBalance int64 `json:"marketing_balance"`
SettlementBalance int64 `json:"settlement_balance"`
}
MarketingView defines model for MarketingView.
type Markup ¶
type Markup struct {
Kind MarkupKind `json:"kind"`
Value int64 `json:"value"`
}
Markup What a merchant adds to a cost to reach a sell price. percent is basis points of the cost; fixed is minor units on top. Resolves most specific wins: variant, then product, then shop.
type MarkupKind ¶
type MarkupKind string
MarkupKind defines model for Markup.Kind.
const ( Fixed MarkupKind = "fixed" Percent MarkupKind = "percent" )
Defines values for MarkupKind.
func (MarkupKind) Valid ¶
func (e MarkupKind) Valid() bool
Valid indicates whether the value is a known member of the MarkupKind enum.
type Merchant ¶
type Merchant struct {
Category *string `json:"category,omitempty"`
CreatedAt time.Time `json:"created_at"`
ExternalId string `json:"external_id"`
Id openapi_types.UUID `json:"id"`
Name string `json:"name"`
Status string `json:"status"`
}
Merchant defines model for Merchant.
type MerchantApiKey ¶
type MerchantApiKey struct {
CreatedAt time.Time `json:"created_at"`
Env MerchantApiKeyEnv `json:"env"`
ExpiresAt *time.Time `json:"expires_at,omitempty"`
Id openapi_types.UUID `json:"id"`
LastUsedAt *time.Time `json:"last_used_at,omitempty"`
Name string `json:"name"`
Scopes []string `json:"scopes"`
Status MerchantApiKeyStatus `json:"status"`
}
MerchantApiKey An API key bound to one merchant. It acts as that merchant on every /v1/clients/{clientId} route and carries no tenant-wide scope. The token itself is returned once, at issuance.
type MerchantApiKeyEnv ¶
type MerchantApiKeyEnv string
MerchantApiKeyEnv defines model for MerchantApiKey.Env.
const ( MerchantApiKeyEnvLive MerchantApiKeyEnv = "live" MerchantApiKeyEnvSandbox MerchantApiKeyEnv = "sandbox" )
Defines values for MerchantApiKeyEnv.
func (MerchantApiKeyEnv) Valid ¶
func (e MerchantApiKeyEnv) Valid() bool
Valid indicates whether the value is a known member of the MerchantApiKeyEnv enum.
type MerchantApiKeyStatus ¶
type MerchantApiKeyStatus string
MerchantApiKeyStatus defines model for MerchantApiKey.Status.
const ( MerchantApiKeyStatusActive MerchantApiKeyStatus = "active" MerchantApiKeyStatusRevoked MerchantApiKeyStatus = "revoked" )
Defines values for MerchantApiKeyStatus.
func (MerchantApiKeyStatus) Valid ¶
func (e MerchantApiKeyStatus) Valid() bool
Valid indicates whether the value is a known member of the MerchantApiKeyStatus enum.
type MerchantVolume ¶
type MerchantVolume struct {
Amount int64 `json:"amount"`
Count int64 `json:"count"`
MerchantId openapi_types.UUID `json:"merchant_id"`
Name string `json:"name"`
}
MerchantVolume defines model for MerchantVolume.
type Offering ¶
type Offering struct {
// Amount The plan price, or for an item the lowest live variant price.
Amount int64 `json:"amount"`
CategoryId *openapi_types.UUID `json:"category_id,omitempty"`
ClientId openapi_types.UUID `json:"client_id"`
// CommissionBps Overrides both the client's rate and the loop's for this one offering, which is how a promotion is priced.
CommissionBps *int `json:"commission_bps,omitempty"`
CreatedAt time.Time `json:"created_at"`
Description *string `json:"description,omitempty"`
Id openapi_types.UUID `json:"id"`
ImageUrl *string `json:"image_url,omitempty"`
Interval *OfferingInterval `json:"interval,omitempty"`
Kind OfferingKind `json:"kind"`
// Markup What a merchant adds to a cost to reach a sell price. percent is basis points of the cost; fixed is minor units on top. Resolves most specific wins: variant, then product, then shop.
Markup *Markup `json:"markup,omitempty"`
// Metadata Whatever the vertical needs and the platform does not model.
Metadata *map[string]string `json:"metadata,omitempty"`
// Options The product's variant axes (Size, Colour), in the order every variant lists its values. Empty for a single-variant item.
Options []string `json:"options"`
Status OfferingStatus `json:"status"`
Title string `json:"title"`
UpdatedAt time.Time `json:"updated_at"`
// Variants Live variants of an item; empty for plans.
Variants []Variant `json:"variants"`
}
Offering defines model for Offering.
type OfferingFilter ¶
OfferingFilter narrows a catalog listing. The zero value is everything.
type OfferingInterval ¶
type OfferingInterval string
OfferingInterval defines model for Offering.Interval.
const ( OfferingIntervalMonthly OfferingInterval = "monthly" OfferingIntervalWeekly OfferingInterval = "weekly" )
Defines values for OfferingInterval.
func (OfferingInterval) Valid ¶
func (e OfferingInterval) Valid() bool
Valid indicates whether the value is a known member of the OfferingInterval enum.
type OfferingKind ¶
type OfferingKind string
OfferingKind defines model for Offering.Kind.
const ( OfferingKindItem OfferingKind = "item" OfferingKindPlan OfferingKind = "plan" )
Defines values for OfferingKind.
func (OfferingKind) Valid ¶
func (e OfferingKind) Valid() bool
Valid indicates whether the value is a known member of the OfferingKind enum.
type OfferingPage ¶
type OfferingPage struct {
// NextCursor Pass back as cursor for the next page; absent on the last page.
NextCursor *openapi_types.UUID `json:"next_cursor,omitempty"`
Offerings []Offering `json:"offerings"`
}
OfferingPage defines model for OfferingPage.
type OfferingStatus ¶
type OfferingStatus string
OfferingStatus defines model for Offering.Status.
const ( OfferingStatusArchived OfferingStatus = "archived" OfferingStatusDraft OfferingStatus = "draft" OfferingStatusPublished OfferingStatus = "published" )
Defines values for OfferingStatus.
func (OfferingStatus) Valid ¶
func (e OfferingStatus) Valid() bool
Valid indicates whether the value is a known member of the OfferingStatus enum.
type OnboardClientJSONRequestBody ¶
type OnboardClientJSONRequestBody = OnboardClientRequest
OnboardClientJSONRequestBody defines body for OnboardClient for application/json ContentType.
type OnboardClientRequest ¶
type OnboardClientRequest struct {
Category *string `json:"category,omitempty"`
Description *string `json:"description,omitempty"`
DisplayName string `json:"display_name"`
LogoUrl *string `json:"logo_url,omitempty"`
}
OnboardClientRequest defines model for OnboardClientRequest.
type OperationsSummary ¶
type OperationsSummary struct {
AwaitingCapture int64 `json:"awaiting_capture"`
AwaitingCaptureAmount int64 `json:"awaiting_capture_amount"`
HoldsExpiring24h int64 `json:"holds_expiring_24h"`
Payouts int64 `json:"payouts"`
PayoutsAmount int64 `json:"payouts_amount"`
Refunds int64 `json:"refunds"`
RefundsAmount int64 `json:"refunds_amount"`
SubscriptionsActive int64 `json:"subscriptions_active"`
SubscriptionsDue30dAmount int64 `json:"subscriptions_due_30d_amount"`
// SubscriptionsMrr Recurring revenue committed by live plans, normalised to one month.
SubscriptionsMrr int64 `json:"subscriptions_mrr"`
SubscriptionsPastDue int64 `json:"subscriptions_past_due"`
SubscriptionsPastDueAmount int64 `json:"subscriptions_past_due_amount"`
// TopupSuccessBps Succeeded over settled top-up intents, in basis points. Zero when none settled.
TopupSuccessBps int `json:"topup_success_bps"`
TopupsFailed int64 `json:"topups_failed"`
TopupsPending int64 `json:"topups_pending"`
TopupsSucceeded int64 `json:"topups_succeeded"`
WebhookFailures int64 `json:"webhook_failures"`
}
OperationsSummary The queues and failure counts a wallet operator has to act on.
type Option ¶
type Option func(*Client)
Option customises a Client.
func WithHTTPClient ¶
WithHTTPClient replaces the HTTP client, for a custom transport, proxy, timeout or instrumentation.
func WithRetryPolicy ¶
func WithRetryPolicy(p RetryPolicy) Option
WithRetryPolicy replaces the retry policy.
func WithUserAgent ¶
WithUserAgent replaces the User-Agent. Identify your application; the SDK name and version are appended so support can see both.
type Order ¶
type Order struct {
ClientId openapi_types.UUID `json:"client_id"`
Commission int64 `json:"commission"`
CreatedAt time.Time `json:"created_at"`
ExpiresAt time.Time `json:"expires_at"`
Id openapi_types.UUID `json:"id"`
Lines []OrderLine `json:"lines"`
MerchantId openapi_types.UUID `json:"merchant_id"`
PaymentId *openapi_types.UUID `json:"payment_id,omitempty"`
RestockedAt *time.Time `json:"restocked_at,omitempty"`
Status OrderStatus `json:"status"`
Subtotal int64 `json:"subtotal"`
// Total What the buyer pays; differs from subtotal only when the loop adds commission on top.
Total int64 `json:"total"`
UpdatedAt time.Time `json:"updated_at"`
UserId openapi_types.UUID `json:"user_id"`
}
Order A cart from one merchant. open holds its stock until expires_at; paying is the moment between claiming the order and the payment landing; paid, canceled and expired are final.
type OrderLine ¶
type OrderLine struct {
Commission int64 `json:"commission"`
Id openapi_types.UUID `json:"id"`
LineAmount int64 `json:"line_amount"`
OfferingId openapi_types.UUID `json:"offering_id"`
Quantity int64 `json:"quantity"`
Sku *string `json:"sku,omitempty"`
Title string `json:"title"`
UnitAmount int64 `json:"unit_amount"`
VariantId openapi_types.UUID `json:"variant_id"`
// VariantTitle The option values joined ("L / Red"); absent for a default variant.
VariantTitle *string `json:"variant_title,omitempty"`
}
OrderLine A snapshot of what was bought at the price it was bought.
type OrderLineInput ¶
type OrderLineInput struct {
Quantity int64 `json:"quantity"`
VariantId openapi_types.UUID `json:"variant_id"`
}
OrderLineInput defines model for OrderLineInput.
type OrderPayment ¶
type OrderPayment struct {
// Order A cart from one merchant. open holds its stock until expires_at; paying is the moment between claiming the order and the payment landing; paid, canceled and expired are final.
Order Order `json:"order"`
Payment Payment `json:"payment"`
}
OrderPayment defines model for OrderPayment.
type OrderStatus ¶
type OrderStatus string
OrderStatus defines model for Order.Status.
const ( OrderStatusCanceled OrderStatus = "canceled" OrderStatusExpired OrderStatus = "expired" OrderStatusOpen OrderStatus = "open" OrderStatusPaid OrderStatus = "paid" OrderStatusPaying OrderStatus = "paying" )
Defines values for OrderStatus.
func (OrderStatus) Valid ¶
func (e OrderStatus) Valid() bool
Valid indicates whether the value is a known member of the OrderStatus enum.
type PageIterator ¶
type PageIterator[T any] struct { // contains filtered or unexported fields }
PageIterator walks a listing whose responses carry next_cursor.
func (*PageIterator[T]) Collect ¶
func (p *PageIterator[T]) Collect(ctx context.Context) ([]T, error)
Collect walks the whole listing into a slice.
func (*PageIterator[T]) Err ¶
func (p *PageIterator[T]) Err() error
Err is the error that stopped the walk.
func (*PageIterator[T]) Item ¶
func (p *PageIterator[T]) Item() T
Item is the current item, defined only after Next returned true.
func (*PageIterator[T]) Next ¶
func (p *PageIterator[T]) Next(ctx context.Context) bool
Next advances to the next item.
func (*PageIterator[T]) PageSize ¶
func (p *PageIterator[T]) PageSize(n int) *PageIterator[T]
PageSize follows Iterator.PageSize: values are bounded, and calls after the first Next are ignored.
type Payment ¶
type Payment struct {
Amount int64 `json:"amount"`
CapturedAmount int64 `json:"captured_amount"`
// Commission The marketplace take on a catalog sale, credited to the loop that operates the marketplace. Zero for a direct payment.
Commission int64 `json:"commission"`
CreatedAt time.Time `json:"created_at"`
// Fee The platform's processing fee, deducted from settlement.
Fee int64 `json:"fee"`
HoldExpiresAt *time.Time `json:"hold_expires_at,omitempty"`
Id openapi_types.UUID `json:"id"`
LineItems *[]LineItem `json:"line_items,omitempty"`
MerchantId openapi_types.UUID `json:"merchant_id"`
Mode string `json:"mode"`
PayerUserId openapi_types.UUID `json:"payer_user_id"`
RefundedAmount int64 `json:"refunded_amount"`
Status PaymentStatus `json:"status"`
}
Payment defines model for Payment.
type PaymentStatus ¶
type PaymentStatus string
PaymentStatus defines model for Payment.Status.
const ( PaymentStatusCaptured PaymentStatus = "captured" PaymentStatusExpired PaymentStatus = "expired" PaymentStatusRequiresCapture PaymentStatus = "requires_capture" PaymentStatusVoided PaymentStatus = "voided" )
Defines values for PaymentStatus.
func (PaymentStatus) Valid ¶
func (e PaymentStatus) Valid() bool
Valid indicates whether the value is a known member of the PaymentStatus enum.
type Payout ¶
type Payout struct {
// Amount What left the merchant's settlement balance.
Amount int64 `json:"amount"`
CreatedAt time.Time `json:"created_at"`
ExternalRef *string `json:"external_ref,omitempty"`
// Fee The part of the amount the wallet kept, so amount less fee is what the merchant receives.
Fee int64 `json:"fee"`
Id openapi_types.UUID `json:"id"`
MerchantId openapi_types.UUID `json:"merchant_id"`
Rail string `json:"rail"`
Status PayoutStatus `json:"status"`
TxnId openapi_types.UUID `json:"txn_id"`
}
Payout defines model for Payout.
type PayoutStatus ¶
type PayoutStatus string
PayoutStatus defines model for Payout.Status.
const ( Completed PayoutStatus = "completed" PendingTransfer PayoutStatus = "pending_transfer" )
Defines values for PayoutStatus.
func (PayoutStatus) Valid ¶
func (e PayoutStatus) Valid() bool
Valid indicates whether the value is a known member of the PayoutStatus enum.
type PlatformClient ¶
type PlatformClient struct {
ApprovedAt *time.Time `json:"approved_at,omitempty"`
Category *string `json:"category,omitempty"`
CreatedAt time.Time `json:"created_at"`
DisplayName string `json:"display_name"`
Id openapi_types.UUID `json:"id"`
MerchantId openapi_types.UUID `json:"merchant_id"`
OrgAlias string `json:"org_alias"`
// Status A self-onboarded client starts pending: it can build its profile and draft offerings, but nothing reaches Explore until the platform approves it. Suspended hides its catalog again without touching its money.
Status CatalogClientStatus `json:"status"`
TenantId openapi_types.UUID `json:"tenant_id"`
TenantName string `json:"tenant_name"`
}
PlatformClient defines model for PlatformClient.
type PlatformOverview ¶
type PlatformOverview struct {
AsOf time.Time `json:"as_of"`
Tenants []PlatformTenantRow `json:"tenants"`
Totals []PlatformTotal `json:"totals"`
}
PlatformOverview defines model for PlatformOverview.
type PlatformSubscription ¶
type PlatformSubscription struct {
Amount int64 `json:"amount"`
CreatedAt time.Time `json:"created_at"`
Currency string `json:"currency"`
Id openapi_types.UUID `json:"id"`
Interval SubscriptionInterval `json:"interval"`
MerchantId openapi_types.UUID `json:"merchant_id"`
NextChargeAt time.Time `json:"next_charge_at"`
PlanName string `json:"plan_name"`
RetryCount int `json:"retry_count"`
Status SubscriptionStatus `json:"status"`
TenantId openapi_types.UUID `json:"tenant_id"`
TenantName string `json:"tenant_name"`
UserId openapi_types.UUID `json:"user_id"`
}
PlatformSubscription defines model for PlatformSubscription.
type PlatformTenantRow ¶
type PlatformTenantRow struct {
Balanced bool `json:"balanced"`
MerchantSettlement int64 `json:"merchant_settlement"`
SubscriptionsActive int64 `json:"subscriptions_active"`
Tenant Tenant `json:"tenant"`
Transactions30d int64 `json:"transactions_30d"`
Treasury int64 `json:"treasury"`
UserCash int64 `json:"user_cash"`
Users int64 `json:"users"`
Volume30d int64 `json:"volume_30d"`
}
PlatformTenantRow One tenant's position. Amounts are minor units of the tenant's own currency; balanced says whether every commodity in this tenant's ledger nets to zero across all accounts.
type PlatformTotal ¶
type PlatformTotal struct {
Currency string `json:"currency"`
MerchantSettlement int64 `json:"merchant_settlement"`
Tenants int64 `json:"tenants"`
Transactions30d int64 `json:"transactions_30d"`
Treasury int64 `json:"treasury"`
UserCash int64 `json:"user_cash"`
Users int64 `json:"users"`
Volume30d int64 `json:"volume_30d"`
}
PlatformTotal Whole-platform sums for one currency, never across currencies.
type PlatformTransaction ¶
type PlatformTransaction struct {
CreatedAt time.Time `json:"created_at"`
Id openapi_types.UUID `json:"id"`
Legs []TransactionLeg `json:"legs"`
Metadata *map[string]string `json:"metadata,omitempty"`
Status string `json:"status"`
TenantId openapi_types.UUID `json:"tenant_id"`
TenantName string `json:"tenant_name"`
Type string `json:"type"`
}
PlatformTransaction defines model for PlatformTransaction.
type PlatformUser ¶
type PlatformUser struct {
CreatedAt time.Time `json:"created_at"`
DisplayName *string `json:"display_name,omitempty"`
ExternalId string `json:"external_id"`
Handle *string `json:"handle,omitempty"`
Id openapi_types.UUID `json:"id"`
Kind UserKind `json:"kind"`
Status string `json:"status"`
TenantId openapi_types.UUID `json:"tenant_id"`
TenantName string `json:"tenant_name"`
}
PlatformUser defines model for PlatformUser.
type PositionSummary ¶
type PositionSummary struct {
// ActiveWallets Wallets with at least one posting in the window.
ActiveWallets int64 `json:"active_wallets"`
// CreditExtended Sum of the overdrawn user balances — money the loop has lent.
CreditExtended int64 `json:"credit_extended"`
// CreditGranted Sum of the credit limits on user accounts.
CreditGranted int64 `json:"credit_granted"`
Fees int64 `json:"fees"`
FundedWallets int64 `json:"funded_wallets"`
// FundsHeld Active authorisation holds against user balances.
FundsHeld int64 `json:"funds_held"`
// MarketingDrawn Rewards already funded out of a marketing account that carries no balance of its own — a tenant subsidy, spent.
MarketingDrawn int64 `json:"marketing_drawn"`
// MarketingPots Funds sitting in marketing accounts, available to spend on rewards.
MarketingPots int64 `json:"marketing_pots"`
MerchantSettlement int64 `json:"merchant_settlement"`
PointsOutstanding int64 `json:"points_outstanding"`
Suspense int64 `json:"suspense"`
// Treasury Value that entered the loop and has not left it.
Treasury int64 `json:"treasury"`
UserCash int64 `json:"user_cash"`
}
PositionSummary Snapshot of what the loop holds and owes right now, in the tenant's currency, plus the point liability counted separately.
type PriceChange ¶
type PriceChange struct {
ActorId *string `json:"actor_id,omitempty"`
ActorType *string `json:"actor_type,omitempty"`
CreatedAt time.Time `json:"created_at"`
Id openapi_types.UUID `json:"id"`
NewAmount int64 `json:"new_amount"`
OfferingId openapi_types.UUID `json:"offering_id"`
OldAmount *int64 `json:"old_amount,omitempty"`
Source PriceChangeSource `json:"source"`
VariantId openapi_types.UUID `json:"variant_id"`
}
PriceChange defines model for PriceChange.
type PriceChangeSource ¶
type PriceChangeSource string
PriceChangeSource defines model for PriceChange.Source.
const ( PriceChangeSourceImport PriceChangeSource = "import" PriceChangeSourceManual PriceChangeSource = "manual" PriceChangeSourceMarkup PriceChangeSource = "markup" )
Defines values for PriceChangeSource.
func (PriceChangeSource) Valid ¶
func (e PriceChangeSource) Valid() bool
Valid indicates whether the value is a known member of the PriceChangeSource enum.
type Pricing ¶
type Pricing struct {
// Markup What a merchant adds to a cost to reach a sell price. percent is basis points of the cost; fixed is minor units on top. Resolves most specific wins: variant, then product, then shop.
Markup *Markup `json:"markup,omitempty"`
// RepricedVariants On a write, how many variants changed price as a result.
RepricedVariants *int `json:"repriced_variants,omitempty"`
// Rounding Lands a derived price on a friendly number. increment is in minor units (100 puts a two-decimal currency on whole units, 0 disables rounding); offset nudges the result (-1 gives x.99).
Rounding Rounding `json:"rounding"`
}
Pricing A shop's pricing defaults for cost_plus variants.
type Problem ¶
type Problem struct {
// Code Stable machine-readable error code
Code string `json:"code"`
Detail *string `json:"detail,omitempty"`
Status int `json:"status"`
Title string `json:"title"`
Type *string `json:"type,omitempty"`
}
Problem defines model for Problem.
func AsProblem ¶
AsProblem extracts the problem from an error returned by any Client method, false if the call failed before or below HTTP.
type PurchaseOfferingParams ¶
type PurchaseOfferingParams struct {
IdempotencyKeyHeader IdempotencyKeyHeader `json:"Idempotency-Key"`
}
PurchaseOfferingParams defines parameters for PurchaseOffering.
type ReconciliationRow ¶
type ReconciliationRow struct {
Accounts int64 `json:"accounts"`
Balanced bool `json:"balanced"`
Commodity string `json:"commodity"`
Net int64 `json:"net"`
}
ReconciliationRow One commodity's books. A balanced ledger nets to zero per commodity; any other value is a P1 defect, not a rounding artefact.
type Refund ¶
type Refund struct {
Amount int64 `json:"amount"`
CreatedAt time.Time `json:"created_at"`
Id openapi_types.UUID `json:"id"`
PaymentId openapi_types.UUID `json:"payment_id"`
Reason *string `json:"reason,omitempty"`
Status string `json:"status"`
}
Refund defines model for Refund.
type RetryPolicy ¶
type RetryPolicy struct {
// MaxAttempts counts the first attempt. 1 disables retries.
MaxAttempts int
// BaseDelay is the first backoff step; each further step doubles it.
BaseDelay time.Duration
// MaxDelay caps one wait. A Retry-After longer than this is not
// waited out: the problem is returned so the caller decides, rather
// than the SDK blocking a request goroutine for minutes.
MaxDelay time.Duration
}
RetryPolicy bounds automatic retries.
Only two classes of answer are ever retried: 429, which means the request was refused before it was acted on, and 5xx, which is retried only when the request is replay-safe — a GET, or a call carrying an idempotency key. Every other 4xx is a statement about the request itself and is returned to the caller unchanged; retrying it would only waste the rate budget.
Example ¶
ExampleRetryPolicy tunes the retry budget for a latency-sensitive caller.
package main
import (
"log"
"time"
"github.com/walletd-io/walletd-go"
)
func main() {
_, err := walletd.New("https://apigw.walletd.io", walletd.APIKey("sk_sandbox_..."),
walletd.WithRetryPolicy(walletd.RetryPolicy{
MaxAttempts: 6,
BaseDelay: 100 * time.Millisecond,
MaxDelay: 10 * time.Second,
}))
if err != nil {
log.Fatal(err)
}
}
Output:
type RevenueSummary ¶
type RevenueSummary struct {
// FeesEarned Credits to tenant and platform fee accounts.
FeesEarned int64 `json:"fees_earned"`
// MoneyIn Value that entered the loop through treasury (top-ups).
MoneyIn int64 `json:"money_in"`
// MoneyOut Value that left the loop through treasury (merchant payouts).
MoneyOut int64 `json:"money_out"`
PaymentVolume int64 `json:"payment_volume"`
PointsIssued int64 `json:"points_issued"`
PointsRedeemed int64 `json:"points_redeemed"`
PreviousFeesEarned int64 `json:"previous_fees_earned"`
// RewardsPaid Cash leaving marketing accounts as cashback and point conversions.
RewardsPaid int64 `json:"rewards_paid"`
// TakeRateBps fees_earned over payment_volume, in basis points. Zero when there was no payment volume.
TakeRateBps int `json:"take_rate_bps"`
}
RevenueSummary What the loop earned and spent in the window, in the tenant's currency.
type RewardGrant ¶
type RewardGrant struct {
Amount int64 `json:"amount"`
CreatedAt time.Time `json:"created_at"`
Id openapi_types.UUID `json:"id"`
Kind string `json:"kind"`
RuleId openapi_types.UUID `json:"rule_id"`
SourceTxn openapi_types.UUID `json:"source_txn"`
TxnId openapi_types.UUID `json:"txn_id"`
UserId openapi_types.UUID `json:"user_id"`
}
RewardGrant defines model for RewardGrant.
type RewardRule ¶
type RewardRule struct {
Caps *map[string]interface{} `json:"caps,omitempty"`
CreatedAt time.Time `json:"created_at"`
// DisabledAt When the rule was switched off. Reward evaluation reads this as of the moment a payment was captured, so a rule disabled after a sale still pays that sale. Absent on an active rule, and also absent on a rule disabled before this field existed, which is excluded from evaluation outright because there is no honest instant to compare against.
DisabledAt *time.Time `json:"disabled_at,omitempty"`
EndsAt *time.Time `json:"ends_at,omitempty"`
Id openapi_types.UUID `json:"id"`
Kind string `json:"kind"`
Params map[string]interface{} `json:"params"`
Scope *map[string]interface{} `json:"scope,omitempty"`
StartsAt *time.Time `json:"starts_at,omitempty"`
Status string `json:"status"`
Version int `json:"version"`
}
RewardRule defines model for RewardRule.
type Rounding ¶
Rounding Lands a derived price on a friendly number. increment is in minor units (100 puts a two-decimal currency on whole units, 0 disables rounding); offset nudges the result (-1 gives x.99).
type RunClientPayoutJSONBody ¶
type RunClientPayoutJSONBody struct {
// Amount Omit for the full settlement balance
Amount *int64 `json:"amount,omitempty"`
}
RunClientPayoutJSONBody defines parameters for RunClientPayout.
type RunClientPayoutJSONRequestBody ¶
type RunClientPayoutJSONRequestBody RunClientPayoutJSONBody
RunClientPayoutJSONRequestBody defines body for RunClientPayout for application/json ContentType.
type RunClientPayoutParams ¶
type RunClientPayoutParams struct {
IdempotencyKeyHeader IdempotencyKeyHeader `json:"Idempotency-Key"`
}
RunClientPayoutParams defines parameters for RunClientPayout.
type SeriesPoint ¶
type SeriesPoint struct {
Amount int64 `json:"amount"`
ByType map[string]int64 `json:"by_type"`
Count int64 `json:"count"`
Start time.Time `json:"start"`
}
SeriesPoint One bucket of the movement series, in the tenant's currency.
type SetClientCommissionJSONRequestBody ¶
type SetClientCommissionJSONRequestBody = SetClientCommissionRequest
SetClientCommissionJSONRequestBody defines body for SetClientCommission for application/json ContentType.
type SetClientCommissionRequest ¶
type SetClientCommissionRequest struct {
// CommissionBps The commission rate in basis points charged on this merchant's sales. Null clears the deal so the tenant's default rate applies; zero is a real rate meaning the merchant is sold commission-free.
CommissionBps *int `json:"commission_bps,omitempty"`
}
SetClientCommissionRequest Only the rate is negotiable; the flat part and band stay with the tenant plan.
type SetClientPricingJSONRequestBody ¶
type SetClientPricingJSONRequestBody = Pricing
SetClientPricingJSONRequestBody defines body for SetClientPricing for application/json ContentType.
type SetCreditLimitRequest ¶
type SetCreditLimitRequest struct {
// CreditLimit Absolute floor in minor units the cash balance may go below zero
CreditLimit int64 `json:"credit_limit"`
}
SetCreditLimitRequest defines model for SetCreditLimitRequest.
type SetTierLimitsJSONRequestBody ¶
type SetTierLimitsJSONRequestBody = SetTierLimitsRequest
SetTierLimitsJSONRequestBody defines body for SetTierLimits for application/json ContentType.
type SetTierLimitsRequest ¶
type SetTierLimitsRequest struct {
MaxBalance *int64 `json:"max_balance,omitempty"`
P2pPerDay *int64 `json:"p2p_per_day,omitempty"`
Tier string `json:"tier"`
TopupPerDay *int64 `json:"topup_per_day,omitempty"`
}
SetTierLimitsRequest defines model for SetTierLimitsRequest.
type SetUserCreditLimitJSONRequestBody ¶
type SetUserCreditLimitJSONRequestBody = SetCreditLimitRequest
SetUserCreditLimitJSONRequestBody defines body for SetUserCreditLimit for application/json ContentType.
type SetUserTierJSONBody ¶
type SetUserTierJSONBody struct {
Tier string `json:"tier"`
}
SetUserTierJSONBody defines parameters for SetUserTier.
type SetUserTierJSONRequestBody ¶
type SetUserTierJSONRequestBody SetUserTierJSONBody
SetUserTierJSONRequestBody defines body for SetUserTier for application/json ContentType.
type StartCatalogImportMultipartBody ¶
type StartCatalogImportMultipartBody struct {
// File The .csv or .xlsx, at most 10 MB
File openapi_types.File `json:"file"`
// Images A .zip of the pictures the image column names, at most 100 MB
Images *openapi_types.File `json:"images,omitempty"`
}
StartCatalogImportMultipartBody defines parameters for StartCatalogImport.
type StartCatalogImportMultipartRequestBody ¶
type StartCatalogImportMultipartRequestBody StartCatalogImportMultipartBody
StartCatalogImportMultipartRequestBody defines body for StartCatalogImport for multipart/form-data ContentType.
type StatementEntry ¶
type StatementEntry struct {
Amount int64 `json:"amount"`
Commodity string `json:"commodity"`
CreatedAt time.Time `json:"created_at"`
Direction StatementEntryDirection `json:"direction"`
TxnId openapi_types.UUID `json:"txn_id"`
TxnType string `json:"txn_type"`
}
StatementEntry defines model for StatementEntry.
type StatementEntryDirection ¶
type StatementEntryDirection string
StatementEntryDirection defines model for StatementEntry.Direction.
const ( StatementEntryDirectionCredit StatementEntryDirection = "credit" StatementEntryDirectionDebit StatementEntryDirection = "debit" )
Defines values for StatementEntryDirection.
func (StatementEntryDirection) Valid ¶
func (e StatementEntryDirection) Valid() bool
Valid indicates whether the value is a known member of the StatementEntryDirection enum.
type StockAdjustmentRequest ¶
type StockAdjustmentRequest struct {
Delta *int64 `json:"delta,omitempty"`
Reason *string `json:"reason,omitempty"`
SetTo *int64 `json:"set_to,omitempty"`
}
StockAdjustmentRequest Exactly one of delta (signed change) or set_to (absolute count).
type StockAdjustmentResult ¶
type StockAdjustmentResult struct {
Movement InventoryMovement `json:"movement"`
// Variant The sellable unit. cost_amount, markup and pricing_mode appear only to the merchant.
Variant Variant `json:"variant"`
}
StockAdjustmentResult defines model for StockAdjustmentResult.
type SubscribeOfferingParams ¶
type SubscribeOfferingParams struct {
IdempotencyKeyHeader IdempotencyKeyHeader `json:"Idempotency-Key"`
}
SubscribeOfferingParams defines parameters for SubscribeOffering.
type Subscription ¶
type Subscription struct {
Amount int64 `json:"amount"`
// Commission The marketplace take per period, fixed when the subscriber signed up so a later rate change cannot move an agreed mandate.
Commission int64 `json:"commission"`
CreatedAt time.Time `json:"created_at"`
Id openapi_types.UUID `json:"id"`
Interval SubscriptionInterval `json:"interval"`
MerchantId openapi_types.UUID `json:"merchant_id"`
Metadata *map[string]string `json:"metadata,omitempty"`
NextChargeAt time.Time `json:"next_charge_at"`
PlanName string `json:"plan_name"`
RetryCount int `json:"retry_count"`
Status SubscriptionStatus `json:"status"`
UserId openapi_types.UUID `json:"user_id"`
}
Subscription defines model for Subscription.
type SubscriptionId ¶
type SubscriptionId = openapi_types.UUID
SubscriptionId defines model for SubscriptionId.
type SubscriptionInterval ¶
type SubscriptionInterval string
SubscriptionInterval defines model for SubscriptionInterval.
const ( SubscriptionIntervalMonthly SubscriptionInterval = "monthly" SubscriptionIntervalWeekly SubscriptionInterval = "weekly" )
Defines values for SubscriptionInterval.
func (SubscriptionInterval) Valid ¶
func (e SubscriptionInterval) Valid() bool
Valid indicates whether the value is a known member of the SubscriptionInterval enum.
type SubscriptionStatus ¶
type SubscriptionStatus string
SubscriptionStatus defines model for SubscriptionStatus.
const ( SubscriptionStatusActive SubscriptionStatus = "active" SubscriptionStatusCanceled SubscriptionStatus = "canceled" SubscriptionStatusPastDue SubscriptionStatus = "past_due" SubscriptionStatusPaused SubscriptionStatus = "paused" )
Defines values for SubscriptionStatus.
func (SubscriptionStatus) Valid ¶
func (e SubscriptionStatus) Valid() bool
Valid indicates whether the value is a known member of the SubscriptionStatus enum.
type SummaryRow ¶
type SummaryRow struct {
Accounts int64 `json:"accounts"`
Balance int64 `json:"balance"`
Commodity string `json:"commodity"`
OwnerType string `json:"owner_type"`
Purpose string `json:"purpose"`
}
SummaryRow defines model for SummaryRow.
type SupportAccessGrant ¶
type SupportAccessGrant struct {
CreatedAt time.Time `json:"created_at"`
CreatedById string `json:"created_by_id"`
CreatedByType string `json:"created_by_type"`
ExpiresAt time.Time `json:"expires_at"`
Id openapi_types.UUID `json:"id"`
Reason string `json:"reason"`
RevokedAt *time.Time `json:"revoked_at,omitempty"`
RevokedById *string `json:"revoked_by_id,omitempty"`
RevokedByType *string `json:"revoked_by_type,omitempty"`
StaffId string `json:"staff_id"`
TenantId openapi_types.UUID `json:"tenant_id"`
TicketReference string `json:"ticket_reference"`
}
SupportAccessGrant defines model for SupportAccessGrant.
type Tenant ¶
type Tenant struct {
// CommissionMode Whether marketplace commission comes out of the merchant's settlement (the consumer pays the list price) or is added to what the consumer pays (the merchant nets the full list price).
CommissionMode CommissionMode `json:"commission_mode"`
CreatedAt time.Time `json:"created_at"`
Currency string `json:"currency"`
// Fees A tenant's price list, one rule per money path. An absent path charges nothing, so a tenant provisioned before a path existed stays free on it. Payments and subscriptions deduct their fee from the merchant's settlement; P2P adds it on top of what the sender pays; top-up deducts it from what is credited; payout deducts it from what leaves.
Fees FeeSchedule `json:"fees"`
Id openapi_types.UUID `json:"id"`
Name string `json:"name"`
Status string `json:"status"`
}
Tenant defines model for Tenant.
type TenantFilter ¶
type TenantFilter = openapi_types.UUID
TenantFilter defines model for TenantFilter.
type TenantSummary ¶
type TenantSummary struct {
InvariantsOk bool `json:"invariants_ok"`
Rows []SummaryRow `json:"rows"`
Tenant Tenant `json:"tenant"`
Violations *[]string `json:"violations,omitempty"`
}
TenantSummary defines model for TenantSummary.
type TierLimits ¶
type TierLimits struct {
// MaxBalance 0 means unlimited
MaxBalance int64 `json:"max_balance"`
// P2pPerDay 0 means unlimited
P2pPerDay int64 `json:"p2p_per_day"`
Tier string `json:"tier"`
// TopupPerDay 0 means unlimited
TopupPerDay int64 `json:"topup_per_day"`
UpdatedAt time.Time `json:"updated_at"`
}
TierLimits defines model for TierLimits.
type Topup ¶
type Topup struct {
Amount int64 `json:"amount"`
// ClientSecret Mirror of next_action.client_secret for older consumers
ClientSecret *string `json:"client_secret,omitempty"`
CreatedAt time.Time `json:"created_at"`
Gateway string `json:"gateway"`
Id openapi_types.UUID `json:"id"`
NextAction *TopupNextAction `json:"next_action,omitempty"`
// Status amount_mismatch parks a confirmation whose gateway-reported amount or currency disagrees with the intent; nothing was credited and an operator must resolve it.
Status TopupStatus `json:"status"`
UserId openapi_types.UUID `json:"user_id"`
}
Topup defines model for Topup.
type TopupMethod ¶
type TopupMethod struct {
Currencies *[]string `json:"currencies,omitempty"`
Flow TopupMethodFlow `json:"flow"`
Gateway string `json:"gateway"`
}
TopupMethod defines model for TopupMethod.
type TopupMethodFlow ¶
type TopupMethodFlow string
TopupMethodFlow defines model for TopupMethod.Flow.
const ( TopupMethodFlowClientSecret TopupMethodFlow = "client_secret" TopupMethodFlowDev TopupMethodFlow = "dev" TopupMethodFlowRedirect TopupMethodFlow = "redirect" )
Defines values for TopupMethodFlow.
func (TopupMethodFlow) Valid ¶
func (e TopupMethodFlow) Valid() bool
Valid indicates whether the value is a known member of the TopupMethodFlow enum.
type TopupNextAction ¶
type TopupNextAction struct {
ClientSecret *string `json:"client_secret,omitempty"`
Kind TopupNextActionKind `json:"kind"`
RedirectUrl *string `json:"redirect_url,omitempty"`
}
TopupNextAction defines model for TopupNextAction.
type TopupNextActionKind ¶
type TopupNextActionKind string
TopupNextActionKind defines model for TopupNextAction.Kind.
const ( TopupNextActionKindClientSecret TopupNextActionKind = "client_secret" TopupNextActionKindRedirect TopupNextActionKind = "redirect" )
Defines values for TopupNextActionKind.
func (TopupNextActionKind) Valid ¶
func (e TopupNextActionKind) Valid() bool
Valid indicates whether the value is a known member of the TopupNextActionKind enum.
type TopupStatus ¶
type TopupStatus string
TopupStatus amount_mismatch parks a confirmation whose gateway-reported amount or currency disagrees with the intent; nothing was credited and an operator must resolve it.
const ( TopupStatusAmountMismatch TopupStatus = "amount_mismatch" TopupStatusCreated TopupStatus = "created" TopupStatusExpired TopupStatus = "expired" TopupStatusFailed TopupStatus = "failed" TopupStatusProcessing TopupStatus = "processing" TopupStatusSucceeded TopupStatus = "succeeded" )
Defines values for TopupStatus.
func (TopupStatus) Valid ¶
func (e TopupStatus) Valid() bool
Valid indicates whether the value is a known member of the TopupStatus enum.
type Transaction ¶
type Transaction struct {
CreatedAt time.Time `json:"created_at"`
Id openapi_types.UUID `json:"id"`
Legs []TransactionLeg `json:"legs"`
Metadata *map[string]string `json:"metadata,omitempty"`
Status string `json:"status"`
Type string `json:"type"`
}
Transaction defines model for Transaction.
type TransactionLeg ¶
type TransactionLeg struct {
Amount int64 `json:"amount"`
Commodity string `json:"commodity"`
Direction EntryDirection `json:"direction"`
OwnerId *openapi_types.UUID `json:"owner_id,omitempty"`
OwnerType string `json:"owner_type"`
Purpose string `json:"purpose"`
}
TransactionLeg defines model for TransactionLeg.
type Transfer ¶
type Transfer struct {
Amount int64 `json:"amount"`
CreatedAt time.Time `json:"created_at"`
Fee int64 `json:"fee"`
FromUser openapi_types.UUID `json:"from_user"`
Id openapi_types.UUID `json:"id"`
Note *string `json:"note,omitempty"`
Status string `json:"status"`
ToUser openapi_types.UUID `json:"to_user"`
}
Transfer defines model for Transfer.
type UpdateCategoryJSONRequestBody ¶
type UpdateCategoryJSONRequestBody = CategoryInput
UpdateCategoryJSONRequestBody defines body for UpdateCategory for application/json ContentType.
type UpdateClientProfileJSONRequestBody ¶
type UpdateClientProfileJSONRequestBody = ClientProfileRequest
UpdateClientProfileJSONRequestBody defines body for UpdateClientProfile for application/json ContentType.
type UpdateFeePlanJSONRequestBody ¶
type UpdateFeePlanJSONRequestBody = UpdateFeePlanRequest
UpdateFeePlanJSONRequestBody defines body for UpdateFeePlan for application/json ContentType.
type UpdateFeePlanRequest ¶
type UpdateFeePlanRequest struct {
// CommissionMode Whether marketplace commission comes out of the merchant's settlement (the consumer pays the list price) or is added to what the consumer pays (the merchant nets the full list price).
CommissionMode *CommissionMode `json:"commission_mode,omitempty"`
// Fees A tenant's price list, one rule per money path. An absent path charges nothing, so a tenant provisioned before a path existed stays free on it. Payments and subscriptions deduct their fee from the merchant's settlement; P2P adds it on top of what the sender pays; top-up deducts it from what is credited; payout deducts it from what leaves.
Fees *FeeSchedule `json:"fees,omitempty"`
}
UpdateFeePlanRequest Each named path's rule is replaced whole and every unnamed path is left alone, so clearing a cap is expressible by sending the path without a max_fee.
type UpdateOfferingJSONRequestBody ¶
type UpdateOfferingJSONRequestBody = UpdateOfferingRequest
UpdateOfferingJSONRequestBody defines body for UpdateOffering for application/json ContentType.
type UpdateOfferingRequest ¶
type UpdateOfferingRequest struct {
// Amount Reprices a plan (drafts only) or a single-variant item's default variant; a multi-variant item is priced through its variants.
Amount *int64 `json:"amount,omitempty"`
CategoryId *openapi_types.UUID `json:"category_id,omitempty"`
Description *string `json:"description,omitempty"`
ImageUrl *string `json:"image_url,omitempty"`
// Markup What a merchant adds to a cost to reach a sell price. percent is basis points of the cost; fixed is minor units on top. Resolves most specific wins: variant, then product, then shop.
Markup *Markup `json:"markup,omitempty"`
Metadata *map[string]string `json:"metadata,omitempty"`
// Options Option names may be renamed, not added or removed.
Options *[]string `json:"options,omitempty"`
Title string `json:"title"`
}
UpdateOfferingRequest defines model for UpdateOfferingRequest.
type UpdateVariantJSONRequestBody ¶
type UpdateVariantJSONRequestBody = VariantInput
UpdateVariantJSONRequestBody defines body for UpdateVariant for application/json ContentType.
type User ¶
type User struct {
CreatedAt time.Time `json:"created_at"`
DisplayName *string `json:"display_name,omitempty"`
Email *openapi_types.Email `json:"email,omitempty"`
ExternalId string `json:"external_id"`
Handle *string `json:"handle,omitempty"`
Id openapi_types.UUID `json:"id"`
Kind UserKind `json:"kind"`
Phone *string `json:"phone,omitempty"`
Status string `json:"status"`
}
User defines model for User.
type UserBalance ¶
type UserBalance struct {
Available int64 `json:"available"`
Balance int64 `json:"balance"`
Commodity string `json:"commodity"`
Held int64 `json:"held"`
Purpose string `json:"purpose"`
}
UserBalance defines model for UserBalance.
type UserKind ¶
type UserKind string
UserKind defines model for UserKind.
Defines values for UserKind.
type UserTransaction ¶
type UserTransaction struct {
Amount int64 `json:"amount"`
Commodity string `json:"commodity"`
CreatedAt time.Time `json:"created_at"`
Direction EntryDirection `json:"direction"`
Purpose string `json:"purpose"`
TxnId openapi_types.UUID `json:"txn_id"`
TxnType string `json:"txn_type"`
}
UserTransaction defines model for UserTransaction.
type Variant ¶
type Variant struct {
Amount int64 `json:"amount"`
Barcode *string `json:"barcode,omitempty"`
CostAmount *int64 `json:"cost_amount,omitempty"`
CreatedAt time.Time `json:"created_at"`
Id openapi_types.UUID `json:"id"`
ImageUrl *string `json:"image_url,omitempty"`
// Inventory Stock as the caller may see it. Shoppers get the three flags only; the merchant also gets the counts and the policy.
Inventory VariantInventory `json:"inventory"`
// Markup What a merchant adds to a cost to reach a sell price. percent is basis points of the cost; fixed is minor units on top. Resolves most specific wins: variant, then product, then shop.
Markup *Markup `json:"markup,omitempty"`
OfferingId openapi_types.UUID `json:"offering_id"`
OptionValues []string `json:"option_values"`
Position int `json:"position"`
PricingMode *VariantPricingMode `json:"pricing_mode,omitempty"`
Sku *string `json:"sku,omitempty"`
Status VariantStatus `json:"status"`
UpdatedAt time.Time `json:"updated_at"`
}
Variant The sellable unit. cost_amount, markup and pricing_mode appear only to the merchant.
type VariantInput ¶
type VariantInput struct {
AllowBackorder *bool `json:"allow_backorder,omitempty"`
Amount *int64 `json:"amount,omitempty"`
Barcode *string `json:"barcode,omitempty"`
CostAmount *int64 `json:"cost_amount,omitempty"`
ImageUrl *string `json:"image_url,omitempty"`
InitialStock *int64 `json:"initial_stock,omitempty"`
LowStockThreshold *int64 `json:"low_stock_threshold,omitempty"`
// Markup What a merchant adds to a cost to reach a sell price. percent is basis points of the cost; fixed is minor units on top. Resolves most specific wins: variant, then product, then shop.
Markup *Markup `json:"markup,omitempty"`
OptionValues *[]string `json:"option_values,omitempty"`
Position *int `json:"position,omitempty"`
PricingMode *VariantInputPricingMode `json:"pricing_mode,omitempty"`
Sku *string `json:"sku,omitempty"`
TrackInventory *bool `json:"track_inventory,omitempty"`
}
VariantInput A variant as the merchant writes it. amount is required in manual mode and ignored in cost_plus mode, where it derives from cost_amount and the most specific markup. initial_stock is honoured on create only; later counts change through the stock endpoint so the movement log is whole.
type VariantInputPricingMode ¶
type VariantInputPricingMode string
VariantInputPricingMode defines model for VariantInput.PricingMode.
const ( VariantInputPricingModeCostPlus VariantInputPricingMode = "cost_plus" VariantInputPricingModeManual VariantInputPricingMode = "manual" )
Defines values for VariantInputPricingMode.
func (VariantInputPricingMode) Valid ¶
func (e VariantInputPricingMode) Valid() bool
Valid indicates whether the value is a known member of the VariantInputPricingMode enum.
type VariantInventory ¶
type VariantInventory struct {
AllowBackorder *bool `json:"allow_backorder,omitempty"`
Available *int64 `json:"available,omitempty"`
InStock bool `json:"in_stock"`
LowStock bool `json:"low_stock"`
LowStockThreshold *int64 `json:"low_stock_threshold,omitempty"`
OnHand *int64 `json:"on_hand,omitempty"`
Reserved *int64 `json:"reserved,omitempty"`
TrackInventory bool `json:"track_inventory"`
}
VariantInventory Stock as the caller may see it. Shoppers get the three flags only; the merchant also gets the counts and the policy.
type VariantPricingMode ¶
type VariantPricingMode string
VariantPricingMode defines model for Variant.PricingMode.
const ( VariantPricingModeCostPlus VariantPricingMode = "cost_plus" VariantPricingModeManual VariantPricingMode = "manual" )
Defines values for VariantPricingMode.
func (VariantPricingMode) Valid ¶
func (e VariantPricingMode) Valid() bool
Valid indicates whether the value is a known member of the VariantPricingMode enum.
type VariantStatus ¶
type VariantStatus string
VariantStatus defines model for Variant.Status.
const ( VariantStatusActive VariantStatus = "active" VariantStatusArchived VariantStatus = "archived" )
Defines values for VariantStatus.
func (VariantStatus) Valid ¶
func (e VariantStatus) Valid() bool
Valid indicates whether the value is a known member of the VariantStatus enum.
type WebhookDelivery ¶
type WebhookDelivery struct {
Attempt int `json:"attempt"`
CreatedAt time.Time `json:"created_at"`
EndpointId openapi_types.UUID `json:"endpoint_id"`
Error *string `json:"error,omitempty"`
EventId openapi_types.UUID `json:"event_id"`
EventType string `json:"event_type"`
Id openapi_types.UUID `json:"id"`
ResponseCode *int `json:"response_code,omitempty"`
Status string `json:"status"`
}
WebhookDelivery defines model for WebhookDelivery.
type WebhookEndpoint ¶
type WebhookEndpoint struct {
// ClientId The merchant this endpoint belongs to; absent on a tenant-wide endpoint
ClientId *openapi_types.UUID `json:"client_id,omitempty"`
CreatedAt time.Time `json:"created_at"`
EventFilters []string `json:"event_filters"`
Id openapi_types.UUID `json:"id"`
// Secret Signing secret, returned only on creation
Secret *string `json:"secret,omitempty"`
Status string `json:"status"`
Url string `json:"url"`
}
WebhookEndpoint defines model for WebhookEndpoint.
type WebhookEvent ¶
type WebhookEvent struct {
CreatedAt time.Time `json:"created_at"`
Data map[string]interface{} `json:"data"`
Id openapi_types.UUID `json:"id"`
Type string `json:"type"`
}
WebhookEvent defines model for WebhookEvent.