slack-ruby-bot-server-stripe 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rspec +3 -0
- data/.rubocop.yml +18 -0
- data/.rubocop_todo.yml +29 -0
- data/.travis.yml +29 -0
- data/CHANGELOG.md +5 -0
- data/CONTRIBUTING.md +125 -0
- data/Dangerfile +1 -0
- data/Gemfile +42 -0
- data/LICENSE +21 -0
- data/README.md +278 -0
- data/RELEASING.md +61 -0
- data/Rakefile +14 -0
- data/lib/slack-ruby-bot-server-stripe.rb +15 -0
- data/lib/slack-ruby-bot-server-stripe/api.rb +1 -0
- data/lib/slack-ruby-bot-server-stripe/api/endpoints.rb +1 -0
- data/lib/slack-ruby-bot-server-stripe/api/endpoints/subscriptions_endpoint.rb +44 -0
- data/lib/slack-ruby-bot-server-stripe/commands.rb +2 -0
- data/lib/slack-ruby-bot-server-stripe/commands/subscription.rb +14 -0
- data/lib/slack-ruby-bot-server-stripe/commands/unsubscribe.rb +34 -0
- data/lib/slack-ruby-bot-server-stripe/config.rb +41 -0
- data/lib/slack-ruby-bot-server-stripe/errors.rb +10 -0
- data/lib/slack-ruby-bot-server-stripe/lifecycle.rb +17 -0
- data/lib/slack-ruby-bot-server-stripe/models.rb +2 -0
- data/lib/slack-ruby-bot-server-stripe/models/activerecord.rb +18 -0
- data/lib/slack-ruby-bot-server-stripe/models/methods.rb +317 -0
- data/lib/slack-ruby-bot-server-stripe/models/mongoid.rb +27 -0
- data/lib/slack-ruby-bot-server-stripe/public/img/icon.png +0 -0
- data/lib/slack-ruby-bot-server-stripe/public/img/stripe.png +0 -0
- data/lib/slack-ruby-bot-server-stripe/public/subscribe.html.erb +99 -0
- data/lib/slack-ruby-bot-server-stripe/version.rb +5 -0
- data/lib/slack-ruby-bot-server/api.rb +2 -0
- data/lib/slack-ruby-bot-server/api/endpoints.rb +9 -0
- data/lib/slack-ruby-bot-server/api/presenters.rb +2 -0
- data/lib/slack-ruby-bot-server/api/presenters/root_presenter.rb +11 -0
- data/lib/slack-ruby-bot-server/api/presenters/team_presenter.rb +10 -0
- data/slack-ruby-bot-server-stripe.gemspec +19 -0
- metadata +107 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b590c6a22b2c9af304f57df7b5e2549fd313877cd61c61790419ed9bba3a21e7
|
4
|
+
data.tar.gz: cb016ad20cc78d2f456b36177b018a3211e2453e168b0bd6e5b455c4e192f675
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d1a9b2c0a58181f9f41f60d3e317ad1233d19ea76c16ddafaed129d900c263fe0fd8e58698ba2a627be8579902f4c8e2b80a5356e855aa456eb18522fb5a54f7
|
7
|
+
data.tar.gz: fb0f0f5e861bbab49ac4a88234d2ca34013e9e6164d3ae93a532e72673674893682ced9d59a1d0b6cb44003ab3ff8f655809ec995a042c849b7ccfc4fa0d2ad9
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
Metrics:
|
2
|
+
Enabled: false
|
3
|
+
|
4
|
+
Layout/LineLength:
|
5
|
+
Max: 500
|
6
|
+
Enabled: false
|
7
|
+
|
8
|
+
Style/Documentation:
|
9
|
+
Enabled: false
|
10
|
+
|
11
|
+
Style/FrozenStringLiteralComment:
|
12
|
+
Enabled: false
|
13
|
+
|
14
|
+
Style/ModuleFunction:
|
15
|
+
EnforcedStyle: extend_self
|
16
|
+
|
17
|
+
inherit_from: .rubocop_todo.yml
|
18
|
+
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2020-04-26 19:57:20 -0400 using RuboCop version 0.81.0.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 1
|
10
|
+
# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms.
|
11
|
+
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
|
12
|
+
Naming/FileName:
|
13
|
+
Exclude:
|
14
|
+
- 'lib/slack-ruby-bot-server-stripe.rb'
|
15
|
+
|
16
|
+
# Offense count: 1
|
17
|
+
Style/MultilineBlockChain:
|
18
|
+
Exclude:
|
19
|
+
- 'spec/slack-ruby-bot-server-stripe/api/endpoints/subscriptions_endpoint_spec.rb'
|
20
|
+
|
21
|
+
# Offense count: 1
|
22
|
+
Style/MultilineTernaryOperator:
|
23
|
+
Exclude:
|
24
|
+
- 'lib/slack-ruby-bot-server-stripe/models/methods.rb'
|
25
|
+
|
26
|
+
# Offense count: 1
|
27
|
+
Style/NestedTernaryOperator:
|
28
|
+
Exclude:
|
29
|
+
- 'lib/slack-ruby-bot-server-stripe/models/methods.rb'
|
data/.travis.yml
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
language: ruby
|
2
|
+
|
3
|
+
cache: bundler
|
4
|
+
|
5
|
+
matrix:
|
6
|
+
include:
|
7
|
+
- rvm: 2.6.2
|
8
|
+
script:
|
9
|
+
- bundle exec danger
|
10
|
+
- rvm: 2.6.2
|
11
|
+
env: DATABASE_ADAPTER=activerecord
|
12
|
+
services:
|
13
|
+
- postgresql
|
14
|
+
- xvfb
|
15
|
+
addons:
|
16
|
+
firefox: 54.0
|
17
|
+
- rvm: 2.6.2
|
18
|
+
env: DATABASE_ADAPTER=mongoid
|
19
|
+
services:
|
20
|
+
- mongodb
|
21
|
+
- xvfb
|
22
|
+
addons:
|
23
|
+
firefox: 54.0
|
24
|
+
|
25
|
+
before_install:
|
26
|
+
- wget https://github.com/mozilla/geckodriver/releases/download/v0.18.0/geckodriver-v0.18.0-linux64.tar.gz
|
27
|
+
- mkdir geckodriver
|
28
|
+
- tar -xzf geckodriver-v0.18.0-linux64.tar.gz -C geckodriver
|
29
|
+
- export PATH=$PATH:$PWD/geckodriver
|
data/CHANGELOG.md
ADDED
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
# Contributing to SlackRubyBotServer::Stripe
|
2
|
+
|
3
|
+
This project is work of [many contributors](https://github.com/slack-ruby/slack-ruby-bot-server-stripe/graphs/contributors).
|
4
|
+
|
5
|
+
You're encouraged to submit [pull requests](https://github.com/slack-ruby/slack-ruby-bot-server-stripe/pulls), [propose features and discuss issues](https://github.com/slack-ruby/slack-ruby-bot-server-stripe/issues).
|
6
|
+
|
7
|
+
In the examples below, substitute your Github username for `contributor` in URLs.
|
8
|
+
|
9
|
+
## Fork the Project
|
10
|
+
|
11
|
+
Fork the [project on Github](https://github.com/slack-ruby/slack-ruby-bot-server-stripe) and check out your copy.
|
12
|
+
|
13
|
+
```
|
14
|
+
git clone https://github.com/contributor/slack-ruby-bot-server-stripe.git
|
15
|
+
cd slack-ruby-bot-server-stripe
|
16
|
+
git remote add upstream https://github.com/slack-ruby/slack-ruby-bot-server-stripe.git
|
17
|
+
```
|
18
|
+
|
19
|
+
## Create a Topic Branch
|
20
|
+
|
21
|
+
Make sure your fork is up-to-date and create a topic branch for your feature or bug fix.
|
22
|
+
|
23
|
+
```
|
24
|
+
git checkout master
|
25
|
+
git pull upstream master
|
26
|
+
git checkout -b my-feature-branch
|
27
|
+
```
|
28
|
+
|
29
|
+
## Bundle Install and Test
|
30
|
+
|
31
|
+
Ensure that you can build the project and run tests.
|
32
|
+
|
33
|
+
```
|
34
|
+
bundle install
|
35
|
+
bundle exec rake
|
36
|
+
```
|
37
|
+
|
38
|
+
## Write Tests
|
39
|
+
|
40
|
+
Try to write a test that reproduces the problem you're trying to fix or describes a feature that you want to build.
|
41
|
+
Add to [spec](spec).
|
42
|
+
|
43
|
+
We definitely appreciate pull requests that highlight or reproduce a problem, even without a fix.
|
44
|
+
|
45
|
+
## Write Code
|
46
|
+
|
47
|
+
Implement your feature or bug fix.
|
48
|
+
|
49
|
+
Ruby style is enforced with [Rubocop](https://github.com/bbatsov/rubocop).
|
50
|
+
Run `bundle exec rubocop` and fix any style issues highlighted.
|
51
|
+
|
52
|
+
Make sure that `bundle exec rake` completes without errors.
|
53
|
+
|
54
|
+
## Write Documentation
|
55
|
+
|
56
|
+
Document any external behavior in the [README](README.md).
|
57
|
+
|
58
|
+
## Update Changelog
|
59
|
+
|
60
|
+
Add a line to [CHANGELOG](CHANGELOG.md) under *Next Release*.
|
61
|
+
Make it look like every other line, including your name and link to your Github account.
|
62
|
+
|
63
|
+
## Commit Changes
|
64
|
+
|
65
|
+
Make sure git knows your name and email address:
|
66
|
+
|
67
|
+
```
|
68
|
+
git config --global user.name "Your Name"
|
69
|
+
git config --global user.email "contributor@example.com"
|
70
|
+
```
|
71
|
+
|
72
|
+
Writing good commit logs is important. A commit log should describe what changed and why.
|
73
|
+
|
74
|
+
```
|
75
|
+
git add ...
|
76
|
+
git commit
|
77
|
+
```
|
78
|
+
|
79
|
+
## Push
|
80
|
+
|
81
|
+
```
|
82
|
+
git push origin my-feature-branch
|
83
|
+
```
|
84
|
+
|
85
|
+
## Make a Pull Request
|
86
|
+
|
87
|
+
Go to https://github.com/contributor/slack-ruby-bot-server-stripe and select your feature branch.
|
88
|
+
Click the 'Pull Request' button and fill out the form. Pull requests are usually reviewed within a few days.
|
89
|
+
|
90
|
+
## Rebase
|
91
|
+
|
92
|
+
If you've been working on a change for a while, rebase with upstream/master.
|
93
|
+
|
94
|
+
```
|
95
|
+
git fetch upstream
|
96
|
+
git rebase upstream/master
|
97
|
+
git push origin my-feature-branch -f
|
98
|
+
```
|
99
|
+
|
100
|
+
## Update CHANGELOG Again
|
101
|
+
|
102
|
+
Update the [CHANGELOG](CHANGELOG.md) with the pull request number. A typical entry looks as follows.
|
103
|
+
|
104
|
+
```
|
105
|
+
* [#123](https://github.com/slack-ruby/slack-ruby-bot-server-stripe/pull/123): Reticulated splines - [@contributor](https://github.com/contributor).
|
106
|
+
```
|
107
|
+
|
108
|
+
Amend your previous commit and force push the changes.
|
109
|
+
|
110
|
+
```
|
111
|
+
git commit --amend
|
112
|
+
git push origin my-feature-branch -f
|
113
|
+
```
|
114
|
+
|
115
|
+
## Check on Your Pull Request
|
116
|
+
|
117
|
+
Go back to your pull request after a few minutes and see whether it passed muster with Travis-CI. Everything should look green, otherwise fix issues and amend your commit as described above.
|
118
|
+
|
119
|
+
## Be Patient
|
120
|
+
|
121
|
+
It's likely that your change will not be merged and that the nitpicky maintainers will ask you to do more, or fix seemingly benign problems. Hang on there!
|
122
|
+
|
123
|
+
## Thank You
|
124
|
+
|
125
|
+
Please do know that we really appreciate and value your time and work. We love you, really.
|
data/Dangerfile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
danger.import_dangerfile(gem: 'slack-ruby-danger')
|
data/Gemfile
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
case ENV['DATABASE_ADAPTER']
|
4
|
+
when 'mongoid' then
|
5
|
+
gem 'kaminari-mongoid'
|
6
|
+
gem 'mongoid'
|
7
|
+
gem 'mongoid-scroll'
|
8
|
+
when 'activerecord' then
|
9
|
+
gem 'activerecord', '~> 5.0.0'
|
10
|
+
gem 'otr-activerecord', '~> 1.2.1'
|
11
|
+
gem 'virtus'
|
12
|
+
gem 'cursor_pagination' # rubocop:disable Bundler/OrderedGems
|
13
|
+
gem 'pg'
|
14
|
+
when nil
|
15
|
+
warn "Missing ENV['DATABASE_ADAPTER']."
|
16
|
+
else
|
17
|
+
warn "Invalid ENV['DATABASE_ADAPTER']: #{ENV['DATABASE_ADAPTER']}."
|
18
|
+
end
|
19
|
+
|
20
|
+
gemspec
|
21
|
+
|
22
|
+
group :development, :test do
|
23
|
+
gem 'bundler'
|
24
|
+
gem 'capybara'
|
25
|
+
gem 'database_cleaner'
|
26
|
+
gem 'fabrication'
|
27
|
+
gem 'faker'
|
28
|
+
gem 'hyperclient'
|
29
|
+
gem 'rack-test'
|
30
|
+
gem 'rake'
|
31
|
+
gem 'rspec'
|
32
|
+
gem 'rubocop', '0.81.0'
|
33
|
+
gem 'selenium-webdriver'
|
34
|
+
gem 'stripe-ruby-mock', '~> 2.4.1', require: 'stripe_mock'
|
35
|
+
gem 'timecop'
|
36
|
+
gem 'vcr'
|
37
|
+
gem 'webmock'
|
38
|
+
end
|
39
|
+
|
40
|
+
group :test do
|
41
|
+
gem 'slack-ruby-danger', '~> 0.1.0', require: false
|
42
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Daniel Doubrovkine & Contributors
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,278 @@
|
|
1
|
+
Slack Ruby Bot Server Stripe Extension
|
2
|
+
======================================
|
3
|
+
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/slack-ruby-bot-server-stripe.svg)](https://badge.fury.io/rb/slack-ruby-bot-server-stripe)
|
5
|
+
[![Build Status](https://travis-ci.org/slack-ruby/slack-ruby-bot-server-stripe.svg?branch=master)](https://travis-ci.org/slack-ruby/slack-ruby-bot-server-stripe)
|
6
|
+
|
7
|
+
A model extension to [slack-ruby-bot-server](https://github.com/slack-ruby/slack-ruby-bot-server) that enables trials and paid subscriptions for your bots using [Stripe](https://stripe.com).
|
8
|
+
|
9
|
+
### Sample
|
10
|
+
|
11
|
+
See [slack-ruby/slack-ruby-bot-server-stripe-sample](https://github.com/slack-ruby/slack-ruby-bot-server-stripe-sample) for a working sample.
|
12
|
+
|
13
|
+
### Usage
|
14
|
+
|
15
|
+
#### Gemfile
|
16
|
+
|
17
|
+
Add 'slack-ruby-bot-server-stripe' to Gemfile.
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
gem 'slack-ruby-bot-server-stripe'
|
21
|
+
```
|
22
|
+
|
23
|
+
#### Configure
|
24
|
+
|
25
|
+
Configure your app, typically via `config/initializers/slack_ruby_bot_server_stripe.rb`.
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
SlackRubyBotServer::Stripe.configure do |config|
|
29
|
+
config.stripe_api_key = ENV['STRIPE_API_KEY'] # Stripe API key
|
30
|
+
config.stripe_api_publishable_key = ENV['STRIPE_API_PUBLISHABLE_KEY'] # Stripe publishable API key
|
31
|
+
config.subscription_plan_id = ENV['STRIPE_SUBSCRIPTION_PLAN_ID'] # Stripe subscription plan ID
|
32
|
+
config.trial_duration = 2.weeks # Trial duration
|
33
|
+
config.root_url = ENV['URL'] || 'http://localhost:5000' # Bot root of subscription info links
|
34
|
+
end
|
35
|
+
```
|
36
|
+
|
37
|
+
By default the configuration will use the values in the environment variables above.
|
38
|
+
|
39
|
+
#### Database Schema
|
40
|
+
|
41
|
+
Define additional fields on your database.
|
42
|
+
|
43
|
+
##### Mongoid
|
44
|
+
|
45
|
+
Additional fields from [models/mongoid.rb](lib/slack-ruby-bot-server/stripe/models/mongoid.rb) are automatically included.
|
46
|
+
|
47
|
+
##### ActiveRecord
|
48
|
+
|
49
|
+
Add migrations for additional fields from [activerecord/schema.rb](spec/database_adapters/activerecord/schema.rb).
|
50
|
+
|
51
|
+
#### Implement Callbacks
|
52
|
+
|
53
|
+
Use callbacks together with default `_text` methods to communicate subscription life cycle to your users. These are typically added by creating `lib/models/team.rb`.
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
class Team
|
57
|
+
before_trial_expiring do
|
58
|
+
inform!(text: trial_text)
|
59
|
+
end
|
60
|
+
|
61
|
+
after_subscribed do
|
62
|
+
inform!(text: subscribed_text)
|
63
|
+
end
|
64
|
+
|
65
|
+
after_unsubscribed do
|
66
|
+
inform!(text: unsubscribed_text)
|
67
|
+
end
|
68
|
+
|
69
|
+
after_subscription_expired do
|
70
|
+
inform!(text: subscription_expired_text)
|
71
|
+
end
|
72
|
+
|
73
|
+
after_subscription_past_due do
|
74
|
+
inform!(text: subscription_past_due_text)
|
75
|
+
end
|
76
|
+
|
77
|
+
private
|
78
|
+
|
79
|
+
def slack_client
|
80
|
+
@slack_client ||= Slack::Web::Client.new(token: token)
|
81
|
+
end
|
82
|
+
|
83
|
+
def slack_channels
|
84
|
+
slack_client.channels_list(
|
85
|
+
exclude_archived: true,
|
86
|
+
exclude_members: true
|
87
|
+
)['channels'].select do |channel|
|
88
|
+
channel['is_member']
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def inform!(message)
|
93
|
+
slack_channels.each do |channel|
|
94
|
+
message_with_channel = message.merge(channel: channel['id'], as_user: true)
|
95
|
+
slack_client.chat_postMessage(message_with_channel)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
```
|
100
|
+
|
101
|
+
#### Add Trial Link
|
102
|
+
|
103
|
+
Your bot's help command should display trial text and subscription link. This is typically done in `lib/commands/help.rb`.
|
104
|
+
|
105
|
+
```ruby
|
106
|
+
class Help < SlackRubyBot::Commands::Base
|
107
|
+
HELP = <<-EOS.freeze
|
108
|
+
```
|
109
|
+
Sample bot.
|
110
|
+
|
111
|
+
General
|
112
|
+
-------
|
113
|
+
|
114
|
+
help - get this helpful message
|
115
|
+
|
116
|
+
```
|
117
|
+
EOS
|
118
|
+
|
119
|
+
def self.call(client, data, _match)
|
120
|
+
client.say(channel: data.channel, text: [
|
121
|
+
HELP,
|
122
|
+
client.owner.reload.subscribed? ? nil : client.owner.trial_text
|
123
|
+
].compact.join("\n"))
|
124
|
+
|
125
|
+
client.say(channel: data.channel, gif: 'help')
|
126
|
+
end
|
127
|
+
end
|
128
|
+
```
|
129
|
+
|
130
|
+
### Attributes
|
131
|
+
|
132
|
+
This library adds the following public attributes to the `Team` class.
|
133
|
+
|
134
|
+
#### stripe_customer_id
|
135
|
+
|
136
|
+
Stripe customer string ID.
|
137
|
+
|
138
|
+
#### subscribed
|
139
|
+
|
140
|
+
Boolean whether the team is subscribed.
|
141
|
+
|
142
|
+
When set without a Stripe customer ID creates a perpetual subscription.
|
143
|
+
|
144
|
+
#### subscription_expired_at
|
145
|
+
|
146
|
+
Timestamp for when a subscription has expired.
|
147
|
+
|
148
|
+
#### trial_informed_at
|
149
|
+
|
150
|
+
Timestamp for when the team was informed of a pending end of trial.
|
151
|
+
|
152
|
+
#### trial_ends_at
|
153
|
+
|
154
|
+
Timestamp for when the trial ends. Will raise an error if a team is subscribed.
|
155
|
+
|
156
|
+
### Methods
|
157
|
+
|
158
|
+
The following public methods are added to `Team`.
|
159
|
+
|
160
|
+
#### trial_text
|
161
|
+
|
162
|
+
A message about the remaining trial period. Will raise an error if a team is subscribed.
|
163
|
+
|
164
|
+
e.g. `Your trial subscription expires in 3 days. Subscribe your team at https://example.com?team_id=id.`
|
165
|
+
|
166
|
+
#### subscribed_text
|
167
|
+
|
168
|
+
A message upon successful subscription.
|
169
|
+
|
170
|
+
e.g. `Your team has been subscribed.`
|
171
|
+
|
172
|
+
#### unsubscribed_text
|
173
|
+
|
174
|
+
A message to use when unsubscribed.
|
175
|
+
|
176
|
+
e.g. `Your team has been unsubscribed. Subscribe your team at https://example.com?team_id=id.`
|
177
|
+
|
178
|
+
#### subscription_expired_text
|
179
|
+
|
180
|
+
A message to use upon subscription expiration.
|
181
|
+
|
182
|
+
e.g. `Your subscription has expired. Subscribe your team at https://example.com?team_id=id.`
|
183
|
+
|
184
|
+
#### subscription_past_due_text
|
185
|
+
|
186
|
+
A message to use when paid subscription is past due.
|
187
|
+
|
188
|
+
e.g. `Your subscription is past due. Update your credit card info at https://example.com?update_cc?team_id=id.`
|
189
|
+
|
190
|
+
#### trial_expired?
|
191
|
+
|
192
|
+
True if number of remaining trial days is zero. Will raise an error if a team is subscribed.
|
193
|
+
|
194
|
+
#### remaining_trial_days
|
195
|
+
|
196
|
+
Number of days remaining in the trial. Will raise an error if a team is subscribed.
|
197
|
+
|
198
|
+
#### subscription_expired?
|
199
|
+
|
200
|
+
Returns `true` when the trial period has ended and/or a subscription has expired.
|
201
|
+
|
202
|
+
#### tags
|
203
|
+
|
204
|
+
A set of tags to support other extensions, such as [slack-ruby-bot-server-mailchimp](https://github.com/slack-ruby/slack-ruby-bot-server-mailchimp). Possible values are `subscribed`, `trial` and `paid`.
|
205
|
+
|
206
|
+
#### active_stripe_subscription
|
207
|
+
|
208
|
+
An active Stripe subscription, if any.
|
209
|
+
|
210
|
+
#### active_stripe_subscription?
|
211
|
+
|
212
|
+
Returns `true` if the team has an active Stripe subscription.
|
213
|
+
|
214
|
+
#### subscription_text(params)
|
215
|
+
|
216
|
+
Returns detailed subscription info or a trial message, typically used in a bot command.
|
217
|
+
|
218
|
+
Pass `include_admin_info: true` to include detailed credit card on file information.
|
219
|
+
|
220
|
+
#### subscribe!(params)
|
221
|
+
|
222
|
+
Creates and returns a Stripe customer. Updates subscription fields. Invokes `subscribed` callbacks.
|
223
|
+
|
224
|
+
Parameters are `stripe_token`, `stripe_email` and an optional `subscription_plan_id`.
|
225
|
+
|
226
|
+
#### unsubscribe!
|
227
|
+
|
228
|
+
Marks a Stripe subscription to be terminated at period end. Invokes `unsubscribed` callbacks.
|
229
|
+
|
230
|
+
#### update_subscription!(params)
|
231
|
+
|
232
|
+
Updates a Stripe customer.
|
233
|
+
|
234
|
+
Parameters are `stripe_token` for the new payment instrument.
|
235
|
+
|
236
|
+
### Lifecycle Methods
|
237
|
+
|
238
|
+
The following methods are invoked before a team is started and from a daily lifecycle cron via `Team#check_stripe!`.
|
239
|
+
|
240
|
+
#### check_subscription!
|
241
|
+
|
242
|
+
Invoked for subscribed teams, unsubscribes teams that have canceled subscriptions or past due payments.
|
243
|
+
|
244
|
+
#### check_trials!
|
245
|
+
|
246
|
+
Invoked for teams during trial. Notify teams that their trial is about to expire.
|
247
|
+
|
248
|
+
### API Endpoints
|
249
|
+
|
250
|
+
This extension adds the following API endpoints.
|
251
|
+
|
252
|
+
#### POST /subscriptions
|
253
|
+
|
254
|
+
Creates or updates a subscription for a team, using a payment method tokenized by Stripe. See [subscription_endpoint.rb](lib/slack-ruby-bot-server-stripe/api/endpoints/subscription_endpoint.rb) for details.
|
255
|
+
|
256
|
+
### HTML Views
|
257
|
+
|
258
|
+
#### /subscribe
|
259
|
+
|
260
|
+
This extension adds a [subscription page](slack-ruby-bot-server-stripe/public/subscribe.html.erb) that handles initial subscriptions and credit card updates. Clone the page into your own project's `public/subscribe.html.erb` to customize.
|
261
|
+
|
262
|
+
### Slack Commands
|
263
|
+
|
264
|
+
This extension adds the following Slack commands.
|
265
|
+
|
266
|
+
#### subscription
|
267
|
+
|
268
|
+
Displays current subscription information, see [subscription.rb](lib/slack-ruby-bot-server-stripe/commands/subscription.rb). This command also displays partial credit card information to the user that has installed the bot.
|
269
|
+
|
270
|
+
#### unsubscribe
|
271
|
+
|
272
|
+
Turns off auto-renew for the current subscription, see [unsubscribe.rb](lib/slack-ruby-bot-server-stripe/commands/unsubscribe.rb). This command will only succeed when run by the user that has installed the bot.
|
273
|
+
|
274
|
+
### Copyright & License
|
275
|
+
|
276
|
+
Copyright [Daniel Doubrovkine](http://code.dblock.org) and Contributors, 2019-2020
|
277
|
+
|
278
|
+
[MIT License](LICENSE)
|