build(); $this->_snsMessageValidator = new SnsMessageValidator( new OpenSslVerifySignature($merchantValues->getCnName(), new HttpRequestFactoryCurlImpl($merchantValues) ) ); } /** * Converts a http POST body and headers into * a notification object * * @param array $headers post request headers * @param string $body post request body, should be json * * @throws OffAmazonPaymentsNotifications_InvalidMessageException * * @return OffAmazonPaymentNotifications_Notification */ public function parseRawMessage($headers, $body) { // Is this json, is this // an sns message, do we have the fields we require $snsMessage = SnsMessageParser::parseNotification($headers, $body); // security validation - check that this message is // from amazon and that it has been signed correctly $this->_snsMessageValidator->validateMessage($snsMessage); // Convert to object - convert from basic class to object $ipnMessage = IpnNotificationParser::parseSnsMessage($snsMessage); return XmlNotificationParser::parseIpnMessage($ipnMessage); } }