1

从格子文档:

一些机构要求用户从一组有限的答案中回答一个问题,即多项选择。可能会返回多个问题,并且 MFA 答案提交必须是 JSON 编码的数组,其中提供的答案与给定问题的顺序相同。

基于此,我理解它的意思是:

  • 如果响应数组中只有一个问题,则将答案作为标量值提交
  • 如果响应数组中有多个问题,则将答案作为一组值提交

这个对吗?

例如,如果格子返回:

{
    "type": "questions",
    "mfa": [{"question":"What was the name of your first pet?"}],
    "access_token": "xxxxx"
}

我会提交:

{
    "mfa": "fido"
}

但是如果格子返回:

{
    "type": "questions",
    "mfa": [
        {"question":"What was the name of your first pet?"},
        {"question":"What was the name of your first girlfriend?"}
    ],
    "access_token": "xxxxx"
}

我会提交:

{
    "mfa": ["fido", "forever alone"]
}

这个对吗?

4

1 回答 1

0

我相信 Plaid 一次只会为用户发送一个 MFA。我已经在沙盒中与他们的一家银行进行了核对并发送了它,然后在我错误地回答了第一个 MFA 后又发送了另一个。

我不相信您会在同一个 JSON 对象中获得 2 个 MFA。

我已经像这样实施了他们的 MFA 方案:

public static function accountOrMFA($response, $formBuilder, $formId = null, $request = null) {
    if ($response) {
        // do we have a MFA or the accounts?
        if (property_exists($response, "mfa")) {
            // we have MFA to deal with
            $mfa['type'] = $response->type;
            $mfa['data'] = $response->mfa;
            $mfa['access_token'] = $response->access_token;

            return response()->json(['html' => PlaidController::makeHTMLForMFA($mfa, $formBuilder)]);
        } else {
            $auth_accounts = [];
            $connect_accounts = [];
            foreach($response->accounts as $account) {
                $auth_accounts[] = [
                    'id' => $account->_id,
                    'number' => $account->meta->number,
                    'name' => $account->meta->name,
                    'type' => $account->type,
                ];
            }

            $connect_response = UserController::storeToken($response, $request); // add this token to the user's tokens

            return response()->json(['html' => PlaidController::makeHTMLForAccounts($auth_accounts, $formBuilder, $formId)]);
        }

    }

    return response()->json(['error' => true, 'response' => json_encode($response)]); // maybe the wrong credentials? we don't know
}
于 2015-05-12T20:50:15.910 回答