Sha256: de1e82f766c71ccd126a918cd5c6e60ddb83ae76192c582f24526b9f079305ca

Contents?: true

Size: 952 Bytes

Versions: 15

Compression:

Stored size: 952 Bytes

Contents

module Effective
  module Providers
    module AppCheckout
      extend ActiveSupport::Concern

      included do
      end

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

        (EffectiveOrders.authorized?(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

15 entries across 15 versions & 1 rubygems

Version Path
effective_orders-2.2.4 app/controllers/effective/providers/app_checkout.rb
effective_orders-2.2.3 app/controllers/effective/providers/app_checkout.rb
effective_orders-2.2.2 app/controllers/effective/providers/app_checkout.rb
effective_orders-2.2.1 app/controllers/effective/providers/app_checkout.rb
effective_orders-2.2.0 app/controllers/effective/providers/app_checkout.rb
effective_orders-2.1.17 app/controllers/effective/providers/app_checkout.rb
effective_orders-2.1.16 app/controllers/effective/providers/app_checkout.rb
effective_orders-2.1.15 app/controllers/effective/providers/app_checkout.rb
effective_orders-2.1.14 app/controllers/effective/providers/app_checkout.rb
effective_orders-2.1.13 app/controllers/effective/providers/app_checkout.rb
effective_orders-2.1.12 app/controllers/effective/providers/app_checkout.rb
effective_orders-2.1.10 app/controllers/effective/providers/app_checkout.rb
effective_orders-2.1.9 app/controllers/effective/providers/app_checkout.rb
effective_orders-2.1.8 app/controllers/effective/providers/app_checkout.rb
effective_orders-2.1.7 app/controllers/effective/providers/app_checkout.rb