protected function parseEnvelope(Request $request)
 {
     $requestValues = $request->getValues();
     $secureLog = Logger::getTaggedLogger('RawData');
     $secureLog->info("Incoming message (raw)", $requestValues);
     $messages = array();
     // Can't even check signature without these four
     $required = array('result', 'x_amount', 'x_invoice', 'x_control');
     $missing = array_diff($required, array_keys($requestValues));
     if (count($missing)) {
         $list = implode(',', $missing);
         throw new ListenerDataException("AstroPay message missing required key(s) {$list}.");
     }
     $result = $requestValues['result'];
     if (array_key_exists($result, $this->byResult)) {
         $klass = $this->byResult[$result];
         $message = new $klass();
         $message->constructFromValues($requestValues);
         $secureLog->debug("Found message ", $message);
         $messages[] = $message;
     } else {
         Logger::info("Message ignored: result = {$result}");
     }
     return $messages;
 }
 protected function parseEnvelope(Request $request)
 {
     $message = new PaymentMessage();
     $message->constructFromValues($request->getValues());
     $this->success = true;
     return array($message);
 }
 public function execute(Request $request, Response $response)
 {
     $this->config = Configuration::getDefaultConfig();
     $requestValues = $request->getValues();
     // Don't store blank messages.
     if (empty($requestValues)) {
         return;
     }
     // Don't store invalid messages.
     $valid = $this->config->object('api')->validate($requestValues);
     if (!$valid) {
         // This will tell them to resend later.
         $response->setStatusCode(403, 'Failed verification');
         return false;
     }
     // Dump the request right into the queue with no validation.
     $job = new Job();
     $job->payload = $requestValues;
     $this->config->object('data-store/jobs-paypal')->push($job);
     Logger::info('Pushed new message to jobs-paypal: ' . print_r($requestValues, true));
 }