getMandatoryField("NotificationData"); $dom = new DOMDocument(); try { $dom->loadXML($notificationData); } catch (Exception $ex) { throw new OffAmazonPaymentsNotifications_InvalidMessageException( "Error with ipn message - NotificationData field does not contain xml, " . "contents: " . $notificationData ); } return $dom->documentElement; } /** * Return a notification object initialised by the xml * * @param Message $ipnMsg ipn message * @param XmlNode $xmlDocumentElement xml message * * @throws OffAmazonPaymentsNotifications_InvalidMessageException * * @return OffAmazonPaymentsNotifications_Notification */ private static function _createNotificationForNotificationType( Message $ipnMsg, $xmlDocumentElement ) { // Construct an instance of the notification class switch ($ipnMsg->getMandatoryField("NotificationType")) { case "OrderReferenceNotification": $notification = new OffAmazonPaymentsNotifications_Model_OrderReferenceNotification( $ipnMsg->getNotificationMetadata(), $xmlDocumentElement ); break; case "BillingAgreementNotification": $notification = new OffAmazonPaymentsNotifications_Model_BillingAgreementNotification( $ipnMsg->getNotificationMetadata(), $xmlDocumentElement ); break; case "PaymentAuthorize": $notification = new OffAmazonPaymentsNotifications_Model_AuthorizationNotification( $ipnMsg->getNotificationMetadata(), $xmlDocumentElement ); break; case "PaymentCapture": $notification = new OffAmazonPaymentsNotifications_Model_CaptureNotification( $ipnMsg->getNotificationMetadata(), $xmlDocumentElement ); break; case "PaymentRefund": $notification = new OffAmazonPaymentsNotifications_Model_RefundNotification( $ipnMsg->getNotificationMetadata(), $xmlDocumentElement ); break; default: throw new OffAmazonPaymentsNotifications_InvalidMessageException( "Error with IPN notification - unknown notification " . $ipnMsg->getMandatoryField("NotificationType") ); } return $notification; } } ?>