public function handleAuthResponse(array $responseData, $inputEncoding) { $hash = $this->generateHash($responseData, Services::getAuthResponseFields()); $verification = $hash === $responseData[Fields::B02K_MAC]; $responseData = ProtocolUtils::convertValues($responseData, $inputEncoding, 'UTF-8'); if ($verification) { $status = 1; } else { $status = 0; } $response = new AuthResponse($status, $responseData); if ($status == 1) { $response->setPersonalCode($responseData[Fields::B02K_CUSTID]); $fullname = $responseData[Fields::B02K_CUSTNAME]; $response->setFirstname(substr($fullname, 0, strpos($fullname, ' '))); $response->setLastname(substr($fullname, strpos($fullname, ' ') + 1)); } return $response; }
public function handleAuthResponse(array $responseData, $verificationSuccess) { // if response was verified, try to guess status by service id if ($verificationSuccess) { $status = $responseData[Fields::SERVICE_ID] == Services::AUTHENTICATE_SUCCESS ? PaymentResponse::STATUS_SUCCESS : PaymentResponse::STATUS_CANCEL; } else { $status = PaymentResponse::STATUS_ERROR; } $response = new AuthResponse($status, $responseData); $response->setPersonalCode($responseData[Fields::VK_USER_ID]); if (AuthResponse::STATUS_SUCCESS === $status) { $fullname = $responseData[Fields::VK_USER_NAME]; if (strpos($fullname, ',') !== false) { $response->setLastname(substr($fullname, 0, strpos($fullname, ','))); $response->setFirstname(substr($fullname, strpos($fullname, ',') + 1)); } else { $response->setFirstname(substr($fullname, 0, strpos($fullname, ' '))); $response->setFirstname(substr($fullname, strpos($fullname, ' ') + 1)); } } return $response; }