Class: OffsitePayments::Integrations::BitPay::Notification
- Inherits:
-
Notification
- Object
- Notification
- OffsitePayments::Integrations::BitPay::Notification
show all
- Defined in:
- lib/offsite_payments/integrations/bit_pay.rb
Instance Attribute Summary
Attributes inherited from Notification
#params, #raw
Instance Method Summary
collapse
#amount, #empty!, #gross_cents, #initialize, #iso_currency, #test?, #valid_sender?
Instance Method Details
#acknowledge(authcode = nil) ⇒ Object
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
# File 'lib/offsite_payments/integrations/bit_pay.rb', line 148
def acknowledge(authcode = nil)
uri = URI.parse("#{OffsitePayments::Integrations::BitPay::API_V2_URL}/#{transaction_id}")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri.path)
response = http.request(request)
received_attributes = [transaction_id, status]
parse(response.body)
received_attributes == [transaction_id, status]
end
|
#complete? ⇒ Boolean
112
113
114
|
# File 'lib/offsite_payments/integrations/bit_pay.rb', line 112
def complete?
status == "Completed"
end
|
#currency ⇒ Object
140
141
142
|
# File 'lib/offsite_payments/integrations/bit_pay.rb', line 140
def currency
params['currency']
end
|
#gross ⇒ Object
144
145
146
|
# File 'lib/offsite_payments/integrations/bit_pay.rb', line 144
def gross
params['price'].to_f
end
|
#item_id ⇒ Object
120
121
122
|
# File 'lib/offsite_payments/integrations/bit_pay.rb', line 120
def item_id
JSON.parse(params['posData'])['orderId']
end
|
#received_at ⇒ Object
When was this payment received by the client.
136
137
138
|
# File 'lib/offsite_payments/integrations/bit_pay.rb', line 136
def received_at
params['invoiceTime'].to_i
end
|
#status ⇒ Object
124
125
126
127
128
129
130
131
132
133
|
# File 'lib/offsite_payments/integrations/bit_pay.rb', line 124
def status
case params['status']
when 'complete'
'Completed'
when 'confirmed'
'Pending'
when 'invalid'
'Failed'
end
end
|
#transaction_id ⇒ Object
116
117
118
|
# File 'lib/offsite_payments/integrations/bit_pay.rb', line 116
def transaction_id
params['id']
end
|