/** * @param GatewayInterface $sap * @param array $params */ public function processRequest(GatewayInterface $sap, $params = null) { try { if (!$params) { $params = $_POST; } $method = $params['method']; if (!in_array($method, array('execute', 'debug'))) { throw new Exception("Unknown method {$method}"); } $transaction = json_decode($params['transaction']); if (!$transaction) { throw new Exception("No valid transaction found"); } if ($params['enableProfiler'] && !$sap->getProfiler()) { $sap->setProfiler(new Profiler()); } $data = $sap->{$method}($transaction->name, $transaction->request, $transaction->responseKeys); $result = array('data' => $data); } catch (Exception $e) { $result = array('exception' => $e->getMessage()); } if ($sap->getProfiler()) { $result['profiler'] = $sap->getProfiler()->getData(); } echo json_encode($result); }
public function autoComplete($dbAdapter, $field, $value, $orderBy, $gatewayName) { $querySet = GatewayInterface::retrieveQuerySetBy($dbAdapter, $field, $value, $orderBy, $gatewayName); $countries = array(); foreach ($querySet as $qs) { $current = json_decode(json_encode($qs), true); array_push($countries, $current['country']['countryName']); } return $this->render($countries); }
private function addCountryName($dbAdapter, $querySet) { $current = json_decode(json_encode($querySet), true); $country = GatewayInterface::retrieveQuerySetBy($dbAdapter, 'fipsCountryCode', $current['visit']['country_code'], 'fipsCountryCode', 'country'); if (count($country) > 0) { $country = json_decode(json_encode($country[0]), true); $country_name = $country['country']['countryName']; $current['visit']['countryName'] = $country_name; } else { $current['visit']['countryName'] = 'N/A'; } return $current; }
public function getById($request, $dbAdapter) { $querySet = GatewayInterface::retrieveQuerySetByID($dbAdapter, $request->path_info[1], $request->path_info[0]); return $this->render($querySet); }