Stripe Connect module API explorer

/api/administrator/connect/person (GET)

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

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

Returns object

{
  "personid": "person_1LEBovDI1MZJCp7FWJjYlGWB",
  "object": "person",
  "accountid": "acct_ef4ff3662754002a",
  "stripeid": "acct_1LEBorDI1MZJCp7F",
  "tokenUpdate": null,
  "stripeObject": {
    "id": "person_1LEBovDI1MZJCp7FWJjYlGWB",
    "object": "person",
    "account": "acct_1LEBorDI1MZJCp7F",
    "address": {
      "city": null,
      "country": "DE",
      "line1": null,
      "line2": null,
      "postal_code": null,
      "state": null
    },
    "created": 1656074469,
    "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": false,
      "executive": false,
      "owner": true,
      "percent_ownership": 1,
      "representative": false,
      "title": "Shareholder"
    },
    "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_1656074464",
  "createdAt": "2022-06-24T12:41:11.715Z",
  "updatedAt": "2022-06-24T12:41:11.716Z"
}

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-personid missing querystring personid
invalid querystring personid

NodeJS source (view on github)

const connect = require('../../../../../index.js')
const dashboard = require('@layeredapps/dashboard')

module.exports = {
  get: async (req) => {
    if (!req.query || !req.query.personid) {
      throw new Error('invalid-personid')
    }
    let person = await dashboard.StorageCache.get(req.query.personid)
    if (!person) {
      const personInfo = await connect.Storage.Person.findOne({
        where: {
          personid: req.query.personid,
          appid: req.appid || global.appid
        }
      })
      if (!personInfo) {
        throw new Error('invalid-personid')
      }
      person = {}
      for (const field of personInfo._options.attributes) {
        person[field] = personInfo.get(field)
      }
      await dashboard.StorageCache.set(req.query.personid, person)
    }
    return person
  }
}

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')

describe('/api/administrator/connect/person', function () {
  before(TestHelper.disableMetrics)
  after(TestHelper.enableMetrics)
  describe('exceptions', () => {
    describe('invalid-personid', () => {
      it('missing querystring personid', async () => {
        const administrator = await TestHelper.createOwner()
        const req = TestHelper.createRequest('/api/administrator/connect/person')
        req.account = administrator.account
        req.session = administrator.session
        let errorMessage
        try {
          await req.get()
        } catch (error) {
          errorMessage = error.message
        }
        assert.strictEqual(errorMessage, 'invalid-personid')
      })

      it('invalid querystring personid', async () => {
        const administrator = await TestHelper.createOwner()
        const req = TestHelper.createRequest('/api/administrator/connect/person?personid=invalid')
        req.account = administrator.account
        req.session = administrator.session
        let errorMessage
        try {
          await req.get()
        } catch (error) {
          errorMessage = error.message
        }
        assert.strictEqual(errorMessage, 'invalid-personid')
      })
    })
  })

  describe('returns', () => {
    it('object', async () => {
      const administrator = await TestHelper.createOwner()
      const user = await TestStripeAccounts.createCompanyWithOwners('DE', 1)
      const req = TestHelper.createRequest(`/api/administrator/connect/person?personid=${user.owner.personid}`)
      req.account = administrator.account
      req.session = administrator.session
      req.filename = __filename
      req.saveResponse = true
      const person = await req.get()
      assert.strictEqual(person.personid, user.owner.personid)
    })
  })
})