Skip to content

Instantly share code, notes, and snippets.

@braidn
Created May 14, 2014 12:46
Show Gist options
  • Save braidn/45ab919448766c9d48c5 to your computer and use it in GitHub Desktop.
Save braidn/45ab919448766c9d48c5 to your computer and use it in GitHub Desktop.
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