#NEWLINE# @ app . route ( '/profile/<profile_id>/subscription' , methods = [ 'DELETE' , 'POST' ] ) #NEWLINE# def user_subscription( profile_id ) : #NEWLINE# #INDENT# profile = get_user_for_response ( profile_id , request ) #NEWLINE# abort_if_user_not_logged_in ( profile ) #NEWLINE# if ( request . method == 'DELETE' ) : #NEWLINE# #INDENT# ret = unsubscribe ( profile ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( request . method == 'POST' ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# ret = subscribe ( profile , stripe_token = request . json [ 'token' ] , coupon = request . json [ 'coupon' ] , plan = request . json [ 'plan' ] ) #NEWLINE# #UNINDENT# except ( stripe . InvalidRequestError , stripe . CardError ) as e : #NEWLINE# #INDENT# return abort_json ( 400 , e . message ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return json_resp_from_thing ( { #NEWLINE# #INDENT# 'result' : ret , #NEWLINE# #UNINDENT# } )