🔗
Linker Studio
  • Welcome!!
  • 🚀GETTING STARTED
    • Set up your custom project from Linker Studio
    • How to run the project
    • Linker Features
      • Glossary
      • Web
      • Mobile
        • Aggregators
        • Analytics
        • Authentication
        • BaaS
        • Carousel
        • Client Support
        • Error and Crash Reporting
        • Info Onboarding
        • KYC
        • Payroll
        • Pii Onboarding
        • Push Notifications - OneSignal
        • Settings
        • Subscriptions
      • Backend
        • Authentication
        • MFA
        • BaaS
        • Aggregators
        • Notifications
        • Payments
        • Deposit Switching
        • Support
        • Vault
        • Storage
        • Monitoring
        • Analytics
  • 🖥️WEB FEATURES
    • Page 2
  • 📱Mobile App Features
    • Project File Structure
    • Figma Tokens Integration
    • Core Module
      • Core UI Components
        • Atoms
        • Molecules
        • Organisms
        • Templates
      • Core Elements
      • Hooks
        • Force update
      • Endpoints used
      • States And Selectors
        • contentsDocuments
    • Modules
      • [New Feature Template]- Feature Name
        • UI Components - Template
          • Atoms
          • Molecules
          • Organisms
          • Templates
        • Hooks - Template
        • Endpoints Used
        • States and Selectors - Template
      • 📥KYC
        • Alloy
        • Baas
          • UI Components
            • Templates
          • Hooks - Template
          • Endpoints Used
          • States and Selectors - Template
        • common
          • UI Components
            • Templates
          • Endpoints Used
      • 🤝Aggregators
        • Plaid
          • Plaid/Rize notification before disabling account
      • 🤖Analytics
        • Amplitude
      • 🔐Authentication
        • Hooks
        • Auth0
          • Hooks
            • Login
            • Forgot password
          • 📧Verify Email
            • Hooks
        • Biometrics
          • Hooks
        • Auto Logout
        • States And Selectors
          • Authentication
      • 💰BaaS
        • Common
          • BaaS Navigation
          • External Accounts
          • UI Components
            • Molecules
            • Organisms
            • Templates
          • Hooks
            • Statements
            • Recurrent Transfers
            • Cards
              • Get Full Card
              • Lock and Unlock
              • Request Physical Debit Card
              • Reissue Debit Card
              • Set / Reset Debit Card Pin
            • Transfer
          • States And Selectors
            • Customer
            • Accounts
            • Cards
            • Transactions
          • Endpoints used
          • Constants
            • ACH_SERVICES
        • treasury
          • Constants
            • CONFIG_VALUES
      • 🛂Client Support
      • 🐛Error and Crash Reporting
        • Crashlytics
      • ℹ️Info Onboarding
        • States and Selectors
        • Hooks
          • Physical Card Request
      • 🌯Linker Wrapper
        • Linker Wrapper Messages Structure
        • Linker Wrapper Features
          • Push Notifications
            • Braze
          • In-App Purchase
      • 🛗MFA Verification Code
        • UI Components
          • Molecules
          • Templates
        • Hooks
        • Endpoints used
        • Configurable Constants
      • 🗞️Payroll
        • UI Components
          • Organisms
          • Templates
        • Hooks
        • States and Selectors
      • 📋PII Onboarding
        • UI Components
          • Atoms
          • Molecules
          • Organisms
          • Templates
        • Hooks
        • States and Selectors
      • 🔔Push Notifications
        • OneSignal
      • 🔧Settings
      • 🗄️Vault
        • VGS Show
        • VGS Collect
    • Cookbook
      • 🏦Neobank
        • Linked Functionalities
          • Edit Personal Details Linking
          • Request Physical Debit Card Linking
          • Get customer Data after SignUp/Login
  • ⛓️Backend API
    • Environments
    • Migrations
      • Configuration
      • Migration Commands
      • Base Model
      • Migration Structure
    • Seeds and Factories
      • Configuration
      • Seeds And Factories
    • SoftDelete
    • DB Fields Encryption
    • DB Structure
    • DB Configuration Table
      • API Endpoints
    • Orchestrator
    • Swagger
      • Setup
      • Decorators for Requests and Responses
      • Decorators for Controllers and HTTP Responses
      • Auth Decorator
      • Multiple Decorators
  • 🪙Finance Integrations
    • Recurring Transfers
      • Architecture
      • Jobs Server
      • Functionality
      • BaaS
        • Rize API Endpoints
        • Treasury Prime API Endpoints
        • Business Treasury Prime API Endpoints
    • BaaS
      • Rize
        • Env Variables
        • Rize API authentication
        • Onboarding
          • Customer Enrollment
          • Get Compliance Workflow
          • Acknowledge Compliance Workflow
          • Customer Complete Enrollment
        • KYC - Know Your Customer
          • Get KYC Documents
          • Upload KYC Document
        • Accounts
          • Get Customer Accounts
          • Get Customer Account By ID
          • Create Customer Account
          • Archive Customer Account
          • Get ACH Customer Accounts
        • Debit Cards
          • Get Debit Cards
          • Get Debit Card Image
          • Lock Debit Card
          • Unlock Debit Card
          • Create Physical Card
          • Activate Debit Card
          • Get Debit Card Set-Pin URL
          • Reissue Debit Card
        • Transactions
          • Get Transactions
        • Transfers
          • Internal Transfers
          • ACH transfers
        • Statements
          • Get Statements
          • Get Statement Document
        • Fake Transactions
        • Message Queue
        • Web Sockets
        • API Endpoints
          • Account Enums
          • Debit Card Enums
          • Transaction Enums
          • KYC Enums
      • Galileo
        • Environment Variables
        • Onboarding
          • Get Customer
          • Customer Enrollment
          • Customer Complete Enrollment
        • Customer Management
          • Get Profile
          • Update Profile
        • Accounts
        • Add Accounts
        • Card Management
          • Get Debit Cards
          • Get Image Card
          • Card Statuses
          • Debit Card Activation
          • Request Physical Card
          • Set PIN
          • Lock/Unlock
        • Transfer
        • Transactions
          • Get Transactions
          • Filter Transactions
        • ACH
          • Add ACH Account
          • Get ACH Accounts
          • Remove ACH Account
          • ACH Transactions
        • Statements
        • Plaid Integration
      • Synapse
        • Environment Variables
        • Terminology
        • Resources
        • API Endpoints
    • Aggregators
      • Add Account Service and new DB Table
      • Plaid
        • Plaid Configuration
        • Application Creation
        • Custom Application
        • Configure Single or Multi Accounts
        • Security Settings
        • Verification of Environment Variables
        • API Endpoints
        • Resources
        • Integrations
          • Rize
      • MX
        • Env Configuration
        • API Endpoints
  • 🔐Authentication
    • Auth0
      • Configuration
      • Protecting an endpoint
      • Email verification
      • API Reference
    • Twilio
      • 2FA
        • Verify Service Configuration
        • Verification Workflow
        • API Endpoints
  • 🪪 KYC
    • Persona
      • Configuration
      • Environment Variables
      • KYC Flow
  • ✉️ Mailings
    • Sendgrid
      • Configuration
      • Environment Variables
      • Send Email with Attachments
  • 🆘Supports
    • Zendesk
      • Configuration
      • API Endpoints
  • 📳NOTIFICATIONS
    • OneSignal
      • Schema
      • Setup
      • Environment Variables
      • API Endpoints
  • 🔐Security
    • VGS
      • Configuration
      • Rize Route Configuration
      • VGS Vault Basics
      • VGS Show
  • 🖥️MONITORING
    • New Relic
      • Configuration
      • Interceptor
  • 🧑‍🔧CONTENT ADMINISTRATOR
    • Notifications
    • Onboardings
      • DB Schema
      • Admin - API Endpoints
      • Client - API Endpoints
    • Documents
      • Document Category
      • Document
      • Client - API Endpoints
      • Admin - API Endpoints
    • App Versions
      • Device App Versions
      • API - Administrator
      • API - Client
  • 💵Payments
    • Stripe
      • Configuration
      • Customers
      • Sources
      • Authorization
      • Charges
      • API Endpoints
