Skip to content

Commit

Permalink
Merge pull request #13 from chekalskiy/itunes-auto-renew
Browse files Browse the repository at this point in the history
Handle latest_receipt field
  • Loading branch information
aporat committed Feb 26, 2015
2 parents 52fa7cb + 80eed4e commit d96fb75
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/ReceiptValidator/iTunes/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,25 @@ class Response

/**
* receipt info
*
* @var array
*/
protected $_receipt = [];

/**
* latest receipt (needs for auto-renewable subscriptions)
*
* @var array
*/
protected $_latest_receipt = [];

/**
* latest receipt info (needs for auto-renewable subscriptions)
*
* @var string
*/
protected $_latest_receipt_info = null;

/**
* purhcases info
* @var array
Expand Down Expand Up @@ -122,6 +137,26 @@ public function getReceipt()
return $this->_receipt;
}

/**
* Get latest receipt info
*
* @return array
*/
public function getLatestReceiptInfo()
{
return $this->_latest_receipt_info;
}

/**
* Get latest receipt
*
* @return string
*/
public function getLatestReceipt()
{
return $this->_latest_receipt;
}

/**
* Get the bundle id assoicated with the receipt
*
Expand Down Expand Up @@ -168,6 +203,13 @@ public function parseJsonResponse($jsonResponse)
$this->_bundle_id = $jsonResponse['receipt']['bundle_id'];
}

if (array_key_exists('latest_receipt_info', $jsonResponse)) {
$this->_latest_receipt_info = $jsonResponse['latest_receipt_info'];
}

if (array_key_exists('latest_receipt', $jsonResponse)) {
$this->_latest_receipt = $jsonResponse['latest_receipt'];
}
} elseif (array_key_exists('receipt', $jsonResponse)) {

// ios <= 6.0 validation
Expand Down

0 comments on commit d96fb75

Please sign in to comment.