Stripe Connect module API explorer

/api/administrator/connect/set-stripe-account-rejected (PATCH)

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

await global.api.administrator.connect.SetStripeAccountRejected.patch(req)

Returns boolean

{
  "stripeid": "acct_1LEBqlRfWa2R9oEV",
  "object": "stripeAccount",
  "accountid": "acct_5dacb7c7444df8ad",
  "tokenUpdate": null,
  "stripeObject": {
    "id": "acct_1LEBqlRfWa2R9oEV",
    "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": "DE",
        "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": "DE",
    "created": 1656074584,
    "default_currency": "eur",
    "details_submitted": true,
    "email": null,
    "external_accounts": {
      "object": "list",
      "data": [],
      "has_more": false,
      "total_count": 0,
      "url": "/v1/accounts/acct_1LEBqlRfWa2R9oEV/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",
        "company.address.city",
        "company.address.line1",
        "company.address.postal_code",
        "company.directors_provided",
        "company.executives_provided",
        "company.name",
        "company.owners_provided",
        "company.phone",
        "company.tax_id",
        "directors.dob.day",
        "directors.dob.month",
        "directors.dob.year",
        "directors.email",
        "directors.first_name",
        "directors.last_name",
        "directors.relationship.title",
        "executives.address.city",
        "executives.address.line1",
        "executives.address.postal_code",
        "executives.dob.day",
        "executives.dob.month",
        "executives.dob.year",
        "executives.email",
        "executives.first_name",
        "executives.last_name",
        "external_account",
        "owners.address.city",
        "owners.address.line1",
        "owners.address.postal_code",
        "owners.dob.day",
        "owners.dob.month",
        "owners.dob.year",
        "owners.email",
        "owners.first_name",
        "owners.last_name",
        "representative.address.city",
        "representative.address.line1",
        "representative.address.postal_code",
        "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",
        "tos_acceptance.date",
        "tos_acceptance.ip"
      ],
      "disabled_reason": "rejected.fraud",
      "errors": [],
      "eventually_due": [
        "business_profile.mcc",
        "business_profile.url",
        "company.address.city",
        "company.address.line1",
        "company.address.postal_code",
        "company.directors_provided",
        "company.executives_provided",
        "company.name",
        "company.owners_provided",
        "company.phone",
        "company.tax_id",
        "directors.dob.day",
        "directors.dob.month",
        "directors.dob.year",
        "directors.email",
        "directors.first_name",
        "directors.last_name",
        "directors.relationship.title",
        "executives.address.city",
        "executives.address.line1",
        "executives.address.postal_code",
        "executives.dob.day",
        "executives.dob.month",
        "executives.dob.year",
        "executives.email",
        "executives.first_name",
        "executives.last_name",
        "external_account",
        "owners.address.city",
        "owners.address.line1",
        "owners.address.postal_code",
        "owners.dob.day",
        "owners.dob.month",
        "owners.dob.year",
        "owners.email",
        "owners.first_name",
        "owners.last_name",
        "representative.address.city",
        "representative.address.line1",
        "representative.address.postal_code",
        "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",
        "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.directors_provided",
        "company.executives_provided",
        "company.name",
        "company.owners_provided",
        "company.phone",
        "company.tax_id",
        "directors.dob.day",
        "directors.dob.month",
        "directors.dob.year",
        "directors.email",
        "directors.first_name",
        "directors.last_name",
        "directors.relationship.title",
        "executives.address.city",
        "executives.address.line1",
        "executives.address.postal_code",
        "executives.dob.day",
        "executives.dob.month",
        "executives.dob.year",
        "executives.email",
        "executives.first_name",
        "executives.last_name",
        "external_account",
        "owners.address.city",
        "owners.address.line1",
        "owners.address.postal_code",
        "owners.dob.day",
        "owners.dob.month",
        "owners.dob.year",
        "owners.email",
        "owners.first_name",
        "owners.last_name",
        "representative.address.city",
        "representative.address.line1",
        "representative.address.postal_code",
        "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",
        "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": 7,
          "interval": "daily"
        },
        "statement_descriptor": null
      },
      "sepa_debit_payments": {}
    },
    "tos_acceptance": {
      "date": null,
      "ip": null,
      "user_agent": null
    },
    "type": "custom"
  },
  "requiresOwners": true,
  "requiresDirectors": true,
  "requiresExecutives": true,
  "appid": "tests_1656074583",
  "createdAt": "2022-06-24T12:43:05.929Z",
  "updatedAt": "2022-06-24T12:43:09.104Z"
}

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

NodeJS source (view on github)

const stripeCache = require('../../../../stripe-cache.js')
const connect = require('../../../../../index.js')
const dashboard = require('@layeredapps/dashboard')

module.exports = {
  patch: async (req) => {
    if (!req.query || !req.query.stripeid) {
      throw new Error('invalid-stripeid')
    }
    if (!req.body || !req.body.reason) {
      throw new Error('invalid-reason')
    }
    if (req.body.reason !== 'fraud' && req.body.reason !== 'other' && req.body.reason !== 'terms_of_service') {
      throw new Error('invalid-reason')
    }
    const stripeAccount = await global.api.administrator.connect.StripeAccount.get(req)
    if (!stripeAccount) {
      throw new Error('invalid-stripeid')
    }
    const updateInfo = {
      reason: req.body.reason
    }
    const stripeAccountNow = await stripeCache.execute('accounts', 'reject', req.query.stripeid, updateInfo, req.stripeKey)
    await connect.Storage.StripeAccount.update({
      stripeObject: stripeAccountNow
    }, {
      where: {
        stripeid: req.query.stripeid
      }
    })
    await dashboard.StorageCache.remove(req.query.stripeid)
    return global.api.administrator.connect.StripeAccount.get(req)
  }
}

Test source (view on github)

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

describe('/api/administrator/connect/set-stripe-account-rejected', 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/set-stripe-account-rejected')
        req.account = administrator.account
        req.session = administrator.session
        req.body = {
          reason: 'fraud'
        }
        let errorMessage
        try {
          await req.patch(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/set-stripe-account-rejected?stripeid=invalid')
        req.account = administrator.account
        req.session = administrator.session
        req.body = {
          reason: 'fraud'
        }
        let errorMessage
        try {
          await req.patch(req)
        } catch (error) {
          errorMessage = error.message
        }
        assert.strictEqual(errorMessage, 'invalid-stripeid')
      })
    })

    describe('invalid-reason', () => {
      it('missing posted reason', async () => {
        const administrator = await TestHelper.createOwner()
        const req = TestHelper.createRequest('/api/administrator/connect/set-stripe-account-rejected?stripeid=invalid')
        req.account = administrator.account
        req.session = administrator.session
        req.body = {
          reason: ''
        }
        let errorMessage
        try {
          await req.patch(req)
        } catch (error) {
          errorMessage = error.message
        }
        assert.strictEqual(errorMessage, 'invalid-reason')
      })

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

  describe('returns', () => {
    it('boolean', async () => {
      const administrator = await TestHelper.createOwner()
      const user = await TestHelper.createUser()
      await TestHelper.createStripeAccount(user, {
        country: 'DE',
        business_type: 'company'
      })
      const req = TestHelper.createRequest(`/api/administrator/connect/set-stripe-account-rejected?stripeid=${user.stripeAccount.stripeid}`)
      req.account = administrator.account
      req.session = administrator.session
      req.filename = __filename
      req.saveResponse = true
      req.body = {
        reason: 'fraud'
      }
      const accountNow = await req.patch()
      assert.strictEqual(accountNow.stripeObject.requirements.disabled_reason, 'rejected.fraud')
    })
  })
})