GameServer.Payments
(game_server_core v1.0.997)
Copy Markdown
Payment catalog, purchase ledger, and entitlements.
Provider-specific integrations validate or create transactions, but this context remains the source of truth for what a user owns inside the game.
Summary
Functions
@spec admin_stats() :: map()
@spec count_entitlements(keyword()) :: non_neg_integer()
@spec count_products(keyword()) :: non_neg_integer()
@spec count_provider_events(keyword()) :: non_neg_integer()
@spec count_provider_products(keyword()) :: non_neg_integer()
@spec count_purchases(keyword()) :: non_neg_integer()
@spec count_reconciliation_cursors(keyword()) :: non_neg_integer()
@spec create_product(map()) :: {:ok, GameServer.Payments.Product.t()} | {:error, Ecto.Changeset.t()}
@spec create_provider_product(map()) :: {:ok, GameServer.Payments.ProviderProduct.t()} | {:error, Ecto.Changeset.t()}
@spec create_purchase( GameServer.Accounts.User.t() | integer(), GameServer.Payments.ProviderProduct.t(), map() ) :: {:ok, GameServer.Payments.Purchase.t()} | {:error, Ecto.Changeset.t()}
@spec create_steam_checkout(GameServer.Accounts.User.t(), map()) :: {:ok, %{ purchase: GameServer.Payments.Purchase.t(), provider_transaction_id: String.t() | nil, steam_url: String.t() | nil }} | {:error, term()}
@spec create_stripe_checkout(GameServer.Accounts.User.t(), map()) :: {:ok, %{ purchase: GameServer.Payments.Purchase.t(), checkout_url: String.t(), provider_session_id: String.t() }} | {:error, term()}
@spec finalize_steam_purchase(GameServer.Accounts.User.t(), map()) :: {:ok, %{purchase: GameServer.Payments.Purchase.t()}} | {:error, term()}
@spec fulfill_purchase(GameServer.Payments.Purchase.t(), map()) :: {:ok, GameServer.Payments.Purchase.t()} | {:error, term()}
@spec get_product(integer()) :: GameServer.Payments.Product.t() | nil
@spec get_product_by_sku(String.t()) :: GameServer.Payments.Product.t() | nil
@spec get_provider_product(integer()) :: GameServer.Payments.ProviderProduct.t() | nil
@spec get_provider_product(String.t(), String.t()) :: GameServer.Payments.ProviderProduct.t() | nil
@spec get_purchase(integer()) :: GameServer.Payments.Purchase.t() | nil
@spec get_purchase_by_order_id(String.t()) :: GameServer.Payments.Purchase.t() | nil
@spec get_purchase_by_provider_original_transaction(String.t(), String.t()) :: GameServer.Payments.Purchase.t() | nil
@spec get_purchase_by_provider_transaction(String.t(), String.t()) :: GameServer.Payments.Purchase.t() | nil
@spec list_admin_entitlements(keyword()) :: [GameServer.Payments.Entitlement.t()]
@spec list_admin_products(keyword()) :: [GameServer.Payments.Product.t()]
@spec list_admin_provider_products(keyword()) :: [ GameServer.Payments.ProviderProduct.t() ]
@spec list_admin_purchases(keyword()) :: [GameServer.Payments.Purchase.t()]
@spec list_catalog(String.t() | nil) :: [GameServer.Payments.ProviderProduct.t()]
@spec list_products(keyword()) :: [GameServer.Payments.Product.t()]
@spec list_provider_events(keyword()) :: [GameServer.Payments.ProviderEvent.t()]
@spec list_reconciliation_cursors(keyword()) :: [ GameServer.Payments.ReconciliationCursor.t() ]
@spec list_user_entitlements( integer(), keyword() ) :: [GameServer.Payments.Entitlement.t()]
@spec list_user_purchases( integer(), keyword() ) :: [GameServer.Payments.Purchase.t()]
@spec product_entitlement_key(GameServer.Payments.Product.t()) :: String.t()
@spec provider_adapter_statuses() :: [map()]
@spec record_provider_event(String.t(), String.t(), String.t(), map(), map()) :: {:ok, GameServer.Payments.ProviderEvent.t(), boolean()} | {:error, Ecto.Changeset.t()}
@spec revoke_purchase(GameServer.Payments.Purchase.t(), map()) :: {:ok, GameServer.Payments.Purchase.t()} | {:error, term()}
@spec stripe_config_status() :: map()
@spec update_product(GameServer.Payments.Product.t(), map()) :: {:ok, GameServer.Payments.Product.t()} | {:error, Ecto.Changeset.t()}
@spec update_provider_product(GameServer.Payments.ProviderProduct.t(), map()) :: {:ok, GameServer.Payments.ProviderProduct.t()} | {:error, Ecto.Changeset.t()}
@spec validate_store_purchase(GameServer.Accounts.User.t(), String.t(), map()) :: {:ok, %{purchase: GameServer.Payments.Purchase.t(), seen_before: boolean()}} | {:error, term()}