-
-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'stripe-prices' into develop
- Loading branch information
Showing
21 changed files
with
438 additions
and
331 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: pluralize_interval(price)) | ||
end | ||
end | ||
|
||
def billing_interval(price) | ||
if interval_count(price) == 1 | ||
_('per user, per {{interval}}', interval: 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 |
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,33 @@ | ||
## | ||
# A wrapper for a Stripe::Price | ||
# | ||
class AlaveteliPro::Price < SimpleDelegator | ||
include Taxable | ||
|
||
tax :unit_amount | ||
|
||
def self.list | ||
AlaveteliConfiguration.stripe_prices.map do |(_key, id)| | ||
retrieve(id) | ||
end | ||
end | ||
|
||
def self.retrieve(id) | ||
key = AlaveteliConfiguration.stripe_prices.key(id) | ||
new(Stripe::Price.retrieve(key)) | ||
rescue Stripe::InvalidRequestError | ||
nil | ||
end | ||
|
||
def to_param | ||
AlaveteliConfiguration.stripe_prices[id] || id | ||
end | ||
|
||
# product | ||
def product | ||
@product ||= ( | ||
product_id = __getobj__.product | ||
Stripe::Product.retrieve(product_id) if product_id | ||
) | ||
end | ||
end |
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.