Skip to content

TheM.externalAccounts Reference

Constructor

The parent TheM class contains functionality enabling the initialization of any TheM subclass or submodule instance by simply calling TheM.doInit('subclassName'), where the input string is a case sensitive space-delimited string containing the names of all submodules that may be required in the current session. Most TheM subclasses also require the 'common' submodule. It is common to initialize the target submodule and any other submodule dependencies concurrently. The following example will initialize a new instance of the necessary submodules using a proxy constructor in TheM parent class.

TheM.doInit('subclassName1 subclassName2 subclassName3 etc');

Example

TheM.doInit('common user accounts cards fdrs externalAccounts');

Properties

Property table for TheM.externalAccounts

Property Description Required Schema
allActive Gets (returns) an array with all the external accounts associated with the user that have an .isActive property value of true. Yes {
  "title": "TheM.externalAccounts.allActive",
  "type": "array",
  "description": "Gets (returns) an array with all
the external accounts associated with the user that
have an .isActive property value of true.",
  "$comment": "getter",
  "examples": [
    [
      {
        "AFiExternalAccountId":
"qweealxsye6pizvuubieaoyoe",
        "accountNumberMasked": "4...0004",
        "bankName": "Debit card",
        "comment": "Adding new individual debit card",
        "dtsCreated": "Fri Jun 28 2024 07:12:10 GMT-0400
(Eastern Daylight Time)",
        "dtsModified": "Fri Jun 28 2024 07:12:10 GMT-0400
(Eastern Daylight Time)",
        "name": "Individual debit card",
        "networkName": "Visa",
        "panMasked": "4...0004",
        "type": "DEBITCARD",
        "isActive": true,
        "isPending": false,
        "isSyncedToServer": true,
        "isValid": false,
        "isVerified": true,
        "validationMessage": "The card number is
invalid",
        "toJSON": {}
      },
      {
        "AFiExternalAccountId":
"qweealxszpo0chsufhuxwwesv",
        "accountNumber": "123467890123456",
        "accountNumberMasked": "...3456",
        "bankName": "Bank ABC",
        "comment": "Bank Account",
        "dtsCreated": "Fri Jun 28 2024 07:12:10 GMT-0400
(Eastern Daylight Time)",
        "dtsModified": "Fri Jun 28 2024 07:12:10 GMT-0400
(Eastern Daylight Time)",
        "name": "Bank Account",
        "routingNumber": "103112617",
        "title": "Suzy Tester",
        "type": "CHECKING",
        "isActive": true,
        "isPending": false,
        "isSyncedToServer": true,
        "isValid": true,
        "isVerified": true,
        "validationMessage": "",
        "toJSON": {}
      }
    ]
  ],
  "nullable": false
}
length Gets (returns) the length of the externalAccounts array. Yes {
  "title": "TheM.externalAccounts.length",
  "type": "number",
  "description": "Gets (returns) the length of the
externalAccounts array.",
  "examples": [
    1
  ],
  "default": 0,
  "nullable": false
}
autofunding Gets (returns) the TheM.externalAccounts.autofunding object. Yes {
  "title": "TheM.externalAccounts.autofunding",
  "type": "object",
  "description": "Gets (returns) the
TheM.externalAccounts.autofunding object.",
  "$comment": "getter",
  "examples": [
    {
      "AFiExternalAccountId":
"qweealxt6213tavxcsmyztaio",
      "amount": 20,
      "cadence": "when_low",
      "currency": "USD",
      "externalAccount": {},
      "isEnabled": true,
      "isValid": true,
      "lowAmount": 15,
      "toJSON": {
        "AFiExternalAccountId":
"qweealxt6213tavxcsmyztaio",
        "amount": 20,
        "cadence": "when_low",
        "currency": "USD",
        "lowAmount": 15
      }
    }
  ],
  "nullable": false
}
isReady Gets (returns) true if TheM.externalAccounts is fully ready. Yes {
  "title": "TheM.externalAccounts.isReady",
  "type": "boolean",
  "description": "Gets (returns) true if
TheM.externalAccounts is fully ready.",
  "$comment": "getter",
  "examples": [
    true,
    false
  ],
  "default": false,
  "nullable": false
}

Methods