Powered by GitBook
On this page

Was this helpful?

  1. Finance Integrations
  2. Aggregators
  3. Plaid
  4. Integrations

Rize

PreviousIntegrationsNextMX

Last updated 2 years ago

Was this helpful?

Rize only allows you to connect one account, so you must modify it in the so that only one can be selected by default, since the first account returned by Plaid will be taken if you use the as true.

This would be the flow to request a link token from Plaid:

This is the flow to make a direct connection with the BaaS:

If a direct connection to the BaaS is not made, you must make a request by sending the id of the account you want to connect:

This section will have the steps to integrate Plaid with Rize, but if you want to know more about Rize, you can see this section:

First, we will import some files in aggregators/aggregators.module.ts

We will import the BaaS module because we will use the Rize service to send our account data in Plaid, and it will be created in the BaaS.

We will add the integration model in TypeOrmModule.forFeature because we will query the database when the user did the last integration, since Rize doesn't allow to connect a new account before 30 days after deleting an account.

import { HttpModule } from '@nestjs/axios';
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { AuthModule } from 'src/auth/auth.module';
import { RizeService } from 'src/baas/rize/rize.service';
import { Account } from 'src/features/account/account.entity';
import { AccountsModule } from 'src/features/account/accounts.module';
import { Integration } from 'src/features/integration/integration.entity';
import { IntegrationsModule } from 'src/features/integration/integrations.module';
import { User } from 'src/features/user/user.entity';
import { PlaidController } from './plaid/plaid.controller';
import { PlaidService } from './plaid/plaid.service';
import { BaasModule } from '../baas/baas.module';

