def purchase!(payment: 'none', provider: 'none', card: 'none', email: true, skip_buyer_validations: false)
      return false if purchased?
      error = nil

      assign_attributes(
        state: EffectiveOrders::PURCHASED,
        purchased_at: Time.zone.now,
        payment: payment_to_h(payment),
        payment_provider: provider,
        payment_card: (card.presence || 'none'),
        skip_buyer_validations: skip_buyer_validations
      )

      Effective::Order.transaction do
        begin
          run_purchasable_callbacks(:before_purchase)
          save!
          update_purchasables_purchased_order!
        rescue => e
          self.state = state_was
          self.purchased_at = nil

          error = e.message
          raise ::ActiveRecord::Rollback
        end
      end

      raise "Failed to purchase order: #{error || errors.full_messages.to_sentence}" unless error.nil?

      send_order_receipts! if email

      run_purchasable_callbacks(:after_purchase)

      true
    end
def purchase!(payment: 'none', provider: 'none', card: 'none', email: true, skip_buyer_validations: false)
      return false if purchased?
      error = nil

      assign_attributes(
        state: EffectiveOrders::PURCHASED,
        purchased_at: Time.zone.now,
        payment: payment_to_h(payment),
        payment_provider: provider,
        payment_card: (card.presence || 'none'),
        skip_buyer_validations: skip_buyer_validations
      )

      Effective::Order.transaction do
        begin
          run_purchasable_callbacks(:before_purchase)
          save!
          update_purchasables_purchased_order!
        rescue => e
          self.state = state_was
          self.purchased_at = nil

          error = e.message
          raise ::ActiveRecord::Rollback
        end
      end

      raise "Failed to purchase order: #{error || errors.full_messages.to_sentence}" unless error.nil?

      send_order_receipts! if email

      run_purchasable_callbacks(:after_purchase)

      true
    end
Effective::Order.new(items: Product.first, user: User.first).purchase!(email: false)