-
Notifications
You must be signed in to change notification settings - Fork 5.4k
[Components] plaid - new components #16586
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
components/plaid/actions/create-access-token/create-access-token.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import app from "../../plaid.app.mjs"; | ||
|
||
export default { | ||
key: "plaid-create-access-token", | ||
name: "Create Access Token", | ||
description: "Exchange a Link `public_token` for an API `access_token`. [See the documentation](https://plaid.com/docs/api/items/#itempublic_tokenexchange).", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
app, | ||
publicToken: { | ||
propDefinition: [ | ||
app, | ||
"publicToken", | ||
], | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const { | ||
app, | ||
publicToken, | ||
} = this; | ||
|
||
const response = await app.exchangePublicToken({ | ||
public_token: publicToken, | ||
}); | ||
|
||
$.export("$summary", "Successfully created access token for public token"); | ||
|
||
return response; | ||
}, | ||
}; |
80 changes: 80 additions & 0 deletions
80
components/plaid/actions/create-sandbox-public-token/create-sandbox-public-token.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import app from "../../plaid.app.mjs"; | ||
import institutions from "../../common/sandbox-institutions.mjs"; | ||
|
||
export default { | ||
key: "plaid-create-sandbox-public-token", | ||
name: "Create Sandbox Public Token", | ||
description: "Creates a valid `public_token` for an arbitrary institution ID, initial products, and test credentials. [See the documentation](https://plaid.com/docs/api/sandbox/#sandboxpublic_tokencreate).", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
app, | ||
institutionId: { | ||
type: "string", | ||
label: "Institution ID", | ||
description: "The ID of the institution the Item will be associated with", | ||
options: Object.values(institutions), | ||
}, | ||
initialProducts: { | ||
type: "string[]", | ||
label: "Initial Products", | ||
description: "The products to initially pull for the Item. May be any products that the specified institution supports.", | ||
options: [ | ||
"assets", | ||
"auth", | ||
"balance", | ||
"employment", | ||
"identity", | ||
"income_verification", | ||
"identity_verification", | ||
"investments", | ||
"liabilities", | ||
"payment_initiation", | ||
"standing_orders", | ||
"statements", | ||
"transactions", | ||
"transfer", | ||
], | ||
}, | ||
webhookUrl: { | ||
type: "string", | ||
label: "Webhook URL", | ||
description: "The URL to which Plaid should send webhook notifications. You must configure at least one webhook to enable webhooks.", | ||
optional: true, | ||
}, | ||
userToken: { | ||
type: "string", | ||
label: "User Token", | ||
description: "The user token associated with the User data is being requested for.", | ||
optional: true, | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const { | ||
app, | ||
institutionId, | ||
initialProducts, | ||
webhookUrl, | ||
userToken, | ||
} = this; | ||
|
||
const response = await app.createSandboxPublicToken({ | ||
institution_id: institutionId, | ||
initial_products: initialProducts, | ||
user_token: userToken, | ||
...( | ||
webhookUrl | ||
? { | ||
options: { | ||
webhook: webhookUrl, | ||
}, | ||
} | ||
: {} | ||
), | ||
}); | ||
|
||
$.export("$summary", `Successfully created sandbox public token for institution ${institutionId}`); | ||
|
||
return response; | ||
}, | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
import app from "../../plaid.app.mjs"; | ||
|
||
export default { | ||
key: "plaid-create-user", | ||
name: "Create User", | ||
description: "Creates a user ID and token to be used with Plaid Check, Income, or Multi-Item Link flow. [See the documentation](https://plaid.com/docs/api/users/#usercreate).", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
app, | ||
clientUserId: { | ||
type: "string", | ||
label: "Client User ID", | ||
description: "A unique ID representing the end user. Maximum of 128 characters. Typically this will be a user ID number from your application. Personally identifiable information, such as an email address or phone number, should not be used in the client_user_id.", | ||
optional: false, | ||
}, | ||
includeConsumerReportUserIdentity: { | ||
type: "boolean", | ||
label: "Include Consumer Report User Identity", | ||
description: "Whether to include the consumer report user identity. This is required for all Plaid Check customers.", | ||
optional: true, | ||
reloadProps: true, | ||
}, | ||
}, | ||
additionalProps() { | ||
if (!this.includeConsumerReportUserIdentity) { | ||
return {}; | ||
} | ||
|
||
return { | ||
firstName: { | ||
type: "string", | ||
label: "First Name", | ||
description: "The user's first name", | ||
}, | ||
lastName: { | ||
type: "string", | ||
label: "Last Name", | ||
description: "The user's last name", | ||
}, | ||
phoneNumbers: { | ||
type: "string[]", | ||
label: "Phone Numbers", | ||
description: "The user's phone number, in E.164 format: +{countrycode}{number}. For example: `+14157452130`. Phone numbers provided in other formats will be parsed on a best-effort basis. Phone number input is validated against valid number ranges; number strings that do not match a real-world phone numbering scheme may cause the request to fail, even in the Sandbox test environment.", | ||
}, | ||
emails: { | ||
type: "string[]", | ||
label: "Emails", | ||
description: "The user's emails", | ||
}, | ||
ssnLast4: { | ||
type: "string", | ||
label: "SSN Last 4", | ||
description: "The last 4 digits of the user's social security number.", | ||
optional: true, | ||
}, | ||
dateOfBirth: { | ||
type: "string", | ||
label: "Date of Birth", | ||
description: "To be provided in the format `yyyy-mm-dd`. This field is required for all Plaid Check customers.", | ||
}, | ||
primaryAddressCity: { | ||
type: "string", | ||
label: "City", | ||
description: "The full city name for the primary address", | ||
}, | ||
primaryAddressRegion: { | ||
type: "string", | ||
label: "Region/State", | ||
description: "The region or state. Example: `NC`", | ||
}, | ||
primaryAddressStreet: { | ||
type: "string", | ||
label: "Street", | ||
description: "The full street address. Example: `564 Main Street, APT 15`", | ||
}, | ||
primaryAddressPostalCode: { | ||
type: "string", | ||
label: "Postal Code", | ||
description: "The postal code", | ||
}, | ||
primaryAddressCountry: { | ||
type: "string", | ||
label: "Country", | ||
description: "The ISO 3166-1 alpha-2 country code", | ||
}, | ||
}; | ||
}, | ||
async run({ $ }) { | ||
const { | ||
app, | ||
clientUserId, | ||
includeConsumerReportUserIdentity, | ||
firstName, | ||
lastName, | ||
phoneNumbers, | ||
emails, | ||
ssnLast4, | ||
dateOfBirth, | ||
primaryAddressCity, | ||
primaryAddressRegion, | ||
primaryAddressStreet, | ||
primaryAddressPostalCode, | ||
primaryAddressCountry, | ||
} = this; | ||
|
||
const response = await app.createUser({ | ||
client_user_id: clientUserId, | ||
...(includeConsumerReportUserIdentity | ||
? { | ||
consumer_report_user_identity: { | ||
first_name: firstName, | ||
last_name: lastName, | ||
phone_numbers: phoneNumbers, | ||
emails: emails, | ||
date_of_birth: dateOfBirth, | ||
ssn_last_4: ssnLast4, | ||
primary_address: { | ||
city: primaryAddressCity, | ||
region: primaryAddressRegion, | ||
street: primaryAddressStreet, | ||
postal_code: primaryAddressPostalCode, | ||
country: primaryAddressCountry, | ||
}, | ||
}, | ||
} | ||
: {} | ||
), | ||
}); | ||
|
||
$.export("$summary", `Successfully created user with ID \`${response.user_id}\`.`); | ||
|
||
return response; | ||
}, | ||
}; |
47 changes: 47 additions & 0 deletions
47
components/plaid/actions/get-real-time-balance/get-real-time-balance.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import app from "../../plaid.app.mjs"; | ||
|
||
export default { | ||
key: "plaid-get-real-time-balance", | ||
name: "Get Real-Time Balance", | ||
description: "Get the real-time balance for each of an Item's accounts. [See the documentation](https://plaid.com/docs/api/products/balance/#accountsbalanceget).", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
app, | ||
accessToken: { | ||
propDefinition: [ | ||
app, | ||
"accessToken", | ||
], | ||
}, | ||
accountIds: { | ||
type: "string[]", | ||
label: "Account IDs", | ||
description: "The specific account IDs to filter by. If not provided, all accounts will be returned.", | ||
propDefinition: [ | ||
app, | ||
"accountId", | ||
({ accessToken }) => ({ | ||
accessToken, | ||
}), | ||
], | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const { | ||
app, | ||
accessToken, | ||
accountIds, | ||
} = this; | ||
|
||
const response = await app.getAccountsBalance({ | ||
access_token: accessToken, | ||
options: { | ||
account_ids: accountIds, | ||
}, | ||
}); | ||
|
||
$.export("$summary", "Successfully fetched account balances"); | ||
return response; | ||
}, | ||
}; |
100 changes: 100 additions & 0 deletions
100
components/plaid/actions/get-transactions/get-transactions.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import app from "../../plaid.app.mjs"; | ||
|
||
export default { | ||
key: "plaid-get-transactions", | ||
name: "Get Transactions", | ||
description: "Retrieves user-authorized transaction data for a specified date range. [See the documentation](https://plaid.com/docs/api/products/transactions/#transactionsget)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
app, | ||
accessToken: { | ||
propDefinition: [ | ||
app, | ||
"accessToken", | ||
], | ||
}, | ||
startDate: { | ||
propDefinition: [ | ||
app, | ||
"startDate", | ||
], | ||
}, | ||
endDate: { | ||
propDefinition: [ | ||
app, | ||
"endDate", | ||
], | ||
}, | ||
accountIds: { | ||
type: "string[]", | ||
label: "Account IDs", | ||
description: "A list of `account_ids` to retrieve for the Item. Note: An error will be returned if a provided `account_id` is not associated with the Item.", | ||
propDefinition: [ | ||
app, | ||
"accountId", | ||
({ accessToken }) => ({ | ||
accessToken, | ||
}), | ||
], | ||
}, | ||
includeOriginalDescription: { | ||
type: "boolean", | ||
label: "Include Original Description", | ||
description: "Include the raw unparsed transaction description from the financial institution.", | ||
default: false, | ||
optional: true, | ||
}, | ||
daysRequested: { | ||
type: "integer", | ||
label: "Days Requested", | ||
description: "Number of days of transaction history to request from the financial institution. Only applies when Transactions product hasn't been initialized. Min: 1, Max: 730, Default: 90.", | ||
min: 1, | ||
max: 730, | ||
optional: true, | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const { | ||
app, | ||
accessToken, | ||
startDate, | ||
endDate, | ||
accountIds, | ||
includeOriginalDescription, | ||
daysRequested, | ||
} = this; | ||
|
||
const options = {}; | ||
|
||
if (accountIds?.length) { | ||
options.account_ids = accountIds; | ||
} | ||
|
||
if (includeOriginalDescription !== undefined) { | ||
options.include_original_description = includeOriginalDescription; | ||
} | ||
|
||
if (daysRequested) { | ||
options.days_requested = daysRequested; | ||
} | ||
|
||
const transactions = await app.paginate({ | ||
resourcesFn: app.getTransactions, | ||
resourcesFnArgs: { | ||
access_token: accessToken, | ||
start_date: startDate, | ||
end_date: endDate, | ||
...(Object.keys(options).length > 0 && { | ||
options, | ||
}), | ||
}, | ||
resourceName: "transactions", | ||
}); | ||
|
||
const transactionCount = transactions?.length || 0; | ||
$.export("$summary", `Successfully retrieved ${transactionCount} transactions from ${startDate} to ${endDate}`); | ||
|
||
return transactions; | ||
}, | ||
}; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.