#NEWLINE# def create_one_time_invoice( self , charges ) : #NEWLINE# #INDENT# "\n        Charges should be a list of charges to execute immediately.  Each\n        value in the charges diectionary should be a dictionary with the \n        following keys:\n\n        code\n            Your code for this charge.  This code will be displayed in the \n            user's invoice and is limited to 36 characters.\n        quantity\n            A positive integer quantity.  If not provided this value will \n            default to 1.\n        each_amount\n            Positive or negative integer or decimal with two digit precision.\n            A positive number will create a charge (debit). A negative number\n            will create a credit.\n        description\n            An optional description for this charge which will be displayed on\n            the user's invoice.\n        " #NEWLINE# data = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for ( n , charge ) in enumerate ( charges ) : #NEWLINE# #INDENT# each_amount = Decimal ( charge [ 'each_amount' ] ) #NEWLINE# each_amount = each_amount . quantize ( Decimal ( '.01' ) ) #NEWLINE# data [ ( 'charges[%d][chargeCode]' % n ) ] = charges [ 'code' ] #NEWLINE# data [ ( 'charges[%d][quantity]' % n ) ] = charge . get ( 'quantity' , 1 ) #NEWLINE# data [ ( 'charges[%d][eachAmount]' % n ) ] = ( '%.2f' % each_amount ) #NEWLINE# if ( 'description' in charge . keys ( ) ) : #NEWLINE# #INDENT# data [ ( 'charges[%d][description]' % n ) ] = charge [ 'description' ] #NEWLINE# #UNINDENT# #UNINDENT# response = self . product . client . make_request ( path = 'invoices/new' , params = { #NEWLINE# #INDENT# 'code' : self . code , #NEWLINE# #UNINDENT# } , data = data ) #NEWLINE# return self . load_data_from_xml ( response . content )