Created
May 14, 2014 12:46
-
-
Save braidn/45ab919448766c9d48c5 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
module Quarterly | |
class CancelSubscriptionOrder | |
def subscription_canceled(sub, plan, user) | |
return unless sub.order | |
cancel_shipment(sub) | |
remove_line_item(sub) | |
cancel_order(sub) | |
cancel_payment_state(sub) | |
end | |
private | |
def cancel_shipment(sub) | |
sub.order.update_attribute(:shipment_state, nil) | |
end | |
def remove_line_item(sub) | |
sub.order.line_item.delete | |
end | |
def cancel_order(sub) | |
sub.order.cancel! | |
end | |
def cancel_payment_state(sub) | |
sub.order.update_attribute(:payment_state, 'canceled') | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment