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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
# File 'lib/offsite_payments/integrations/bit_pay.rb', line 117
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
end
|
#complete? ⇒ Boolean
81
82
83
|
# File 'lib/offsite_payments/integrations/bit_pay.rb', line 81
def complete?
status == "Completed"
end
|
#currency ⇒ Object
109
110
111
|
# File 'lib/offsite_payments/integrations/bit_pay.rb', line 109
def currency
params['currency']
end
|
#gross ⇒ Object
113
114
115
|
# File 'lib/offsite_payments/integrations/bit_pay.rb', line 113
def gross
params['price'].to_f
end
|
#item_id ⇒ Object
89
90
91
|
# File 'lib/offsite_payments/integrations/bit_pay.rb', line 89
def item_id
JSON.parse(params['posData'])['orderId']
end
|
#received_at ⇒ Object
When was this payment received by the client.
105
106
107
|
# File 'lib/offsite_payments/integrations/bit_pay.rb', line 105
def received_at
params['invoiceTime'].to_i
end
|
#status ⇒ Object
93
94
95
96
97
98
99
100
101
102
|
# File 'lib/offsite_payments/integrations/bit_pay.rb', line 93
def status
case params['status']
when 'complete'
'Completed'
when 'confirmed'
'Pending'
when 'invalid'
'Failed'
end
end
|
#transaction_id ⇒ Object
85
86
87
|
# File 'lib/offsite_payments/integrations/bit_pay.rb', line 85
def transaction_id
params['id']
end
|