/** * @param IpnEntity $ipn * @return bool */ public function forwardIpn(IpnEntity $ipn) { $urls = $ipn->getForwardUrls(); if (!empty($urls)) { $requests = []; foreach ($urls as $url) { $request = $this->guzzle->createRequest('post', $url); $request->setHeader($this->customHeader, $this->getKey()); if (in_array($url, $this->disabledJsonFormatting)) { $request->getQuery()->merge($ipn->toArray()); } else { $request->setHeader('content-type', 'application/json'); if ($this->formatter) { $response = $this->formatter->formatJsonResponse($ipn); } else { $response = ['ipn' => $ipn->toArray()]; } $request->setBody(Stream::factory(json_encode($response))); } $requests[] = $request; } $this->guzzle->sendAll($requests, ['parallel' => $this->maxRequests]); return true; } return false; }
/** * @param IpnEntity $ipn * @param $logData * @return array */ protected function makeForwardedResponse($logData, $ipn) { $msg = 'Notified ' . count($ipn->getForwardUrls()) . ' urls.'; $response = ['status' => 'ok', 'msg' => $msg]; $this->log($msg, $logData); return $response; }