Class: Gold::ConvertAffiliateToPaidOp
- Inherits:
-
Object
- Object
- Gold::ConvertAffiliateToPaidOp
- Defined in:
- app/operations/gold/convert_affiliate_to_paid_op.rb
Overview
Convert an affiliate store to a paid store.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(billing, return_url, test_charge = Gold.configuration.test_charge?) ⇒ ConvertAffiliateToPaidOp
constructor
A new instance of ConvertAffiliateToPaidOp.
Constructor Details
#initialize(billing, return_url, test_charge = Gold.configuration.test_charge?) ⇒ ConvertAffiliateToPaidOp
Returns a new instance of ConvertAffiliateToPaidOp.
6 7 8 9 10 |
# File 'app/operations/gold/convert_affiliate_to_paid_op.rb', line 6 def initialize(billing, return_url, test_charge = Gold.configuration.test_charge?) @billing = billing @return_url = return_url @test_charge = test_charge end |
Instance Method Details
#call ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/operations/gold/convert_affiliate_to_paid_op.rb', line 12 def call unless @billing.shopify_plan. raise ConversionError, "This is not a paying plan" end @billing.transition_to_or_stay_in!(:affiliate_to_paid) if @billing.last_selected_tier.free? ApplyTierOp.new(@billing).call else outcome = ChargeOp.new(@billing, @return_url, @test_charge).call if outcome.is_a? Outcomes::PendingCharge BillingMailer.affiliate_to_paid(@billing, outcome.confirmation_url).deliver_now end outcome end end |