webhooks

package
v1.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 22, 2025 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package webhooks webhooks related Utilities

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CheckoutCompletedPayload added in v1.0.3

type CheckoutCompletedPayload struct {
	ID           string                      `json:"id,omitempty"`
	Object       string                      `json:"object,omitempty"`
	RequestID    string                      `json:"request_id,omitempty"`
	Order        *checkouts.Order            `json:"order,omitempty"`
	Product      *products.Product           `json:"product,omitempty"`
	Customer     *customers.Customer         `json:"customer,omitempty"`
	Subscription *subscriptions.Subscription `json:"subscription,omitempty"`
	CustomFields []creem.CustomField         `json:"custom_fields,omitempty"`
	Units        int64                       `json:"units,omitempty"`
	SuccessURL   string                      `json:"success_url,omitempty"`
	Status       checkouts.CheckoutStatus    `json:"status,omitempty"`
	Metadata     map[string]any              `json:"metadata,omitempty"`
	Mode         creem.Mode                  `json:"mode,omitempty"`
}

CheckoutCompletedPayload A checkout session was completed, returning all the information about the payment and the order created.

type DisputeCreate

type DisputeCreate struct {
	ID           string                      `json:"id,omitempty"`
	Object       string                      `json:"object,omitempty"`
	Amount       int64                       `json:"amount,omitempty"`
	Currency     string                      `json:"currency,omitempty"`
	Transaction  *transactions.Transaction   `json:"transaction,omitempty"`
	Subscription *subscriptions.Subscription `json:"subscription,omitempty"`
	Checkout     *checkouts.Checkout         `json:"checkout,omitempty"`
	Order        *checkouts.Order            `json:"order,omitempty"`
	Customer     *customers.Customer         `json:"customer,omitempty"`
	CreatedAt    time.Time                   `json:"created_at,omitzero"`
	Mode         creem.Mode                  `json:"mode,omitempty"`
}

DisputeCreate A dispute was created by the customer

type Event

type Event struct {
	// ID event id
	ID string `json:"id,omitempty"`
	// EventType type of the event
	EventType EventType `json:"eventType,omitempty"`
	// CreatedAt event created timestamp
	CreatedAt int64 `json:"created_at,omitempty"`
	// Object event payload
	Object json.RawMessage `json:"object,omitempty"`
}

type EventHandler

type EventHandler func(context.Context, *Event) error

type EventType

type EventType string
const (
	// CheckoutCompleted A checkout session was completed, returning all the information about the payment and the order created.
	CheckoutCompleted EventType = "checkout.completed"
	// SubscriptionActive Received when a new subscription is created, the payment was successful and Creem collected the payment creating a new subscription object in your account. Use only for synchronization, we encourage using subscription.paid for activating access.
	SubscriptionActive EventType = "subscription.active"
	// SubscriptionPaid A subscription transaction was paid by the customer
	SubscriptionPaid EventType = "subscription.paid"
	// SubscriptionCanceled A subscription transaction was canceled by the customer
	SubscriptionCanceled EventType = "subscription.canceled"
	// SubscriptionExpired The subscription was expired, given that the current_end_period has been reached without a new payment. Payment retries can happen at this stage, and the subscription status will be terminal only when status is changed to canceled.
	SubscriptionExpired EventType = "subscription.expired"
	// SubscriptionUpdate A subscription object was updated
	SubscriptionUpdate EventType = "subscription.update"
	// SubscriptionTrialing A subscription started a trial period
	SubscriptionTrialing EventType = "subscription.trialing"
	// RefundCreated A refund was created by the merchant
	RefundCreated EventType = "refund.created"
	// DisputedCreated A dispute was created by the customer
	DisputedCreated EventType = "dispute.created"
)

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler(secret []byte, handler EventHandler) *Handler

func (*Handler) Handle

func (h *Handler) Handle(req *http.Request) error

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type RefundCreatedPayload

