Documentation ¶
Index ¶
- Constants
- Variables
- func ValidatePayload(r *http.Request, secret []byte, checkIp bool) ([]byte, error)
- func ValidatePayloadRaw(contentType string, body []byte, signature string, secret []byte, ...) error
- type Customer
- type DeclineReason
- type Event
- type EventType
- type HeadlessBasket
- type HeadlessBasketAddPackageRequest
- type HeadlessBasketLinks
- type HeadlessClient
- func (c *HeadlessClient) BasketAddPackage(ctx context.Context, basketId string, body HeadlessBasketAddPackageRequest) (*HeadlessBasket, error)
- func (c *HeadlessClient) BasketApplyCreatorCode(ctx context.Context, webstoreId, basketId, creatorCode string) error
- func (c *HeadlessClient) BasketRemoveCreatorCode(ctx context.Context, webstoreId, basketId string) error
- func (c *HeadlessClient) CreateBasket(ctx context.Context, webstoreId string, body HeadlessCreateBasketRequest) (*HeadlessBasket, error)
- type HeadlessClientParams
- type HeadlessCreateBasketRequest
- type Payment
- type PaymentCompletedEvent
- type PaymentDeclinedEvent
- type PaymentDisputeClosedEvent
- type PaymentDisputeLostEvent
- type PaymentDisputeOpenedEvent
- type PaymentDisputeWonEvent
- type PaymentMethod
- type PaymentRefundedEvent
- type PaymentSequence
- type PaymentStatus
- type PaymentStatusType
- type Price
- type ProductPurchase
- type RecurringPayment
- type RecurringPaymentEndedEvent
- type RecurringPaymentRenewedEvent
- type RecurringPaymentStartedEvent
- type RecurringPaymentStatusChangedEvent
- type TebexWebhookData
- type User
- type ValidationEvent
- type Variable
Constants ¶
View Source
const DefaultBaseUrl = "https://headless.tebex.io"
Variables ¶
View Source
var ( ErrHeadlessWebstoreNotFound = fmt.Errorf("webstore not found") ErrHeadlessBasketNotFound = fmt.Errorf("basket not found") ErrHeadlessCreatorCodeNotFound = fmt.Errorf("creator code not found") )
View Source
var ( ErrInvalidIp = errors.New("invalid remote ip address") ErrInvalidContentType = errors.New("invalid content type") ErrMissingSignature = errors.New("missing signature") ErrInvalidSignature = errors.New("invalid signature") TebexWebhookIpAddresses = []string{"18.209.80.3", "54.87.231.232"} )
View Source
var DefaultHeadlessClient = NewHeadlessClient(DefaultBaseUrl)
Functions ¶
func ValidatePayload ¶
Types ¶
type DeclineReason ¶
type Event ¶
type Event struct { Id string `json:"id"` Type EventType `json:"type"` Date time.Time `json:"date"` Subject interface{} `json:"subject"` }
Event is the common wrapper around any Tebex event
func ParseEvent ¶
type EventType ¶
type EventType string
const ( ValidationEventType EventType = "validation.webhook" PaymentCompletedEventType EventType = "payment.completed" PaymentDeclinedEventType EventType = "payment.declined" PaymentRefundedEventType EventType = "payment.refunded" PaymentDisputeOpenedEventType EventType = "payment.dispute.opened" PaymentDisputeWonEventType EventType = "payment.dispute.won" PaymentDisputeLostEventType EventType = "payment.dispute.lost" PaymentDisputeClosedEventType EventType = "payment.dispute.closed" RecurringPaymentStartedEventType EventType = "recurring-payment.started" RecurringPaymentRenewedEventType EventType = "recurring-payment.renewed" RecurringPaymentEndedEventType EventType = "recurring-payment.ended" RecurringPaymentStatusChangedEventType EventType = "recurring-payment.status-changed" )
type HeadlessBasket ¶
type HeadlessBasket struct { Ident string `json:"ident"` Complete bool `json:"complete"` Id int `json:"id"` Country string `json:"country"` Ip string `json:"ip"` UsernameId string `json:"username_id"` Username string `json:"username"` BasePrice float64 `json:"base_price"` SalesTax float64 `json:"sales_tax"` TotalPrice float64 `json:"total"` Packages []any `json:"packages"` Coupons []any `json:"coupons"` GiftCards []any `json:"gift_cards"` CreatorCode string `json:"creator_code"` Links *HeadlessBasketLinks `json:"links"` }
type HeadlessBasketLinks ¶
type HeadlessBasketLinks struct {
Checkout string `json:"checkout"`
}
func (*HeadlessBasketLinks) UnmarshalJSON ¶
func (h *HeadlessBasketLinks) UnmarshalJSON(raw []byte) error
type HeadlessClient ¶
type HeadlessClient struct {
// contains filtered or unexported fields
}
func NewHeadlessClient ¶
func NewHeadlessClient(url string) *HeadlessClient
func NewHeadlessClientWithOptions ¶
func NewHeadlessClientWithOptions(params HeadlessClientParams) *HeadlessClient
func (*HeadlessClient) BasketAddPackage ¶
func (c *HeadlessClient) BasketAddPackage(ctx context.Context, basketId string, body HeadlessBasketAddPackageRequest) (*HeadlessBasket, error)
func (*HeadlessClient) BasketApplyCreatorCode ¶
func (c *HeadlessClient) BasketApplyCreatorCode(ctx context.Context, webstoreId, basketId, creatorCode string) error
func (*HeadlessClient) BasketRemoveCreatorCode ¶
func (c *HeadlessClient) BasketRemoveCreatorCode(ctx context.Context, webstoreId, basketId string) error
func (*HeadlessClient) CreateBasket ¶
func (c *HeadlessClient) CreateBasket(ctx context.Context, webstoreId string, body HeadlessCreateBasketRequest) (*HeadlessBasket, error)
type HeadlessClientParams ¶
type HeadlessCreateBasketRequest ¶
type HeadlessCreateBasketRequest struct { CompleteUrl string `json:"complete_url,omitempty"` CompleteAutoRedirect bool `json:"complete_auto_redirect,omitempty"` CancelUrl string `json:"cancel_url,omitempty"` Custom map[string]any `json:"custom,omitempty"` // Should be present for Minecraft webstores. Username string `json:"username,omitempty"` }
type Payment ¶
type Payment struct { TransactionId string `json:"transaction_id"` Status PaymentStatus `json:"status"` PaymentSequence PaymentSequence `json:"payment_sequence"` CreatedAt time.Time `json:"created_at"` Price Price `json:"price"` PricePaid Price `json:"price_paid"` PaymentMethod PaymentMethod `json:"payment_method"` Fees map[string]Price `json:"fees"` Customer Customer `json:"customer"` Products []*ProductPurchase `json:"products"` Coupons []interface{} `json:"coupons"` // todo GiftCards []interface{} `json:"gift_cards"` // todo RecurringPaymentReference *string `json:"recurring_payment_reference"` // Only present for recurring payments DeclineReason *DeclineReason `json:"decline_reason"` // Only present for payment.declined (I think) }
type PaymentCompletedEvent ¶
type PaymentCompletedEvent Payment
type PaymentDeclinedEvent ¶
type PaymentDeclinedEvent Payment
type PaymentDisputeClosedEvent ¶
type PaymentDisputeClosedEvent Payment
type PaymentDisputeLostEvent ¶
type PaymentDisputeLostEvent Payment
type PaymentDisputeOpenedEvent ¶
type PaymentDisputeOpenedEvent Payment
type PaymentDisputeWonEvent ¶
type PaymentDisputeWonEvent Payment
type PaymentMethod ¶
type PaymentRefundedEvent ¶
type PaymentRefundedEvent Payment
type PaymentSequence ¶
type PaymentSequence string
const ( PaymentSequenceOneOff PaymentSequence = "oneoff" PaymentSequenceFirst PaymentSequence = "first" )
type PaymentStatus ¶
type PaymentStatus struct { Id PaymentStatusType `json:"id"` Description string `json:"description"` }
type PaymentStatusType ¶
type PaymentStatusType int
const ( PaymentStatus__0 PaymentStatusType = iota // Unknown, is there a 0 entry?? PaymentStatusComplete PaymentStatusRefund PaymentStatus__3 // Unknown PaymentStatus__4 // Unknown PaymentStatusCancelled )
type ProductPurchase ¶
type ProductPurchase struct { Id int `json:"id"` Name string `json:"name"` Quantity int `json:"quantity"` BasePrice Price `json:"base_price"` PaidPrice Price `json:"paid_price"` Variables []*Variable `json:"variables"` ExpiresAt *time.Time `json:"expires_at"` Custom *string `json:"custom"` Username User `json:"username"` }
type RecurringPayment ¶
type RecurringPayment struct { Reference string `json:"reference"` CreatedAt time.Time `json:"created_at"` NextPaymentAt time.Time `json:"next_payment_at"` Status PaymentStatus `json:"status"` InitialPayment Payment `json:"initial_payment"` LastPayment Payment `json:"last_payment"` FailCount int `json:"fail_count"` Price Price `json:"price"` CancelledAt *time.Time `json:"cancelled_at"` // Only present if Status.Id == PaymentStatusCancelled CancelReason *string `json:"cancel_reason"` // Only present if Status.Id == PaymentStatusCancelled }
type RecurringPaymentEndedEvent ¶
type RecurringPaymentEndedEvent RecurringPayment
type RecurringPaymentRenewedEvent ¶
type RecurringPaymentRenewedEvent RecurringPayment
type RecurringPaymentStartedEvent ¶
type RecurringPaymentStartedEvent RecurringPayment
type RecurringPaymentStatusChangedEvent ¶
type RecurringPaymentStatusChangedEvent RecurringPayment
type TebexWebhookData ¶
type ValidationEvent ¶
type ValidationEvent struct { }
ValidationEvent is sent by Tebex when the webhook is added to the project to verify that it expects to receive Tebex webhooks.
type = `validation.webhook`
Click to show internal directories.
Click to hide internal directories.