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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
# File 'lib/offsite_payments/integrations/bit_pay.rb', line 119
def acknowledge(authcode = nil)
uri = URI.parse("#{OffsitePayments::Integrations::BitPay.invoicing_url}/#{transaction_id}")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri.path)
request.basic_auth @options[:credential1], ''
response = http.request(request)
posted_json = JSON.parse(@raw).tap { |j| j.delete('currentTime') }
parse(response.body)
retrieved_json = JSON.parse(@raw).tap { |j| j.delete('currentTime') }
posted_json == retrieved_json
rescue JSON::ParserError
end
|
#complete? ⇒ Boolean
82
83
84
|
# File 'lib/offsite_payments/integrations/bit_pay.rb', line 82
def complete?
status == "Completed"
end
|
#currency ⇒ Object
111
112
113
|
# File 'lib/offsite_payments/integrations/bit_pay.rb', line 111
def currency
params['currency']
end
|
#gross ⇒ Object
115
116
117
|
# File 'lib/offsite_payments/integrations/bit_pay.rb', line 115
def gross
params['price'].to_f
end
|
#item_id ⇒ Object
90
91
92
93
|
# File 'lib/offsite_payments/integrations/bit_pay.rb', line 90
def item_id
JSON.parse(params['posData'])['orderId']
rescue JSON::ParserError
end
|
#received_at ⇒ Object
When was this payment received by the client.
107
108
109
|
# File 'lib/offsite_payments/integrations/bit_pay.rb', line 107
def received_at
params['invoiceTime'].to_i
end
|
#status ⇒ Object
95
96
97
98
99
100
101
102
103
104
|
# File 'lib/offsite_payments/integrations/bit_pay.rb', line 95
def status
case params['status']
when 'complete'
'Completed'
when 'confirmed'
'Pending'
when 'invalid'
'Failed'
end
end
|
#transaction_id ⇒ Object
86
87
88
|
# File 'lib/offsite_payments/integrations/bit_pay.rb', line 86
def transaction_id
params['id']
end
|