Method Name Parameter Descriptions Description Example
doSave
[]
Saves externalAccounts data in local storage. Normally, there is no need to use this method as the framework knows automatically when to save and when to load the data to and from local storage. Returns true. TheM.externalAccounts.doSave();
doLoad
[]
Loads externalAccounts data from local storage. On success, a(n) 'modelBank external accounts loaded' event will occur.Normally, there is no need to use this method as the framework knows automatically when to save and when to load the data to and from local storage. TheM.externalAccounts.doLoad();
doUpdate
[
{
"title": "given",
"type": "boolean",
"nullable": true,
"example": true,
"$comment": "Forces framework to
pull fresh data from server if
true."
}
]
Causes framework to pull fresh externalAccounts data from the server. If the data is fresh enough, meaning an update has happened recently, the framework will ignore the suggestion. However, you can force the framework to update the data by sending true as an argument. On success, a(n) 'modelBank external accounts updated' event will occur. A 'modelBank external accounts changed' event also occurs if the server sent new data. Local updates are sent to the server prior to pulling the data from the server. TheM.externalAccounts.doUpdate(true);
isValidField
[
{
"title": "fieldName",
"type": "string",
"nullable": false,
"example": "accountNumber"
},
{
"title": "value",
"type": "string",
"nullable": false,
"example": "1234567890123456"
}
]
Checks to make sure the given value is valid for the given fieldName. If the fieldName is not recognized by the isValidField method, it will return false. If the fieldName is recognized but the value is invalid, it will return an appropriate validation error message. Possible fieldNames to check are 'pan', 'date', 'cvv', 'name', 'bankName', 'type', 'accountNumber', and 'routingNumber'. Returns true if valid. TheM.externalAccounts.isValidField("accountNumber","1234567890123456");
doGetPlaidLinkToken
[
{
"title": "payload",
"type": "object",
"nullable": true,
"properties": {
"redirectURL": {
"type": "string",
"nullable": true,
"$comment": "A URL to redirect to
after requested action takes
place"
}
},
"example": {
"redirectURL":
"www.asfsdf.something"
}
}
]
Generates a link token to identify the external account. If successful, a 'modelBank external account link_token received' event occurs and the received linkToken is returned. TheM.externalAccounts.doGetPlaidLinkToken(
  {
   "redirectURL": "www.asfsdf.something"
  }
);
new
[
{
"title": "given",
"type": "object",
"nullable": false,
"properties": {
"AFiExternalAccountId": {
"type": "string",
"nullable": true,
"$comment": "Present only if
modifying an existing
externalAccount"
},
"type": {
"type": "string",
"nullable": false,
"enum": [
"CHECKING",
"SAVINGS",
"DEBITCARD",
"CREDITCARD"
]
},
"subtype": {
"type": "string",
"nullable": true
},
"name": {
"type": "string",
"nullable": true,
"$comment": "A name visible to the
client, maximum of 25 characters"
},
"title": {
"type": "string",
"nullable": true,
"$comment": "External account
owner"
},
"comment": {
"type": "string",
"nullable": true
},
"isSyncedToServer": {
"type": "boolean",
"default": false
},
"isActive": {
"type": "boolean",
"nullable": true
},
"isPending": {
"type": "boolean",
"nullable": true
},
"isVerified": {
"type": "boolean",
"nullable": true
},
"dtsModified": {
"type": "Date",
"nullable": false
},
"pan": {
"type": "string",
"nullable": true,
"$comment": "Required for
DEBITCARD or CREDITCARD type
external accounts, 16 digits"
},
"panMasked": {
"type": "string",
"nullable": true
},
"cvv": {
"type": "string",
"nullable": true,
"$comment": "Required for
DEBITCARD or CREDITCARD type
external accounts"
},
"expiryYYYYMM": {
"type": "string",
"nullable": true,
"$comment": "Either
expiryYYYYMM or both of expiryYY
and expiryMM must be present for
DEBITCARD or CREDITCARD type
external accounts."
},
"expiryYY": {
"type": "string",
"nullable": true,
"$comment": "Either
expiryYYYYMM or both of expiryYY
and expiryMM must be present for
DEBITCARD or CREDITCARD type
external accounts."
},
"expiryMM": {
"type": "string",
"nullable": true,
"$comment": "Either
expiryYYYYMM or both of expiryYY
and expiryMM must be present for
DEBITCARD or CREDITCARD type
external accounts."
},
"name_on_card": {
"type": "string",
"nullable": true,
"$comment": "If not present for
DEBITCARD or CREDITCARD type
external accounts, the local
user's first and last name will be
used, separated by a space."
},
"cardImageFront": {
"type": "string",
"nullable": true,
"$comment": "Scanned raw image"
},
"cardImageBack": {
"type": "string",
"nullable": true,
"$comment": "Scanned raw image"
},
"image": {
"type": "string",
"nullable": true,
"$comment": "Image to be used as an
icon, sent by server"
},
"networkName": {
"type": "string",
"nullable": true,
"$comment": "The payment system"
},
"accountNumber": {
"type": "string",
"nullable": true,
"$comment": "Required for
CHECKING or SAVINGS type external
accounts"
},
"accountNumberMasked": {
"type": "string",
"nullable": true
},
"routingNumber": {
"type": "string",
"nullable": true,
"$comment": "Required for
CHECKING or SAVINGS type external
accounts, 9 digits"
},
"bankName": {
"type": "string",
"nullable": true,
"$comment": "Required for
CHECKING or SAVINGS type external
accounts"
},
"logoB64": {
"type": "string",
"nullable": true,
"$comment": "Bank logo in base 64
string format"
}
},
"example": {
"type": "DEBITCARD",
"pan": "1234567890123456",
"cvv": "123",
"expiryYYYYMM": "202610",
"name_on_card": "SUZY QUEUE
TESTER",
"expiryYY": "26",
"expiryMM": "10",
"panMasked":
"123456**3456",
"comment": "Adding new
individual debit card",
"name": "Individual debit card",
"title": "Suzy Tester",
"cardImageFront":
"Very_Long_B64_Image_String",
"cardImageBack":
"Very_Long_B64_Image_String",
"networkName": "Visa",
"dtsModified":
"2024-06-28T11:12:10.068Z"
}
}
]
Creates and returns a new instance of the ExternalAccount class using the given object properties. ExternalAccount types include CHECKING, SAVINGS, DEBITCARD, or CREDITCARD, and required properties depend on the type of external account being added. TheM.externalAccounts.new(
  {
   "type": "DEBITCARD",
   "pan": "1234567890123456",
   "cvv": "123",
   "expiryYYYYMM": "202610",
   "name_on_card": "SUZY QUEUE TESTER",
   "expiryYY": "26",
   "expiryMM": "10",
   "panMasked": "123456**3456",
   "comment": "Adding new individual debit card",
   "name": "Individual debit card",
   "title": "Suzy Tester",
   "cardImageFront": "Very_Long_B64_Image_String",
   "cardImageBack": "Very_Long_B64_Image_String",
   "networkName": "Visa",
   "dtsModified": "2024-06-28T11:12:10.068Z"
  }
);
newAutofunding
[
{
"title": "given",
"type": "object",
"nullable": false,
"properties": {
"AFiExternalAccountId": {
"type": "string",
"nullable": true,
"$comment": "Present only if
adding or modifying autofunding
for an existing
externalAccount."
},
"amount": {
"type": "number",
"nullable": true,
"$comment": "Can configure a
minTopup and/or maxTopup amount
using
TheM.fdrs.externalAccountsConf
ig."
},
"currency": {
"type": "string",
"nullable": true,
"default": "USD"
},
"cadence": {
"type": "string",
"nullable": true,
"enum": [
"weekly",
"monthly",
"when_low"
],
"$comment": ""
},
"weekday": {
"type": "string",
"nullable": true,
"enum": [
"Sun",
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
"Sat"
],
"$comment": "Required if cadence
is 'weekly'."
},
"day": {
"type": "number",
"nullable": true,
"$comment": "Required if cadence
is 'monthly'. Will be a number
between 1 and 31, inclusive,
representing the day of the month
to process the autofunding."
},
"lowAmount": {
"type": "number",
"nullable": true,
"$comment": "Required if cadence
is 'when_low'. Specifies the
account balance threshold at
which to initiate the
autofunding."
},
"isSyncedToServer": {
"type": "boolean",
"nullable": true
},
"isValid": {
"type": "boolean",
"nullable": true
}
},
"example": {
"AFiExternalAccountId":
"qweealxsye6pizvuubieaoyoe",
"cadence": "when_low",
"amount": 100,
"currency": "USD",
"lowAmount": 10
}
}
]
Creates a new temporary instance of the Autofunding class using the given object properties. Autofunding transfers a set amount from the external account on a regular schedule, or cadence. The transfer may be weekly, monthly, or when the user's account is low. See the ampliFi MODULES documentation for the /externalaccount/autofunding endpoint (which is called when TheM.externalAccounts.autofunding is updated) for additional information on autofunding. TheM.externalAccounts.newAutofunding(
  {
   "AFiExternalAccountId": "qweealxsye6pizvuubieaoyoe",
   "cadence": "when_low",
   "amount": 100,
   "currency": "USD",
   "lowAmount": 10
  }
);

Submodules

Submodule Name Link
ExternalAccount ExternalAccount Reference
Autofunding Autofunding Reference