An Elixir client for the App Store Server API.
Add app_store to your application's dependencies:
def deps do
[
{:app_store, "~> 0.5.0"}
]
endStart 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.
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.
See the complete HexDocs API reference.