lib/stripe_mock/request_handlers/subscriptions.rb
# Ensure customer has card to charge unless one of the following criterias is met:
# 1) is in trial
# 2) is free
# 3) has billing set to send invoice
Ensure customer has card to charge unless one of the following criterias is met:
1) is in trial
2) is free
3) has billing set to send invoice
Ensure customer has card to charge unless one of the following criterias is met : 1 ) is in trial 2 ) is free 3 ) has billing set to send invoice
def verify_card_present(customer, plan, subscription, params={})
        return if customer[:default_source]
        return if customer[:invoice_settings][:default_payment_method]
        return if customer[:trial_end]
        return if params[:trial_end]
        return if params[:payment_behavior] == 'default_incomplete'
        return if subscription[:default_payment_method]
        plan_trial_period_days = plan[:trial_period_days] || 0
        plan_has_trial = plan_trial_period_days != 0 || plan[:amount] == 0 || plan[:trial_end]
        return if plan && plan_has_trial
        return if subscription && subscription[:trial_end] && subscription[:trial_end] != 'now'
        if subscription[:items]
          trial = subscription[:items][:data].none? do |item|
            plan = item[:plan]
            (plan[:trial_period_days].nil? || plan[:trial_period_days] == 0) &&
              (plan[:trial_end].nil? || plan[:trial_end] == 'now')
          end
          return if trial
        end
        return if params[:billing] == 'send_invoice'
        raise Stripe::InvalidRequestError.new('This customer has no attached payment source', nil, http_status: 400)
      end
def verify_card_present ( customer , plan , subscription , params = { } ) return if customer [ :default_source ] return if customer [ :invoice_settings ] [ :default_payment_method ] return if customer [ :trial_end ] return if params [ :trial_end ] return if params [ :payment_behavior ] == 'default_incomplete' return if subscription [ :default_payment_method ] plan_trial_period_days = plan [ :trial_period_days ] || 0 plan_has_trial = plan_trial_period_days != 0 || plan [ :amount ] == 0 || plan [ :trial_end ] return if plan && plan_has_trial return if subscription && subscription [ :trial_end ] && subscription [ :trial_end ] != 'now' if subscription [ :items ] trial = subscription [ :items ] [ :data ] . none? do | item | plan = item [ :plan ] ( plan [ :trial_period_days ] . nil? || plan [ :trial_period_days ] == 0 ) && ( plan [ :trial_end ] . nil? || plan [ :trial_end ] == 'now' ) end return if trial end return if params [ :billing ] == 'send_invoice' raise Stripe :: InvalidRequestError . new ( 'This customer has no attached payment source' , nil , http_status : 400 ) end
Ensure customer has card to charge unless one of the following criterias is met:
1) is in trial
2) is free
3) has billing set to send invoice
Ensure customer has card to charge unless one of the following criterias is met : 1 ) is in trial 2 ) is free 3 ) has billing set to send invoice
customer
<not_specific>
plan
<not_specific>
subscription
<not_specific>
params
<not_specific>