creem

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package creem implements the payment.PaymentProvider interface for Creem (https://creem.io) hosted checkout.

Creem is a merchant-of-record payment provider for international SaaS sales. The adapter talks to Creem's REST API to create checkouts and verifies webhook payloads using HMAC-SHA256 signatures.

The adapter is stateless after construction and safe for concurrent use.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

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

Adapter implements payment.PaymentProvider for Creem.

func New

func New(cfg Config, opts ...Option) *Adapter

New constructs a Creem adapter.

func (*Adapter) BuildWebhookResponse

func (a *Adapter) BuildWebhookResponse(ctx context.Context, success bool, msg string) (*payment.WebhookResponse, error)

BuildWebhookResponse returns a 200 OK with empty body for Creem.

func (*Adapter) Configured

func (a *Adapter) Configured() bool

Configured reports whether the adapter has the minimum credentials.

func (*Adapter) CreateCheckout

func (a *Adapter) CreateCheckout(ctx context.Context, req *payment.CheckoutRequest) (*payment.CheckoutResult, error)

CreateCheckout creates a Creem checkout session and returns the hosted checkout URL.

req.ProductID must be a pre-registered Creem product id. req.TradeNo is passed as request_id and echoed back in webhook events.

func (*Adapter) Provider

func (a *Adapter) Provider() payment.Provider

Provider returns the gateway identifier.

func (*Adapter) QueryOrder

func (a *Adapter) QueryOrder(ctx context.Context, req *payment.OrderQuery) (*payment.OrderQueryResult, error)

QueryOrder is not currently supported by the Creem public API in this adapter. Returns an error wrapping payment.ErrProviderError.

func (*Adapter) VerifyWebhook

func (a *Adapter) VerifyWebhook(ctx context.Context, req *payment.WebhookVerifyRequest) (*payment.WebhookEvent, error)

VerifyWebhook verifies the creem-signature HMAC-SHA256 header and parses the JSON payload into a normalized WebhookEvent.

req.RawBody must be the exact bytes of the webhook request body. req.Signature is the creem-signature header value.

type Config

type Config struct {
	// APIKey is the Creem merchant API key (x-api-key header).
	APIKey string

	// WebhookSecret is the HMAC-SHA256 signing secret used to verify
	// webhook payloads (creem-signature header).
	WebhookSecret string

	// TestMode selects the test API endpoint (https://test-api.creem.io)
	// instead of the production endpoint (https://api.creem.io).
	TestMode bool

	// HTTPTimeout is the timeout for outbound API calls. Defaults to 30s.
	HTTPTimeout time.Duration
}

Config holds the Creem API credentials.

type Option

type Option func(*Config)

Option mutates Config.

func WithHTTPTimeout

func WithHTTPTimeout(d time.Duration) Option

WithHTTPTimeout sets the outbound HTTP timeout.

Jump to

Keyboard shortcuts

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