// Language definitions
addMessages(array(
- 'WERNIS_STATUS_UNKNWOWN' => "Wernis-Typ <span class=\"data\">%s</span> unbekannt.",
- 'WERNIS_STATUS_WITHDRAW' => "Einzahlung von WDS66",
- 'WERNIS_STATUS_PAYOUT' => "Auszahlung an WDS66",
- 'WERNIS_STATUS_FAILED' => "Fehlgeschlagen",
'WERNIS_TIMESTAMP' => "Buchungszeitmarke",
'WERNIS_ACCOUNT' => "WDS66-Hauptaccount",
'WERNIS_TOTAL_WERNIS' => "Gesamt überwiesen",
+ // Transfer status
+ 'WERNIS_TRANSFER_STATUS_UNKNWOWN' => "Wernis-Typ <span class=\"data\">%s</span> unbekannt.",
+ 'WERNIS_TRANSFER_STATUS_WITHDRAW' => "Einzahlung von WDS66",
+ 'WERNIS_TRANSFER_STATUS_PAYOUT' => "Auszahlung an WDS66",
+ 'WERNIS_TRANSFER_STATUS_FAILED' => "Fehlgeschlagen",
+
+ // Auth status
+ 'WERNIS_AUTH_STATUS_UNKNOWN' => "Unbekannt",
+ 'WERNIS_AUTH_STATUS_ACCEPTED' => "Angenommen",
+ 'WERNIS_AUTH_STATUS_REJECTED' => "Abgelehnt",
+ 'WERNIS_AUTH_STATUS_PENDING' => "Wartend",
+
// Admin messages
'ADMIN_CONFIG_WERNIS_TITLE' => "Einstellungen zum WDS66-Hauptaccount:",
'ADMIN_CONFIG_WERNIS_MIN_PAYOUT' => "Minimumguthaben für Auszahlungen.",
'WERNIS_API_REQUEST_FAILED_AMOUNT' => "Konto weist nicht genügend Deckung auf.",
'WERNIS_API_REQUEST_FAILED_API_AMOUNT' => "API-Konto weist nicht genügend Deckung auf.",
'WERNIS_API_REQUEST_FAILED_GENERIC' => "API-Abfrage fehlgeschlagen oder Auswertung der Antwort fehlgeschlagen.",
+ 'WERNIS_API_REQUEST_FAILED_AUTH_STATUS' => "API-Authorisierung hat unerwarteten Status <em>{OPEN_TEMPLATE}pipe,translateWernisAuthStatu=%s{CLOSE_TEMPLATE}</em>.",
+ 'WERNIS_API_REQUEST_FAILED_AUTH_STATUS_ACCEPTED' => "Bei der API-Authorisierung ist ein Fehler unterlaufen, da <em>{--WERNIS_AUTH_STATUS_ACCEPTED--}</em> als Fehler gemeldet wurde.",
+ 'WERNIS_API_REQUEST_FAILED_AUTH_STATUS_REJECTED' => "Sie hatten dem Datentransfer zu diesem {?MT_WORD?} nicht zugestimmt.",
+ 'WERNIS_API_REQUEST_FAILED_AUTH_STATUS_UNKNOWN' => "Sie haben noch keine Authorisierung durchgeführt und haben vermutlich einen alten Link benutzt.",
'WERNIS_API_PURPOSE_WITHDRAW' => "Einzahlung auf {?MAIN_TITLE?} ({?URL?}), id: <span class=\"data\">%s</span>",
'WERNIS_API_PURPOSE_PAYOUT' => "Auszahlung von {?MAIN_TITLE?} ({?URL?}), id: <span class=\"data\">%s</span>",
'GUEST_WERNIS_REGISTRATION_PASSWORD_NOT_SET' => "Bitte geben Sie Ihr Wernis-Passwort ein. Tipp: Dies ist <strong>nicht</strong> Ihr Account-Passwort.",
'GUEST_WERNIS_REGISTRATION_INVALID_CHALLENGE_RESPONSE' => "Es ist beim Anmeldeversuch ein Fehler unterlaufen: Falsche Challenge-Response",
'GUEST_WERNIS_REGISTRATION_ZERO_ROWS_FOUND' => "Es konnte keine Anmeldedaten von der WDS66-API gefunden werden. Haben Sie auch den richtigen Link aufgerufen?",
+ 'GUEST_WERNIS_REGISTRATION_AUTH_REJECTED' => "Die Anmeldung mit WDS66 kann nicht abgeschlossen werden, da Sie den Datenzugriff verweigert haben.",
'GUEST_REGISTER_WERNIS_PROVIDER_TITLE' => "Anmeldung mit WDS66 am {?mt_word?} <strong>{?MAIN_TITLE?}</strong>:",
// Points accounts - subject
// We use only the first two entries (which shall be fine)
if ($data[0] === 'error') {
- // The request has failed... :(
- switch ($data[1]) {
+ // The request has failed...
+ $status = $data[1];
+ $extraData = '';
+
+ // Explode status code
+ $exploded = explode(':', $status);
+
+ // More extra data found?
+ if (count($exploded) > 1) {
+ // Then set all
+ $status = $exploded[0];
+ $extraData = $exploded[1];
+ } // END - if
+
+ switch ($status) {
case '404': // Invalid API id
case 'AUTH': // Authorization has failed
$return = array(
);
break;
+ case 'AUTH-STATUS': // Unexpected auth status
+ // Switch on extra data
+ switch ($extraData) {
+ case 'ACCEPTED':
+ $return = array(
+ 'status' => 'api_auth_status_accepted',
+ 'message' => '{--WERNIS_API_REQUEST_FAILED_AUTH_STATUS_ACCEPTED--}'
+ );
+ break;
+
+ case 'REJECTED':
+ $return = array(
+ 'status' => 'api_auth_status_rejected',
+ 'message' => '{--WERNIS_API_REQUEST_FAILED_AUTH_STATUS_REJECTED--}'
+ );
+ break;
+
+ case 'UNKNOWN':
+ $return = array(
+ 'status' => 'api_auth_status_unknown',
+ 'message' => '{--WERNIS_API_REQUEST_FAILED_AUTH_STATUS_UNKNOWN--}'
+ );
+ break;
+
+ default: // Unknown
+ $return = array(
+ 'status' => 'api_auth_status_failed',
+ 'message' => getMaskedMessage('WERNIS_API_REQUEST_FAILED_AUTH_STATUS', $extraData)
+ );
+ break;
+ } // END - switch
+ break;
+
default: // Unknown error (maybe new?)
logDebugMessage(__FUNCTION__, __LINE__, sprintf('Unknown error %s from WDS66 API received.', $data[1]));
$return = array(
'message' => '{%message,WERNIS_API_REQUEST_FAILED=' . $data[1] . '%}'
);
break;
- }
+ } // END - switch
} else {
// All fine, then analyze API response
$return = convertApiResponseToArray($responseLine, '&', '=');
return $return;
}
+// Translate auth status
+function translateWernisAuthStatu ($status) {
+ return '{%message,WERNIS_AUTH_STATUS_' . strtoupper($status) . '%}';
+}
+
// Translate the status IN/OUT
function translateWernisTransferStatus ($status) {
// Default status is unknown
- $return = '{%message,WERNIS_STATUS_UNKNWOWN=' . $status . '%}';
+ $return = '{%message,WERNIS_TRANSFER_STATUS_UNKNWOWN=' . $status . '%}';
// Construct message id
- $messageId = 'WERNIS_STATUS_' . $status;
+ $messageId = 'WERNIS_TRANSFER_STATUS_' . $status;
// Is it there?
if (isMessageIdValid($messageId)) {
// Is the status 1? (= all fine with API call)
if ($status == '1') {
// Get mapped data based on challenge
- $return = getWernisMappedDataFromApiByChallenge($challenge, $status);
+ $return = getWernisMappedDataFromApiByChallenge($challenge, $challengeResponse, $status);
// Is the array filled?
//* DEBUG-DIE */ die(__METHOD__ . ':return=<pre>' . print_r($return, TRUE) . '</pre> - EXIT!');
return FALSE;
}
} else {
- // Status does not need to be changed
- die(__FUNCTION__ . ':' . __LINE__ . ': Reached!');
+ // Not accepted
+ displayMessage('{--GUEST_WERNIS_REGISTRATION_AUTH_REJECTED--}');
}
}
// "Getter" for mapped data by calling the API and given challenge and status
-function getWernisMappedDataFromApiByChallenge ($challenge, $status) {
+function getWernisMappedDataFromApiByChallenge ($challenge, $challengeResponse, $status) {
// Get stored registration data
$rows = getWernisRegistrationDataByKey('api_redirect_challenge', $challenge);
* will always run.
*/
updateWernisRegistrationDataByKey('api_auth_status', 'api_redirect_challenge', $challenge, 'ACCEPTED');
+ updateWernisRegistrationDataByKey('api_challenge_response', 'api_redirect_challenge', $challenge, $challengeResponse);
} // END - if
// Now call "get.php"
`api_auth_status`,
`api_auth_key`,
`api_redirect_challenge`,
+ `api_challenge_response`,
UNIX_TIMESTAMP(`record_inserted`) AS `record_inserted`
FROM
`{?_MYSQL_PREFIX?}_wernis_regs`
// auth_key and wernis_userid must be set
assert(isset($args['auth_key']));
assert(isset($args['wernis_userid']));
- die(__FUNCTION__ . ':' . __LINE__ . '<pre>' . print_r($args, TRUE) . '</pre>');
+
+ // Get registration data by auth_key
+ $rows = getWernisRegistrationDataByKey('api_auth_key', $args['auth_key']);
+
+ // The userid should be same
+ assert(isset($rows[0]['wernis_userid']));
+ assert($rows[0]['wernis_userid'] === $args['wernis_userid']);
+
+ // Check both challenge + response
+ assert(isset($rows[0]['api_redirect_challenge']));
+ assert(isset($rows[0]['api_challenge_response']));
+
+ // Both are fine, so get the data
+ $return = doWernisFinishUserRegistration($rows[0]['api_redirect_challenge'], $rows[0]['api_challenge_response'], '1');
+
+ // All fine?
+ if ($return === FALSE) {
+ // @TODO Should not happen???
+ reportBug(__FUNCTION__, __LINE__, 'args=<pre>' . print_r($args, TRUE) . '</pre>rows=<pre>' . print_r($rows, TRUE) . '</pre> - Failed!');
+ } // END - if
+
+ // Generate URL
+ $url = basename(detectRequestUri()) . '&challenge=' . $rows[0]['api_redirect_challenge'] . '&__challenge_response=' . $rows[0]['api_challenge_response'] . '&status=1';
+
+ // Redirect to URL
+ redirectToUrl($url);
}
//------------------------------------------------------------------------------