/**
  * Constructor.
  *
  * @param string $response_body RAW response body from the API
  */
 public function __construct($response_body)
 {
     parent::__construct($response_body);
     $version = (string) $this->get('version');
     if ($version !== '1.1') {
         throw new Trustly_JSONRPCVersionException("JSON RPC Version {$version} is not supported. " . json_encode($this->payload));
     }
     /* An unsigned JSON RPC Error result basically looks like this:
      * {
      *		"version": "1.1",
      *		"error": {
      *			"name": "JSONRPCError",
      *			"code": 620,
      *			"message": "ERROR_UNKNOWN"
      *		}
      *	}
      *
      * And a unsigned result will be on the form:
      * {
      *		"version": "1.1",
      *		"result": {
      *			"now": "...",
      *			"data": []
      *		}
      * }
      *
      * We want response_result to always be the result of the
      * operation, The Trustly_Data will point response_result /result
      * or /error respectivly, we need to do nothing extra here
      * */
 }
Exemple #2
0
 /**
  * Check to make sure that the given response (instance of
  * Trustly_Data_Response) has been signed with the correct key when
  * originating from the host
  *
  * @param Trustly_Data_Response $response Response from the API call.
  *
  * @return boolean Indicating if the data was indeed properly signed by the
  *		API we think we are talking to
  */
 public function verifyTrustlySignedResponse($response)
 {
     $method = $response->getMethod();
     $uuid = $response->getUUID();
     $signature = $response->getSignature();
     $data = $response->getData();
     return $this->verifyTrustlySignedData($method, $uuid, $signature, $data);
 }