Stripe Subscriptions module API explorer

/api/administrator/subscriptions/refund-requests-count (GET)

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

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

NodeJS source (view on github)

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

module.exports = {
  get: async (req) => {
    const minDate = new Date()
    minDate.setDate(minDate.getDate() + 1)
    return subscriptions.Storage.Charge.count({
      where: {
        refundRequested: {
          [sequelize.Op.lte]: minDate
        },
        appid: req.appid || global.appid
      }
    })
  }
}

Test source (view on github)

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

describe('/api/administrator/subscriptions/refund-requests-count', function () {
  before(TestHelper.disableMetrics)
  after(TestHelper.enableMetrics)
  describe('returns', () => {
    it('integer', async () => {
      const administrator = await TestStripeAccounts.createOwnerWithPrice()
      for (let i = 0, len = global.pageSize + 1; i < len; i++) {
        const user = await TestStripeAccounts.createUserWithPaidSubscription(administrator.price)
        await TestHelper.requestRefund(user, user.charge.chargeid)
      }
      const req = TestHelper.createRequest('/api/administrator/subscriptions/refund-requests-count')
      req.account = administrator.account
      req.session = administrator.session
      req.filename = __filename
      req.saveResponse = true
      const refunds = await req.get()
      assert.strictEqual(refunds, global.pageSize + 1)
    })
  })
})