storekit

package
v1.260716.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package storekit implements Apple's In-App Purchase and StoreKit server APIs.

StoreKit API credentials are intentionally separate from App Store Connect API credentials. Retention Messaging signs a fresh JWT for every request.

Index

Constants

View Source
const (
	ProductionBaseURL = "https://api.storekit.apple.com/inApps/v1/messaging"
	SandboxBaseURL    = "https://api.storekit-sandbox.apple.com/inApps/v1/messaging"
)
View Source
const (
	StatePending  = "PENDING"
	StateApproved = "APPROVED"
	StateRejected = "REJECTED"
)

Variables

This section is empty.

Functions

func RemoveAllCredentials

func RemoveAllCredentials() error

func RemoveCredentials

func RemoveCredentials(name string) error

func SetDefaultCredentials

func SetDefaultCredentials(name string) error

func ShouldBypassKeychain

func ShouldBypassKeychain() bool

ShouldBypassKeychain reports whether StoreKit keychain access is disabled.

func StoreCredentials

func StoreCredentials(name string, credentials Credentials) error

StoreCredentials stores a credential in the system keychain when available.

func StoreCredentialsConfig

func StoreCredentialsConfig(name string, credentials Credentials) error

func StoreCredentialsConfigAt

func StoreCredentialsConfigAt(name string, credentials Credentials, path string) error

func ValidateMessage

func ValidateMessage(message Message) error

ValidateMessage checks documented Retention Messaging limits before upload.

func ValidateRealtimeURL

func ValidateRealtimeURL(value string) error

Types

type APIError

type APIError struct {
	StatusCode int
	Code       string
	Message    string
	RetryAfter time.Time
	Body       string
}

APIError describes an error returned by the Retention Messaging API.

func (*APIError) Error

func (e *APIError) Error() string

func (*APIError) HTTPStatusCode added in v1.260713.0

func (e *APIError) HTTPStatusCode() int

type Client

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

func NewClient

func NewClient(credentials Credentials, environment Environment, opts ...ClientOption) (*Client, error)

func (*Client) DeleteDefault

func (c *Client) DeleteDefault(ctx context.Context, productID, locale string) error

func (*Client) DeleteImage

func (c *Client) DeleteImage(ctx context.Context, identifier string) error

func (*Client) DeleteMessage

func (c *Client) DeleteMessage(ctx context.Context, identifier string) error

func (*Client) DeleteRealtimeURL

func (c *Client) DeleteRealtimeURL(ctx context.Context) error

func (*Client) GetDefault

func (c *Client) GetDefault(ctx context.Context, productID, locale string) (*DefaultMessageResponse, error)

func (*Client) GetPerformanceTestResult

func (c *Client) GetPerformanceTestResult(ctx context.Context, requestID string) (*PerformanceTestResult, error)

func (*Client) GetRealtimeURL

func (c *Client) GetRealtimeURL(ctx context.Context) (*RealtimeURLResponse, error)

func (*Client) ListImages

func (c *Client) ListImages(ctx context.Context) (*ImageListResponse, error)

func (*Client) ListMessages

func (c *Client) ListMessages(ctx context.Context) (*MessageListResponse, error)

func (*Client) SetDefault

func (c *Client) SetDefault(ctx context.Context, productID, locale, messageIdentifier string) (*DefaultMessageResponse, error)

func (*Client) SetRealtimeURL

func (c *Client) SetRealtimeURL(ctx context.Context, realtimeURL string) (*RealtimeURLResponse, error)

func (*Client) StartPerformanceTest

func (c *Client) StartPerformanceTest(ctx context.Context, originalTransactionID string) (*PerformanceTestStartResponse, error)

func (*Client) UploadImage

func (c *Client) UploadImage(ctx context.Context, identifier string, size ImageSize, data []byte) error

func (*Client) UploadMessage

func (c *Client) UploadMessage(ctx context.Context, identifier string, message Message) error

func (*Client) Validate

func (c *Client) Validate() error

Validate signs a token and parses the configured private key without making a network request.

type ClientOption

type ClientOption func(*Client)

func WithBaseURL

func WithBaseURL(baseURL string) ClientOption

WithBaseURL overrides the complete Retention Messaging API base URL. It exists for tests and Apple-compatible proxies.

func WithHTTPClient

func WithHTTPClient(httpClient *http.Client) ClientOption

func WithNow

func WithNow(now func() time.Time) ClientOption

type Credentials

type Credentials struct {
	KeyID          string
	IssuerID       string
	PrivateKeyPath string
	PrivateKeyPEM  string
	BundleID       string
	Profile        string
}

Credentials holds an In-App Purchase API key and its target app bundle ID.

func GetCredentialsWithSource

