Methods
- C
- D
- E
- I
- R
Included Modules
Attributes
| [RW] | description | |
| [RW] | stripe_error |
Class Public methods
create_from_stripe(site_id, data) Link
Source: show
# File app/models/db/coupon.rb, line 108 def self.create_from_stripe(site_id, data) return false if exists?(site_id: site_id, code: data[:id]) if data[:valid] create( {site_id: site_id, code: data[:id], payment_type: "subscription", amount_off: data[:amount_off]&.to_i, currency: data[:currency].presence, percent_off: data[:percent_off]&.to_i, max_redemptions: data[:max_redemptions], duration: data[:duration], duration_in_months: data[:duration_in_months], redeem_end: data[:redeem_by] ? Time.zone.at(data[:redeem_by]) : nil, redemption_count: data[:times_redeemed]} ) end end
Instance Public methods
discount_duration() Link
Source: show
# File app/models/db/coupon.rb, line 79 def discount_duration # TODO: MUST FIX FOR ADMIN APPLETS: # fix the DB duration from 'repeating' to 'recurring' recurring_duration? ? "recurring" : duration end
expired?() Link
Source: show
# File app/models/db/coupon.rb, line 85 def expired? return true unless enabled? return true if max_redemptions && redemption_count >= max_redemptions now = Time.zone.now return true if redeem_start && redeem_start >= now return true if redeem_end && now >= redeem_end false end
increment_redemption_count!() Link
Source: show
# File app/models/db/coupon.rb, line 104 def increment_redemption_count! self.class.increment_counter(:redemption_count, id) end
recurring_duration?() Link
Source: show
# File app/models/db/coupon.rb, line 75 def recurring_duration? duration == "repeating" end