Class: Spree::PaymentNotification

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/spree/payment_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/payment_notification.rb', line 7

def self.create_from_params(params)
  email = Order.pag_seguro_payment_method.preferred_email
  token = Order.pag_seguro_payment_method.preferred_token
  notification_code = params[:notificationCode]
  notification = ::PagSeguro::Notification.new(email, token, notification_code)

  self.create!(
    params: params,
    order_id: notification.id,
    status: notification.status,
    transaction_id: notification.transaction_id,
    notification_code: notification_code
  )
  
  notification
end