Stripe Connect module API explorer

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

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

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

Returns object

{
  "stripeid": "acct_1LEC1HRZQC6TLnvW",
  "object": "stripeAccount",
  "accountid": "acct_577ee6e1610ec3ae",
  "tokenUpdate": null,
  "stripeObject": {
    "id": "acct_1LEC1HRZQC6TLnvW",
    "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": 1656075236,
    "default_currency": "usd",
    "details_submitted": false,
    "email": null,
    "external_accounts": {
      "object": "list",
      "data": [],
      "has_more": false,
      "total_count": 0,
      "url": "/v1/accounts/acct_1LEC1HRZQC6TLnvW/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_1656075234",
  "createdAt": "2022-06-24T12:53:57.658Z",
  "updatedAt": "2022-06-24T12:53:57.659Z"
}

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-account ineligible accessing account
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')
      }
      if (stripeAccountInfo.dataValues.accountid !== req.account.accountid) {
        throw new Error('invalid-account')
      }
      stripeAccount = {}
      for (const field of stripeAccountInfo._options.attributes) {
        stripeAccount[field] = stripeAccountInfo.get(field)
      }
      await dashboard.StorageCache.set(req.query.stripeid, stripeAccount)
    }
    if (stripeAccount.accountid !== req.account.accountid) {
      throw new Error('invalid-account')
    }
    return stripeAccount
  }
}

Test source (view on github)

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

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

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

    describe('invalid-account', () => {
      it('ineligible accessing account', async () => {
        const user = await TestHelper.createUser()
        await TestHelper.createStripeAccount(user, {
          country: 'US',
          business_type: 'company'
        })
        const user2 = await TestHelper.createUser()
        const req = TestHelper.createRequest(`/api/user/connect/stripe-account?stripeid=${user.stripeAccount.stripeid}`)
        req.account = user2.account
        req.session = user2.session
        let errorMessage
        try {
          await req.get()
        } catch (error) {
          errorMessage = error.message
        }
        assert.strictEqual(errorMessage, 'invalid-account')
      })
    })
  })

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