# collab: Require billing address in all Stripe checkouts \(\#32980\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/13f134448de4b309ec8265b05b1190f7995db328)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 13f134448de4b309ec8265b05b1190f7995db328

Requested commit: 13f134448de4b309ec8265b05b1190f7995db328

Commit: 13f134448de4b309ec8265b05b1190f7995db328

Tree: 3bd2fb8ce4928555fa7ba695eab373d3dd326d4d

Author: morgankrey

Committer: GitHub

## Message

```
collab: Require billing address in all Stripe checkouts (#32980)

Summary

I've successfully implemented the required billing address collection
feature for Stripe Checkout sessions. Here's what was done:

### 1. **Added New Data Structures** (`stripe_client.rs`):
- Added `StripeBillingAddressCollection` enum with `Auto` and `Required`
variants
- Added `billing_address_collection` field to
`StripeCreateCheckoutSessionParams`

### 2. **Updated Stripe Client Implementation**
(`real_stripe_client.rs`):
- Added conversion from `StripeBillingAddressCollection` to Stripe's
`CheckoutSessionBillingAddressCollection`
- Updated the `TryFrom` implementation to map the billing address
collection field when creating checkout sessions
- Added the necessary import

### 3. **Updated Billing Service** (`stripe_billing.rs`):
- Set `billing_address_collection` to `Required` in both
`checkout_with_zed_pro()` and `checkout_with_zed_pro_trial()` methods
- Added the necessary import

### 4. **Updated Test Infrastructure** (`fake_stripe_client.rs`):
- Added `billing_address_collection` field to
`StripeCreateCheckoutSessionCall`
- Updated the `create_checkout_session` implementation to capture the
new field
- Added the necessary import

### 5. **Updated Tests** (`stripe_billing_tests.rs`):
- Added assertions to verify that `billing_address_collection` is set to
`Required` in all three test cases:
  - `test_checkout_with_zed_pro`
  - `test_checkout_with_zed_pro_trial` (regular trial)
  - `test_checkout_with_zed_pro_trial` (extended trial)
- Added the necessary import

The implementation follows the pattern established in the codebase and
ensures that whenever a Stripe Checkout session is created for Zed Pro
subscriptions (both regular and trial), the billing address will be
required from customers. This aligns with the Stripe documentation you
provided, which shows that setting `billing_address_collection=required`
will ensure the billing address is always collected during checkout.

Release Notes:

- N/A

Co-authored-by: Marshall Bowers <git@maxdeviant.com>
```

## Parents

- [94735aef69cb94426df578326198980633b36927](https://git.cafe/gitcafe/zed/commit/94735aef69cb94426df578326198980633b36927?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/13f134448de4b309ec8265b05b1190f7995db328?format=markdown)
