zulip/corporate
Mateusz Mandera 834dbd552b remote_billing: Make handle_customer_migration_... more robust.
The logic in the case where there's only one realm and the function
tries to migrate the server's plan to it, had two main unhandled edge
cases that would throw exceptions:
1.
```
        remote_realm = RemoteRealm.objects.get(
            uuid=realm_uuids[0], plan_type=RemoteRealm.PLAN_TYPE_SELF_MANAGED
        )
```

This could throw an exception if the RemoteRealm exists, but has an
active e.g. Legacy plan. Then there'd be no object matching the
plan_type in the query, raising RemoteRealm.DoesNotExist.

2. If the RemoteRealm had e.g. a Legacy plan in the past, that's now
   expired, then it'd have a Customer object. Meaning that the attempt
   to move the server's customer to the realm:
   `server_plan.customer = remote_realm_customer`
   would trigger an IntegrityError since a RemoteRealm can't have two
   Customer objects.

In simple cases the situation in (2) can still be easily migrated, by
moving the plan from the server's customer to the realm's customer.
2024-02-20 16:02:03 -08:00
..
lib stripe: Add a check to create invoices only for paid plans. 2024-02-20 08:25:49 -08:00
management billing: Do subscription management in-house instead of with Stripe Billing. 2018-12-22 13:39:30 -08:00
migrations support: Add support to configure fixed-price plan with pay-by-invoice. 2024-02-06 18:43:23 -08:00
tests remote_billing: Make handle_customer_migration_... more robust. 2024-02-20 16:02:03 -08:00
views remote_billing: Make handle_customer_migration_... more robust. 2024-02-20 16:02:03 -08:00
__init__.py
models.py billing: Rename self-managed to free. 2024-02-12 21:25:19 -08:00
urls.py stripe: Add billing portal for customer name and address. 2024-02-13 14:18:38 -08:00