boneburrito / budgetsimple

MIT License
0 stars 0 forks source link

Implement Plaid - link account and transactions #34

Open brukeg opened 9 months ago

brukeg commented 9 months ago

Plaid

Plaid is a fintech company that facilitates communication between financial services apps and users' banks and credit card providers for the purpose of exchanging data seamlessly and securely

Story:

As user of BudgetSimple I should be able to seamlessly acquire my bank and credit card transaction data to enrich my BudgetSimple profile.

Implementation (extremely vague plan)

Plaid Link Plaid Link is the client-side component that your users will interact with in order to link their accounts to Plaid and allow you to access their accounts via the Plaid API.

https://plaid.com/docs/link/

Transaction endpoint Retrieve and refresh up to 24 months of historical transaction data, including geolocation, merchant, and category information.

https://plaid.com/docs/api/products/transactions/

ENDPOINTS  
/transactions/sync Get transaction data or incremental transaction updates
/transactions/get Fetch transaction data
/transactions/recurring/get Fetch recurring transaction data
/transactions/refresh Refresh transaction data
/categories/get Fetch all transaction categories

Build functionality around transaction/get and transaction/sync. Use /get the first time a user links their account, and use /sync each subsequent time to update new transaction--the update cadence is TBD, but in the sandbox let's say daily, or use your best judgment.

Save account data, like name, subtype, type, etc in a new Accounts model. Save transaction data in the transaction model and or removing from the model as needed. We are keeping the upload document option for now so don't delete stuff related to that. You may need to add "Category" as a new field in the transaction model.

Example response body from transaction/get:

{
  "accounts": [
    {
      "account_id": "BxBXxLj1m4HMXBm9WZZmCWVbPjX16EHwv99vp",
      "balances": {
        "available": 110.94,
        "current": 110.94,
        "iso_currency_code": "USD",
        "limit": null,
        "unofficial_currency_code": null
      },
      "mask": "0000",
      "name": "Plaid Checking",
      "official_name": "Plaid Gold Standard 0% Interest Checking",
      "subtype": "checking",
      "type": "depository"
    }
  ],
  "transactions": [
    {
      "account_id": "BxBXxLj1m4HMXBm9WZZmCWVbPjX16EHwv99vp",
      "account_owner": null,
      "amount": 28.34,
      "iso_currency_code": "USD",
      "unofficial_currency_code": null,
      "category": [
        "Food and Drink",
        "Restaurants",
        "Fast Food"
      ],
      "category_id": "13005032",
      "check_number": null,
      "counterparties": [
        {
          "name": "DoorDash",
          "type": "marketplace",
          "logo_url": "https://plaid-counterparty-logos.plaid.com/doordash_1.png",
          "website": "doordash.com",
          "entity_id": "YNRJg5o2djJLv52nBA1Yn1KpL858egYVo4dpm",
          "confidence_level": "HIGH"
        },
        {
          "name": "Burger King",
          "type": "merchant",
          "logo_url": "https://plaid-merchant-logos.plaid.com/burger_king_155.png",
          "website": "burgerking.com",
          "entity_id": "mVrw538wamwdm22mK8jqpp7qd5br0eeV9o4a1",
          "confidence_level": "VERY_HIGH"
        }
      ],
      "date": "2023-09-28",
      "datetime": "2023-09-28T15:10:09Z",
      "authorized_date": "2023-09-27",
      "authorized_datetime": "2023-09-27T08:01:58Z",
      "location": {
        "address": null,
        "city": null,
        "region": null,
        "postal_code": null,
        "country": null,
        "lat": null,
        "lon": null,
        "store_number": null
      },
      "name": "Dd Doordash Burgerkin",
      "merchant_name": "Burger King",
      "merchant_entity_id": "mVrw538wamwdm22mK8jqpp7qd5br0eeV9o4a1",
      "logo_url": "https://plaid-merchant-logos.plaid.com/burger_king_155.png",
      "website": "burgerking.com",
      "payment_meta": {
        "by_order_of": null,
        "payee": null,
        "payer": null,
        "payment_method": null,
        "payment_processor": null,
        "ppd_id": null,
        "reason": null,
        "reference_number": null
      },
      "payment_channel": "online",
      "pending": true,
      "pending_transaction_id": null,
      "personal_finance_category": {
        "primary": "FOOD_AND_DRINK",
        "detailed": "FOOD_AND_DRINK_FAST_FOOD",
        "confidence_level": "VERY_HIGH"
      },
      "personal_finance_category_icon_url": "https://plaid-category-icons.plaid.com/PFC_FOOD_AND_DRINK.png",
      "transaction_id": "yhnUVvtcGGcCKU0bcz8PDQr5ZUxUXebUvbKC0",
      "transaction_code": null,
      "transaction_type": "digital"
    },