Sha256: 8c42641e3c5f291fbdfe42c4a1173b8c73b7f24be8400e24e01d39ceb00ad85e

Contents?: true

Size: 1.17 KB

Versions: 6

Compression:

Stored size: 1.17 KB

Contents

module Workarea
  decorate SaveUserOrderDetails, with: :forter do
    def save_payment_details(order, user)
      payment = Payment.find_or_initialize_by(id: order.id)
      payment_profile = Payment::Profile.lookup(PaymentReference.new(user))
      billing_address = extract_address_attributes(payment.address)

      if billing_address.present?
        user.auto_save_billing_address(billing_address)

        if user.public_info.blank?
          user.update_attributes!(
            first_name: billing_address[:first_name],
            last_name: billing_address[:last_name]
          )
        end
      end

      if payment.credit_card? && !payment.credit_card.saved?
        payment_profile.credit_cards.create(
          first_name: payment.credit_card.first_name,
          last_name: payment.credit_card.last_name,
          display_number: payment.credit_card.display_number,
          issuer: payment.credit_card.issuer,
          month: payment.credit_card.month,
          year: payment.credit_card.year,
          token: payment.credit_card.token,
          default: payment_profile.credit_cards.none?,
          bin: payment.credit_card.bin
        )
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
workarea-forter-1.3.2 app/workers/workarea/save_user_order_details.decorator
workarea-forter-1.3.1 app/workers/workarea/save_user_order_details.decorator
workarea-forter-1.3.0 app/workers/workarea/save_user_order_details.decorator
workarea-forter-1.2.4 app/workers/workarea/save_user_order_details.decorator
workarea-forter-1.2.3 app/workers/workarea/save_user_order_details.decorator
workarea-forter-1.2.2 app/workers/workarea/save_user_order_details.decorator