Download the PHP package busuu/ios-receipts-api without Composer
On this page you can find all versions of the php package busuu/ios-receipts-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package ios-receipts-api
PHP IOS Receipt validation library
A library to get information on auto-renewing subscriptions from the App Store receipts API, as described in the IOS documentation.
This is useful for:
- maintaining on your server an up-to-date database of your IOS users' auto-renewing subscriptions
- giving cross-platform access to users based on their IOS purchases
- knowing the type of plans a user has subscribed to, when is the plan expiration date, has the user requested a cancellation of the subscription
To retrieve information about a user's purchases from the App store, a receipt for this user must be sent to the App store. This receipt is stored as a file on the user's device. This receipt must then be sent from the IOS device to your server and stored by you, so that it can be used to retrieve the user's purchases afterward.
Features
- Abstracts the complexity of interacting with IOS receipts
- Extensively unit tested and used in production at Busuu, a language learning platform with 60M users
- Follows PSR-4 conventions and coding standard: autoload friendly
Requirements
- PHP >= 5.5
- Guzzle library,
- (optional) PHPUnit to run tests.
Installation
We recommend using composer to install this library.
Run this commands to install composer if you don't already have it:
Then install this library with:
Or edit composer.json
and add:
Basic usage
You can generate your apple shared secret from iTunes Connect, see official documentation. In this example, "receipt_data" is the encoded receipt data that was sent by your app. This string should be base64-encoded by the app before being sent to the server. For more information read the following paragraph.
About the receipt data
Here's an excerpt from the official IOS documentation relative to sending the receipt data from the app to your server (source).
Read the Receipt Data
To retrieve the receipt data, use the appStoreReceiptURL method of NSBundle to locate the app’s receipt, and then read the entire file. If the appStoreReceiptURL method is not available, you can fall back to the value of a transaction's transactionReceipt property for backward compatibility. Then send this data to your server—as with all interactions with your server, the details are your responsibility.
Possible issues
This method of validating IOS purchases relies on the API returning information about payments more recent than the generation date of receipt that was sent to the API. This API feature has been deprecated since IOS 7 and it's unclear if Apple will go forward with removing it entirely or if they will provide a replacement API for it. As far as we know, some major businesses rely on this feature to provide cross-platform subscriptions, so it seems unlikely to sudenly disappear. See relevant discussion.