@Module({
  imports: [
    HttpModule,
    AuthModule,
    TypeOrmModule.forFeature([User, Integration, Account]),
    IntegrationsModule,
    AccountsModule,
    BaasModule,
  ],
  controllers: [PlaidController],
  providers: [PlaidService, RizeService],
})
export class AggregatorsModule {}

Now, in the Plaid service's constructor, we must create our variables that will have the instance for the Rize service and the connection to the integration repository.

We will modify the file aggregators/plaid.service.ts:

import { RizeService } from 'src/baas/rize/rize.service';
import { CreateSyntheticAccountDto } from 'src/baas/rize/dto/create-synthetic-account.dto';
import { SyntheticAccount } from 'src/baas/rize/interfaces';
..... 
public constructor(
  @InjectRepository(Integration)
  private readonly integrationRepository: Repository<Integration>,
  private readonly rizetyService: RizeService,
)
.....
  • Third Party Connection

This method is automatically executed if, when using the aggregators/banking-connection endpoint, the third_party_connection property is passed as true.

public async thirdPartyConnection(user: User): Promise<void> {
  const { accounts } = await this.getMyAccounts(user);
  const [account] = accounts;
  const accountParams: ProcessorTokenBodyDto = {
    account_id: account.account_id,
  };

  await this.bankingAccountConnection(user, accountParams);

  return;
}

Now, we will modify some Plaid methods that will communicate with the Rize service.

In the function called bankingAccountConnection, you must change the following code:

  • Banking Account Connection

Before:

public async bankingAccountConnection(
  user: User,
  dto: ProcessorTokenBodyDto,
): Promise<void> {
  if (!user.aggregator_plaid_access_token) {
    throw new UnprocessableEntityException(
      'User has not created a Plaid account.',
    );
  }

  try {
    const request: ProcessorTokenCreateRequest = {
      access_token: user.aggregator_plaid_access_token,
      account_id: dto.account_id,
      processor: ProcessorTokenCreateRequestProcessorEnum.Rize,
    };

    const processorTokenResponse =
      await this.plaidClient.processorTokenCreate(request);
    const processorToken = processorTokenResponse.data.processor_token;
    await this.userService.saveBankingAccountConnection(
      user.id,
      processorToken,
      dto.account_id,
    );
  } catch (err) {
    throw new NotFoundException(err.message);
  }
}

After:

