Created
July 18, 2014 16:46
-
-
Save Austio/2bba43af6e49578883ae 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
def self.create_subscription(recurrance, recurly_token, paysysid) | |
response = Recurly::Subscription.create! plan_code: "premium-#{recurrance}", | |
account: { | |
account_code: paysysid, | |
billing_info: { token_id: recurly_token } | |
} | |
if response.is_a? Recurly::Subscription | |
return paysysid if response.state == "active" | |
end | |
#activated_at, state, valid | |
return "Error Processing: #{response.try(:errors).try(:first)}" | |
rescue Recurly::Resource::Invalid, Recurly::API::ResponseError => e | |
return "Error Processing: #{e.try(:message)}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment