Stripe Connect module API explorer

/api/administrator/connect/persons (GET)

Account information like email addresses is generated with faker-js it is not real user information.

await global.api.administrator.connect.Persons.get(req)

Returns array

[
  {
    "personid": "person_1LEBqURWlXhsfg4STy812wyj",
    "object": "person",
    "accountid": "acct_42f15039e73ca835",
    "stripeid": "acct_1LEBqNRWlXhsfg4S",
    "tokenUpdate": null,
    "stripeObject": {
      "id": "person_1LEBqURWlXhsfg4STy812wyj",
      "object": "person",
      "account": "acct_1LEBqNRWlXhsfg4S",
      "address": {
        "city": null,
        "country": "DE",
        "line1": null,
        "line2": null,
        "postal_code": null,
        "state": null
      },
      "created": 1656074567,
      "dob": {
        "day": null,
        "month": null,
        "year": null
      },
      "first_name": null,
      "future_requirements": {
        "alternatives": [],
        "currently_due": [],
        "errors": [],
        "eventually_due": [],
        "past_due": [],
        "pending_verification": []
      },
      "last_name": null,
      "metadata": {},
      "relationship": {
        "director": true,
        "executive": true,
        "owner": false,
        "percent_ownership": null,
        "representative": false,
        "title": "SVP Testing"
      },
      "requirements": {
        "alternatives": [],
        "currently_due": [
          "address.city",
          "address.line1",
          "address.postal_code",
          "dob.day",
          "dob.month",
          "dob.year",
          "email",
          "first_name",
          "last_name"
        ],
        "errors": [],
        "eventually_due": [
          "address.city",
          "address.line1",
          "address.postal_code",
          "dob.day",
          "dob.month",
          "dob.year",
          "email",
          "first_name",
          "last_name"
        ],
        "past_due": [
          "address.city",
          "address.line1",
          "address.postal_code",
          "dob.day",
          "dob.month",
          "dob.year",
          "email",
          "first_name",
          "last_name"
        ],
        "pending_verification": []
      },
      "verification": {
        "additional_document": {
          "back": null,
          "details": null,
          "details_code": null,
          "front": null
        },
        "details": null,
        "details_code": null,
        "document": {
          "back": null,
          "details": null,
          "details_code": null,
          "front": null
        },
        "status": "unverified"
      }
    },
    "appid": "tests_1656074529",
    "createdAt": "2022-06-24T12:42:49.808Z",
    "updatedAt": "2022-06-24T12:42:49.808Z"
  },
  {
    "personid": "person_1LEBqRRWlXhsfg4Sz46ugQor",
    "object": "person",
    "accountid": "acct_42f15039e73ca835",
    "stripeid": "acct_1LEBqNRWlXhsfg4S",
    "tokenUpdate": null,
    "stripeObject": {
      "id": "person_1LEBqRRWlXhsfg4Sz46ugQor",
      "object": "person",
      "account": "acct_1LEBqNRWlXhsfg4S",
      "address": {
        "city": null,
        "country": "DE",
        "line1": null,
        "line2": null,
        "postal_code": null,
        "state": null
      },
      "created": 1656074563,
      "dob": {
        "day": null,
        "month": null,
        "year": null
      },
      "first_name": null,
      "future_requirements": {
        "alternatives": [],
        "currently_due": [],
        "errors": [],
        "eventually_due": [],
        "past_due": [],
        "pending_verification": []
      },
      "last_name": null,
      "metadata": {},
      "relationship": {
        "director": true,
        "executive": false,
        "owner": false,
        "percent_ownership": null,
        "representative": false,
        "title": "Director"
      },
      "requirements": {
        "alternatives": [],
        "currently_due": [
          "dob.day",
          "dob.month",
          "dob.year",
          "email",
          "first_name",
          "last_name"
        ],
        "errors": [],
        "eventually_due": [
          "dob.day",
          "dob.month",
          "dob.year",
          "email",
          "first_name",
          "last_name"
        ],
        "past_due": [
          "dob.day",
          "dob.month",
          "dob.year",
          "email",
          "first_name",
          "last_name"
        ],
        "pending_verification": []
      },
      "verification": {
        "additional_document": {
          "back": null,
          "details": null,
          "details_code": null,
          "front": null
        },
        "details": null,
        "details_code": null,
        "document": {
          "back": null,
          "details": null,
          "details_code": null,
          "front": null
        },
        "status": "unverified"
      }
    },
    "appid": "tests_1656074529",
    "createdAt": "2022-06-24T12:42:45.239Z",
    "updatedAt": "2022-06-24T12:42:46.538Z"
  },
  {
    "personid": "person_1LEBqMRV3CkaOXbJmKbNM1Kq",
    "object": "person",
    "accountid": "acct_944c5bd7c0a89ffd",
    "stripeid": "acct_1LEBqIRV3CkaOXbJ",
    "tokenUpdate": null,
    "stripeObject": {
      "id": "person_1LEBqMRV3CkaOXbJmKbNM1Kq",
      "object": "person",
      "account": "acct_1LEBqIRV3CkaOXbJ",
      "address": {
        "city": null,
        "country": "DE",
        "line1": null,
        "line2": null,
        "postal_code": null,
        "state": null
      },
      "created": 1656074558,
      "dob": {
        "day": null,
        "month": null,
        "year": null
      },
      "first_name": null,
      "future_requirements": {
        "alternatives": [],
        "currently_due": [],
        "errors": [],
        "eventually_due": [],
        "past_due": [],
        "pending_verification": []
      },
      "last_name": null,
      "metadata": {},
      "relationship": {
        "director": true,
        "executive": false,
        "owner": false,
        "percent_ownership": null,
        "representative": false,
        "title": "Director"
      },
      "requirements": {
        "alternatives": [],
        "currently_due": [
          "dob.day",
          "dob.month",
          "dob.year",
          "email",
          "first_name",
          "last_name"
        ],
        "errors": [],
        "eventually_due": [
          "dob.day",
          "dob.month",
          "dob.year",
          "email",
          "first_name",
          "last_name"
        ],
        "past_due": [
          "dob.day",
          "dob.month",
          "dob.year",
          "email",
          "first_name",
          "last_name"
        ],
        "pending_verification": []
      },
      "verification": {
        "additional_document": {
          "back": null,
          "details": null,
          "details_code": null,
          "front": null
        },
        "details": null,
        "details_code": null,
        "document": {
          "back": null,
          "details": null,
          "details_code": null,
          "front": null
        },
        "status": "unverified"
      }
    },
    "appid": "tests_1656074529",
    "createdAt": "2022-06-24T12:42:39.686Z",
    "updatedAt": "2022-06-24T12:42:41.080Z"
  }
]

Receives

API routes may receive parameters from the URL and POST supporting simple and multipart:

Field Value Required Type
all boolean optional URL
limit integer optional URL
offset integer optional URL
stripeid string optional URL

Exceptions

These exceptions are thrown (NodeJS) or returned as JSON (HTTP) if you provide incorrect data or do not meet the requirements:

Exception Circumstances
invalid-stripeid invalid Stripe account is individual

NodeJS source (view on github)

const connect = require('../../../../../index.js')

module.exports = {
  get: async (req) => {
    req.query = req.query || {}
    const where = {
      appid: req.appid || global.appid
    }
    if (req.query.stripeid) {
      const stripeAccount = await global.api.administrator.connect.StripeAccount.get(req)
      if (!stripeAccount) {
        throw new Error('invalid-stripeid')
      }
      if (stripeAccount.stripeObject.business_type !== 'company') {
        throw new Error('invalid-stripe-account')
      }
      where.stripeid = req.query.stripeid
    }
    let personids
    if (req.query.all) {
      personids = await connect.Storage.Person.findAll({
        where,
        attributes: ['personid'],
        order: [
          ['createdAt', 'DESC']
        ]
      })
    } else {
      const offset = req.query.offset ? parseInt(req.query.offset, 10) : 0
      const limit = req.query.limit ? parseInt(req.query.limit, 10) : global.pageSize
      personids = await connect.Storage.Person.findAll({
        where,
        attributes: ['personid'],
        offset,
        limit,
        order: [
          ['createdAt', 'DESC']
        ]
      })
    }
    if (!personids || !personids.length) {
      return null
    }
    const items = []
    for (const personInfo of personids) {
      req.query.personid = personInfo.dataValues.personid
      const person = await global.api.administrator.connect.Person.get(req)
      items.push(person)
    }
    return items
  }
}

Test source (view on github)


/* eslint-env mocha */
const assert = require('assert')
const TestHelper = require('../../../../../test-helper.js')
const TestStripeAccounts = require('../../../../../test-stripe-accounts.js')
const DashboardTestHelper = require('@layeredapps/dashboard/test-helper.js')

