class OffsitePayments::Integrations::Coinbase::Notification
def acknowledge(authcode = {})
apc arrives. Coinbase will verify that all the information we received are correct
Acknowledge the transaction to Coinbase. This method has to be called after a new
def acknowledge(authcode = {}) uri = URI.parse(Coinbase.notification_confirmation_url % transaction_id) response = Coinbase.do_request(uri, @options[:credential1], @options[:credential2]) return false if response.nil? posted_order = @params parse(response) return false unless @params %w(id custom total_native status).all? { |param| posted_order[param] == @params[param] } end
def complete?
def complete? status == "Completed" end
def currency
def currency params['total_native']['currency_iso'] end
def gross
def gross if params['total_original'].present? "%.2f" % (params['total_original']['cents'].to_f / 100) else "%.2f" % (params['total_native']['cents'].to_f / 100) end end
def item_id
def item_id params['custom'] end
def parse(post)
def parse(post) @raw = post.to_s @params = JSON.parse(post)['order'] rescue JSON::ParserError @params = {} end
def received_at
def received_at Time.iso8601(params['created_at']).to_time.to_i end
def status
def status case params['status'] when "completed" "Completed" else "Failed" end end
def transaction_id
def transaction_id params['id'] end