From c9772316299ed8a5332c012a08944d0c82441f54 Mon Sep 17 00:00:00 2001 From: AnirudhaAgashe Date: Tue, 10 Mar 2015 22:51:12 +0530 Subject: [PATCH 1/2] Added password field which is used for auto renewable subscriptions --- itunesReceiptValidator.php | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/itunesReceiptValidator.php b/itunesReceiptValidator.php index 90c0df4..9e4be15 100644 --- a/itunesReceiptValidator.php +++ b/itunesReceiptValidator.php @@ -4,12 +4,15 @@ class itunesReceiptValidator { const SANDBOX_URL = 'https://sandbox.itunes.apple.com/verifyReceipt'; const PRODUCTION_URL = 'https://buy.itunes.apple.com/verifyReceipt'; - function __construct($endpoint, $receipt = NULL) { + function __construct($endpoint, $receipt = NULL, $password = NULL) { $this->setEndPoint($endpoint); if ($receipt) { $this->setReceipt($receipt); } + if ($password) { + $this->password; + } } function getReceipt() { @@ -24,6 +27,14 @@ function setReceipt($receipt) { } } + function getPassword(){ + return $this->password; + } + + function setPassword($password){ + $this->password = $password; + } + function getEndpoint() { return $this->endpoint; } @@ -49,7 +60,13 @@ function validateReceipt() { } private function encodeRequest() { - return json_encode(array('receipt-data' => $this->getReceipt())); + $request_data = array('receipt-data' => $this->getReceipt()); + + if ($this->getPassword()) { + $request_data['password'] = $this->getPassword(); + } + + return json_encode($request_data); } private function decodeResponse($response) { From c59c3f201d24807f1635f313b28aa25fa1088539 Mon Sep 17 00:00:00 2001 From: Anirudha Agashe Date: Mon, 10 Aug 2015 22:59:16 +0530 Subject: [PATCH 2/2] fixed password setting in construct --- itunesReceiptValidator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/itunesReceiptValidator.php b/itunesReceiptValidator.php index 9e4be15..39cd980 100644 --- a/itunesReceiptValidator.php +++ b/itunesReceiptValidator.php @@ -11,7 +11,7 @@ function __construct($endpoint, $receipt = NULL, $password = NULL) { $this->setReceipt($receipt); } if ($password) { - $this->password; + $this->setPassword($password); } }