/api/administrator/connect/stripe-accounts (GET)
Account information like email addresses is generated with faker-js it is not real user information.
await global.api.administrator.connect.StripeAccounts.get(req)Returns array
[
{
"stripeid": "acct_1LEBrTDFE7gToZYy",
"object": "stripeAccount",
"accountid": "acct_03e7768574aa6c3d",
"tokenUpdate": null,
"stripeObject": {
"id": "acct_1LEBrTDFE7gToZYy",
"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": 1656074627,
"default_currency": "usd",
"details_submitted": false,
"email": null,
"external_accounts": {
"object": "list",
"data": [],
"has_more": false,
"total_count": 0,
"url": "/v1/accounts/acct_1LEBrTDFE7gToZYy/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_1656074614",
"createdAt": "2022-06-24T12:43:49.532Z",
"updatedAt": "2022-06-24T12:43:49.532Z"
},
{
"stripeid": "acct_1LEBrQRa0hh4pqan",
"object": "stripeAccount",
"accountid": "acct_03e7768574aa6c3d",
"tokenUpdate": null,
"stripeObject": {
"id": "acct_1LEBrQRa0hh4pqan",
"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": "individual",
"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": true,
"executives_provided": true,
"name": null,
"owners_provided": true,
"tax_id_provided": false,
"verification": {
"document": {
"back": null,
"details": null,
"details_code": null,
"front": null
}
}
},
"country": "US",
"created": 1656074625,
"default_currency": "usd",
"details_submitted": false,
"email": null,
"external_accounts": {
"object": "list",
"data": [],
"has_more": false,
"total_count": 0,
"url": "/v1/accounts/acct_1LEBrQRa0hh4pqan/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": [],
"current_deadline": null,
"currently_due": [
"business_profile.mcc",
"business_profile.url",
"external_account",
"individual.address.city",
"individual.address.line1",
"individual.address.postal_code",
"individual.address.state",
"individual.dob.day",
"individual.dob.month",
"individual.dob.year",
"individual.email",
"individual.first_name",
"individual.last_name",
"individual.phone",
"individual.ssn_last_4",
"tos_acceptance.date",
"tos_acceptance.ip"
],
"disabled_reason": "requirements.past_due",
"errors": [],
"eventually_due": [
"business_profile.mcc",
"business_profile.url",
"external_account",
"individual.address.city",
"individual.address.line1",
"individual.address.postal_code",
"individual.address.state",
"individual.dob.day",
"individual.dob.month",
"individual.dob.year",
"individual.email",
"individual.first_name",
"individual.last_name",
"individual.phone",
"individual.ssn_last_4",
"tos_acceptance.date",
"tos_acceptance.ip"
],
"past_due": [
"business_profile.mcc",
"business_profile.url",
"external_account",
"individual.address.city",
"individual.address.line1",
"individual.address.postal_code",
"individual.address.state",
"individual.dob.day",
"individual.dob.month",
"individual.dob.year",
"individual.email",
"individual.first_name",
"individual.last_name",
"individual.phone",
"individual.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": false,
"requiresDirectors": false,
"requiresExecutives": false,
"appid": "tests_1656074614",
"createdAt": "2022-06-24T12:43:46.790Z",
"updatedAt": "2022-06-24T12:43:46.790Z"
},
{
"stripeid": "acct_1LEBrORXt0cQmwHZ",
"object": "stripeAccount",
"accountid": "acct_6e874382f0dbe280",
"tokenUpdate": null,
"stripeObject": {
"id": "acct_1LEBrORXt0cQmwHZ",
"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": 1656074622,
"default_currency": "usd",
"details_submitted": false,
"email": null,
"external_accounts": {
"object": "list",
"data": [],
"has_more": false,
"total_count": 0,
"url": "/v1/accounts/acct_1LEBrORXt0cQmwHZ/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_1656074614",
"createdAt": "2022-06-24T12:43:44.373Z",
"updatedAt": "2022-06-24T12:43:44.374Z"
}
]
Receives
API routes may receive parameters from the URL and POST supporting simple and multipart:
Field | Value | Required | Type |
---|---|---|---|
accountid | string | optional | URL |
all | boolean | optional | URL |
limit | integer | optional | URL |
offset | integer | 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-accountid | invalid querystring accountid |
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.accountid) {
const account = await global.api.administrator.Account.get(req)
if (!account) {
throw new Error('invalid-accountid')
}
where.accountid = req.query.accountid
}
let stripeids
if (req.query.all) {
stripeids = await connect.Storage.StripeAccount.findAll({
where,
attributes: ['stripeid'],
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
stripeids = await connect.Storage.StripeAccount.findAll({
where,
attributes: ['stripeid'],
offset,
limit,
order: [
['createdAt', 'DESC']
]
})
}
if (!stripeids || !stripeids.length) {
return null
}
const items = []
for (const stripeAccountInfo of stripeids) {
req.query.stripeid = stripeAccountInfo.dataValues.stripeid
const stripeAccount = await global.api.administrator.connect.StripeAccount.get(req)
items.push(stripeAccount)
}
return items
}
}
Test source (view on github)
/* eslint-env mocha */
const assert = require('assert')
const TestHelper = require('../../../../../test-helper.js')
const DashboardTestHelper = require('@layeredapps/dashboard/test-helper.js')
describe('/api/administrator/connect/stripe-accounts', function () {
before(TestHelper.disableMetrics)
after(TestHelper.enableMetrics)
let cachedResponses, cachedStripeAccounts
async function bundledData (retryNumber) {
if (retryNumber > 0) {
cachedResponses = {}
}
if (cachedResponses && cachedResponses.finished) {
return
}
cachedResponses = {}
cachedStripeAccounts = []
await DashboardTestHelper.setupBeforeEach()
await TestHelper.setupBeforeEach()
const administrator = await TestHelper.createOwner()
for (let i = 0, len = global.pageSize + 2; i < len; i++) {
const user = await TestHelper.createUser()
await TestHelper.createStripeAccount(user, {
country: 'US',
business_type: 'company'
})
cachedStripeAccounts.unshift(user.stripeAccount.stripeid)
}
const user = await TestHelper.createUser()
await TestHelper.createStripeAccount(user, {
country: 'US',
business_type: 'individual'
})
cachedStripeAccounts.unshift(user.stripeAccount.stripeid)
await TestHelper.createStripeAccount(user, {
country: 'US',
business_type: 'company'
})
cachedStripeAccounts.unshift(user.stripeAccount.stripeid)
const req1 = TestHelper.createRequest('/api/administrator/connect/stripe-accounts')
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/stripe-accounts?offset=1')
req2.account = administrator.account
req2.session = administrator.session
cachedResponses.offset = await req2.get()
const req3 = TestHelper.createRequest('/api/administrator/connect/stripe-accounts?limit=1')
req3.account = administrator.account
req3.session = administrator.session
cachedResponses.limit = await req3.get()
const req4 = TestHelper.createRequest('/api/administrator/connect/stripe-accounts?all=true')
req4.account = administrator.account
req4.session = administrator.session
cachedResponses.all = await req4.get()
const req5 = TestHelper.createRequest(`/api/administrator/connect/stripe-accounts?accountid=${user.account.accountid}`)
req5.account = administrator.account
req5.session = administrator.session
cachedResponses.accountid = await req5.get()
cachedResponses.finished = true
}
describe('exceptions', () => {
describe('invalid-accountid', () => {
it('invalid querystring accountid', async () => {
const administrator = await TestHelper.createOwner()
const req = TestHelper.createRequest('/api/administrator/connect/stripe-accounts?accountid=invalid')
req.account = administrator.account
req.session = administrator.session
let errorMessage
try {
await req.get()
} catch (error) {
errorMessage = error.message
}
assert.strictEqual(errorMessage, 'invalid-accountid')
})
})
})
describe('receives', function () {
it('optional querystring offset (integer)', async function () {
await bundledData(this.test.currentRetry())
const offset = 1
const stripeAccountsNow = cachedResponses.offset
for (let i = 0, len = global.pageSize; i < len; i++) {
assert.strictEqual(stripeAccountsNow[i].stripeid, cachedStripeAccounts[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, cachedStripeAccounts.length)
})
it('optional querystring accountid (string)', async function () {
await bundledData(this.test.currentRetry())
const stripeAccountsNow = cachedResponses.accountid
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)
})
})
})