Sha256: 1fa3a6db562d496dbb1838fe52c731226e7b40131f3f39ccc8c2575bb7142b07
Contents?: true
Size: 1.1 KB
Versions: 2
Compression:
Stored size: 1.1 KB
Contents
require 'json' class Spike class Charge def initialize(client) @client = client end def create(params, products) res = @client.post(request_path: "/charges", request_params: params.merge(products: JSON.generate(products))) Spike::Charge::Response.new(res) end class Spike::Charge::Response def initialize(hash) @attributes = Hash[hash.map{|k,v| [k.to_s, v] }] end def id @attributes['id'] end def object @attributes['object'] end def created_at Time.at(@attributes['created']) end def live_mode? @attributes['livemode'] end def paid? @attributes['paid'] end def captured? @attributes['captured'] end def amount @attributes['amount'].to_f end def currency @attributes['currency'] end def refunded? @attributes['refunded'] end def amount_refunded @attributes['amount_refunded'] end def refunds @attributes['refunds'] end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
spike-ruby-0.0.2 | lib/spike/charge.rb |
spike-ruby-0.0.1 | lib/spike/charge.rb |