#NEWLINE# def test_update_from_transparent_redirect_and_update_existing_billing_address( self ) : #NEWLINE# #INDENT# customer = Customer . create ( { #NEWLINE# #INDENT# 'credit_card' : { #NEWLINE# #INDENT# 'number' : '4111111111111111' , #NEWLINE# 'expiration_date' : '05/2012' , #NEWLINE# 'billing_address' : { #NEWLINE# #INDENT# 'street_address' : '123 Old St' , #NEWLINE# 'locality' : 'Chicago' , #NEWLINE# 'region' : 'Illinois' , #NEWLINE# 'postal_code' : '60621' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ) . customer #NEWLINE# card = customer . credit_cards [ 0 ] #NEWLINE# tr_data = { #NEWLINE# #INDENT# 'payment_method_token' : card . token , #NEWLINE# 'credit_card' : { #NEWLINE# #INDENT# 'billing_address' : { #NEWLINE# #INDENT# 'street_address' : '123 New St' , #NEWLINE# 'locality' : 'Columbus' , #NEWLINE# 'region' : 'Ohio' , #NEWLINE# 'postal_code' : '43215' , #NEWLINE# 'options' : { #NEWLINE# #INDENT# 'update_existing' : True , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# post_params = { #NEWLINE# #INDENT# 'tr_data' : CreditCard . tr_data_for_update ( self , 'http://example.com/path' ) , #NEWLINE# #UNINDENT# } #NEWLINE# query_string = TestHelper . simulate_tr_form_post ( post_params , CreditCard . transparent_redirect_update_url ( ) ) #NEWLINE# result = CreditCard . confirm_transparent_redirect ( query_string ) #NEWLINE# self . assertEquals ( 1 , len ( Customer . find ( customer . id ) . addresses ) ) #NEWLINE# updated_card = CreditCard . find ( card . token ) #NEWLINE# self . assertEquals ( '123 New St' , updated_card . billing_address . street_address ) #NEWLINE# self . assertEquals ( 'Columbus' , updated_card . billing_address . locality ) #NEWLINE# self . assertEquals ( 'Ohio' , updated_card . billing_address . region ) #NEWLINE# self . assertEquals ( '43215' , updated_card . billing_address . postal_code )