Class: ActiveMerchant::Billing::Integrations::PagSeguro::Notification

Inherits:
Notification
  • Object
show all
Defined in:
lib/active_merchant/billing/integrations/pag_seguro/notification.rb

Instance Attribute Summary

Attributes inherited from Notification

#params, #raw

Instance Method Summary collapse

Methods inherited from Notification

#amount, #empty!, #gross_cents, #test?, #valid_sender?

Constructor Details

#initialize(post, options = {}) ⇒ Notification

Returns a new instance of Notification.



10
11
12
13
14
15
16
17
# File 'lib/active_merchant/billing/integrations/pag_seguro/notification.rb', line 10

def initialize(post, options = {})
  notify_code = parse_http_query(post)["notificationCode"]
  email = options[:credential1]
  token = options[:credential2]

  uri = URI.join(PagSeguro.notification_url, notify_code)
  parse_xml(web_get(uri, email: email, token: token))
end

Instance Method Details

#acknowledgeObject

There’s no acknowledge for PagSeguro



73
74
75
# File 'lib/active_merchant/billing/integrations/pag_seguro/notification.rb', line 73

def acknowledge
  true
end

#complete?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/active_merchant/billing/integrations/pag_seguro/notification.rb', line 19

def complete?
  status == "Completed"
end

#currencyObject



43
44
45
# File 'lib/active_merchant/billing/integrations/pag_seguro/notification.rb', line 43

def currency
  "BRL"
end

#grossObject



39
40
41
# File 'lib/active_merchant/billing/integrations/pag_seguro/notification.rb', line 39

def gross
  params["transaction"]["grossAmount"]
end

#item_idObject



23
24
25
# File 'lib/active_merchant/billing/integrations/pag_seguro/notification.rb', line 23

def item_id
  params["transaction"]["reference"]
end

#payer_emailObject



35
36
37
# File 'lib/active_merchant/billing/integrations/pag_seguro/notification.rb', line 35

def payer_email
  params["sender"]["email"]
end

#payment_method_codeObject



51
52
53
# File 'lib/active_merchant/billing/integrations/pag_seguro/notification.rb', line 51

def payment_method_code
  params["transaction"]["paymentMethod"]["code"]
end

#payment_method_typeObject



47
48
49
# File 'lib/active_merchant/billing/integrations/pag_seguro/notification.rb', line 47

def payment_method_type
  params["transaction"]["paymentMethod"]["type"]
end

#received_atObject



31
32
33
# File 'lib/active_merchant/billing/integrations/pag_seguro/notification.rb', line 31

def received_at
  params["transaction"]["date"]
end

#statusObject



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/active_merchant/billing/integrations/pag_seguro/notification.rb', line 55

def status
  case params["transaction"]["status"]
  when "1", "2"
    "Pending"
  when "3"
    "Completed"
  when "4"
    "Available"
  when "5"
    "Dispute"
  when "6"
    "Reversed"
  when "7"
    "Failed"
  end
end

#transaction_idObject



27
28
29
# File 'lib/active_merchant/billing/integrations/pag_seguro/notification.rb', line 27

def transaction_id
  params["transaction"]["code"]
end