/**
  * validate the receipt data
  *
  * @param string $receiptData
  * @param string $iStoreSharedSecret
  *
  * @return Response
  */
 public function validate($receiptData = null, $iStoreSharedSecret = null)
 {
     if ($receiptData != null) {
         $this->setReceiptData($receiptData);
     }
     if ($iStoreSharedSecret != null) {
         $this->setIStoreSharedSecret($iStoreSharedSecret);
     }
     $httpResponse = $this->getClient()->post(null, null, $this->encodeRequest(), array('verify' => false))->send();
     if ($httpResponse->getStatusCode() != 200) {
         throw new RunTimeException('Unable to get response from itunes server');
     }
     $response = new Response($httpResponse->json());
     // on a 21007 error retry the request in the sandbox environment (if the current environment is Production)
     // these are receipts from apple review team
     if ($this->_endpoint == self::ENDPOINT_PRODUCTION && $response->getResultCode() == Response::RESULT_SANDBOX_RECEIPT_SENT_TO_PRODUCTION) {
         $client = new GuzzleClient(self::ENDPOINT_SANDBOX);
         $httpResponse = $client->post(null, null, $this->encodeRequest(), array('verify' => false))->send();
         if ($httpResponse->getStatusCode() != 200) {
             throw new RunTimeException('Unable to get response from itunes server');
         }
         $response = new Response($httpResponse->json());
     }
     return $response;
 }