Created
March 28, 2010 04:25
-
-
Save ecordell/346566 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Subscription < Base | |
def self.find_by_customer_reference(reference) | |
customer = Customer.find_by_reference(reference) | |
find(:first, :params => {:customer_id => customer.id}) | |
end | |
# Strip off nested attributes of associations before saving, or type-mismatch errors will occur | |
def save | |
self.attributes.delete('customer') | |
self.attributes.delete('product') | |
self.attributes.delete('credit_card') | |
super | |
end | |
def cancel | |
destroy | |
end | |
# Perform a one-time charge on an existing subscription. | |
# For more information, please see the one-time charge API docs available | |
# at: http://support.chargify.com/faqs/api/api-charges | |
def charge(attrs = {}) | |
post :charges, :charge => attrs | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment