Skip to content
linjunpopPublic

About

👩‍💻 An App Store Server API (StoreKit 2) client in Elixir.

Topics

Resources

Stars

20 stars

Watchers

2 watching

Forks

Latest commit

 

History

33 Commits

Folders and files

Repository files navigation

App Store

An Elixir client for the App Store Server API.

Installation

Add app_store to your application's dependencies:

def deps do
  [
    {:app_store, "~> 0.5.0"}
  ]
end

Quick Start

Start the default HTTP client under your application's supervisor:

children = [
  {AppStore.HTTPClient.DefaultClient, []}
]

Build the client, generate an App Store Connect API token, and call an endpoint:

app_store = AppStore.build()

{:ok, token, _claims} =
  AppStore.Token.generate_token(
    System.fetch_env!("APP_STORE_ISSUER_ID"),
    "com.example.app",
    %{
      id: System.fetch_env!("APP_STORE_KEY_ID"),
      pem: System.fetch_env!("APP_STORE_PRIVATE_KEY")
    }
  )

{:ok, %AppStore.API.Response{body: body, status: 200}} =
  AppStore.API.get_transaction_history(
    app_store.api_config,
    token,
    "original-transaction-id"
  )

signed_transactions = body["signedTransactions"]

API calls return {:ok, %AppStore.API.Response{}} or {:error, %AppStore.API.Error{}}. Signed responses should be verified before their purchase data is used.

Server Notifications

Use the framework-neutral notification decoder with the unmodified HTTP request body received from Apple:

config =
  AppStore.SignedDataVerifier.Config.build(
    environment: "Production",
    bundle_id: "com.example.app",
    app_apple_id: 123_456_789
  )

{:ok, notification} = AppStore.ServerNotifications.decode(config, request_body)

The decoder verifies the outer notification and any nested signed transaction or renewal data.

Guides

See the complete HexDocs API reference.

About

👩‍💻 An App Store Server API (StoreKit 2) client in Elixir.

Topics

Resources

Stars

20 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages