Stripe Connect module API explorer

/api/administrator/connect/stripe-account (GET)

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

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

Returns object

{
  "stripeid": "acct_1LEBquRiCtfXe6XJ",
  "object": "stripeAccount",
  "accountid": "acct_b08de7fe70630dae",
  "tokenUpdate": null,
  "stripeObject": {
    "id": "acct_1LEBquRiCtfXe6XJ",
    "object": "account",
    "business_profile": {
      "mcc": null,
      "name": null,
      "product_description": null,
      "support_address": null,
      "support_email": null,
      "support_phone": null,
      "support_url": null,
      "url": null
    },
    "business_type": "company",
    "capabilities": {
      "card_payments": "inactive",
      "transfers": "inactive"
    },
    "charges_enabled": false,
    "company": {
      "address": {
        "city": null,
        "country": "US",
        "line1": null,
        "line2": null,
        "postal_code": null,
        "state": null
      },
      "directors_provided": false,
      "executives_provided": false,
      "name": null,
      "owners_provided": false,
      "tax_id_provided": false,
      "verification": {
        "document": {
          "back": null,
          "details": null,
          "details_code": null,
          "front": null
        }
      }
    },
    "country": "US",
    "created": 1656074593,
    "default_currency": "usd",
    "details_submitted": false,
    "email": null,
    "external_accounts": {
      "object": "list",
      "data": [],
      "has_more": false,
      "total_count": 0,
      "url": "/v1/accounts/acct_1LEBquRiCtfXe6XJ/external_accounts"
    },
    "future_requirements": {
      "alternatives": [],
      "current_deadline": null,
      "currently_due": [],
      "disabled_reason": null,
      "errors": [],
      "eventually_due": [],
      "past_due": [],
      "pending_verification": []
    },
    "metadata": {},
    "payouts_enabled": false,
    "requirements": {
      "alternatives": [
        {
          "alternative_fields_due": [
            "owners.verification.document"
          ],
          "original_fields_due": [
            "owners.ssn_last_4"
          ]
        },
        {
          "alternative_fields_due": [
            "representative.verification.document"
          ],
          "original_fields_due": [
            "representative.ssn_last_4"
          ]
        }
      ],
      "current_deadline": null,
      "currently_due": [
        "business_profile.mcc",
        "business_profile.url",
        "company.address.city",
        "company.address.line1",
        "company.address.postal_code",
        "company.address.state",
        "company.name",
        "company.owners_provided",
        "company.phone",
        "company.tax_id",
        "external_account",
        "owners.email",
        "owners.first_name",
        "owners.last_name",
        "representative.address.city",
        "representative.address.line1",
        "representative.address.postal_code",
        "representative.address.state",
        "representative.dob.day",
        "representative.dob.month",
        "representative.dob.year",
        "representative.email",
        "representative.first_name",
        "representative.last_name",
        "representative.phone",
        "representative.relationship.executive",
        "representative.relationship.title",
        "representative.ssn_last_4",
        "tos_acceptance.date",
        "tos_acceptance.ip"
      ],
      "disabled_reason": "requirements.past_due",
      "errors": [],
      "eventually_due": [
        "business_profile.mcc",
        "business_profile.url",
        "company.address.city",
        "company.address.line1",
        "company.address.postal_code",
        "company.address.state",
        "company.name",
        "company.owners_provided",
        "company.phone",
        "company.tax_id",
        "external_account",
        "owners.address.city",
        "owners.address.line1",
        "owners.address.postal_code",
        "owners.address.state",
        "owners.dob.day",
        "owners.dob.month",
        "owners.dob.year",
        "owners.email",
        "owners.first_name",
        "owners.last_name",
        "owners.phone",
        "owners.ssn_last_4",
        "representative.address.city",
        "representative.address.line1",
        "representative.address.postal_code",
        "representative.address.state",
        "representative.dob.day",
        "representative.dob.month",
        "representative.dob.year",
        "representative.email",
        "representative.first_name",
        "representative.last_name",
        "representative.phone",
        "representative.relationship.executive",
        "representative.relationship.title",
        "representative.ssn_last_4",
        "tos_acceptance.date",
        "tos_acceptance.ip"
      ],
      "past_due": [
        "business_profile.mcc",
        "business_profile.url",
        "company.address.city",
        "company.address.line1",
        "company.address.postal_code",
        "company.address.state",
        "company.name",
        "company.owners_provided",
        "company.phone",
        "company.tax_id",
        "external_account",
        "owners.email",
        "owners.first_name",
        "owners.last_name",
        "representative.address.city",
        "representative.address.line1",
        "representative.address.postal_code",
        "representative.address.state",
        "representative.dob.day",
        "representative.dob.month",
        "representative.dob.year",
        "representative.email",
        "representative.first_name",
        "representative.last_name",
        "representative.phone",
        "representative.relationship.executive",
        "representative.relationship.title",
        "representative.ssn_last_4",
        "tos_acceptance.date",
        "tos_acceptance.ip"
      ],
      "pending_verification": []
    },
    "settings": {
      "bacs_debit_payments": {},
      "branding": {
        "icon": null,
        "logo": null,
        "primary_color": null,
        "secondary_color": null
      },
      "card_issuing": {
        "tos_acceptance": {
          "date": null,
          "ip": null
        }
      },
      "card_payments": {
        "decline_on": {
          "avs_failure": false,
          "cvc_failure": false
        },
        "statement_descriptor_prefix": null,
        "statement_descriptor_prefix_kana": null,
        "statement_descriptor_prefix_kanji": null
      },
      "dashboard": {
        "display_name": null,
        "timezone": "Etc/UTC"
      },
      "payments": {
        "statement_descriptor": null,
        "statement_descriptor_kana": null,
        "statement_descriptor_kanji": null
      },
      "payouts": {
        "debit_negative_balances": false,
        "schedule": {
          "delay_days": 2,
          "interval": "daily"
        },
        "statement_descriptor": null
      },
      "sepa_debit_payments": {}
    },
    "tos_acceptance": {
      "date": null,
      "ip": null,
      "user_agent": null
    },
    "type": "custom"
  },
  "requiresOwners": true,
  "requiresDirectors": false,
  "requiresExecutives": false,
  "appid": "tests_1656074592",
  "createdAt": "2022-06-24T12:43:15.117Z",
  "updatedAt": "2022-06-24T12:43:15.118Z"
}

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

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.stripeid) {
      throw new Error('invalid-stripeid')
    }
    let stripeAccount = await dashboard.StorageCache.get(req.query.stripeid)
    if (!stripeAccount) {
      const stripeAccountInfo = await connect.Storage.StripeAccount.findOne({
        where: {
          stripeid: req.query.stripeid,
          appid: req.appid || global.appid
        }
      })
      if (!stripeAccountInfo) {
        throw new Error('invalid-stripeid')
      }
      stripeAccount = {}
      for (const field of stripeAccountInfo._options.attributes) {
        stripeAccount[field] = stripeAccountInfo.get(field)
      }
      await dashboard.StorageCache.set(req.query.stripeid, stripeAccount)
    }
    return stripeAccount
  }
}

Test source (view on github)

/* eslint-env mocha */
const assert = require('assert')
const TestHelper = require('../../../../../test-helper.js')

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

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

  describe('returns', () => {
    it('object', async () => {
      const administrator = await TestHelper.createOwner()
      const user = await TestHelper.createUser()
      await TestHelper.createStripeAccount(user, {
        country: 'US',
        business_type: 'company'
      })
      const req = TestHelper.createRequest(`/api/administrator/connect/stripe-account?stripeid=${user.stripeAccount.stripeid}`)
      req.account = administrator.account
      req.session = administrator.session
      req.filename = __filename
      req.saveResponse = true
      const stripeAccountNow = await req.get()
      assert.strictEqual(stripeAccountNow.stripeid, user.stripeAccount.stripeid)
    })
  })
})