Documentation
ΒΆ
Index ΒΆ
- Variables
- func VerifyWebhookSignature(payload []byte, signature string, ipnSecret string) bool
- type APIError
- type Client
- func (c *Client) CheckHealth(ctx context.Context) (map[string]interface{}, error)
- func (c *Client) CreateInvoice(ctx context.Context, req CreateInvoiceRequest) (*CreateInvoiceResponse, error)
- func (c *Client) GetInvoice(ctx context.Context, invoiceID string) (*GetInvoiceResponse, error)
- func (c *Client) ListInvoices(ctx context.Context, query ListInvoicesQuery) (*ListInvoicesResponse, error)
- type ClientOption
- type CreateInvoiceRequest
- type CreateInvoiceResponse
- type GetInvoiceResponse
- type Invoice
- type ListInvoicesQuery
- type ListInvoicesResponse
- type PaymentRecord
- type WebhookEvent
Constants ΒΆ
This section is empty.
Variables ΒΆ
var ( // ErrInvalidSignature is returned when the webhook HMAC signature does not match. ErrInvalidSignature = errors.New("kkhay: invalid webhook signature") )
Functions ΒΆ
Types ΒΆ
type APIError ΒΆ
type APIError struct {
Status int `json:"status"`
Message string `json:"message"`
Code string `json:"code,omitempty"`
Details interface{} `json:"details,omitempty"`
}
APIError represents an error response returned by the K Khay API.
type Client ΒΆ
type Client struct {
// contains filtered or unexported fields
}
Client is the official Go HTTP client for K Khay Payment Gateway.
func NewClient ΒΆ
func NewClient(apiKey string, opts ...ClientOption) (*Client, error)
NewClient constructs a new K Khay API client.
func (*Client) CheckHealth ΒΆ
CheckHealth queries API health status.
func (*Client) CreateInvoice ΒΆ
func (c *Client) CreateInvoice(ctx context.Context, req CreateInvoiceRequest) (*CreateInvoiceResponse, error)
CreateInvoice creates a new sovereign crypto payment invoice.
func (*Client) GetInvoice ΒΆ
GetInvoice retrieves an existing invoice by UUID.
func (*Client) ListInvoices ΒΆ
func (c *Client) ListInvoices(ctx context.Context, query ListInvoicesQuery) (*ListInvoicesResponse, error)
ListInvoices queries and paginates merchant invoices.
type ClientOption ΒΆ
type ClientOption func(*Client)
ClientOption configures a Client instance.
func WithHTTPClient ΒΆ
func WithHTTPClient(client *http.Client) ClientOption
WithHTTPClient sets a custom http.Client.
func WithTimeout ΒΆ
func WithTimeout(timeout time.Duration) ClientOption
WithTimeout sets a custom request timeout.
type CreateInvoiceRequest ΒΆ
type CreateInvoiceRequest struct {
PriceAmount float64 `json:"priceAmount"`
PriceCurrency string `json:"priceCurrency,omitempty"`
PayNetwork string `json:"payNetwork"`
PayToken string `json:"payToken"`
OrderID string `json:"orderId,omitempty"`
Title string `json:"title,omitempty"`
CustomerName string `json:"customerName,omitempty"`
CustomerEmail string `json:"customerEmail,omitempty"`
RedirectURL string `json:"redirectUrl,omitempty"`
CancelURL string `json:"cancelUrl,omitempty"`
IPNCallbackURL string `json:"ipnCallbackUrl,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
CreateInvoiceRequest parameters for generating a new crypto invoice.
type CreateInvoiceResponse ΒΆ
CreateInvoiceResponse contains the created invoice and status.
type GetInvoiceResponse ΒΆ
type GetInvoiceResponse struct {
OK bool `json:"ok"`
Invoice Invoice `json:"invoice"`
Payments []PaymentRecord `json:"payments"`
}
GetInvoiceResponse contains the requested invoice and transaction records.
type Invoice ΒΆ
type Invoice struct {
ID string `json:"id"`
MerchantID string `json:"merchantId"`
OrderID *string `json:"orderId"`
Title *string `json:"title"`
PriceAmount float64 `json:"priceAmount"`
PriceCurrency string `json:"priceCurrency"`
PayAmount string `json:"payAmount"`
PayToken string `json:"payToken"`
PayNetwork string `json:"payNetwork"`
DepositAddress string `json:"depositAddress"`
Status string `json:"status"`
FeeAmount string `json:"feeAmount"`
NetAmount string `json:"netAmount"`
SettlementMode *string `json:"settlementMode"`
PaymentMethod *string `json:"paymentMethod"`
HostedURL string `json:"hostedUrl"`
RedirectURL *string `json:"redirectUrl"`
CancelURL *string `json:"cancelUrl"`
ExpiresAt string `json:"expiresAt"`
CreatedAt string `json:"createdAt"`
}
Invoice represents a K Khay invoice record.
type ListInvoicesQuery ΒΆ
type ListInvoicesQuery struct {
Page int `json:"page,omitempty"`
Limit int `json:"limit,omitempty"`
Status string `json:"status,omitempty"`
Search string `json:"search,omitempty"`
}
ListInvoicesQuery parameters for pagination and filtering.
type ListInvoicesResponse ΒΆ
type ListInvoicesResponse struct {
OK bool `json:"ok"`
Items []Invoice `json:"items"`
TotalCount int `json:"totalCount"`
TotalPages int `json:"totalPages"`
CurrentPage int `json:"currentPage"`
Limit int `json:"limit"`
}
ListInvoicesResponse paginated list of merchant invoices.
type PaymentRecord ΒΆ
type PaymentRecord struct {
ID string `json:"id"`
TxHash string `json:"txHash"`
AmountReceived string `json:"amountReceived"`
Confirmations int `json:"confirmations"`
Status string `json:"status"`
ForwardedTxHash *string `json:"forwardedTxHash"`
CreatedAt string `json:"createdAt"`
}
PaymentRecord details on-chain transaction hashes and confirmations.
type WebhookEvent ΒΆ
type WebhookEvent struct {
Event string `json:"event"`
InvoiceID string `json:"invoice_id"`
OrderID *string `json:"order_id"`
PriceAmount float64 `json:"price_amount"`
PriceCurrency string `json:"price_currency"`
PayAmount string `json:"pay_amount"`
PayToken string `json:"pay_token"`
PayNetwork string `json:"pay_network"`
DepositAddress string `json:"deposit_address"`
TxHash *string `json:"tx_hash"`
Status string `json:"status"`
Timestamp string `json:"timestamp"`
}
WebhookEvent payload sent via IPN.
func ParseWebhookEvent ΒΆ
func ParseWebhookEvent(rawBody []byte, signature string, ipnSecret string) (*WebhookEvent, error)
ParseWebhookEvent validates signature and parses the raw JSON body into WebhookEvent.