-
-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace Stripe Plan API with the Prices API
Using Prices provides more flexibility and will allow us to change the which prices are used on both current and future subscriptions.
- Loading branch information
Showing
18 changed files
with
351 additions
and
295 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
## | ||
# Helper methods for formatting and displaying billing and price information | ||
# in the Alaveteli Pro interface | ||
# | ||
module AlaveteliPro::PriceHelper | ||
def billing_frequency(price) | ||
if interval(price) == 'day' && interval_count(price) == 1 | ||
_('Billed: Daily') | ||
elsif interval(price) == 'week' && interval_count(price) == 1 | ||
_('Billed: Weekly') | ||
elsif interval(price) == 'month' && interval_count(price) == 1 | ||
_('Billed: Monthly') | ||
elsif interval(price) == 'year' && interval_count(price) == 1 | ||
_('Billed: Annually') | ||
else | ||
_('Billed: every {{interval}}', interval: interval(price)) | ||
end | ||
end | ||
|
||
def billing_interval(price) | ||
if interval_count(price) == 1 | ||
_('per user, per {{interval}}', interval: pluralize_interval(price)) | ||
else | ||
_('per user, every {{interval}}', interval: pluralize_interval(price)) | ||
end | ||
end | ||
|
||
private | ||
|
||
def pluralize_interval(price) | ||
count = interval_count(price) | ||
interval = interval(price) | ||
return interval if count == 1 | ||
|
||
pluralize(count, interval) | ||
end | ||
|
||
def interval(price) | ||
price.recurring['interval'] | ||
end | ||
|
||
def interval_count(price) | ||
price.recurring['interval_count'] | ||
end | ||
end |
14 changes: 9 additions & 5 deletions
14
app/models/alaveteli_pro/plan.rb → app/models/alaveteli_pro/price.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.