def _record_purchase(params, order):
 ccnum_str = params.get('req_card_number', '')
 first_digit = re.search('\\d', ccnum_str)
 if first_digit:
  ccnum = ccnum_str[first_digit.start():]
 else:
  ccnum = '####'
 if settings.FEATURES.get('LOG_POSTPAY_CALLBACKS'):
  log.info('Order %d purchased with params: %s', order.id, json.dumps(params))
 order.purchase(first=params.get('req_bill_to_forename', ''), last=params.get('req_bill_to_surname', ''), street1=params.get('req_bill_to_address_line1', ''), street2=params.get('req_bill_to_address_line2', ''), city=params.get('req_bill_to_address_city', ''), state=params.get('req_bill_to_address_state', ''), country=params.get('req_bill_to_address_country', ''), postalcode=params.get('req_bill_to_address_postal_code', ''), ccnum=ccnum, cardtype=CARDTYPE_MAP[params.get('req_card_type', '')], processor_reply_dump=json.dumps(params))

def _record_purchase ( params , order ) : ccnum_str = params . get ( 'req_card_number' , '' ) first_digit = re . search ( '\\d' , ccnum_str ) if first_digit : ccnum = ccnum_str [ first_digit . start ( ) : ] else : ccnum = '####' if settings . FEATURES . get ( 'LOG_POSTPAY_CALLBACKS' ) : log . info ( 'Order %d purchased with params: %s' , order . id , json . dumps ( params ) ) order . purchase ( first = params . get ( 'req_bill_to_forename' , '' ) , last = params . get ( 'req_bill_to_surname' , '' ) , street1 = params . get ( 'req_bill_to_address_line1' , '' ) , street2 = params . get ( 'req_bill_to_address_line2' , '' ) , city = params . get ( 'req_bill_to_address_city' , '' ) , state = params . get ( 'req_bill_to_address_state' , '' ) , country = params . get ( 'req_bill_to_address_country' , '' ) , postalcode = params . get ( 'req_bill_to_address_postal_code' , '' ) , ccnum = ccnum , cardtype = CARDTYPE_MAP [ params . get ( 'req_card_type' , '' ) ] , processor_reply_dump = json . dumps ( params ) )
record the purchase and run purchased_callbacks args: params : the parameters we received from cybersource .