Class: OffsitePayments::Integrations::PagSeguro::Notification

Inherits:
Notification
  • Object
show all
Defined in:
lib/offsite_payments/integrations/pag_seguro.rb

Instance Attribute Summary

Attributes inherited from Notification

#params, #raw

Instance Method Summary collapse

Methods inherited from Notification

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

Constructor Details

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

Returns a new instance of Notification.



164
165
166
167
168
169
170
171
# File 'lib/offsite_payments/integrations/pag_seguro.rb', line 164

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



227
228
229
# File 'lib/offsite_payments/integrations/pag_seguro.rb', line 227

def acknowledge
  true
end

#complete?Boolean

Returns:

  • (Boolean)


173
174
175
# File 'lib/offsite_payments/integrations/pag_seguro.rb', line 173

def complete?
  status == "Completed"
end

#currencyObject



197
198
199
# File 'lib/offsite_payments/integrations/pag_seguro.rb', line 197

def currency
  "BRL"
end

#grossObject



193
194
195
# File 'lib/offsite_payments/integrations/pag_seguro.rb', line 193

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

#item_idObject



177
178
179
# File 'lib/offsite_payments/integrations/pag_seguro.rb', line 177

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

#payer_emailObject



189
190
191
# File 'lib/offsite_payments/integrations/pag_seguro.rb', line 189

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

#payment_method_codeObject



205
206
207
# File 'lib/offsite_payments/integrations/pag_seguro.rb', line 205

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

#payment_method_typeObject



201
202
203
# File 'lib/offsite_payments/integrations/pag_seguro.rb', line 201

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

#received_atObject



185
186
187
# File 'lib/offsite_payments/integrations/pag_seguro.rb', line 185

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

#statusObject



209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
# File 'lib/offsite_payments/integrations/pag_seguro.rb', line 209

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



181
182
183
# File 'lib/offsite_payments/integrations/pag_seguro.rb', line 181

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