#NEWLINE# def credit( order_number , pnref = None , amt = None ) : #NEWLINE# #INDENT# '\n    Return funds that have been previously settled.\n\n    :order_number: Order number\n    :pnref: The PNREF of the authorization transaction to use.  If not\n            specified, the order number is used to retrieve the appropriate transaction.\n    :amt: A custom amount to capture.  If not specified, the entire transaction\n          is refuneded.\n    ' #NEWLINE# if ( pnref is None ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# auth_txn = models . PayflowTransaction . objects . get ( comment1 = order_number , trxtype__in = ( codes . AUTHORIZATION , codes . SALE ) ) #NEWLINE# #UNINDENT# except models . PayflowTransaction . DoesNotExist : #NEWLINE# #INDENT# raise exceptions . UnableToTakePayment ( ( 'No authorization transaction found with PNREF=%s' % pnref ) ) #NEWLINE# #UNINDENT# pnref = auth_txn #NEWLINE# #UNINDENT# txn = gateway . credit ( order_number , auth_txn , amt ) #NEWLINE# if ( not txn . is_approved ) : #NEWLINE# #INDENT# raise exceptions . PaymentError ( txn . respmsg ) #NEWLINE# #UNINDENT# return txn