{"id":24394431,"url":"https://github.com/tylerhoran/tellimus","last_synced_at":"2025-04-11T13:43:47.252Z","repository":{"id":59157444,"uuid":"187422483","full_name":"tylerhoran/tellimus","owner":"tylerhoran","description":"Robust subscription support for Rails with Braintree.","archived":false,"fork":false,"pushed_at":"2019-06-11T20:39:15.000Z","size":45,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-04-25T19:01:43.080Z","etag":null,"topics":["braintree","braintree-dropin","payments","rails","ruby"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tylerhoran.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-05-19T01:48:18.000Z","updated_at":"2019-06-20T20:48:01.000Z","dependencies_parsed_at":"2022-09-13T20:11:04.024Z","dependency_job_id":null,"html_url":"https://github.com/tylerhoran/tellimus","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/tylerhoran%2Ftellimus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tylerhoran%2Ftellimus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tylerhoran%2Ftellimus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tylerhoran%2Ftellimus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tylerhoran","download_url":"https://codeload.github.com/tylerhoran/tellimus/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248410877,"owners_count":21098789,"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":["braintree","braintree-dropin","payments","rails","ruby"],"created_at":"2025-01-19T19:24:39.518Z","updated_at":"2025-04-11T13:43:47.224Z","avatar_url":"https://github.com/tylerhoran.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tellimus\n\nRobust subscription support for Ruby on Rails apps using [Braintree](https://braintreepayments.com), including out-of-the-box pricing pages, payment pages, and  subscription management for your customers. This is a fork of [Koudoku](https://github.com/andrewculver/koudoku) specifically for Braintree.\n\n## Installation\n\nInclude the following in your `Gemfile`:\n\n```ruby\n    gem 'tellimus'\n```\n\nAfter running `bundle install`, you can run a Rails generator to do the rest.  You should have a user model.\n\n```ruby\n    rails g tellimus:install\n    rake db:migrate\n```\n\nAdd the following to `app/views/layouts/application.html.erb` before your `\u003chead\u003e` tag closes:\n\n```ruby\n    \u003cscript src=\"https://js.braintreegateway.com/js/braintree-2.32.1.min.js\"\u003e\u003c/script\u003e\n    \u003c%= yield :tellimus %\u003e\n```\n\n(This allows us to inject a Braintree `\u003cscript\u003e` tag in the correct place. If you don't, the payment form will not work.)\n\nAfter installing, you'll need to add some subscription plans. (You can see an explanation of each of the attributes in the table below.)\n\n**Note:** You need to create the plans in your [Braintree Dashboard](https://braintreepayments.com) separately.\n\n```ruby\n    Plan.create({\n      name: 'Personal',\n      price: 10.00,\n      interval: 'month',\n      braintree_id: '1',\n      features: ['1 Project', '1 Page', '1 User', '1 Organization'].join(\"\\n\\n\"),\n      display_order: 1\n    })\n\n    Plan.create({\n      name: 'Team',\n      highlight: true, # This highlights the plan on the pricing page.\n      price: 30.00,\n      interval: 'month',\n      braintree_id: '2',\n      features: ['3 Projects', '3 Pages', '3 Users', '3 Organizations'].join(\"\\n\\n\"),\n      display_order: 2\n    })\n\n    Plan.create({\n      name: 'Enterprise',\n      price: 100.00,\n      interval: 'month',\n      braintree_id: '3',\n      features: ['10 Projects', '10 Pages', '10 Users', '10 Organizations'].join(\"\\n\\n\"),\n      display_order: 3\n    })\n```\n\nTo help you understand the attributes:\n\n| Attribute       | Type    | Function |\n| --------------- | ------- | -------- |\n| `name`          | string  | Name for the plan to be presented to customers. |\n| `price`         | float   | Price per billing cycle. |\n| `interval`      | string  | *Optional.* What is the billing cycle? Valid options are `month`, `year`, `week`, `3-month`, `6-month`. Defaults to `month`. |\n| `braintree_id`     | string  | The Plan ID in Braintree. |\n| `features`      | string  | A list of features. Supports Markdown syntax. |\n| `display_order` | integer | Order in which to display plans. |\n| `highlight`     | boolean | *Optional.* Whether to highlight the plan on the pricing page. |\n\nThe only view installed locally into your app by default is the `koudoku/subscriptions/_social_proof.html.erb` partial which is displayed alongside the pricing table. It's designed as a placeholder where you can provide quotes about your product from customers that could positively influence your visitors.\n\n### Configuring Braintree API Keys\n\nYou can supply your publishable and secret API keys in `config/initializers/tellimus.rb`. However, by default it will use the `BRAINTREE_PUBLISHABLE_KEY` and `BRAINTREE_SECRET_KEY` shell environment variables. This encourages people to keep these API keys out of version control. You may want to rename these environment variables to be more application specific.\n\nIn a bash shell, you can set them in `~/.bash_profile` like so:\n\n```bash\n    export BRAINTREE_PUBLIC_KEY=pk_0CJwDH9sdh98f79FDHDOjdiOxQob0\n    export BRAINTREE_PRIVATE_KEY=sk_0CJwFDIUshdfh97JDJOjZ5OIDjOCH\n    export BRAINTREE_MERCHANT_ID=2dj90d2j3dhnxn2\n    export BRAINTREE_ENVIRONMENT=\"sandbox\"\n```\n\n(Reload your terminal for these settings to take effect.)\n\n## User-Facing Subscription Management\n\nBy default a `pricing_path` route is defined which you can link to in order to show visitors a pricing table. If a user is signed in, this pricing table will take into account their current plan. For example, you can link to this page like so:\n\n```ruby\n    \u003c%= link_to 'Pricing', main_app.pricing_path %\u003e\n```\n\n(Note: Tellimus uses the application layout, so it's important that application paths referenced in that layout are prefixed with \"`main_app.`\" like you see above or Rails will try to look the paths up in the Tellimus engine instead of your application.)\n\nExisting users can view available plans, select a plan, enter credit card details, review their subscription, change plans, and cancel at the following route:\n\n```ruby\n    tellimus.owner_subscriptions_path(@user)\n```\n\nIn these paths, `owner` refers to `User` by default, or whatever model has been configured to be the owner of the `Subscription` model.\n\nA number of views are provided by default. To customize the views, use the following generator:\n\n```ruby\n    rails g tellimus:views\n```\n\n### Pricing Table\n\nTellimus ships with a stock pricing table. By default it depends on Twitter Bootstrap, but also has some additional styles required. In order to import these styles, add the following to your `app/assets/stylesheets/application.css`:\n\n```css\n    *= require 'tellimus/pricing-table'\n```\n\nOr, if you've replaced your `application.css` with an `application.scss` (like I always do):\n\n```css\n    @import \"tellimus/pricing-table\"\n```\n\n## Implementing Logging, Notifications, etc.\n\nThe included module defines the following empty \"template methods\" which you're able to provide an implementation for in `Subscription`:\n\n - `prepare_for_plan_change`\n - `prepare_for_new_subscription`\n - `prepare_for_upgrade`\n - `prepare_for_downgrade`\n - `prepare_for_cancelation`\n - `prepare_for_card_update`\n - `finalize_plan_change!`\n - `finalize_new_subscription!`\n - `finalize_upgrade!`\n - `finalize_downgrade!`\n - `finalize_cancelation!`\n - `finalize_card_update!`\n - `card_was_declined`\n\nBe sure to include a call to `super` in each of your implementations, especially if you're using multiple concerns to break all this logic into smaller pieces.\n\nBetween `prepare_for_*` and `finalize_*`, so far I've used `finalize_*` almost exclusively. The difference is that `prepare_for_*` runs before we settle things with Stripe, and `finalize_*` runs after everything is settled in Stripe. For that reason, please be sure not to implement anything in `finalize_*` implementations that might cause issues with ActiveRecord saving the updated state of the subscription.\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftylerhoran%2Ftellimus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftylerhoran%2Ftellimus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftylerhoran%2Ftellimus/lists"}