Skip to Content Skip to Search
Methods
A
N
P

Constants

CANCELABLE_STATUSES = %w[ requires_payment_method requires_source requires_capture requires_confirmation requires_action requires_source_action ].freeze
 

Class Public methods

new(args = {})

# File app/actions/action/billing/charge.rb, line 13
def initialize(args = {})
  super
  code = args[:coupon_code] || existing_coupon_code
  @billing_coupon = Action::Billing::Coupon.new(code:, plan:)
  @coupon_code = @billing_coupon.code
  @coupon = @billing_coupon.coupon
end

Instance Public methods

after_purchase()

# File app/actions/action/billing/charge.rb, line 32
def after_purchase
  charge_data = {member_id: @member.id, plan_id: @plan.id}

  if order_amount < 50
    charge_data[:payment_gateway_id] = "ch_free"
    charge_data[:amount] = 0
  else
    charge_data[:payment_gateway_id] = @intent.latest_charge.id
    charge_data[:amount] = order_amount
    charge_data[:tax_amount] = get_tax_amount
  end

  @ms_order = @member.charges.create!(charge_data)
  reference_coupon_used(@ms_order)
end

purchase()

# File app/actions/action/billing/charge.rb, line 21
def purchase
  @site = @plan.site

  update_intent! if should_update_intent?

  generate_payment_response
rescue Stripe::CardError => e
  handle_stripe_error(e)
  raise e
end