Class: OffsitePayments::Integrations::PagSeguro::Notification
- Inherits:
-
Notification
- Object
- Notification
- OffsitePayments::Integrations::PagSeguro::Notification
show all
- Defined in:
- lib/offsite_payments/integrations/pag_seguro.rb
Defined Under Namespace
Classes: NotificationError
Instance Attribute Summary
Attributes inherited from Notification
#params, #raw
Instance Method Summary
collapse
#amount, #empty!, #gross_cents, #iso_currency, #test?, #valid_sender?
Constructor Details
#initialize(post, options = {}) ⇒ Notification
Returns a new instance of Notification.
170
171
172
173
174
175
176
177
178
179
180
181
|
# File 'lib/offsite_payments/integrations/pag_seguro.rb', line 170
def initialize(post, options = {})
@acknowledge = true
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))
rescue NotificationError
@acknowledge = false
end
|
Instance Method Details
#acknowledge ⇒ Object
236
237
238
|
# File 'lib/offsite_payments/integrations/pag_seguro.rb', line 236
def acknowledge
@acknowledge
end
|
#complete? ⇒ Boolean
183
184
185
|
# File 'lib/offsite_payments/integrations/pag_seguro.rb', line 183
def complete?
status == "Completed"
end
|
#currency ⇒ Object
207
208
209
|
# File 'lib/offsite_payments/integrations/pag_seguro.rb', line 207
def currency
"BRL"
end
|
#gross ⇒ Object
203
204
205
|
# File 'lib/offsite_payments/integrations/pag_seguro.rb', line 203
def gross
params["transaction"]["grossAmount"]
end
|
#item_id ⇒ Object
187
188
189
|
# File 'lib/offsite_payments/integrations/pag_seguro.rb', line 187
def item_id
params["transaction"]["reference"]
end
|
#payer_email ⇒ Object
199
200
201
|
# File 'lib/offsite_payments/integrations/pag_seguro.rb', line 199
def payer_email
params["sender"]["email"]
end
|
#payment_method_code ⇒ Object
215
216
217
|
# File 'lib/offsite_payments/integrations/pag_seguro.rb', line 215
def payment_method_code
params["transaction"]["paymentMethod"]["code"]
end
|
#payment_method_type ⇒ Object
211
212
213
|
# File 'lib/offsite_payments/integrations/pag_seguro.rb', line 211
def payment_method_type
params["transaction"]["paymentMethod"]["type"]
end
|
#received_at ⇒ Object
195
196
197
|
# File 'lib/offsite_payments/integrations/pag_seguro.rb', line 195
def received_at
params["transaction"]["date"]
end
|
#status ⇒ Object
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
|
# File 'lib/offsite_payments/integrations/pag_seguro.rb', line 219
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_id ⇒ Object
191
192
193
|
# File 'lib/offsite_payments/integrations/pag_seguro.rb', line 191
def transaction_id
params["transaction"]["code"]
end
|