1

Plaidのドキュメントから:

一部の教育機関では、ユーザーが制限された一連の回答から質問に回答する必要があります。つまり、多肢選択式です。複数の質問が返される場合があり、MFA 回答の送信は、指定された質問と同じ順序で回答が提供される JSON エンコードされた配列である必要があります。

これに基づいて、私はそれが次のことを意味すると理解しています:

  • 応答配列に質問が 1 つしかない場合は、回答をスカラー値として送信します
  • 応答配列に複数の質問がある場合は、回答を値の配列として送信します

これは正しいです?

たとえば、plaid が返す場合:

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

私は提出します:

{
    "mfa": "fido"
}

しかし、plaid が返された場合:

{
    "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 は一度に 1 つの MFA しかユーザーに送信しないと思います。サンドボックスで銀行の 1 つに確認したところ、送信され、最初の 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 に答える