func GetCredentialsWithSource(profile string) (Credentials, string, error)

type DefaultMessageResponse

type DefaultMessageResponse struct {
	MessageIdentifier string `json:"messageIdentifier"`
}

type Environment

type Environment string

Environment selects the StoreKit server environment.

const (
	Production Environment = "production"
	Sandbox    Environment = "sandbox"
)

func ParseEnvironment

func ParseEnvironment(value string) (Environment, error)

ParseEnvironment validates a StoreKit environment.

type HeaderPosition

type HeaderPosition string

HeaderPosition controls where the header appears in a retention message.

const (
	HeaderAboveBody  HeaderPosition = "ABOVE_BODY"
	HeaderAboveImage HeaderPosition = "ABOVE_IMAGE"
)

type ImageIdentifier

type ImageIdentifier struct {
	ImageIdentifier string    `json:"imageIdentifier"`
	ImageSize       ImageSize `json:"imageSize"`
	ImageState      string    `json:"imageState"`
}

type ImageListResponse

type ImageListResponse struct {
	ImageIdentifiers []ImageIdentifier `json:"imageIdentifiers"`
}

type ImageSize

type ImageSize string

ImageSize is the placement for a Retention Messaging image.

const (
	ImageSizeFull        ImageSize = "FULL_SIZE"
	ImageSizeBulletPoint ImageSize = "BULLET_POINT"
)

type ImageState

type ImageState string

ImageState is Apple's review state for an uploaded image.

type Message

type Message struct {
	Header         string               `json:"header"`
	Body           string               `json:"body"`
	Image          *MessageImage        `json:"image,omitempty"`
	BulletPoints   []MessageBulletPoint `json:"bulletPoints,omitempty"`
	HeaderPosition HeaderPosition       `json:"headerPosition,omitempty"`
}

type MessageBulletPoint

type MessageBulletPoint struct {
	ImageIdentifier string `json:"imageIdentifier"`
	AltText         string `json:"altText"`
	Text            string `json:"text"`
}

type MessageIdentifier

type MessageIdentifier struct {
	MessageIdentifier string `json:"messageIdentifier"`
	MessageState      string `json:"messageState"`
}

type MessageImage

type MessageImage struct {
	ImageIdentifier string `json:"imageIdentifier"`
	AltText         string `json:"altText"`
}

type MessageListResponse

type MessageListResponse struct {
	MessageIdentifiers []MessageIdentifier `json:"messageIdentifiers"`
}

type MutationResult

type MutationResult struct {
	Resource    string      `json:"resource"`
	Identifier  string      `json:"identifier,omitempty"`
	Action      string      `json:"action"`
	Environment Environment `json:"environment"`
	Success     bool        `json:"success"`
}

MutationResult is the stable CLI response for an empty successful mutation.

type PerformanceResponseTimes

type PerformanceResponseTimes struct {
	Average int64 `json:"average,omitempty"`
	P50     int64 `json:"p50,omitempty"`
	P90     int64 `json:"p90,omitempty"`
	P95     int64 `json:"p95,omitempty"`
	P99     int64 `json:"p99,omitempty"`
}

type PerformanceTestConfig

type PerformanceTestConfig struct {
	MaxConcurrentRequests int64 `json:"maxConcurrentRequests"`
	ResponseTimeThreshold int64 `json:"responseTimeThreshold"`
	SuccessRateThreshold  int32 `json:"successRateThreshold"`
	TotalDuration         int64 `json:"totalDuration"`
	TotalRequests         int   `json:"totalRequests"`
}

type PerformanceTestResult

type PerformanceTestResult struct {
	Config        PerformanceTestConfig    `json:"config"`
	Failures      map[string]int32         `json:"failures,omitempty"`
	NumPending    int                      `json:"numPending,omitempty"`
	RequestID     string                   `json:"requestId,omitempty"`
	ResponseTimes PerformanceResponseTimes `json:"responseTimes,omitempty"`
	Result        string                   `json:"result"`
	SuccessRate   int32                    `json:"successRate,omitempty"`
	Target        string                   `json:"target,omitempty"`
}

type PerformanceTestStartResponse

type PerformanceTestStartResponse struct {
	Config    PerformanceTestConfig `json:"config"`
	RequestID string                `json:"requestId"`
}

type RealtimeURLResponse

type RealtimeURLResponse struct {
	RealtimeURL string `json:"realtimeURL"`
}

type StoredCredential

type StoredCredential struct {
	Credentials `json:"-"`
	Name        string `json:"name"`
	IsDefault   bool   `json:"default"`
	Source      string `json:"source"`
	SourcePath  string `json:"source_path,omitempty"`
}

func ListCredentials

func ListCredentials() ([]StoredCredential, error)

Jump to

Keyboard shortcuts

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