class OffsitePayments::Integrations::BitPay::Notification

def acknowledge(authcode = nil)

def acknowledge(authcode = nil)
  uri = URI.parse("#{OffsitePayments::Integrations::BitPay.invoicing_url(@options[:credential1])}/#{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

def complete?

def complete?
  status == "Completed"
end

def currency

def currency
  params['currency']
end

def gross

def gross
  params['price'].to_f
end

def item_id

def item_id
  JSON.parse(params['posData'])['orderId']
end

def parse(body)

def parse(body)
  @raw = body
  @params = JSON.parse(@raw)
end

def received_at

When was this payment received by the client.
def received_at
  params['invoiceTime'].to_i
end

def status

def status
  case params['status']
  when 'complete'
    'Completed'
  when 'confirmed'
    'Pending'
  when 'invalid'
    'Failed'
  end
end

def transaction_id

def transaction_id
  params['id']
end