Sha256: b78e2b82db05b15b5586b20f54caaf0cc6fcc2af1ba9e798c3419859c8967bc3

Contents?: true

Size: 1018 Bytes

Versions: 14

Compression:

Stored size: 1018 Bytes

Contents

module Effective
  module Providers
    module AppCheckout
      extend ActiveSupport::Concern

      included do
      end

      # TODO: Make app checkout work with admin checkout workflow

      def app_checkout
        @order = Order.find(params[:id])

        (EffectiveOrders.authorize!(self, :update, @order) rescue false)

        checkout = EffectiveOrders.app_checkout[:service].call(order: @order)
        if checkout.success?
          order_purchased(details: payment_details(checkout), provider: 'app_checkout', card: 'none')
        else
          flash = EffectiveOrders.app_checkout[:declined_flash]
          order_declined(details: payment_details(checkout), message: flash, provider: 'app_checkout', card: 'none')
        end
      end

      private

      def payment_details(checkout)
        default = 'App Checkout'
        if checkout.respond_to?(:payment_details)
          checkout.payment_details.presence || default
        else
          default
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
effective_orders-3.2.3 app/controllers/effective/providers/app_checkout.rb
effective_orders-3.2.2 app/controllers/effective/providers/app_checkout.rb
effective_orders-3.2.1 app/controllers/effective/providers/app_checkout.rb
effective_orders-3.2.0 app/controllers/effective/providers/app_checkout.rb
effective_orders-3.1.7 app/controllers/effective/providers/app_checkout.rb
effective_orders-3.1.6 app/controllers/effective/providers/app_checkout.rb
effective_orders-3.1.4 app/controllers/effective/providers/app_checkout.rb
effective_orders-3.1.3 app/controllers/effective/providers/app_checkout.rb
effective_orders-3.1.0 app/controllers/effective/providers/app_checkout.rb
effective_orders-3.0.4 app/controllers/effective/providers/app_checkout.rb
effective_orders-3.0.3 app/controllers/effective/providers/app_checkout.rb
effective_orders-3.0.2 app/controllers/effective/providers/app_checkout.rb
effective_orders-3.0.1 app/controllers/effective/providers/app_checkout.rb
effective_orders-3.0.0 app/controllers/effective/providers/app_checkout.rb