Sha256: 9cf5634ea769d2b9c6b95b305d522e251fc1eb4f195001b214cb7066965a4622
Contents?: true
Size: 1.05 KB
Versions: 1
Compression:
Stored size: 1.05 KB
Contents
class Exchequer::Biller def initialize(card, options = {}) @card = card @options = options end def charge map_errors_from(customer) and return false if customer.id.nil? map_errors_from(subscription) and return false if !subscription.save true end def subscription_id subscription.id end private attr_reader :card, :options def customer @customer ||= begin Chargify::Customer.find_by_reference(options[:reference]) rescue ActiveResource::ResourceNotFound Chargify::Customer.create( :first_name => card.first_name, :last_name => card.last_name, :email => options[:email], :reference => options[:reference] ) end end def map_errors_from(object) Exchequer::ErrorMapper.map object, :to => card end def subscription @subscription ||= Chargify::Subscription.new( :customer_id => customer.id, :product_handle => options[:product_handle], :credit_card_attributes => card.to_hash ) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
exchequer-0.1.0 | lib/exchequer/biller.rb |