PHPackages                             yanlongli/app-store-server-api - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. yanlongli/app-store-server-api

ActiveLibrary[Payment Processing](/categories/payments)

yanlongli/app-store-server-api
==============================

PHP client for App Store Server API. Manage your customers’ App Store transactions from your server.The App Store Server API is a REST API that you call from your server to request and provide information about your customers' in-app purchases. The App Store signs the transaction and subscription renewal information that this API returns using the JSON Web Signature (JWS) specification.App Store Server API is independent of the app’s installation status on the customer’s devices. The App Store server returns information based on the customer’s in-app purchase history regardless of whether the customer installed, removed, or reinstalled the app on their devices.To request transaction and subscription status information with this API, provide any original transaction identifier that belongs to the customer. The transaction history API responds with a complete list of transactions, 20 at a time, starting with the oldest first. The subscription status API returns the status for all of the customer’s subscriptions, organized by their subscription group identifier.Use the Send Consumption Information endpoint to send information to the App Store when customers request a refund for a consumable in-app purchase, after you receive the CONSUMPTION\_REQUEST App Store server notification. Your data helps inform refund decisions.

1.15(11mo ago)2532.0k↓21.1%6MITPHPPHP &gt;=7.1

Since Oct 22Pushed 11mo ago1 watchersCompare

[ Source](https://github.com/yanlong-li/AppStoreServerAPI)[ Packagist](https://packagist.org/packages/yanlongli/app-store-server-api)[ RSS](/packages/yanlongli-app-store-server-api/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (2)Versions (10)Used By (0)

App Store Server API / 苹果应用商店服务端 API
====================================

[](#app-store-server-api--苹果应用商店服务端-api)

> Manage your customers’ App Store transactions from your server. 从服务器管理客户的应用商店事务。譬如订阅状态、订单历史记录、退款记录、通知推送记录等

Overview
--------

[](#overview)

The App Store Server API is a REST API that you call from your server to request and provide information about your customers' in-app purchases. The App Store signs the transaction and subscription renewal information that this API returns using the [JSON Web Signature](https://datatracker.ietf.org/doc/html/rfc7515) (JWS) specification.

App Store Server API is independent of the app’s installation status on the customer’s devices. The App Store server returns information based on the customer’s in-app purchase history regardless of whether the customer installed, removed, or reinstalled the app on their devices.

To request transaction and subscription status information with this API, provide any original transaction identifier that belongs to the customer. The transaction history API responds with a complete list of transactions, 20 at a time, starting with the oldest first. The subscription status API returns the status for all of the customer’s subscriptions, organized by their subscription group identifier.

概述
--

[](#概述)

App Store Server API是一个REST API，您可以从服务器调用它来请求并提供有关您客户的应用内购买的信息。 应用商店将签署此API提供的交易和订阅续订信息使用[JSON Web签名](https://datatracker.ietf.org/doc/html/rfc7515)（JWS）规范返回。 应用商店服务器API独立于客户设备上的应用安装状态。 应用商店服务器根据客户的应用程序内购买历史记录返回信息，无论客户是否已安装， 已在其设备上删除或重新安装应用程序。 要使用此API请求事务和订阅状态信息，请提供任何原始事务标识符那是属于顾客的。 事务历史API响应一个完整的事务列表，每次20个，先从最老的开始。 subscription status API返回客户所有订阅的状态，由其订阅组标识符组织。

Use
---

[](#use)

the [Send Consumption Information](https://developer.apple.com/documentation/appstoreserverapi/send_consumption_information)endpoint to send information to the App Store when customers request a refund for a consumable in-app purchase, after you receive the App Store server notification. Your data helps inform refund decisions.CONSUMPTION\_REQUEST

Authorize Your API Calls
------------------------

[](#authorize-your-api-calls)

Calls to the API require JSON Web Tokens (JWT) for authorization; you obtain keys to create the tokens from your organization’s App Store Connect account. See [Creating API Keys to Use With the App Store Server API](https://developer.apple.com/documentation/appstoreserverapi/creating_api_keys_to_use_with_the_app_store_server_api)to create your keys. See [Generating Tokens for API Requests](https://developer.apple.com/documentation/appstoreserverapi/generating_tokens_for_api_requests)to generate tokens using your keys, and send API requests. After you have a complete and signed token, provide the token in the request’s authorization header as a bearer token.

Use the Sandbox Environment for Testing
---------------------------------------

[](#use-the-sandbox-environment-for-testing)

Most App Store Server APIs are available in the sandbox environment for testing. Access the sandbox environment by sending requests to the endpoints using the following base URL:

```
https://api.storekit-sandbox.itunes.apple.com/

```

For example, to call [Get Transaction History](https://developer.apple.com/documentation/appstoreserverapi/get_transaction_history) in the sandbox environment, send a request to:

```
https://api.storekit-sandbox.itunes.apple.com/inApps/v1/history/{originalTransactionId}

```

Note that in the path is case-sensitive./inApps

The Look Up Order ID endpoint isn’t available in the sandbox environment.

Params 参数
---------

[](#params-参数)

### IssuerID &amp; private key id &amp; private key 私钥获取方式

[](#issuerid--private-key-id--private-key-私钥获取方式)

[Creating API Keys for App Store Connect API Documentation](https://developer.apple.com/documentation/appstoreconnectapi/creating_api_keys_for_app_store_connect_api)

[创建 API Keys 的文档](https://developer.apple.com/documentation/appstoreconnectapi/creating_api_keys_for_app_store_connect_api)

```
https://appstoreconnect.apple.com/access/api
or
https://appstoreconnect.apple.com/access/api/subs

```

### app bundle id 应用 bundle id

[](#app-bundle-id-应用-bundle-id)

If you only manage a single application, you can pass the default settings in the constructor.

如果你仅管理单个应用，可以在构造函数中传递默认设定。

```
new \yanlongli\AppStoreServerApi\AppStoreServerApi(
    ...
    'bundleId',
);
```

If you want to manage multiple applications at the same time, you can pass bundleid in the specific interface to override the settings in the constructor.

如果你要同时管理多个应用，可以在具体的接口中传递 bundleId 以覆盖构造函数中的设定。

```
$example->subscriptions(...,'bundleId');
```

Example
-------

[](#example)

```