public async bankingAccountConnection(
  user: User,
  dto: ProcessorTokenBodyDto,
): Promise<void> {
  const integration = await this.integrationService.getIntegrationByUser(
    user.id,
    IntegrationServices.PLAID,
  );

  await this.verifyLastAccount(integration, user);

  const account = await this.accountService.getAccount(
    dto.account_id,
    integration.id,
  );

  if (account) {
    throw new UnprocessableEntityException(
      'User has already created a Plaid account.',
    );
  }

  try {
    const { accounts } = await this.getMyAccounts(user);

    const userAccount = accounts.find(
      (account) => account.account_id == dto.account_id,
    );

    if (!userAccount) {
      throw new UnprocessableEntityException('This account not exists.');
    }

    const processorToken = await this.generateProcessorToken(
      user.id,
      userAccount.account_id,
      ProcessorTokenCreateRequestProcessorEnum.Rize,
    );

    const SyntheticAccountParams: CreateSyntheticAccountDto = {
      account_name: userAccount.name,
      plaid_processor_token: processorToken,
      external_uid: userAccount.account_id,
    };

    const syntheticAccount = await this.rizeService.createSyntheticAccount(
      user,
      SyntheticAccountParams,
    );

    await this.accountService.addAccount(
      userAccount.account_id,
      user.id,
      integration.id,
      processorToken,
      syntheticAccount.uid,
    );
  } catch (err) {
    throw new NotFoundException(err.message);
  }
}

In the function called mapAccount, you must change the following code:

  • Map Account

Before:

public async mapAccount(account, user: User): Promise<CustomAccountDto> {
  // here you must check which accounts you have connected to
  // the baas to return the account id and status.
  return {
    baas_account_uid: null,
    account_id: account.account_id,
    name: account.name,
    baas_status: null,
    subtype: account.subtype,
    type: account.type,
    mask: account.mask,
    balances: account.balances,
  };
}

After:

In this function, a SyntheticAccount variable is declared, which will be used to check if the account it receives as a parameter is connected to the BaaS.

If the account is connected to the BaaS, the id assigned by the BaaS and the account status will be returned, because when creating the account, the BaaS assigns a started status to the account, and then the BaaS contacts Plaid to get the associated account information. If everything was successful, the account goes from started to active, but if a failure occurs, it goes from started to failed, and another request must be made again to try to connect the account.

public async mapAccount(account, user: User): Promise<CustomAccountDto> {
  let syntheticAccount: SyntheticAccount;
  const integration = await this.integrationService.getIntegrationByUser(
    user.id,
    IntegrationServices.RIZE,
  );

  const userAccount = await this.accountService.getAccountByExternalId(
    account.account_id,
  );

  if (userAccount) {
    syntheticAccount = await this.rizeService.getSyntheticAccount(
      integration,
      userAccount.baasId,
    );
  }

  return {
    baas_account_uid: syntheticAccount ? syntheticAccount.uid : null,
    account_id: account.account_id,
    name: account.name,
    baas_status: syntheticAccount ? syntheticAccount.status : null,
    subtype: account.subtype,
    type: account.type,
    mask: account.mask,
    balances: account.balances,
    deleted_at: userAccount ? userAccount.deletedAt : null,
  };
}

Generate Processor Token

public async generateProcessorToken(
  userId: string,
  externalAccountId: string,
  processorType: ProcessorTokenCreateRequestProcessorEnum,
): Promise<string> {
  try {
    const request: ProcessorTokenCreateRequest = {
      access_token: await this.integrationService.getAuthenticationId(
        IntegrationServices.PLAID,
        userId,
      ),
      account_id: externalAccountId,
      processor: processorType,
    };
    const processorTokenResponse =
      await this.plaidClient.processorTokenCreate(request);
    return processorTokenResponse.data.processor_token;
  } catch (err) {
    throw new NotFoundException(err.message);
  }
}

Verify Last Integration

public async verifyLastIntegration(user: User): Promise<void> {
  const integration = await this.integrationRepository.findOne({
    where: {
      userId: user.id,
      service: IntegrationServices.PLAID,
    },
    withDeleted: true,
    order: {
      createdAt: 'DESC',
    },
  });

  if (integration && integration.deletedAt) {
    const days = dayjs().diff(dayjs(integration.deletedAt), 'days');
    if (days <= 30) {
      throw new UnprocessableEntityException(
        'You must wait 30 days to be able to reconnect an account',
      );
    }
  }
}

Click for more details.

This method is used to generate the processor token according to the service with which Plaid is to connect. You can see all the services allowed in this .

In Rize, after deleting an account with plaid_external type, you have to Therefore, a method was created to verify the number of days elapsed. This verification is done only if the user has previously deleted an account.

🪙
Rize
here
link
wait 30 days to create a new one.
plaid_external
Plaid dashboard
third_party_connection field