type RefundCreatedPayload struct {
	ID             string                      `json:"id,omitempty"`
	Object         string                      `json:"object,omitempty"`
	Status         string                      `json:"status,omitempty"`
	RefundAmount   int64                       `json:"refund_amount,omitempty"`
	RefundCurrency string                      `json:"refund_currency,omitempty"`
	Reason         string                      `json:"reason,omitempty"`
	Transaction    *transactions.Transaction   `json:"transaction,omitempty"`
	Subscription   *subscriptions.Subscription `json:"subscriptions,omitempty"`
	Checkout       *checkouts.Checkout         `json:"checkout,omitempty"`
	Order          *checkouts.Order            `json:"order,omitempty"`
	Customer       *customers.Customer         `json:"customer,omitempty"`
	CreatedAt      time.Time                   `json:"created_at,omitzero"`
	Mode           creem.Mode                  `json:"mode,omitempty"`
}

RefundCreatedPayload A refund was created by the merchant

type SubscriptionActivePayload

type SubscriptionActivePayload SubscriptionPayload

SubscriptionActivePayload Received when a new subscription is created, the payment was successful and Creem collected the payment creating a new subscription object in your account. Use only for synchronization, we encourage using subscription.paid for activating access.

type SubscriptionCanceledPayload

type SubscriptionCanceledPayload struct {
	SubscriptionPayload
	LastTransactionID      string    `json:"last_transaction_id,omitempty"`
	LastTransactionDate    time.Time `json:"last_transaction_date,omitzero"`
	CurrentPeriodStartDate time.Time `json:"current_period_start_date,omitzero"`
	CurrentPeriodEndDate   time.Time `json:"current_period_end_date,omitzero"`
}

SubscriptionCanceledPayload The subscription was canceled by the merchant or by the customer.

type SubscriptionExpiredPayload

type SubscriptionExpiredPayload SubscriptionPaidPayload

SubscriptionExpiredPayload The subscription was expired, given that the current_end_period has been reached without a new payment. Payment retries can happen at this stage, and the subscription status will be terminal only when status is changed to canceled.

type SubscriptionPaidPayload

type SubscriptionPaidPayload struct {
	SubscriptionPayload
	LastTransactionID      string    `json:"last_transaction_id,omitempty"`
	LastTransactionDate    time.Time `json:"last_transaction_date,omitzero"`
	NextTransactionDate    time.Time `json:"next_transaction_date,omitzero"`
	CurrentPeriodStartDate time.Time `json:"current_period_start_date,omitzero"`
	CurrentPeriodEndDate   time.Time `json:"current_period_end_date,omitzero"`
}

SubscriptionPaidPayload A subscription transaction was paid by the customer

type SubscriptionPayload

type SubscriptionPayload struct {
	ID               string               `json:"id,omitempty"`
	Object           string               `json:"object,omitempty"`
	Product          *products.Product    `json:"product,omitempty"`
	Customer         *customers.Customer  `json:"customer,omitempty"`
	CollectionMethod string               `json:"collection_method,omitempty"`
	Status           subscriptions.Status `json:"status,omitempty"`
	CanceledAt       time.Time            `json:"canceled_at,omitzero"`
	CreatedAt        time.Time            `json:"created_at,omitzero"`
	UpdatedAt        time.Time            `json:"updated_at,omitzero"`
	Metadata         map[string]any       `json:"metadata,omitempty"`
	Mode             creem.Mode           `json:"mode,omitempty"`
}

SubscriptionPayload common payload in subscription events

type SubscriptionTrialingPayload

type SubscriptionTrialingPayload SubscriptionUpdatePayload

SubscriptionTrialingPayload A subscription started a trial period

type SubscriptionUpdatePayload

type SubscriptionUpdatePayload struct {
	SubscriptionPayload
	Items                  []subscriptions.SubscriptionItem `json:"items,omitempty"`
	CurrentPeriodStartDate time.Time                        `json:"current_period_start_date,omitzero"`
	CurrentPeriodEndDate   time.Time                        `json:"current_period_end_date,omitzero"`
}

SubscriptionUpdatePayload A subscription object was updated

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL