Stripe Subscriptions module API explorer

/api/administrator/subscriptions/prices-count (GET)

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

await global.api.administrator.subscriptions.PricesCount.get(req)

NodeJS source (view on github)

const subscriptions = require('../../../../../index.js')

module.exports = {
  get: async (req) => {
    return subscriptions.Storage.Price.count({
      where: {
        appid: req.appid || global.appid
      }
    })
  }
}

Test source (view on github)

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

describe('/api/administrator/subscriptions/prices-count', function () {
  before(TestHelper.disableMetrics)
  after(TestHelper.enableMetrics)
  describe('returns', () => {
    it('integer', async () => {
      const administrator = await TestHelper.createOwner()
      await TestHelper.createProduct(administrator, {
        active: 'true'
      })
      for (let i = 0, len = global.pageSize + 1; i < len; i++) {
        await TestHelper.createPrice(administrator, {
          productid: administrator.product.productid,
          active: 'true',
          unit_amount: '1000',
          recurring_usage_type: 'licensed',
          recurring_unit_amount: '2000',
          recurring_interval: 'month',
          recurring_interval_count: '1',
          recurrinf_aggregate_usage: 'sum',
          currency: 'usd',
          tax_behavior: 'inclusive'
        })
      }
      const req = TestHelper.createRequest('/api/administrator/subscriptions/prices-count')
      req.account = administrator.account
      req.session = administrator.session
      req.filename = __filename
      req.saveResponse = true
      const result = await req.get()
      assert.strictEqual(result, global.pageSize + 1)
    })
  })
})