describe('/api/administrator/connect/persons', function () {
  before(TestHelper.disableMetrics)
  after(TestHelper.enableMetrics)
  let cachedResponses, cachedPersons
  async function bundledData (retryNumber) {
    if (retryNumber > 0) {
      cachedResponses = {}
    }
    if (cachedResponses && cachedResponses.finished) {
      return
    }
    cachedResponses = {}
    cachedPersons = []
    await DashboardTestHelper.setupBeforeEach()
    await TestHelper.setupBeforeEach()
    const administrator = await TestHelper.createOwner()
    const user = await TestStripeAccounts.createIndividualMissingIndividualDetails()
    const req = TestHelper.createRequest(`/api/administrator/connect/persons?stripeid=${user.stripeAccount.stripeid}`)
    req.account = administrator.account
    req.session = administrator.session
    try {
      await req.get()
    } catch (error) {
      cachedResponses.invalidStripe = error.message
    }
    for (let i = 0, len = global.pageSize + 2; i < len; i++) {
      const user2 = await TestStripeAccounts.createCompanyWithDirectors('DE', 1)
      cachedPersons.unshift(user2.director.personid)
    }
    const user3 = await TestStripeAccounts.createCompanyWithDirectors('DE', 1)
    cachedPersons.unshift(user3.director.personid)
    await TestHelper.createPerson(user3, {
      relationship_director: 'true',
      relationship_executive: 'true',
      relationship_title: 'SVP Testing',
      relationship_percent_ownership: '0'
    })
    cachedPersons.unshift(user3.director.personid)
    const req1 = TestHelper.createRequest('/api/administrator/connect/persons')
    req1.account = administrator.account
    req1.session = administrator.session
    req1.filename = __filename
    req1.saveResponse = true
    cachedResponses.returns = await req1.get()
    global.pageSize = 3
    cachedResponses.pageSize = await req1.get()
    global.pageSize = 2
    const req2 = TestHelper.createRequest('/api/administrator/connect/persons?offset=1')
    req2.account = administrator.account
    req2.session = administrator.session
    cachedResponses.offset = await req2.get()
    const req3 = TestHelper.createRequest('/api/administrator/connect/persons?limit=1')
    req3.account = administrator.account
    req3.session = administrator.session
    cachedResponses.limit = await req3.get()
    const req4 = TestHelper.createRequest('/api/administrator/connect/persons?all=true')
    req4.account = administrator.account
    req4.session = administrator.session
    cachedResponses.all = await req4.get()
    const req5 = TestHelper.createRequest(`/api/administrator/connect/persons?stripeid=${user3.stripeAccount.stripeid}`)
    req5.account = administrator.account
    req5.session = administrator.session
    cachedResponses.stripeid = await req5.get()
    cachedResponses.finished = true
  }
  describe('exceptions', () => {
    describe('invalid-stripeid', () => {
      it('invalid Stripe account is individual', async function () {
        await bundledData(this.test.currentRetry())
        const errorMessage = cachedResponses.invalidStripe
        assert.strictEqual(errorMessage, 'invalid-stripe-account')
      })
    })
  })

  describe('receives', function () {
    it('optional querystring offset (integer)', async function () {
      await bundledData(this.test.currentRetry())
      const offset = 1
      const personsNow = cachedResponses.offset
      for (let i = 0, len = global.pageSize; i < len; i++) {
        assert.strictEqual(personsNow[i].personid, cachedPersons[offset + i])
      }
    })

    it('optional querystring limit (integer)', async function () {
      await bundledData(this.test.currentRetry())
      const limit = 1
      const stripeAccountsNow = cachedResponses.limit
      assert.strictEqual(stripeAccountsNow.length, limit)
    })

    it('optional querystring all (boolean)', async function () {
      await bundledData(this.test.currentRetry())
      const stripeAccountsNow = cachedResponses.all
      assert.strictEqual(stripeAccountsNow.length, cachedPersons.length)
    })

    it('optional querystring stripeid (string)', async function () {
      await bundledData(this.test.currentRetry())
      const stripeAccountsNow = cachedResponses.stripeid
      assert.strictEqual(stripeAccountsNow.length, 2)
    })
  })

  describe('returns', function () {
    it('array', async function () {
      await bundledData(this.test.currentRetry())
      const payouts = cachedResponses.returns
      assert.strictEqual(payouts.length, global.pageSize)
    })
  })

  describe('configuration', function () {
    it('environment PAGE_SIZE', async function () {
      await bundledData(this.test.currentRetry())
      const payouts = cachedResponses.pageSize
      assert.strictEqual(payouts.length, global.pageSize + 1)
    })
  })
})