Skip to content

Instantly share code, notes, and snippets.

@saikat
Created September 6, 2012 01:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saikat/3649545 to your computer and use it in GitHub Desktop.
Save saikat/3649545 to your computer and use it in GitHub Desktop.
found_previously_successful_charge = false
Card.load_all({:number => card.number, :merchant => card.merchant}, {:limit => 10, :sort => [[:created, :desc]]}) do |c|
Charge.load_all({:merchant => card.merchant, :livemode => card.livemode, :authorized => true, :card => card.token}, {:limit => 2}) do |ch|
if ch.token != charge.token
found_previously_successful_charge = true
break
end
end
if found_previously_successful_charge
Track.increment("charges.#{operation}.#{status}.card.previously_successful.last_10")
break
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment