Skip to content

Instantly share code, notes, and snippets.

@adamjstevenson
Last active December 15, 2017 13:00
Show Gist options
  • Save adamjstevenson/bb635b0baca70a405f5a96e267ef2d29 to your computer and use it in GitHub Desktop.
Save adamjstevenson/bb635b0baca70a405f5a96e267ef2d29 to your computer and use it in GitHub Desktop.
Advanced decline report
require 'stripe'
Stripe.api_key = "YOUR-API-KEY"
declines = Stripe::Charge.list(paid: false, limit: 100)
declines.auto_paging_each do |decline|
# Format the timestamp
formatted_date = Time.at(decline.created)
# Output the date, card id, brand, last 4, and decline message
puts "#{formatted_date},#{decline.id},#{decline.source.id},#{decline.source.brand},#{decline.source.last4},#{decline.failure_message}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment