diff --git a/src/ReceiptValidator/iTunes/Response.php b/src/ReceiptValidator/iTunes/Response.php index 99f8820..3a8befe 100644 --- a/src/ReceiptValidator/iTunes/Response.php +++ b/src/ReceiptValidator/iTunes/Response.php @@ -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; } diff --git a/tests/iTunes/ResponseTest.php b/tests/iTunes/ResponseTest.php index 7b3bd55..d0f3516 100644 --- a/tests/iTunes/ResponseTest.php +++ b/tests/iTunes/ResponseTest.php @@ -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'); } } \ No newline at end of file