2017 © Pedro Peláez
 

package iap-validator

Composer package to validate in-app purchase receipts made to iTunes or Google through mobile apps.

image

raazpuspa/iap-validator

Composer package to validate in-app purchase receipts made to iTunes or Google through mobile apps.

  • Friday, December 22, 2017
  • by raazpuspa
  • Repository
  • 1 Watchers
  • 1 Stars
  • 11 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 22 % Grown

The README.md

in-app purchase validator

iap-validator is a php composer package to validate in-app purchase receipts received from iTunes App Store. Also, this package provides easy access to all the information and details of purchase identified by provided receipt key., (*1)

iap-validator uses Guzzle Http Client in background to make Http request to the iTunes App Store server., (*2)

Requirement

  • PHP >= 5.6
  • Guzzle Http Client >= 6.3

Package will automatically install Guzzle Http Client for your convenience, (*3)

Installation

We recommend you to install iap-validator through Composer. Move to https://getcomposer.org for detail instructions on installing and using composer or run the following command on your terminal., (*4)

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

Run Composer command to install iap-validator, (*5)

composer require raazpuspa/iap-validator

If you have not linked your composer installer to your bin path, checkout to your directory consisting composer.phar and run composer with php., (*6)

php composer.phar require raazpuspa/iap-validator

For smooth running, you need to require Composer's autoloder:, (*7)

require 'vendor/autoload.php'

To pull latest update of iap-validator use composer update:, (*8)

composer update

OR, (*9)

composer.phar update

Usage

Its too easy to use iap-validator. You just need to place single use statement on your related file to include the package., (*10)

use RaazPuspa\IAPValidator\iTunes\IAPValidator;

Next, initialize an object of IAPValidator class to access any provided methods., (*11)

$iapValidator = new IAPValidator();

We extract your application's secured secret key used to make Http requests to iTunes App Store from your .env file. Set IAP_ITUNES_SECRET=<your secured secret key> in your .env file., (*12)

Two constant values are provided for easy selection of server endpoint., (*13)

const PRODUCTION_ENDPOINT = 'https://buy.itunes.apple.com/verifyReceipt';
const SANDBOX_ENDPOINT = 'https://sandbox.itunes.apple.com/verifyReceipt';

Example

# import validator class
use RaazPuspa\IAPValidator\iTunes\IAPValidator;

# initialize new validator class instance
$iapValidator = new IAPValidator();

# Set server end-point for instance of IAPValidator class.
# Choose one from the two provided end-point constants. Select production
# end-point for live app while sandbox end-point during testing
$iapValidator->setEndPoint($iapValidator::PRODUCTION_ENDPOINT);

# Validates provided data and returns validation receipt.
# @param $receiptData string base64 encoded purchase receipt from App Store
# @param $endPoint string server end-point (optional, but is required if you
# had not set it earlier)
$response = $iapValidator->validateReceipt($receipt, $endPoint);

# get validation status code
$statusCode = $response->getStatusCode();

# If validated successfully, status code will be 0 (zero). On other scenario,
# status codes represent as mentioned in official iTunes documentation.

iTunes Developer Documentation, list of status codes, (*14)

# if validation is successful, you can get receipt information with following
# method calls
# get the status of validation
$statusCode = $response->getStatusCode();

# get current app environment upon which validation is performed
$environment = $response->getEnvironment();

# get just the receipt object
$receipt = $response->getReceipt();

# get in-app product information
$inApp = $response->getInApp();

# get latest receipt information
$latestReceiptInfo = $response->getLatestReceiptInfo();

# get latest base64 encoded receipt string
$latestReceipt = $response->getLatestReceipt();

# get pending renewal information if product is renewable/subscription based
$pendingRenewalInfo = $response->getPendingRenewalInfo();

The Versions

22/12 2017

dev-master

9999999-dev

Composer package to validate in-app purchase receipts made to iTunes or Google through mobile apps.

  Sources   Download

MIT

The Requires

 

The Development Requires

23/11 2017

v1.0

1.0.0.0

Composer package to validate in-app purchase receipts made to iTunes or Google through mobile apps.

  Sources   Download

MIT

The Requires

 

The Development Requires