You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: order.rb
    path of file: ./repos/solidus/core/lib/spree/core/importer
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

module Spree
  module Core
    module Importer
      class Order
        def self.import(user, params)
          params = params.to_h
          ActiveRecord::Base.transaction do
            ensure_country_id_from_params params[:ship_address_attributes]
            ensure_state_id_from_params params[:ship_
    
        def self.create_payments_from_params(payments_hash, order)
          return [] unless payments_hash
          payments_hash.each do |target|
            payment = order.payments.build order: order
            payment.amount = target[:amount].to_f
            # Order API should be using state as that's the normal payment field.
            # spree_wombat serializes payment state as status so imported orders should fall back to status field.
            payment.state = target[:state] || target[:status] || 'completed'
            payment.payment_method = Spree::PaymentMethod.find_by!(name: target[:payment_method])
            source_attributes = target[:source] || target[:source_attributes]
            payment.source = create_source_payment_from_params(source_attributes, payment) if source_attributes
            payment.save!
          end
        end