Class: Spree::BcashNotification

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/spree/bcash_notification.rb

Class Method Summary collapse

Class Method Details

.create_from_params(params) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/models/spree/bcash_notification.rb', line 7

def self.create_from_params(params)
  notification = ::Bcash::Notification.new(params)

  notify = self.find_by_id_transaction(notification.id_transacao)
  if notify
    notify.update_attributes(status: notification.status.force_encoding("iso-8859-1"))
  else
    self.create!(
      order_id: Order.find_by_number(notification.id_pedido).id,
      id_transaction: notification.id_transacao,
      status: notification.status.force_encoding("iso-8859-1")
    )
  end

  notification
end