Documentation
¶
Overview ¶
Package plugipay is the official Go SDK for the Plugipay payments API. It mirrors the public surface of @forjio/plugipay-node and the Python `plugipay` package: HMAC-signed REST requests, a single resource namespace per concept (customers, plans, checkout-sessions, invoices, subscriptions, refunds, adapters, payouts, ledger, reports, webhooks, etc.), and stdlib-only deps.
Quickstart:
c, err := plugipay.NewClient(plugipay.ClientOptions{
KeyID: "ak_live_...",
Secret: "sk_...",
})
if err != nil { /* missing creds */ }
cust, err := c.Customers.Create(ctx, plugipay.CustomerCreateInput{
Email: ptr("buyer@example.com"),
})
Index ¶
- Constants
- func AuthorizationHeader(keyID, signature string) string
- func VerifyWebhookSignature(rawBody []byte, signatureHeader string, secret string, ...) bool
- type APIEnvelope
- type APIError
- type AccountEmailChangeInput
- type AccountEmailChangeResult
- type AccountPasswordChangeInput
- type AccountProfile
- type AccountResource
- func (r *AccountResource) ChangeEmail(ctx context.Context, in AccountEmailChangeInput) (*AccountEmailChangeResult, error)
- func (r *AccountResource) ChangePassword(ctx context.Context, in AccountPasswordChangeInput) error
- func (r *AccountResource) Get(ctx context.Context) (*AccountProfile, error)
- func (r *AccountResource) ListLinked(ctx context.Context) ([]LinkedAccount, error)
- func (r *AccountResource) ListMembers(ctx context.Context) ([]WorkspaceMember, error)
- func (r *AccountResource) ListSessions(ctx context.Context) ([]BrowserSession, error)
- func (r *AccountResource) RevokeAllSessions(ctx context.Context) (*AccountRevokeAllResult, error)
- func (r *AccountResource) RevokeSession(ctx context.Context, id string) error
- func (r *AccountResource) Unlink(ctx context.Context, provider string) error
- func (r *AccountResource) Update(ctx context.Context, patch AccountUpdateInput) (*AccountProfile, error)
- type AccountRevokeAllResult
- type AccountUpdateInput
- type AdapterConfig
- type AdapterKind
- type AdaptersResource
- func (r *AdaptersResource) List(ctx context.Context) ([]AdapterConfig, error)
- func (r *AdaptersResource) ManagedOnboardingState(ctx context.Context) (*ManagedOnboardingState, error)
- func (r *AdaptersResource) SimulateManagedOnboarding(ctx context.Context, in ManagedOnboardingSimulateInput) (*ManagedOnboardingState, error)
- func (r *AdaptersResource) StartManagedOnboarding(ctx context.Context, in ManagedOnboardingStartInput) (*ManagedOnboardingState, error)
- func (r *AdaptersResource) UpdateManual(ctx context.Context, config map[string]any) (*AdapterConfig, error)
- func (r *AdaptersResource) UpdateMidtrans(ctx context.Context, config map[string]any) (*AdapterConfig, error)
- func (r *AdaptersResource) UpdatePaypal(ctx context.Context, config map[string]any) (*AdapterConfig, error)
- func (r *AdaptersResource) UpdateXendit(ctx context.Context, config map[string]any) (*AdapterConfig, error)
- type AdminPartnerUsageParams
- type AdminPortalIdentity
- type AdminPortalResource
- func (r *AdminPortalResource) CreatePartner(ctx context.Context, in map[string]any) (json.RawMessage, error)
- func (r *AdminPortalResource) DeletePartner(ctx context.Context, id string) error
- func (r *AdminPortalResource) ListBillingAccounts(ctx context.Context) ([]json.RawMessage, error)
- func (r *AdminPortalResource) ListPartners(ctx context.Context) ([]json.RawMessage, error)
- func (r *AdminPortalResource) Me(ctx context.Context) (*AdminPortalIdentity, error)
- func (r *AdminPortalResource) UpdateBillingAccount(ctx context.Context, accountID string, patch map[string]any) (json.RawMessage, error)
- func (r *AdminPortalResource) UpdatePartner(ctx context.Context, id string, patch map[string]any) (json.RawMessage, error)
- type AdminProvisionWorkspaceInput
- type AdminResource
- func (r *AdminResource) GetWorkspace(ctx context.Context, accountID string) (*PartnerWorkspace, error)
- func (r *AdminResource) PartnerUsage(ctx context.Context, p AdminPartnerUsageParams) (*PartnerUsageSummary, error)
- func (r *AdminResource) ProvisionWorkspace(ctx context.Context, in AdminProvisionWorkspaceInput) (*PartnerWorkspace, error)
- type ApiKey
- type ApiKeyCreateInput
- type ApiKeysResource
- type AvailableBalance
- type BankAccount
- type BankAccountInput
- type BillingRefreshResult
- type BillingResource
- type BillingTier
- type BrowserSession
- type CashFlowBucket
- type CashFlowReport
- type CheckoutMethod
- type CheckoutSession
- type CheckoutSessionCreateInput
- type CheckoutSessionLineItem
- type CheckoutSessionListParams
- type CheckoutSessionsResource
- func (r *CheckoutSessionsResource) Cancel(ctx context.Context, id string) (*CheckoutSession, error)
- func (r *CheckoutSessionsResource) Confirm(ctx context.Context, id string) (*CheckoutSession, error)
- func (r *CheckoutSessionsResource) Create(ctx context.Context, in CheckoutSessionCreateInput) (*CheckoutSession, error)
- func (r *CheckoutSessionsResource) Get(ctx context.Context, id string) (*CheckoutSession, error)
- func (r *CheckoutSessionsResource) List(ctx context.Context, params CheckoutSessionListParams) (Page[CheckoutSession], error)
- type CheckoutSettings
- type CheckoutSettingsResource
- type CheckoutSettingsUpdateInput
- type Client
- type ClientOptions
- type CurrencyCode
- type Customer
- type CustomerCreateInput
- type CustomerListParams
- type CustomerUpdateInput
- type CustomersResource
- func (r *CustomersResource) Create(ctx context.Context, in CustomerCreateInput) (*Customer, error)
- func (r *CustomersResource) Get(ctx context.Context, id string) (*Customer, error)
- func (r *CustomersResource) List(ctx context.Context, params CustomerListParams) (Page[Customer], error)
- func (r *CustomersResource) Update(ctx context.Context, id string, patch CustomerUpdateInput) (*Customer, error)
- type EnvelopeMeta
- type Error
- type EventListParams
- type EventRecord
- type EventsResource
- type Invoice
- type InvoiceCreateInput
- type InvoiceCreateLine
- type InvoiceLine
- type InvoiceListParams
- type InvoiceSendEmailResult
- type InvoicesResource
- func (r *InvoicesResource) Create(ctx context.Context, in InvoiceCreateInput) (*Invoice, error)
- func (r *InvoicesResource) Finalize(ctx context.Context, id string) (*Invoice, error)
- func (r *InvoicesResource) Get(ctx context.Context, id string) (*Invoice, error)
- func (r *InvoicesResource) List(ctx context.Context, params InvoiceListParams) (Page[Invoice], error)
- func (r *InvoicesResource) Pay(ctx context.Context, id string) (*Invoice, error)
- func (r *InvoicesResource) SendEmail(ctx context.Context, id string, to *string) (*InvoiceSendEmailResult, error)
- func (r *InvoicesResource) Void(ctx context.Context, id string) (*Invoice, error)
- type LedgerBalance
- type LedgerEntry
- type LedgerListParams
- type LedgerResource
- type LinkedAccount
- type ManagedOnboardingSimulateInput
- type ManagedOnboardingStartInput
- type ManagedOnboardingState
- type OnboardingProvisionManagedInput
- type OnboardingResource
- type Page
- type PartnerUsageLine
- type PartnerUsageSummary
- type PartnerWorkspace
- type Payout
- type PayoutCreateInput
- type PayoutListParams
- type PayoutMethod
- type PayoutStatus
- type PayoutsResource
- func (r *PayoutsResource) Balance(ctx context.Context) (*AvailableBalance, error)
- func (r *PayoutsResource) Cancel(ctx context.Context, id string) (*Payout, error)
- func (r *PayoutsResource) Create(ctx context.Context, in PayoutCreateInput) (*Payout, error)
- func (r *PayoutsResource) Get(ctx context.Context, id string) (*Payout, error)
- func (r *PayoutsResource) GetBankAccount(ctx context.Context) (*BankAccount, error)
- func (r *PayoutsResource) List(ctx context.Context, params PayoutListParams) (Page[Payout], error)
- func (r *PayoutsResource) MarkFailed(ctx context.Context, id string, failureReason string) (*Payout, error)
- func (r *PayoutsResource) MarkInTransit(ctx context.Context, id string, reference *string) (*Payout, error)
- func (r *PayoutsResource) MarkPaid(ctx context.Context, id string, reference *string) (*Payout, error)
- func (r *PayoutsResource) UpdateBankAccount(ctx context.Context, in BankAccountInput) (*BankAccount, error)
- type Plan
- type PlanCreateInput
- type PlanListParams
- type PlanUpdateInput
- type PlansResource
- func (r *PlansResource) Archive(ctx context.Context, id string) (*Plan, error)
- func (r *PlansResource) Create(ctx context.Context, in PlanCreateInput) (*Plan, error)
- func (r *PlansResource) Get(ctx context.Context, id string) (*Plan, error)
- func (r *PlansResource) List(ctx context.Context, params PlanListParams) (Page[Plan], error)
- func (r *PlansResource) Update(ctx context.Context, id string, patch PlanUpdateInput) (*Plan, error)
- type PnLReport
- type PnLReportLine
- type PortalSession
- type PortalSessionCreateInput
- type PortalSessionsResource
- type ReceiptListParams
- type ReceiptSummary
- type ReceiptsResource
- type Refund
- type RefundCreateInput
- type RefundListParams
- type RefundStatus
- type RefundsResource
- type ReportRangeParams
- type ReportsResource
- type RequestOptions
- type SignInput
- type SignResult
- type SourceType
- type Subscription
- type SubscriptionCreateInput
- type SubscriptionListParams
- type SubscriptionsResource
- func (r *SubscriptionsResource) Cancel(ctx context.Context, id string, at string) (*Subscription, error)
- func (r *SubscriptionsResource) Create(ctx context.Context, in SubscriptionCreateInput) (*Subscription, error)
- func (r *SubscriptionsResource) Get(ctx context.Context, id string) (*Subscription, error)
- func (r *SubscriptionsResource) List(ctx context.Context, params SubscriptionListParams) (Page[Subscription], error)
- func (r *SubscriptionsResource) Pause(ctx context.Context, id string, resumeAt *string) (*Subscription, error)
- func (r *SubscriptionsResource) Resume(ctx context.Context, id string) (*Subscription, error)
- type Template
- type TemplateCreateInput
- type TemplateKind
- type TemplateListParams
- type TemplatePreviewInput
- type TemplatePreviewResult
- type TemplateUpdateInput
- type TemplatesResource
- func (r *TemplatesResource) Create(ctx context.Context, in TemplateCreateInput) (*Template, error)
- func (r *TemplatesResource) Delete(ctx context.Context, id string) error
- func (r *TemplatesResource) Duplicate(ctx context.Context, id string, name *string) (*Template, error)
- func (r *TemplatesResource) Get(ctx context.Context, id string) (*Template, error)
- func (r *TemplatesResource) List(ctx context.Context, params TemplateListParams) ([]Template, error)
- func (r *TemplatesResource) MakeDefault(ctx context.Context, id string) (*Template, error)
- func (r *TemplatesResource) Preview(ctx context.Context, in TemplatePreviewInput) (*TemplatePreviewResult, error)
- func (r *TemplatesResource) Update(ctx context.Context, id string, patch TemplateUpdateInput) (*Template, error)
- type UploadImageInput
- type UploadedFile
- type UploadsResource
- type VerifyWebhookOptions
- type WebhookEndpoint
- type WebhookEndpointCreateInput
- type WebhookEndpointsResource
- type WebhookEvent
- type WebhookEventData
- type Workspace
- type WorkspaceCreateInput
- type WorkspaceMember
- type WorkspaceUpdateInput
- type WorkspacesResource
- func (r *WorkspacesResource) Create(ctx context.Context, in WorkspaceCreateInput) (*Workspace, error)
- func (r *WorkspacesResource) Delete(ctx context.Context, id string) error
- func (r *WorkspacesResource) List(ctx context.Context) ([]Workspace, error)
- func (r *WorkspacesResource) Update(ctx context.Context, id string, patch WorkspaceUpdateInput) (*Workspace, error)
Constants ¶
const DefaultBaseURL = "https://plugipay.com"
DefaultBaseURL is the production Plugipay endpoint. Override via ClientOptions.BaseURL or PLUGIPAY_BASE_URL.
const DefaultTimeout = 30 * time.Second
DefaultTimeout is the per-request timeout when ClientOptions.Timeout is zero.
Variables ¶
This section is empty.
Functions ¶
func AuthorizationHeader ¶
AuthorizationHeader returns the value for the Authorization header given a keyId and signature. Format is:
Plugipay-HMAC-SHA256 keyId=<id>, scope=*, signature=<hex>
func VerifyWebhookSignature ¶
func VerifyWebhookSignature( rawBody []byte, signatureHeader string, secret string, options *VerifyWebhookOptions, ) bool
VerifyWebhookSignature returns true iff the X-Plugipay-Signature header over the given raw request body validates against the secret within the tolerance window.
Plugipay signs webhooks with HMAC-SHA256 over `${timestamp}.${rawBody}` and sends the signature as
X-Plugipay-Signature: t=<unix>,v1=<hex>
Mount your webhook handler so that you can read the raw body — if a framework parses JSON first and re-stringifies, whitespace drift will break the signature. Pass the exact bytes that arrived on the wire.
net/http example:
func plugipayWebhook(w http.ResponseWriter, r *http.Request) {
body, err := io.ReadAll(r.Body)
if err != nil { http.Error(w, "bad body", 400); return }
sig := r.Header.Get("X-Plugipay-Signature")
if !plugipay.VerifyWebhookSignature(body, sig, os.Getenv("PLUGIPAY_WEBHOOK_SECRET"), nil) {
http.Error(w, "bad signature", 400); return
}
// unmarshal body into plugipay.WebhookEvent, dispatch.
}
Types ¶
type APIEnvelope ¶
type APIEnvelope struct {
Data json.RawMessage `json:"data"`
Error *APIError `json:"error,omitempty"`
Meta *EnvelopeMeta `json:"meta,omitempty"`
}
APIEnvelope is the standard Plugipay response shape: { data, error, meta }. Generic-free for simplicity — callers usually decode `Data` into a concrete type via json.Unmarshal a second time.
type APIError ¶
type APIError struct {
Code string `json:"code"`
Message string `json:"message"`
DocURL string `json:"docUrl,omitempty"`
}
APIError is the error block inside an envelope.
type AccountEmailChangeInput ¶
type AccountEmailChangeResult ¶
type AccountEmailChangeResult struct {
PendingVerification bool `json:"pendingVerification"`
}
type AccountProfile ¶
type AccountResource ¶
type AccountResource struct {
// contains filtered or unexported fields
}
AccountResource — /api/v1/account (merchant profile + sessions + linked accounts)
func (*AccountResource) ChangeEmail ¶
func (r *AccountResource) ChangeEmail(ctx context.Context, in AccountEmailChangeInput) (*AccountEmailChangeResult, error)
func (*AccountResource) ChangePassword ¶
func (r *AccountResource) ChangePassword(ctx context.Context, in AccountPasswordChangeInput) error
func (*AccountResource) Get ¶
func (r *AccountResource) Get(ctx context.Context) (*AccountProfile, error)
func (*AccountResource) ListLinked ¶
func (r *AccountResource) ListLinked(ctx context.Context) ([]LinkedAccount, error)
func (*AccountResource) ListMembers ¶
func (r *AccountResource) ListMembers(ctx context.Context) ([]WorkspaceMember, error)
func (*AccountResource) ListSessions ¶
func (r *AccountResource) ListSessions(ctx context.Context) ([]BrowserSession, error)
func (*AccountResource) RevokeAllSessions ¶
func (r *AccountResource) RevokeAllSessions(ctx context.Context) (*AccountRevokeAllResult, error)
func (*AccountResource) RevokeSession ¶
func (r *AccountResource) RevokeSession(ctx context.Context, id string) error
func (*AccountResource) Unlink ¶
func (r *AccountResource) Unlink(ctx context.Context, provider string) error
func (*AccountResource) Update ¶
func (r *AccountResource) Update(ctx context.Context, patch AccountUpdateInput) (*AccountProfile, error)
type AccountRevokeAllResult ¶
type AccountRevokeAllResult struct {
Revoked int64 `json:"revoked"`
}
type AccountUpdateInput ¶
type AccountUpdateInput struct {
Name *string `json:"name,omitempty"`
}
type AdapterConfig ¶
type AdapterConfig struct {
Kind AdapterKind `json:"kind"`
Configured bool `json:"configured"`
PublicConfig map[string]any `json:"publicConfig,omitempty"`
UpdatedAt string `json:"updatedAt,omitempty"`
}
type AdapterKind ¶
type AdapterKind string
const ( AdapterKindXendit AdapterKind = "xendit" AdapterKindPaypal AdapterKind = "paypal" AdapterKindMidtrans AdapterKind = "midtrans" AdapterKindManual AdapterKind = "manual" )
type AdaptersResource ¶
type AdaptersResource struct {
// contains filtered or unexported fields
}
AdaptersResource — /api/v1/adapters (payment provider config)
func (*AdaptersResource) List ¶
func (r *AdaptersResource) List(ctx context.Context) ([]AdapterConfig, error)
func (*AdaptersResource) ManagedOnboardingState ¶
func (r *AdaptersResource) ManagedOnboardingState(ctx context.Context) (*ManagedOnboardingState, error)
func (*AdaptersResource) SimulateManagedOnboarding ¶
func (r *AdaptersResource) SimulateManagedOnboarding(ctx context.Context, in ManagedOnboardingSimulateInput) (*ManagedOnboardingState, error)
func (*AdaptersResource) StartManagedOnboarding ¶
func (r *AdaptersResource) StartManagedOnboarding(ctx context.Context, in ManagedOnboardingStartInput) (*ManagedOnboardingState, error)
func (*AdaptersResource) UpdateManual ¶
func (r *AdaptersResource) UpdateManual(ctx context.Context, config map[string]any) (*AdapterConfig, error)
func (*AdaptersResource) UpdateMidtrans ¶
func (r *AdaptersResource) UpdateMidtrans(ctx context.Context, config map[string]any) (*AdapterConfig, error)
func (*AdaptersResource) UpdatePaypal ¶
func (r *AdaptersResource) UpdatePaypal(ctx context.Context, config map[string]any) (*AdapterConfig, error)
func (*AdaptersResource) UpdateXendit ¶
func (r *AdaptersResource) UpdateXendit(ctx context.Context, config map[string]any) (*AdapterConfig, error)
type AdminPartnerUsageParams ¶
type AdminPortalIdentity ¶
type AdminPortalResource ¶
type AdminPortalResource struct {
// contains filtered or unexported fields
}
AdminPortalResource — /api/v1/admin-portal (Plugipay internal operators)
func (*AdminPortalResource) CreatePartner ¶
func (r *AdminPortalResource) CreatePartner(ctx context.Context, in map[string]any) (json.RawMessage, error)
func (*AdminPortalResource) DeletePartner ¶
func (r *AdminPortalResource) DeletePartner(ctx context.Context, id string) error
func (*AdminPortalResource) ListBillingAccounts ¶
func (r *AdminPortalResource) ListBillingAccounts(ctx context.Context) ([]json.RawMessage, error)
func (*AdminPortalResource) ListPartners ¶
func (r *AdminPortalResource) ListPartners(ctx context.Context) ([]json.RawMessage, error)
func (*AdminPortalResource) Me ¶
func (r *AdminPortalResource) Me(ctx context.Context) (*AdminPortalIdentity, error)
func (*AdminPortalResource) UpdateBillingAccount ¶
func (r *AdminPortalResource) UpdateBillingAccount(ctx context.Context, accountID string, patch map[string]any) (json.RawMessage, error)
func (*AdminPortalResource) UpdatePartner ¶
func (r *AdminPortalResource) UpdatePartner(ctx context.Context, id string, patch map[string]any) (json.RawMessage, error)
type AdminResource ¶
type AdminResource struct {
// contains filtered or unexported fields
}
AdminResource — /api/v1/admin (requires plugipay:platform:admin scope)
func (*AdminResource) GetWorkspace ¶
func (r *AdminResource) GetWorkspace(ctx context.Context, accountID string) (*PartnerWorkspace, error)
func (*AdminResource) PartnerUsage ¶
func (r *AdminResource) PartnerUsage(ctx context.Context, p AdminPartnerUsageParams) (*PartnerUsageSummary, error)
func (*AdminResource) ProvisionWorkspace ¶
func (r *AdminResource) ProvisionWorkspace(ctx context.Context, in AdminProvisionWorkspaceInput) (*PartnerWorkspace, error)
type ApiKey ¶
type ApiKey struct {
ID string `json:"id"`
AccountID string `json:"accountId"`
KeyID string `json:"keyId"`
Description *string `json:"description"`
Scope string `json:"scope"`
Secret string `json:"secret,omitempty"` // only on create
CreatedAt string `json:"createdAt"`
RevokedAt *string `json:"revokedAt"`
}
type ApiKeyCreateInput ¶
type ApiKeysResource ¶
type ApiKeysResource struct {
// contains filtered or unexported fields
}
ApiKeysResource — /api/v1/api-keys
func (*ApiKeysResource) Create ¶
func (r *ApiKeysResource) Create(ctx context.Context, in ApiKeyCreateInput) (*ApiKey, error)
type AvailableBalance ¶
type BankAccount ¶
type BankAccountInput ¶
type BillingRefreshResult ¶
type BillingRefreshResult struct {
Refreshed bool `json:"refreshed"`
}
type BillingResource ¶
type BillingResource struct {
// contains filtered or unexported fields
}
BillingResource — /api/v1/billing (merchant subscription to Plugipay itself)
func (*BillingResource) ListPlans ¶
func (r *BillingResource) ListPlans(ctx context.Context) ([]Plan, error)
func (*BillingResource) ListTiers ¶
func (r *BillingResource) ListTiers(ctx context.Context) ([]BillingTier, error)
func (*BillingResource) RefreshTiers ¶
func (r *BillingResource) RefreshTiers(ctx context.Context) (*BillingRefreshResult, error)
type BillingTier ¶
type BrowserSession ¶
type CashFlowBucket ¶
type CashFlowReport ¶
type CheckoutMethod ¶
type CheckoutMethod string
const ( CheckoutMethodQRIS CheckoutMethod = "qris" CheckoutMethodVA CheckoutMethod = "va" CheckoutMethodEwallet CheckoutMethod = "ewallet" CheckoutMethodCard CheckoutMethod = "card" CheckoutMethodRetail CheckoutMethod = "retail" CheckoutMethodPaypal CheckoutMethod = "paypal" )
type CheckoutSession ¶
type CheckoutSession struct {
ID string `json:"id"`
AccountID string `json:"accountId"`
CustomerID *string `json:"customerId"`
Amount int64 `json:"amount"`
Currency CurrencyCode `json:"currency"`
Status string `json:"status"`
Methods []CheckoutMethod `json:"methods"`
Adapter *string `json:"adapter"`
LineItems json.RawMessage `json:"lineItems"`
SuccessURL string `json:"successUrl"`
CancelURL string `json:"cancelUrl"`
HostedURL string `json:"hostedUrl"`
ExpiresAt string `json:"expiresAt"`
CompletedAt *string `json:"completedAt"`
Metadata map[string]string `json:"metadata"`
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
}
type CheckoutSessionCreateInput ¶
type CheckoutSessionCreateInput struct {
Amount int64 `json:"amount"`
Currency CurrencyCode `json:"currency"`
Methods []CheckoutMethod `json:"methods"`
SuccessURL string `json:"successUrl"`
CancelURL string `json:"cancelUrl"`
CustomerID *string `json:"customerId,omitempty"`
LineItems []CheckoutSessionLineItem `json:"lineItems"`
ExpiresInSec *int `json:"expiresInSec,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
TemplateID *string `json:"templateId,omitempty"`
}
type CheckoutSessionLineItem ¶
type CheckoutSessionsResource ¶
type CheckoutSessionsResource struct {
// contains filtered or unexported fields
}
CheckoutSessionsResource — /api/v1/checkout-sessions
func (*CheckoutSessionsResource) Cancel ¶
func (r *CheckoutSessionsResource) Cancel(ctx context.Context, id string) (*CheckoutSession, error)
func (*CheckoutSessionsResource) Confirm ¶
func (r *CheckoutSessionsResource) Confirm(ctx context.Context, id string) (*CheckoutSession, error)
func (*CheckoutSessionsResource) Create ¶
func (r *CheckoutSessionsResource) Create(ctx context.Context, in CheckoutSessionCreateInput) (*CheckoutSession, error)
func (*CheckoutSessionsResource) Get ¶
func (r *CheckoutSessionsResource) Get(ctx context.Context, id string) (*CheckoutSession, error)
func (*CheckoutSessionsResource) List ¶
func (r *CheckoutSessionsResource) List(ctx context.Context, params CheckoutSessionListParams) (Page[CheckoutSession], error)
type CheckoutSettings ¶
type CheckoutSettings struct {
AccountID string `json:"accountId"`
BrandLogoURL *string `json:"brandLogoUrl"`
BrandColor *string `json:"brandColor"`
DefaultTemplateID *string `json:"defaultTemplateId"`
TermsURL *string `json:"termsUrl"`
PrivacyURL *string `json:"privacyUrl"`
UpdatedAt string `json:"updatedAt"`
}
type CheckoutSettingsResource ¶
type CheckoutSettingsResource struct {
// contains filtered or unexported fields
}
CheckoutSettingsResource — /api/v1/checkout/settings
func (*CheckoutSettingsResource) Get ¶
func (r *CheckoutSettingsResource) Get(ctx context.Context) (*CheckoutSettings, error)
func (*CheckoutSettingsResource) Update ¶
func (r *CheckoutSettingsResource) Update(ctx context.Context, patch CheckoutSettingsUpdateInput) (*CheckoutSettings, error)
type CheckoutSettingsUpdateInput ¶
type CheckoutSettingsUpdateInput struct {
BrandLogoURL *string `json:"brandLogoUrl,omitempty"`
BrandColor *string `json:"brandColor,omitempty"`
DefaultTemplateID *string `json:"defaultTemplateId,omitempty"`
TermsURL *string `json:"termsUrl,omitempty"`
PrivacyURL *string `json:"privacyUrl,omitempty"`
}
type Client ¶
type Client struct {
// Resource groups — exposed as fields so callers do
// c.Customers.Get(...) just like the Node SDK does c.customers.get(...).
Customers *CustomersResource
Plans *PlansResource
CheckoutSessions *CheckoutSessionsResource
Invoices *InvoicesResource
Subscriptions *SubscriptionsResource
PortalSessions *PortalSessionsResource
Receipts *ReceiptsResource
Payouts *PayoutsResource
Ledger *LedgerResource
Reports *ReportsResource
WebhookEndpoints *WebhookEndpointsResource
Events *EventsResource
Refunds *RefundsResource
Adapters *AdaptersResource
ApiKeys *ApiKeysResource
Billing *BillingResource
Onboarding *OnboardingResource
CheckoutSettings *CheckoutSettingsResource
Templates *TemplatesResource
Uploads *UploadsResource
Workspaces *WorkspacesResource
Account *AccountResource
AdminPortal *AdminPortalResource
Admin *AdminResource
// contains filtered or unexported fields
}
Client is the main SDK entry point. Construct with NewClient. Safe for concurrent use by multiple goroutines.
func NewClient ¶
func NewClient(opts ClientOptions) (*Client, error)
NewClient builds a configured client. Returns an error if KeyID or Secret cannot be resolved from options or env.
func (*Client) Do ¶
Do executes a signed request and unmarshals the envelope's `data` into out. Returns *Error on any failure. If out is nil, the response body is decoded but discarded — useful for endpoints that return void/empty payloads (DELETE, revoke, etc).
func (*Client) ForMerchant ¶
ForMerchant returns a shallow clone scoped to a different on-behalf-of account id — useful when a platform-admin key is reused across many merchant accounts. The clone shares the underlying *http.Client.
func (*Client) OnBehalfOf ¶
OnBehalfOf returns the default on-behalf-of merchant id, if any.
type ClientOptions ¶
type ClientOptions struct {
// HMAC access key id (e.g. "ak_live_..."). Defaults to PLUGIPAY_KEY_ID.
KeyID string
// HMAC secret. Defaults to PLUGIPAY_SECRET.
Secret string
// Base URL. Defaults to PLUGIPAY_BASE_URL or DefaultBaseURL.
BaseURL string
// Optional merchant accountId to scope calls against. Forwarded as
// X-Plugipay-On-Behalf-Of. Only allowed for platform-admin keys.
// Defaults to PLUGIPAY_ON_BEHALF_OF.
OnBehalfOf string
// Per-request timeout. Zero falls back to DefaultTimeout.
Timeout time.Duration
// HTTP client. Nil falls back to a fresh http.Client (does NOT use
// http.DefaultClient — we want our own Timeout default).
HTTP *http.Client
}
ClientOptions configures a Client. KeyID + Secret are required; the rest default from env vars (PLUGIPAY_KEY_ID, PLUGIPAY_SECRET, PLUGIPAY_BASE_URL, PLUGIPAY_ON_BEHALF_OF) so a zero-value ClientOptions{} works in production environments where the standard env vars are set.
type CurrencyCode ¶
type CurrencyCode string
const ( CurrencyIDR CurrencyCode = "IDR" CurrencyUSD CurrencyCode = "USD" )
type CustomerCreateInput ¶
type CustomerListParams ¶
type CustomerUpdateInput ¶
type CustomersResource ¶
type CustomersResource struct {
// contains filtered or unexported fields
}
CustomersResource — /api/v1/customers
func (*CustomersResource) Create ¶
func (r *CustomersResource) Create(ctx context.Context, in CustomerCreateInput) (*Customer, error)
func (*CustomersResource) List ¶
func (r *CustomersResource) List(ctx context.Context, params CustomerListParams) (Page[Customer], error)
func (*CustomersResource) Update ¶
func (r *CustomersResource) Update(ctx context.Context, id string, patch CustomerUpdateInput) (*Customer, error)
type EnvelopeMeta ¶
type EnvelopeMeta struct {
RequestID string `json:"requestId,omitempty"`
Timestamp string `json:"timestamp,omitempty"`
Cursor *string `json:"cursor,omitempty"`
HasMore bool `json:"hasMore,omitempty"`
}
EnvelopeMeta covers all known meta fields. Cursor + HasMore appear on list endpoints; RequestID + Timestamp appear on every response.
type Error ¶
type Error struct {
// HTTP status code. 0 for transport-layer failures (timeout, DNS, etc).
Status int
// Stable error code (e.g. "rate_limited", "signature_invalid",
// "network_error", "timeout", "invalid_response").
Code string
// Human-readable message. Safe to surface to operators; not safe to
// surface to end users without context.
Message string
// RequestID from the API envelope's meta block, when present.
RequestID string
}
Error is the single error type returned by every SDK operation. Wraps an HTTP status code, an opaque error code from the backend, a message, and an optional request id so callers can branch on well-defined reasons without matching strings.
Use errors.As to extract:
var pe *plugipay.Error
if errors.As(err, &pe) && pe.Code == "rate_limited" { ... }
type EventListParams ¶
type EventRecord ¶
type EventsResource ¶
type EventsResource struct {
// contains filtered or unexported fields
}
EventsResource — /api/v1/events
func (*EventsResource) Get ¶
func (r *EventsResource) Get(ctx context.Context, id string) (*EventRecord, error)
func (*EventsResource) List ¶
func (r *EventsResource) List(ctx context.Context, params EventListParams) (Page[EventRecord], error)
type Invoice ¶
type Invoice struct {
ID string `json:"id"`
AccountID string `json:"accountId"`
CustomerID string `json:"customerId"`
Status string `json:"status"`
Number string `json:"number"`
Currency CurrencyCode `json:"currency"`
Subtotal int64 `json:"subtotal"`
Discount int64 `json:"discount"`
Tax int64 `json:"tax"`
Total int64 `json:"total"`
AmountPaid int64 `json:"amountPaid"`
AmountDue int64 `json:"amountDue"`
DueAt *string `json:"dueAt"`
IssuedAt *string `json:"issuedAt"`
PaidAt *string `json:"paidAt"`
HostedInvoiceURL *string `json:"hostedInvoiceUrl"`
Lines []InvoiceLine `json:"lines"`
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
}
type InvoiceCreateInput ¶
type InvoiceCreateInput struct {
CustomerID string `json:"customerId"`
Currency CurrencyCode `json:"currency"`
Lines []InvoiceCreateLine `json:"lines"`
Discount *int64 `json:"discount,omitempty"`
Tax *int64 `json:"tax,omitempty"`
DueAt *string `json:"dueAt,omitempty"`
Status *string `json:"status,omitempty"` // draft | open
Memo *string `json:"memo,omitempty"`
}
type InvoiceCreateLine ¶
type InvoiceLine ¶
type InvoiceListParams ¶
type InvoiceSendEmailResult ¶
InvoiceSendEmailResult — what /send-email returns.
type InvoicesResource ¶
type InvoicesResource struct {
// contains filtered or unexported fields
}
InvoicesResource — /api/v1/invoices
func (*InvoicesResource) Create ¶
func (r *InvoicesResource) Create(ctx context.Context, in InvoiceCreateInput) (*Invoice, error)
func (*InvoicesResource) List ¶
func (r *InvoicesResource) List(ctx context.Context, params InvoiceListParams) (Page[Invoice], error)
func (*InvoicesResource) SendEmail ¶
func (r *InvoicesResource) SendEmail(ctx context.Context, id string, to *string) (*InvoiceSendEmailResult, error)
type LedgerBalance ¶
type LedgerEntry ¶
type LedgerEntry struct {
ID string `json:"id"`
AccountID string `json:"accountId"`
TxID string `json:"txId"`
Code string `json:"code"`
Direction string `json:"direction"`
Amount int64 `json:"amount"`
Currency string `json:"currency"`
SourceType string `json:"sourceType"`
SourceID string `json:"sourceId"`
Memo *string `json:"memo"`
PostedAt string `json:"postedAt"`
}
type LedgerListParams ¶
type LedgerListParams struct {
Limit *int `json:"limit,omitempty"`
Cursor *string `json:"cursor,omitempty"`
Order *string `json:"order,omitempty"`
TxID *string `json:"txId,omitempty"`
Code *string `json:"code,omitempty"`
SourceType *string `json:"sourceType,omitempty"`
SourceID *string `json:"sourceId,omitempty"`
}
type LedgerResource ¶
type LedgerResource struct {
// contains filtered or unexported fields
}
LedgerResource — /api/v1/ledger
func (*LedgerResource) Balances ¶
func (r *LedgerResource) Balances(ctx context.Context) ([]LedgerBalance, error)
func (*LedgerResource) List ¶
func (r *LedgerResource) List(ctx context.Context, params LedgerListParams) (Page[LedgerEntry], error)
type LinkedAccount ¶
type ManagedOnboardingSimulateInput ¶
type ManagedOnboardingSimulateInput struct {
Result string `json:"result"` // verified | failed
}
type ManagedOnboardingStartInput ¶
type ManagedOnboardingStartInput struct {
Kind AdapterKind `json:"kind"`
Details map[string]any `json:"details,omitempty"`
}
type ManagedOnboardingState ¶
type OnboardingResource ¶
type OnboardingResource struct {
// contains filtered or unexported fields
}
OnboardingResource — /api/v1/onboarding
func (*OnboardingResource) ProvisionManaged ¶
func (r *OnboardingResource) ProvisionManaged(ctx context.Context, in OnboardingProvisionManagedInput) (*Workspace, error)
type Page ¶
type Page[T any] struct { Data []T `json:"data"` Cursor *string `json:"cursor"` HasMore bool `json:"hasMore"` }
Page wraps a list-endpoint result. Mirrors the Node SDK's requestList return shape: { data, cursor, hasMore }.
type PartnerUsageLine ¶
type PartnerUsageSummary ¶
type PartnerWorkspace ¶
type Payout ¶
type Payout struct {
ID string `json:"id"`
AccountID string `json:"accountId"`
Amount int64 `json:"amount"`
Currency string `json:"currency"`
Status PayoutStatus `json:"status"`
Method PayoutMethod `json:"method"`
BankCode *string `json:"bankCode"`
BankName string `json:"bankName"`
BankAccountNumber string `json:"bankAccountNumber"`
BankAccountHolder string `json:"bankAccountHolder"`
Note *string `json:"note"`
Reference *string `json:"reference"`
FailureReason *string `json:"failureReason"`
LedgerTransactionID *string `json:"ledgerTransactionId"`
ProcessedAt *string `json:"processedAt"`
CompletedAt *string `json:"completedAt"`
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
}
type PayoutCreateInput ¶
type PayoutCreateInput struct {
Amount int64 `json:"amount"`
Currency CurrencyCode `json:"currency"`
BankCode *string `json:"bankCode,omitempty"`
BankName *string `json:"bankName,omitempty"`
BankAccountNumber *string `json:"bankAccountNumber,omitempty"`
BankAccountHolder *string `json:"bankAccountHolder,omitempty"`
Note *string `json:"note,omitempty"`
}
type PayoutListParams ¶
type PayoutListParams struct {
Limit *int `json:"limit,omitempty"`
Cursor *string `json:"cursor,omitempty"`
Status *PayoutStatus `json:"status,omitempty"`
}
type PayoutMethod ¶
type PayoutMethod string
const ( PayoutMethodManual PayoutMethod = "manual" PayoutMethodXenditDisbursement PayoutMethod = "xendit_disbursement" )
type PayoutStatus ¶
type PayoutStatus string
const ( PayoutStatusPending PayoutStatus = "pending" PayoutStatusInTransit PayoutStatus = "in_transit" PayoutStatusPaid PayoutStatus = "paid" PayoutStatusFailed PayoutStatus = "failed" PayoutStatusCancelled PayoutStatus = "cancelled" )
type PayoutsResource ¶
type PayoutsResource struct {
// contains filtered or unexported fields
}
PayoutsResource — /api/v1/payouts
func (*PayoutsResource) Balance ¶
func (r *PayoutsResource) Balance(ctx context.Context) (*AvailableBalance, error)
func (*PayoutsResource) Create ¶
func (r *PayoutsResource) Create(ctx context.Context, in PayoutCreateInput) (*Payout, error)
func (*PayoutsResource) GetBankAccount ¶
func (r *PayoutsResource) GetBankAccount(ctx context.Context) (*BankAccount, error)
func (*PayoutsResource) List ¶
func (r *PayoutsResource) List(ctx context.Context, params PayoutListParams) (Page[Payout], error)
func (*PayoutsResource) MarkFailed ¶
func (*PayoutsResource) MarkInTransit ¶
func (*PayoutsResource) UpdateBankAccount ¶
func (r *PayoutsResource) UpdateBankAccount(ctx context.Context, in BankAccountInput) (*BankAccount, error)
type Plan ¶
type Plan struct {
ID string `json:"id"`
AccountID string `json:"accountId"`
Name string `json:"name"`
Currency CurrencyCode `json:"currency"`
Interval string `json:"interval"`
Amount int64 `json:"amount"`
Active bool `json:"active"`
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
}
type PlanCreateInput ¶
type PlanCreateInput struct {
Name string `json:"name"`
Currency CurrencyCode `json:"currency"`
Amount int64 `json:"amount"`
Interval string `json:"interval"` // day | week | month | year
}
type PlanListParams ¶
type PlanUpdateInput ¶
type PlansResource ¶
type PlansResource struct {
// contains filtered or unexported fields
}
PlansResource — /api/v1/plans
func (*PlansResource) Create ¶
func (r *PlansResource) Create(ctx context.Context, in PlanCreateInput) (*Plan, error)
func (*PlansResource) List ¶
func (r *PlansResource) List(ctx context.Context, params PlanListParams) (Page[Plan], error)
func (*PlansResource) Update ¶
func (r *PlansResource) Update(ctx context.Context, id string, patch PlanUpdateInput) (*Plan, error)
type PnLReportLine ¶
type PortalSession ¶
type PortalSessionsResource ¶
type PortalSessionsResource struct {
// contains filtered or unexported fields
}
PortalSessionsResource — /api/v1/portal-sessions
func (*PortalSessionsResource) Create ¶
func (r *PortalSessionsResource) Create(ctx context.Context, in PortalSessionCreateInput) (*PortalSession, error)
type ReceiptListParams ¶
type ReceiptListParams struct {
Limit *int `json:"limit,omitempty"`
Cursor *string `json:"cursor,omitempty"`
SourceType *string `json:"sourceType,omitempty"` // checkout_session | invoice
CustomerID *string `json:"customerId,omitempty"`
IssuedAfter *string `json:"issuedAfter,omitempty"`
IssuedBefore *string `json:"issuedBefore,omitempty"`
}
type ReceiptSummary ¶
type ReceiptSummary struct {
ID string `json:"id"`
Number string `json:"number"`
SourceType string `json:"sourceType"`
SourceID string `json:"sourceId"`
CustomerID *string `json:"customerId"`
Amount int64 `json:"amount"`
Currency string `json:"currency"`
Method *string `json:"method"`
Adapter *string `json:"adapter"`
IssuedAt string `json:"issuedAt"`
EmailedAt *string `json:"emailedAt"`
EmailedTo *string `json:"emailedTo"`
}
type ReceiptsResource ¶
type ReceiptsResource struct {
// contains filtered or unexported fields
}
ReceiptsResource — /api/v1/receipts
func (*ReceiptsResource) Get ¶
func (r *ReceiptsResource) Get(ctx context.Context, id string) (json.RawMessage, error)
Get returns the raw receipt payload — the backend shape here is richer than ReceiptSummary and intentionally opaque to the SDK.
func (*ReceiptsResource) List ¶
func (r *ReceiptsResource) List(ctx context.Context, params ReceiptListParams) (Page[ReceiptSummary], error)
type Refund ¶
type Refund struct {
ID string `json:"id"`
AccountID string `json:"accountId"`
Amount int64 `json:"amount"`
Currency CurrencyCode `json:"currency"`
Status RefundStatus `json:"status"`
Reason *string `json:"reason"`
SourceType SourceType `json:"sourceType"`
SourceID string `json:"sourceId"`
FailureReason *string `json:"failureReason"`
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
}
type RefundCreateInput ¶
type RefundCreateInput struct {
SourceType SourceType `json:"sourceType"` // checkout_session | invoice
SourceID string `json:"sourceId"`
Amount *int64 `json:"amount,omitempty"`
Reason *string `json:"reason,omitempty"`
}
type RefundListParams ¶
type RefundListParams struct {
Limit *int `json:"limit,omitempty"`
Cursor *string `json:"cursor,omitempty"`
Status *RefundStatus `json:"status,omitempty"`
SourceID *string `json:"sourceId,omitempty"`
}
type RefundStatus ¶
type RefundStatus string
const ( RefundStatusPending RefundStatus = "pending" RefundStatusSucceeded RefundStatus = "succeeded" RefundStatusFailed RefundStatus = "failed" RefundStatusCanceled RefundStatus = "canceled" )
type RefundsResource ¶
type RefundsResource struct {
// contains filtered or unexported fields
}
RefundsResource — /api/v1/refunds
func (*RefundsResource) Create ¶
func (r *RefundsResource) Create(ctx context.Context, in RefundCreateInput) (*Refund, error)
func (*RefundsResource) List ¶
func (r *RefundsResource) List(ctx context.Context, params RefundListParams) (Page[Refund], error)
type ReportRangeParams ¶
type ReportsResource ¶
type ReportsResource struct {
// contains filtered or unexported fields
}
ReportsResource — /api/v1/reports
func (*ReportsResource) CashFlow ¶
func (r *ReportsResource) CashFlow(ctx context.Context, p ReportRangeParams) (*CashFlowReport, error)
func (*ReportsResource) PnL ¶
func (r *ReportsResource) PnL(ctx context.Context, p ReportRangeParams) (*PnLReport, error)
type RequestOptions ¶
type RequestOptions struct {
Method string // GET, POST, PATCH, PUT, DELETE
Path string // e.g. "/api/v1/customers"
Body any // serialized via json.Marshal; nil → no body
IdempotencyKey string
OnBehalfOf string // overrides the client default
}
RequestOptions tunes a single call. Body, IdempotencyKey, OnBehalfOf are all optional. Query is appended as a URL querystring (sorted-key order is not guaranteed; signatures cover the path-as-sent).
type SignInput ¶
type SignInput struct {
Method string
Path string
Body string
IdempotencyKey string
Timestamp int64 // unix seconds. If 0, time.Now().Unix() is used.
}
SignInput captures the bytes that go into a Plugipay HMAC signature. The string-to-sign is:
METHOD\nPATH\nTIMESTAMP\nHEX(SHA256(BODY))[\nIDEMPOTENCY_KEY]
where BODY is the raw request body as serialized over the wire (the empty string if no body), and IDEMPOTENCY_KEY is appended only when non-empty. This must match sdk/node/src/client.ts#sign and sdk/python/plugipay/_client.py#_sign byte-for-byte — drift will break every authenticated request.
type SignResult ¶
SignResult is the output of Sign — signature plus the timestamp that went into it (callers need both to set the request headers).
func Sign ¶
func Sign(secret string, in SignInput) SignResult
Sign computes the HMAC-SHA256 signature for a Plugipay API request. Exposed so callers building lower-level integrations (proxies, per-merchant fan-out, custom retry loops) can re-derive the exact signature without going through Client.
type SourceType ¶
type SourceType string
const ( SourceTypeCheckoutSession SourceType = "checkout_session" SourceTypeInvoice SourceType = "invoice" )
type Subscription ¶
type Subscription struct {
ID string `json:"id"`
AccountID string `json:"accountId"`
CustomerID string `json:"customerId"`
PlanID string `json:"planId"`
Status string `json:"status"`
CurrentPeriodStart string `json:"currentPeriodStart"`
CurrentPeriodEnd string `json:"currentPeriodEnd"`
CancelAtPeriodEnd bool `json:"cancelAtPeriodEnd"`
TrialEndsAt *string `json:"trialEndsAt"`
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
}
type SubscriptionCreateInput ¶
type SubscriptionCreateInput struct {
CustomerID string `json:"customerId"`
PlanID string `json:"planId"`
PriceID string `json:"priceId"`
TrialDays *int `json:"trialDays,omitempty"`
PaymentTokenID *string `json:"paymentTokenId,omitempty"`
CollectionMethod *string `json:"collectionMethod,omitempty"` // charge_automatically | send_invoice
Metadata map[string]string `json:"metadata,omitempty"`
InitialDiscount *int64 `json:"initialDiscount,omitempty"`
}
type SubscriptionListParams ¶
type SubscriptionsResource ¶
type SubscriptionsResource struct {
// contains filtered or unexported fields
}
SubscriptionsResource — /api/v1/subscriptions
func (*SubscriptionsResource) Cancel ¶
func (r *SubscriptionsResource) Cancel(ctx context.Context, id string, at string) (*Subscription, error)
Cancel — pass "now" or "period_end" (default).
func (*SubscriptionsResource) Create ¶
func (r *SubscriptionsResource) Create(ctx context.Context, in SubscriptionCreateInput) (*Subscription, error)
func (*SubscriptionsResource) Get ¶
func (r *SubscriptionsResource) Get(ctx context.Context, id string) (*Subscription, error)
func (*SubscriptionsResource) List ¶
func (r *SubscriptionsResource) List(ctx context.Context, params SubscriptionListParams) (Page[Subscription], error)
func (*SubscriptionsResource) Pause ¶
func (r *SubscriptionsResource) Pause(ctx context.Context, id string, resumeAt *string) (*Subscription, error)
Pause — optional resumeAt ISO timestamp.
func (*SubscriptionsResource) Resume ¶
func (r *SubscriptionsResource) Resume(ctx context.Context, id string) (*Subscription, error)
type TemplateCreateInput ¶
type TemplateCreateInput struct {
Kind TemplateKind `json:"kind"`
Name string `json:"name"`
Document map[string]any `json:"document"`
}
type TemplateKind ¶
type TemplateKind string
const ( TemplateKindCheckout TemplateKind = "checkout" TemplateKindReceipt TemplateKind = "receipt" TemplateKindInvoice TemplateKind = "invoice" )
type TemplateListParams ¶
type TemplateListParams struct {
Kind *TemplateKind `json:"kind,omitempty"`
}
type TemplatePreviewInput ¶
type TemplatePreviewInput struct {
Kind TemplateKind `json:"kind"`
Document map[string]any `json:"document"`
SampleData map[string]any `json:"sampleData,omitempty"`
}
type TemplatePreviewResult ¶
type TemplatePreviewResult struct {
HTML string `json:"html"`
}
type TemplateUpdateInput ¶
type TemplatesResource ¶
type TemplatesResource struct {
// contains filtered or unexported fields
}
TemplatesResource — /api/v1/templates
func (*TemplatesResource) Create ¶
func (r *TemplatesResource) Create(ctx context.Context, in TemplateCreateInput) (*Template, error)
func (*TemplatesResource) Delete ¶
func (r *TemplatesResource) Delete(ctx context.Context, id string) error
func (*TemplatesResource) List ¶
func (r *TemplatesResource) List(ctx context.Context, params TemplateListParams) ([]Template, error)
func (*TemplatesResource) MakeDefault ¶
func (*TemplatesResource) Preview ¶
func (r *TemplatesResource) Preview(ctx context.Context, in TemplatePreviewInput) (*TemplatePreviewResult, error)
func (*TemplatesResource) Update ¶
func (r *TemplatesResource) Update(ctx context.Context, id string, patch TemplateUpdateInput) (*Template, error)
type UploadImageInput ¶
type UploadedFile ¶
type UploadsResource ¶
type UploadsResource struct {
// contains filtered or unexported fields
}
UploadsResource — /api/v1/uploads
func (*UploadsResource) Image ¶
func (r *UploadsResource) Image(ctx context.Context, in UploadImageInput) (*UploadedFile, error)
Image uploads a base64-encoded image. Pass raw bytes + filename + mime.
type VerifyWebhookOptions ¶
type VerifyWebhookOptions struct {
// ToleranceSeconds rejects signatures with a timestamp older than this
// many seconds. Zero or negative means "use the default" (300).
ToleranceSeconds int64
// Now is the clock used for the freshness check. Nil means time.Now.
// Useful in tests.
Now func() time.Time
}
VerifyWebhookOptions tunes the webhook verifier.
type WebhookEndpoint ¶
type WebhookEndpoint struct {
ID string `json:"id"`
AccountID string `json:"accountId"`
URL string `json:"url"`
Events []string `json:"events"`
Description *string `json:"description"`
Active bool `json:"active"`
Secret string `json:"secret,omitempty"` // only on create
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
}
type WebhookEndpointsResource ¶
type WebhookEndpointsResource struct {
// contains filtered or unexported fields
}
WebhookEndpointsResource — /api/v1/webhook-endpoints
func (*WebhookEndpointsResource) Create ¶
func (r *WebhookEndpointsResource) Create(ctx context.Context, in WebhookEndpointCreateInput) (*WebhookEndpoint, error)
func (*WebhookEndpointsResource) Delete ¶
func (r *WebhookEndpointsResource) Delete(ctx context.Context, id string) error
func (*WebhookEndpointsResource) List ¶
func (r *WebhookEndpointsResource) List(ctx context.Context) ([]WebhookEndpoint, error)
type WebhookEvent ¶
type WebhookEvent struct {
ID string `json:"id"`
Type string `json:"type"`
AccountID string `json:"accountId"`
OccurredAt string `json:"occurredAt"`
Data WebhookEventData `json:"data"`
}
WebhookEvent is the parsed webhook payload. The shape is type-tagged: inspect Type, then unmarshal Data.Object into the matching resource struct (CheckoutSession, Invoice, Subscription). Mirrors the discriminated-union in sdk/node/src/types.ts#WebhookEvent.
func VerifyWebhook ¶
func VerifyWebhook( rawBody []byte, signatureHeader string, secret string, options *VerifyWebhookOptions, ) (*WebhookEvent, error)
VerifyWebhook is the typed convenience wrapper: verifies the signature AND unmarshals the body into a WebhookEvent. Returns *Error on any failure (signature_missing, signature_malformed, signature_stale, signature_invalid, invalid_payload).
type WebhookEventData ¶
type WebhookEventData struct {
Object json.RawMessage `json:"object"`
}
WebhookEventData wraps the resource snapshot at event time. Object is kept as a RawMessage so callers can decode it into the concrete type they care about.
type WorkspaceCreateInput ¶
type WorkspaceMember ¶
type WorkspaceUpdateInput ¶
type WorkspacesResource ¶
type WorkspacesResource struct {
// contains filtered or unexported fields
}
WorkspacesResource — /api/v1/workspaces (merchant-facing CRUD)
func (*WorkspacesResource) Create ¶
func (r *WorkspacesResource) Create(ctx context.Context, in WorkspaceCreateInput) (*Workspace, error)
func (*WorkspacesResource) Delete ¶
func (r *WorkspacesResource) Delete(ctx context.Context, id string) error
func (*WorkspacesResource) List ¶
func (r *WorkspacesResource) List(ctx context.Context) ([]Workspace, error)
func (*WorkspacesResource) Update ¶
func (r *WorkspacesResource) Update(ctx context.Context, id string, patch WorkspaceUpdateInput) (*Workspace, error)
Source Files
¶
- account.go
- adapters.go
- admin.go
- api_keys.go
- auth.go
- billing_onboarding_settings.go
- checkout_sessions.go
- client.go
- customers.go
- errors.go
- invoices.go
- ledger_reports.go
- payouts.go
- plans.go
- portal_sessions.go
- receipts.go
- refunds.go
- resources.go
- subscriptions.go
- templates.go
- uploads_workspaces.go
- webhook_endpoints_events.go
- webhooks.go