A Ruby client for the App Store Server API, offering:
- Transaction history, transaction info, and subscription status endpoints
- Test notification and notification history endpoints
- Automatic ES256 JWT authentication with token refresh
- Helpers for decoding and verifying JWS payloads
- Built-in trust chain validation against Apple Root CAs
- Transaction history, transaction info, and subscription status endpoints
- Test notification and notification history endpoints
- Automatic ES256 JWT authentication with token refresh
- Helpers for decoding and verifying JWS payloads
- Built-in trust chain validation against Apple Root CAs
- Ruby 3.0 or higher
gem install app_store_server_apiAdd to your Gemfile:
gem 'app_store_server_api'Run:
bundle installTo get started, you must obtain the following:
In your Rails application, create a client configure
# my_app/config/app_store_server.yml
default: &default
private_key: |
-----BEGIN PRIVATE KEY-----
key_id: S4AZ693A4A
issuer_id: fd02853a-1290-4854-875e-918c86459b3e
bundle_id: com.myapp.app
environment: sandbox
development:
<<: *default
test:
<<: *default
production:
<<: *defaultLoad the configure
# my_app/config/application.rb
config.app_store_server = config_for :app_store_serverCreate a global client
# my_app/config/initializers/app_store_server_api.rb
AppStoreServerApiClient = AppStoreServerApi::Client.new(**Rails.configuration.app_store_server)Get Transaction History
data = client.get_transaction_history(transaction_id,
params: {
sort: "DESCENDING"
})
transactions = AppStoreServerApi::Utils::Decoder.decode_transactions signed_transactions: data["signedTransactions"]Get Transaction Info
client.get_transaction_info transaction_idGet All Subscription Statuses
response = client.get_all_subscription_statuses transaction_id
signed = response["data"].first["lastTransactions"].first["signedTransactionInfo"]
transaction = AppStoreServerApi::Utils::Decoder.decode_transaction signed_transaction: signedRequest a Test Notification
client.request_a_test_notificationUtils
- AppStoreServerApi::Utils::Decoder.decode_transaction
- AppStoreServerApi::Utils::Decoder.decode_jws!
The gem is available as open source under the terms of the MIT License.
Everyone interacting in the AppStoreServerApi project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.