Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added password field used for auto renewable subscriptions #10

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions itunesReceiptValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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->setPassword($password);
}
}

function getReceipt() {
Expand All @@ -24,6 +27,14 @@ function setReceipt($receipt) {
}
}

function getPassword(){
return $this->password;
}

function setPassword($password){
$this->password = $password;
}

function getEndpoint() {
return $this->endpoint;
}
Expand All @@ -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) {
Expand Down