plaid / react-plaid-link

React bindings for Plaid Link
https://plaid.github.io/react-plaid-link
MIT License
268 stars 149 forks source link

The open function returned by usePlaid does not support the institution parameter for Plaid.open #327

Closed msssk closed 9 months ago

msssk commented 9 months ago

I believe this line: https://github.com/plaid/react-plaid-link/blob/fd5e476d619a7155c80c27ccf691259ec4840fea/src/factory.ts#L64 should support passing an institution.

I am migrating from an Angular app to React and the Angular app supports passing the institution so the user can skip selecting their bank from the Plaid Link dialog: https://github.com/mike-roberts/ngx-plaid-link/blob/385701db294545871f6cc10630646163baa6dba1/projects/ngx-plaid-link/src/lib/ngx-plaid-link-handler.ts#L15-L25

phoenixy1 commented 9 months ago

Thank you for the report!

This is by design -- the Angular wrapper is a third-party, community-based wrapper and is not supported by Plaid. As per the official docs Plaid.open() does not take an institution parameter, and none of the official Plaid SDKs support passing an institution to Plaid.open(). I'd actually be fairly surprised if the linked code in the Angular wrapper does anything because the wrapper appears to be wrapping functionality that does not exist -- this bug report e.g. seems to indicate that it doesn't work: https://github.com/mike-roberts/ngx-plaid-link/issues/30

msssk commented 9 months ago

@phoenixy1 Plaid.open does take an institution parameter, so it would be good if the documentation was updated to reflect that. The following changes in factory.ts do actually work, I have just tested it:

-const open = () => {
+const open = (institutionId?: string) => {
    if (!state.plaid) {
        return;
    }
    state.open = true;
    state.onExitCallback = null;
-   state.plaid.open();
+   state.plaid.open(institutionId);
};
phoenixy1 commented 9 months ago

@msssk sorry for the confusion! I double checked with the mobile team and confirmed that using plaid.open with an institution parameter is a deprecated pattern that is no longer supported. Going forward, any customer who is approved by their account manager to initialize Link in this way should specify the institution_id in the /link/token/create call: https://plaid.com/docs/api/tokens/#link-token-create-request-institution-id.

msssk commented 9 months ago

@phoenixy1 Thank you for clarifying that. I did previously read the linked documentation, but it was not at all clear from the description that I needed to use that - perhaps the documentation could be updated to provide more clarity on the requirements, purpose, and result of passing institution_id. I have tested the endpoint with institution_id and it is working as Plaid.open(institution_id) previously was. Thanks for the help!