Skip to Content Skip to Search
Methods
C
E
G
N

Attributes

[RW] code
[RW] error
[RW] payment_type
[RW] plan
[RW] site
[RW] status_code

Class Public methods

new(site, plan)

# File app/actions/action/coupon_fetcher.rb, line 5
def initialize(site, plan)
  @site = site
  @plan = plan
  @remote_coupon = Stripe::Coupon.new
  @payment_type = plan.recurring? ? "subscription" : "charge"
  @error = nil
end

Instance Public methods

coupon_message(remote_coupon)

# File app/actions/action/coupon_fetcher.rb, line 27
def coupon_message(remote_coupon)
  @remote_coupon = remote_coupon
  generate_desciption
end

error_message()

# File app/actions/action/coupon_fetcher.rb, line 32
def error_message
  remote_coupon.error[:message]
end

get(coupon_id)

# File app/actions/action/coupon_fetcher.rb, line 13
def get(coupon_id)
  @code = coupon_id.strip

  validate_coupon!

  if error.present?
    remote_coupon.error = error
  else
    get_coupon_from_source
  end

  [status_code, remote_coupon]
end