Skip to content

Commit

Permalink
Merge pull request #15 from grEvenX/fix_status_code_error
Browse files Browse the repository at this point in the history
Fix failure to return correct status code in Response
  • Loading branch information
aporat committed Mar 3, 2015
2 parents d96fb75 + 2391be4 commit 9a3044c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/ReceiptValidator/iTunes/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ public function parseJsonResponse($jsonResponse)
$this->_bundle_id = $jsonResponse['receipt']['bid'];
}
}
} elseif (array_key_exists('status', $jsonResponse)) {
$this->_code = $jsonResponse['status'];
} else {
$this->_code = self::RESULT_DATA_MALFORMED;
}
Expand Down
10 changes: 10 additions & 0 deletions tests/iTunes/ResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,23 @@ public function testInvalidReceipt()
$response = new Response(array('status' => 21002, 'receipt' => []));

$this->assertFalse($response->isValid(), 'receipt must be invalid');
$this->assertEquals(21002, $response->getResultCode(), 'receipt result code must match');
}

public function testReceiptSentToWrongEndpoint()
{
$response = new Response(array('status' => 21007));

$this->assertFalse($response->isValid(), 'receipt must be invalid');
$this->assertEquals(21007, $response->getResultCode(), 'receipt result code must match');
}

public function testValidReceipt()
{
$response = new Response(array('status' => 0, 'receipt' => []));

$this->assertTrue($response->isValid(), 'receipt must be valid');
$this->assertEquals(0, $response->getResultCode(), 'receipt result code must match');
}

}

0 comments on commit 9a3044c

Please sign in to comment.