Documentation
¶
Overview ¶
Package paymos provides the official server-side Go client for the Paymos Merchant API. It includes canonical HMAC signing, typed API errors, bounded cursor traversal, safe retries, and raw-body webhook verification.
Index ¶
- Constants
- Variables
- func AuthorizationHeader(apiKey, apiSecret, timestamp, method, path, query string, body []byte) string
- func BuildQuery(filters any) (string, error)
- func EncodePathSegment(value string) string
- func Sign(secret, value string) string
- func StringToSign(timestamp, method, path, query string, body []byte) string
- type APIError
- type Balance
- type BalancesService
- type Client
- type CreateInvoiceParams
- type CreateWithdrawalParams
- type HTTPDoer
- type Invoice
- type InvoiceListItem
- type InvoiceListParams
- type InvoiceStatus
- type InvoicesService
- func (s *InvoicesService) Cancel(ctx context.Context, id, reason string) (Invoice, error)
- func (s *InvoicesService) ConfirmPayment(ctx context.Context, id, currency, network string) (Invoice, error)
- func (s *InvoicesService) Create(ctx context.Context, payload CreateInvoiceParams) (Invoice, error)
- func (s *InvoicesService) Get(ctx context.Context, id string) (Invoice, error)
- func (s *InvoicesService) List(ctx context.Context, filters InvoiceListParams) (Page[InvoiceListItem], error)
- func (s *InvoicesService) SimulatePayment(ctx context.Context, id, stage string) (Invoice, error)
- type Iterator
- type Option
- type Order
- type Page
- type Payment
- type Problem
- type ProblemError
- type ServerTime
- type SystemService
- type Transfer
- type WebhookEvent
- type WebhookVerifier
- type Withdrawal
- type WithdrawalListParams
- type WithdrawalStatus
- type WithdrawalsService
- func (s *WithdrawalsService) Cancel(ctx context.Context, id, reason string) (Withdrawal, error)
- func (s *WithdrawalsService) Create(ctx context.Context, payload CreateWithdrawalParams) (Withdrawal, error)
- func (s *WithdrawalsService) Get(ctx context.Context, id string) (Withdrawal, error)
- func (s *WithdrawalsService) List(ctx context.Context, filters WithdrawalListParams) (Page[Withdrawal], error)
- func (s *WithdrawalsService) SimulateCompletion(ctx context.Context, id string) (Withdrawal, error)
Constants ¶
View Source
const Version = "2.1.1"
Variables ¶
View Source
var ErrWebhookSignature = errors.New("Paymos webhook signature mismatch")
View Source
var ErrWebhookTimestamp = errors.New("Paymos webhook timestamp outside tolerance")
Functions ¶
func AuthorizationHeader ¶
func BuildQuery ¶
func EncodePathSegment ¶
func StringToSign ¶
Types ¶
type BalancesService ¶
type BalancesService struct {
// contains filtered or unexported fields
}
type Client ¶
type Client struct {
Invoices *InvoicesService
Withdrawals *WithdrawalsService
Balances *BalancesService
System *SystemService
// contains filtered or unexported fields
}
type CreateInvoiceParams ¶
type CreateInvoiceParams struct {
ProjectID string `json:"project_id"`
Amount string `json:"amount"`
Currency string `json:"currency"`
ExternalOrderID string `json:"external_order_id"`
Network *string `json:"network,omitempty"`
AllowMultiplePayments *bool `json:"allow_multiple_payments,omitempty"`
CustomerFeePercent *int `json:"customer_fee_percent,omitempty"`
ClientID *string `json:"client_id,omitempty"`
}
type CreateWithdrawalParams ¶
type Invoice ¶
type Invoice struct {
InvoiceID string `json:"invoice_id"`
ProjectID string `json:"project_id"`
Status InvoiceStatus `json:"status"`
IsFinal bool `json:"is_final"`
IsTest bool `json:"is_test"`
PaymentURL string `json:"payment_url"`
Order Order `json:"order"`
Payment *Payment `json:"payment,omitempty"`
CreatedAt int64 `json:"created_at"`
UpdatedAt int64 `json:"updated_at"`
ExpiresAt *int64 `json:"expires_at,omitempty"`
CompletedAt *int64 `json:"completed_at,omitempty"`
}
type InvoiceListItem ¶
type InvoiceListItem struct {
InvoiceID string `json:"invoice_id"`
ProjectID string `json:"project_id"`
ExternalOrderID string `json:"external_order_id"`
ClientID *string `json:"client_id,omitempty"`
Status InvoiceStatus `json:"status"`
IsFinal bool `json:"is_final"`
IsTest bool `json:"is_test"`
Amount string `json:"amount"`
Currency string `json:"currency"`
Network *string `json:"network,omitempty"`
CreatedAt int64 `json:"created_at"`
ExpiresAt *int64 `json:"expires_at,omitempty"`
CompletedAt *int64 `json:"completed_at,omitempty"`
}
type InvoiceListParams ¶
type InvoiceListParams struct {
Limit int `json:"limit,omitempty"`
Cursor *string `json:"cursor,omitempty"`
Status []InvoiceStatus `json:"status,omitempty"`
ExternalOrderID *string `json:"external_order_id,omitempty"`
ProjectID *string `json:"project_id,omitempty"`
CreatedFrom *int64 `json:"created_from,omitempty"`
CreatedTo *int64 `json:"created_to,omitempty"`
}
type InvoiceStatus ¶
type InvoiceStatus string
const ( InvoiceAwaitingClient InvoiceStatus = "awaiting_client" InvoiceAwaitingPayment InvoiceStatus = "awaiting_payment" InvoiceConfirming InvoiceStatus = "confirming" InvoiceUnderpaidWaiting InvoiceStatus = "underpaid_waiting" InvoicePaid InvoiceStatus = "paid" InvoicePaidOver InvoiceStatus = "paid_over" InvoiceUnderpaid InvoiceStatus = "underpaid" InvoiceExpired InvoiceStatus = "expired" InvoiceCancelled InvoiceStatus = "cancelled" )
type InvoicesService ¶
type InvoicesService struct {
// contains filtered or unexported fields
}
func (*InvoicesService) ConfirmPayment ¶
func (*InvoicesService) Create ¶
func (s *InvoicesService) Create(ctx context.Context, payload CreateInvoiceParams) (Invoice, error)
func (*InvoicesService) List ¶
func (s *InvoicesService) List(ctx context.Context, filters InvoiceListParams) (Page[InvoiceListItem], error)
func (*InvoicesService) SimulatePayment ¶
type Iterator ¶
func NewInvoiceIterator ¶
func NewInvoiceIterator(service *InvoicesService, filters InvoiceListParams, maxPages int) *Iterator[InvoiceListItem, InvoiceListParams]
func NewWithdrawalIterator ¶
func NewWithdrawalIterator(service *WithdrawalsService, filters WithdrawalListParams, maxPages int) *Iterator[Withdrawal, WithdrawalListParams]
type Payment ¶
type Payment struct {
Currency string `json:"currency"`
Network string `json:"network"`
ChainID int64 `json:"chain_id"`
ContractAddress *string `json:"contract_address,omitempty"`
Expected string `json:"expected"`
Address *string `json:"address,omitempty"`
ExchangeRate *string `json:"exchange_rate,omitempty"`
Paid *string `json:"paid,omitempty"`
Remaining *string `json:"remaining,omitempty"`
Fee *string `json:"fee,omitempty"`
Net *string `json:"net,omitempty"`
Transfers []Transfer `json:"transfers,omitempty"`
}
type ProblemError ¶
type ServerTime ¶
type ServerTime struct {
ServerTime int64 `json:"server_time"`
}
type SystemService ¶
type SystemService struct {
// contains filtered or unexported fields
}
func (*SystemService) Time ¶
func (s *SystemService) Time(ctx context.Context) (ServerTime, error)
type Transfer ¶
type Transfer struct {
TxHash string `json:"tx_hash"`
Amount string `json:"amount"`
Status string `json:"status"`
CreatedAt int64 `json:"created_at"`
ConfirmedAt *int64 `json:"confirmed_at,omitempty"`
RequiredConfirmations *int `json:"required_confirmations,omitempty"`
EstimatedConfirmationAt *int64 `json:"estimated_confirmation_at,omitempty"`
ExplorerURL *string `json:"explorer_url,omitempty"`
}
type WebhookEvent ¶
type WebhookVerifier ¶
type WebhookVerifier struct {
// contains filtered or unexported fields
}
func NewWebhookVerifier ¶
func NewWebhookVerifier(secret string, tolerance time.Duration) (*WebhookVerifier, error)
func (*WebhookVerifier) ConstructEvent ¶
type Withdrawal ¶
type Withdrawal struct {
WithdrawalID string `json:"withdrawal_id"`
ExternalOrderID string `json:"external_order_id"`
Status WithdrawalStatus `json:"status"`
IsFinal bool `json:"is_final"`
IsTest bool `json:"is_test"`
Amount string `json:"amount"`
Fee *string `json:"fee,omitempty"`
Currency string `json:"currency"`
Network string `json:"network"`
DestinationAddress string `json:"destination_address"`
TxHash *string `json:"tx_hash,omitempty"`
ExplorerURL *string `json:"explorer_url,omitempty"`
CreatedAt int64 `json:"created_at"`
CompletedAt *int64 `json:"completed_at,omitempty"`
FailedAt *int64 `json:"failed_at,omitempty"`
CancelledAt *int64 `json:"cancelled_at,omitempty"`
}
type WithdrawalListParams ¶
type WithdrawalListParams struct {
Limit int `json:"limit,omitempty"`
Cursor *string `json:"cursor,omitempty"`
Status []WithdrawalStatus `json:"status,omitempty"`
ExternalOrderID *string `json:"external_order_id,omitempty"`
CreatedFrom *int64 `json:"created_from,omitempty"`
CreatedTo *int64 `json:"created_to,omitempty"`
}
type WithdrawalStatus ¶
type WithdrawalStatus string
const ( WithdrawalCreated WithdrawalStatus = "created" WithdrawalPendingReview WithdrawalStatus = "pending_review" WithdrawalSigned WithdrawalStatus = "signed" WithdrawalCancelling WithdrawalStatus = "cancelling" WithdrawalCompleted WithdrawalStatus = "completed" WithdrawalFailed WithdrawalStatus = "failed" WithdrawalCancelled WithdrawalStatus = "cancelled" )
type WithdrawalsService ¶
type WithdrawalsService struct {
// contains filtered or unexported fields
}
func (*WithdrawalsService) Cancel ¶
func (s *WithdrawalsService) Cancel(ctx context.Context, id, reason string) (Withdrawal, error)
func (*WithdrawalsService) Create ¶
func (s *WithdrawalsService) Create(ctx context.Context, payload CreateWithdrawalParams) (Withdrawal, error)
func (*WithdrawalsService) Get ¶
func (s *WithdrawalsService) Get(ctx context.Context, id string) (Withdrawal, error)
func (*WithdrawalsService) List ¶
func (s *WithdrawalsService) List(ctx context.Context, filters WithdrawalListParams) (Page[Withdrawal], error)
func (*WithdrawalsService) SimulateCompletion ¶
func (s *WithdrawalsService) SimulateCompletion(ctx context.Context, id string) (Withdrawal, error)
Click to show internal directories.
Click to hide internal directories.