{"id":22505304,"url":"https://github.com/azer/subscription","last_synced_at":"2025-08-03T11:33:08.961Z","repository":{"id":11452471,"uuid":"13913300","full_name":"azer/subscription","owner":"azer","description":"NodeJS library to simplify paid subscriptions with Stripe and LevelDB.","archived":false,"fork":false,"pushed_at":"2013-11-10T02:51:10.000Z","size":140,"stargazers_count":12,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-15T03:09:40.716Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"ethereum/go-ethereum","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/azer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-10-28T00:40:56.000Z","updated_at":"2024-02-17T01:58:17.000Z","dependencies_parsed_at":"2022-09-07T01:41:45.867Z","dependency_job_id":null,"html_url":"https://github.com/azer/subscription","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azer%2Fsubscription","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azer%2Fsubscription/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azer%2Fsubscription/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azer%2Fsubscription/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/azer","download_url":"https://codeload.github.com/azer/subscription/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228540840,"owners_count":17934031,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-07T00:17:19.472Z","updated_at":"2024-12-07T00:17:19.936Z","avatar_url":"https://github.com/azer.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## subscription\n\nNodeJS library to simplify paid subscriptions with Stripe and LevelDB.\n\n## Install\n\n```bash\n$ npm install subscription\n```\n\n## Usage\n\nDefine a new subscription:\n\n```js\nsubscription = require('subscription')('stripe-api-key', 'leveldb-path')\n\nsubscription.service.define('atlas magazine', { 'price': 1000, period: '1 month', currency: 'usd' }, function (error, atlas) {\n\n  subscription.priceOf(atlas, '1 month')\n  // =\u003e 1000 (Ten dollars)\n\n    subscription.priceOf(atlas, '1 year')\n  // =\u003e 12000 (One Twenty Dollars)\n\n})\n```\n\nPurchase a subscription:\n\n```js\noptions = {\n  customer: 'customer@website.com',\n  length: '1 year',\n  token: 'tok_2oWvm6yRBFSMSh' // obtain it with Stripe.js\n}\n\nsubscription.purchase('atlas magazine', options, function (error, purchase) {\n  purchase.amount\n  // =\u003e 12000\n\n  purchase.expires_ts\n  // =\u003e 1390912838816\n})\n```\n\nValidate a subscription:\n\n```js\nsubscription.has('azer@kodfabrik.com', 'atlas magazine', function (error, has) {\n  has\n  // =\u003e true\n})\n```\n\nGet remaining subscription of a customer:\n\n```js\nsubscription.remaining('azer@kodfabrik.com', 'atlas magazine', function (error, remaining) {\n  remaining\n  // =\u003e 8035200000 (3 months)\n})\n```\n\nList subscriptions of a user:\n\n```js\nsubscription.subscriptionsOf('azer@kodfabrik.com', function (error, subs) {\n  subs\n  // =\u003e ['atlas magazine']\n})\n```\n\nExtend a subscription:\n\n```js\nsubscription.purchase.extension('atlas magazine', { customer: 'azer@kodfabrik.com', length: '2 years', token: token }, function (error, purchase) {\n  purchase.amount\n  // =\u003e 24000\n});\n```\n\nUpgrade a subscription:\n\n```js\nsubscription.purchase.upgrade({ customer: 'hi@ada.io', from: 'cheaper', to: 'more expensive service', token: token }, function (error, purchase) {\n  if (error) return callback(error);\n});\n```\n\n## Debugging\n\nVerbose:\n\n```bash\n$ DEBUG=subscription:* npm test\n```\n\nLess Verbose:\n\n```bash\n$ DEBUG=subscription:fatal,subscription:purchase\n```\n\n## Running Tests\n\n```bash\n$ API_KEY=sk_test_FIvJu2hkZszNIFzGgVNAqo2x npm test\n```\n\n## More Docs\n\n* `test.js`\n* [english-time](http://github.com/azer/english-time): The library used for parsing time inputs.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fazer%2Fsubscription","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fazer%2Fsubscription","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fazer%2Fsubscription/lists"}