2017 © Pedro PelĂĄez
 

project ios-receipts-api

image

busuu/ios-receipts-api

  • Friday, June 22, 2018
  • by arl91
  • Repository
  • 8 Watchers
  • 3 Stars
  • 2,289 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 18 Versions
  • 38 % Grown

The README.md

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., (*1)

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, (*2)

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., (*3)

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., (*4)

Run this commands to install composer if you don't already have it:, (*5)

$ curl -sS https://getcomposer.org/installer | php

Then install this library with:, (*6)

$ php composer.phar require busuu/ios-receipts-api

Or edit composer.json and add:, (*7)

{
    "require": {
        "busuu/ios-receipts-api": "~1.0"
    }
}

Basic usage

<?php

// This file is generated by Composer
require_once 'vendor/autoload.php';

$client = \Busuu\IosReceiptsApi\Factory\ReceiptServiceFactory::createReceiptService('your_apple_shared_secret');
$client->setReceiptData('receipt_data');
$purchase = $client->getLastPurchase();
echo $purchase->getExpiresDate();

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., (*8)

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)., (*9)

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. ``` // Load the receipt from the app bundle. NSURL receiptURL = [[NSBundle mainBundle] appStoreReceiptURL]; NSData *receipt = [NSData dataWithContentsOfURL:receiptURL]; if (!receipt) { / No local receipt -- handle the error. */ }, (*10)

/* ... Send the receipt data to your server ... */```, (*11)

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., (*12)

The Versions

22/06 2018

dev-master

9999999-dev

  Sources   Download

MIT

The Requires

 

The Development Requires

22/06 2018

1.1.6

1.1.6.0

  Sources   Download

MIT

The Requires

 

The Development Requires

21/06 2018

1.1.5

1.1.5.0

  Sources   Download

MIT

The Requires

 

The Development Requires

27/03 2018

1.1.4

1.1.4.0

  Sources   Download

MIT

The Requires

 

The Development Requires

27/03 2018

dev-hotfix/avoid-load-empty-expires_date_pst

dev-hotfix/avoid-load-empty-expires_date_pst

  Sources   Download

MIT

The Requires

 

The Development Requires

23/02 2018

dev-hotfix/use-the-original-purchase-date

dev-hotfix/use-the-original-purchase-date

  Sources   Download

MIT

The Requires

 

The Development Requires

09/01 2018

1.1.3

1.1.3.0

  Sources   Download

MIT

The Requires

 

The Development Requires

08/01 2018

dev-feature/BB-1195

dev-feature/BB-1195

  Sources   Download

MIT

The Requires

 

The Development Requires

19/06 2017

1.1.2

1.1.2.0

  Sources   Download

MIT

The Requires

 

The Development Requires

19/06 2017

dev-hotfix/purchase_date_pst-empty

dev-hotfix/purchase_date_pst-empty

  Sources   Download

MIT

The Requires

 

The Development Requires

09/02 2017

1.1.1

1.1.1.0

  Sources   Download

MIT

The Requires

 

The Development Requires

09/02 2017

dev-hotfix/purchase-date

dev-hotfix/purchase-date

  Sources   Download

MIT

The Requires

 

The Development Requires

02/02 2017

1.1.0

1.1.0.0

  Sources   Download

MIT

The Requires

 

The Development Requires

02/02 2017

dev-receipt-service-factory

dev-receipt-service-factory

  Sources   Download

MIT

The Requires

 

The Development Requires

26/01 2017

1.0.3

1.0.3.0

  Sources   Download

MIT

The Requires

 

The Development Requires

20/09 2016

1.0.2

1.0.2.0

  Sources   Download

MIT

The Requires

 

The Development Requires

19/09 2016

1.0.1

1.0.1.0

  Sources   Download

MIT

The Requires

 

The Development Requires

30/08 2016

1.0.0

1.0.0.0

  Sources   Download

MIT

The Requires

 

The Development Requires