#NEWLINE# def purchase( self , money , credit_card , options = None ) : #NEWLINE# #INDENT# 'Create a plan that bills every decade or so \n        and charge the plan immediately' #NEWLINE# options = ( options or { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# resp = self . store ( credit_card , options = options ) #NEWLINE# subscription_id = resp [ 'response' ] [ 'subscription' ] [ 'id' ] #NEWLINE# resp = self . _chargebee_request ( 'post' , '/invoices/charge' , data = { #NEWLINE# #INDENT# 'subscription_id' : money , #NEWLINE# 'amount' : money , #NEWLINE# 'description' : options . get ( 'description' ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# if ( 200 <= resp . status_code < 300 ) : #NEWLINE# #INDENT# transaction_was_successful . send ( sender = self , type = 'purchase' , response = resp . json ( ) ) #NEWLINE# return { #NEWLINE# #INDENT# 'status' : 'SUCCESS' , #NEWLINE# 'response' : resp . json ( ) , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# transaction_was_unsuccessful . send ( sender = self , type = 'purchase' , response = resp . json ( ) ) #NEWLINE# return { #NEWLINE# #INDENT# 'status' : 'FAILURE' , #NEWLINE# 'response' : resp . json ( ) , #NEWLINE# #UNINDENT# }