diff --git a/src/factory.ts b/src/factory.ts index e750dfdf..70bc78f6 100644 --- a/src/factory.ts +++ b/src/factory.ts @@ -50,6 +50,10 @@ export const createPlaid = (options: PlaidLinkOptions) => { config.onExit && config.onExit(error, metadata); state.onExitCallback && state.onExitCallback(); }, + onSuccess: (public_token, metadata) => { + state.open = false; + options.onSuccess && options.onSuccess(public_token, metadata) + }, }); const open = () => { diff --git a/src/usePlaidLink.ts b/src/usePlaidLink.ts index 53535db3..aa412a2a 100644 --- a/src/usePlaidLink.ts +++ b/src/usePlaidLink.ts @@ -52,6 +52,9 @@ export const usePlaidLink = (options: PlaidLinkOptions) => { setIframeLoaded(true); options.onLoad && options.onLoad(); }, + onSuccess: (public_token, metadata) => { + options.onSuccess && options.onSuccess(public_token, metadata) + }, }); setPlaid(next);