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 ¶
- type Adapter
- func (a *Adapter) BuildWebhookResponse(ctx context.Context, success bool, msg string) (*payment.WebhookResponse, error)
- func (a *Adapter) Configured() bool
- func (a *Adapter) CreateCheckout(ctx context.Context, req *payment.CheckoutRequest) (*payment.CheckoutResult, error)
- func (a *Adapter) Provider() payment.Provider
- func (a *Adapter) QueryOrder(ctx context.Context, req *payment.OrderQuery) (*payment.OrderQueryResult, error)
- func (a *Adapter) VerifyWebhook(ctx context.Context, req *payment.WebhookVerifyRequest) (*payment.WebhookEvent, error)
- type Config
- type Option
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 (*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 ¶
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) 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.