使用Plaid Link显示自定义用户名和密码模式对话框

Display custom user name and password modal dialog with Plaid Link

本文关键字:密码 模式 对话框 用户 Plaid Link 显示 自定义 使用      更新时间:2023-09-26

我正在使用Plaid Link及其自定义集成,到目前为止,我能够提取机构列表。这很好,因为我不必对机构列表进行硬编码,而且我可以为选择机构显示自定义模式对话框。

现在,下一步是让用户输入他们的凭据,这样我就可以通过onSuccess回调获得public_tokenmetadata。Plaid Link希望我使用传入的所选机构的类型调用linkHandler.open,它显示Plaid模式对话框,允许用户输入他们的凭据并进行确认。然后调用onSuccess回调。

但是,如果我想让用户通过自定义模式输入他们的用户名和密码,该怎么办。是否有类似linkHandler.auth(userName, password)的东西会导致以类似的方式调用onSuccess,但如果不显示我无法设置样式的模式对话框?

这是一个片段,但它基本上是从文档中复制粘贴的,所以这并不奇怪:

let plaidLink = Plaid.create({
  env: "tartan",
  clientName: "",
  key: "blahblahblah", // A correct public key.
  product: "auth",
  onLoad: () => {
    console.debug("onLoad");
  },
  onSuccess: (publicToken, metadata) => {
    console.debug("onSuccess");
  },
  onExit: () => {
    console.debug("onExit");
  }
});
// Don't want this!
//plaidLink.open("bofa"); 
// Want this, this is cool, but can I get the same for the credential dialog?
console.debug("institutions", plaidLink.institutions);

恐怕您正在寻找的功能目前在Plaid Link中不存在,而且很可能在不久的将来不会实现。这是因为Link是专门为处理每家银行所拥有的相当复杂的流程和各种可能性而建立的。

对于像Wells Fargo这样不需要MFA问题或答案的简单集成,您的建议可能会奏效。

Plaid.auth('wells', userName, password)

但对于其他机构,如ChaseBank of America,它们都有各种MFA问题,流程将更加复杂,并且不可能使用一个方法调用。

Plaid.auth('chase', userName, password)
Plaid.mfaDevice('chase', device)
Plaid.mfaCode('chase', code)
Plaid.handleMfaError('chase', error)
// ...

如果您确实想向用户展示自定义模态,您可以选择构建自己的Plaid API实现。然而,Plaid Link为您处理了所有这些复杂性,我强烈建议您使用它来确保您的用户拥有良好的用户体验。Plaid团队积极维护Link,因此它不断改进,同时还经常发布新功能。