@@ -1150,29 +1150,51 @@ def test_subscription_schedule_updated_logs_changes_to_schedule(
11501150 assert self .owner .plan == original_plan
11511151 assert self .owner .plan_user_count == original_quantity
11521152
1153- def test_checkout_session_completed_sets_stripe_customer_id (self ):
1153+ def test_checkout_session_completed_sets_stripe_ids (self ):
11541154 self .owner .stripe_customer_id = None
11551155 self .owner .save ()
11561156
1157- expected_id = "fhjtwoo40"
1157+ expected_customer_id = "cus_1234"
1158+ expected_subscription_id = "sub_7890"
11581159
11591160 self ._send_event (
11601161 payload = {
11611162 "type" : "checkout.session.completed" ,
11621163 "data" : {
11631164 "object" : {
1164- "customer" : expected_id ,
1165+ "customer" : expected_customer_id ,
11651166 "client_reference_id" : str (self .owner .ownerid ),
1167+ "subscription" : expected_subscription_id ,
11661168 }
11671169 },
11681170 }
11691171 )
11701172
11711173 self .owner .refresh_from_db ()
1172- assert self .owner .stripe_customer_id == expected_id
1174+ assert self .owner .stripe_customer_id == expected_customer_id
1175+ assert self .owner .stripe_subscription_id == expected_subscription_id
11731176
11741177 @patch ("billing.views.stripe.Subscription.modify" )
11751178 def test_customer_update_but_not_payment_method (self , subscription_modify_mock ):
1179+ payment_method = "pm_123"
1180+ self ._send_event (
1181+ payload = {
1182+ "type" : "customer.updated" ,
1183+ "data" : {
1184+ "object" : {
1185+ "invoice_settings" : {"default_payment_method" : None },
1186+ "subscriptions" : {
1187+ "data" : [{"default_payment_method" : payment_method }]
1188+ },
1189+ }
1190+ },
1191+ }
1192+ )
1193+
1194+ subscription_modify_mock .assert_not_called ()
1195+
1196+ @patch ("billing.views.stripe.Subscription.modify" )
1197+ def test_customer_update_but_payment_method_is_same (self , subscription_modify_mock ):
11761198 payment_method = "pm_123"
11771199 self ._send_event (
11781200 payload = {
0 commit comments