Sha256: af1197ce71bc60352c630e9f9619359be0e6fa1c6bca8c2c4ccc55b3e2df2d82

Contents?: true

Size: 680 Bytes

Versions: 5

Compression:

Stored size: 680 Bytes

Contents

module Spree
  class Recurring < Spree::Base
    class StripeRecurring < Spree::Recurring
      module ApiHandler
        module SubscriptionApiHandler
          def subscribe(subscription)
            raise_invalid_object_error(subscription, Spree::Subscription)
            customer = subscription.user.find_or_create_stripe_customer(subscription.card_token)
            customer.subscriptions.create(plan: subscription.api_plan_id)
          end

          def unsubscribe(subscription)
            raise_invalid_object_error(subscription, Spree::Subscription)
            subscription.user.api_customer.cancel_subscription
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
spree_account_recurring-2.0.0 app/models/concerns/spree/recurring/stripe_recurring/api_handler/subscription_api_handler.rb
spree_account_recurring-1.3.1 app/models/concerns/spree/recurring/stripe_recurring/api_handler/subscription_api_handler.rb
spree_account_recurring-1.2.1 app/models/concerns/spree/recurring/stripe_recurring/api_handler/subscription_api_handler.rb
spree_account_recurring-1.3.0 app/models/concerns/spree/recurring/stripe_recurring/api_handler/subscription_api_handler.rb
spree_account_recurring-1.2.0 app/models/concerns/spree/recurring/stripe_recurring/api_handler/subscription_api_handler.rb