Documentation
¶
Overview ¶
Package paymentwall provides a Go SDK for interacting with the Paymentwall APIs.
Package paymentwall provides a Go SDK for interacting with the Paymentwall APIs.
Package paymentwall provides a Go SDK for interacting with the Paymentwall APIs.
Package paymentwall provides a Go SDK for interacting with the Paymentwall APIs.
Index ¶
- Constants
- type APIType
- type Client
- type Pingback
- func (p *Pingback) ErrorSummary() string
- func (p *Pingback) GetPingbackUniqueID() string
- func (p *Pingback) GetProduct() (*Product, error)
- func (p *Pingback) GetProductID() string
- func (p *Pingback) GetProducts() ([]*Product, error)
- func (p *Pingback) GetReferenceID() string
- func (p *Pingback) GetType() (int, error)
- func (p *Pingback) GetUserID() string
- func (p *Pingback) GetVCAmount() string
- func (p *Pingback) IsCancelable() bool
- func (p *Pingback) IsDeliverable() bool
- func (p *Pingback) IsUnderReview() bool
- func (p *Pingback) Validate(skipIPWhitelist bool) bool
- type Product
- type SignatureVersion
- type Widget
Constants ¶
const ( VCController = "ps" GoodsController = "subscription" CartController = "cart" BaseURL = "https://api.paymentwall.com/api" VersionString = "0.1.1" )
const ( ProductTypeFixed = "fixed" ProductTypeSubscription = "subscription" )
ProductType constants
const ( PeriodDay = "day" PeriodWeek = "week" PeriodMonth = "month" PeriodYear = "year" )
PeriodType constants
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
Client holds global configuration and error state for the SDK.
func (*Client) AppendError ¶
AppendError records an error message in the client's error list.
func (*Client) CalculateSignature ¶
func (c *Client) CalculateSignature( params map[string]any, version SignatureVersion, ) (string, error)
CalculateSignature builds a signature string based on the provided parameters and version. It implements SigV1, SigV2, and SigV3 signature algorithms as per Paymentwall's documentation.
func (*Client) ErrorSummary ¶
ErrorSummary returns all recorded errors as a single string.
func (*Client) SetAPIType ¶
SetAPIType allows overriding the API type on an existing client.
type Pingback ¶
Pingback represents a Paymentwall webhook notification validator.
func NewPingback ¶
NewPingback constructs a Pingback with given params and source IP.
func (*Pingback) ErrorSummary ¶
ErrorSummary returns accumulated errors.
func (*Pingback) GetPingbackUniqueID ¶
GetPingbackUniqueID returns a unique ID composed of ref and type, e.g. "REF123_0".
func (*Pingback) GetProduct ¶
GetProduct reconstructs a Product from pingback parameters.
func (*Pingback) GetProductID ¶
GetProductID returns the product ID from "goodsid".
func (*Pingback) GetProducts ¶
GetProducts returns a slice of Products for Cart API.
func (*Pingback) GetReferenceID ¶
GetReferenceID returns the "ref" parameter.
func (*Pingback) GetVCAmount ¶
GetVCAmount returns the "currency" parameter for virtual currency.
func (*Pingback) IsCancelable ¶
IsCancelable returns true if pingback type indicates cancellation.
func (*Pingback) IsDeliverable ¶
IsDeliverable returns true if pingback type indicates delivery.
func (*Pingback) IsUnderReview ¶
IsUnderReview returns true if pingback type indicates under review.
type Product ¶
type Product struct {
ID string // Unique identifier for the product
Amount float64 // Price, rounded to two decimals
CurrencyCode string // ISO currency code, e.g., "USD"
Name string // Human-readable name
Type string // Product type: fixed or subscription
PeriodLength int // Subscription period length
PeriodType string // Subscription period unit: day, week, month, year
Recurring bool // Whether subscription auto-renews
TrialProduct *Product // Trial period product; non-nil only for recurring subscriptions
}
Product represents a one-time or subscription-based item in the Paymentwall SDK.
func NewProduct ¶
func NewProduct( id string, amount float64, currencyCode, name, prodType string, periodLength int, periodType string, recurring bool, trial *Product, ) (*Product, error)
NewProduct constructs and validates a Product, rounding amount to two decimals. Returns an error if prodType or periodType is invalid.
func (*Product) IsRecurring ¶
IsRecurring returns true if the product is a recurring subscription.
type SignatureVersion ¶
type SignatureVersion int
SignatureVersion denotes the version of the signature algorithm.
const ( SigV1 SignatureVersion = 1 // MD5(params + secret) SigV2 SignatureVersion = 2 // MD5(sorted params + secret) SigV3 SignatureVersion = 3 // SHA256(sorted params + secret) )
type Widget ¶
type Widget struct {
Client *Client
UserID string
WidgetCode string
Products []*Product
ExtraParams map[string]any
}
Widget builds Paymentwall widget URLs and HTML.
func NewWidget ¶
func NewWidget(client *Client, userID, widgetCode string, products []*Product, extra map[string]any) *Widget
NewWidget initializes a new Widget.
func (*Widget) GetHTMLCode ¶
GetHTMLCode returns the iframe HTML code for the widget.