Sha256: 220bca2f99d637526046eb99aebd384870a2ad945f9a759d6b7abcc26125f037

Contents?: true

Size: 871 Bytes

Versions: 2

Compression:

Stored size: 871 Bytes

Contents

module Workarea
  decorate Checkout, with: :kount do
    def handle_kount_review
      return false unless order.under_review?
      return false unless complete?
      return false unless shippable?
      return false unless payable?

      inventory.purchase
      return false unless inventory.captured?

      return true unless payment.uses_credit_card?
      store_credit_card
    end

    def handle_kount_approved
      unless payment_collection.purchase
        captured_inventory&.rollback
        return false
      end

      result = order.place
      place_order_side_effects if result
      result
    end

    private

      def captured_inventory
        @captured_inventory ||= Inventory::Transaction.captured_for_order(order.id)
      end

      def store_credit_card
        Payment::StoreCreditCard.new(payment.credit_card).save!
      end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
workarea-kount-3.3.1 app/models/workarea/checkout.decorator
workarea-kount-3.3.0 app/models/workarea/checkout.decorator