Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Address Glue Updates for modifying default payment method #621

Merged
merged 1 commit into from
Jun 18, 2024

Conversation

ajay-sentry
Copy link
Contributor

@ajay-sentry ajay-sentry commented Jun 18, 2024

Purpose/Motivation

This updates the existing update_billing_address function to actually update the stripe default payment method billing details, as well as the customer billing address.

Stemmed from doing some local testing with the new address component where i saw the default_payment_method billing details address wasn't being updated when we were updating the users address. Now we update both the customer as well as the payment method address with this set of changes.

Notes to Reviewer

Most of the review is UT updates, but for the stripe stuff we are doing three things:

  • Retrieve the stripe customer details, and pull off the default payment method from that detail
  • modify the default payment method address fields with the address fields being passed in
  • update the customer object's address itself with the address fields being passed in.
    • I believe this last piece will cover us when the user wants to add or remove a payment method in the dashboard with support for example
Screen.Recording.2024-06-17.at.5.14.11.PM.mov

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. In 2022 this entity acquired Codecov and as result Sentry is going to need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

@codecov-qa
Copy link

codecov-qa bot commented Jun 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.48%. Comparing base (128e122) to head (2160484).

✅ All tests successful. No failed tests found.

@@           Coverage Diff           @@
##             main     #621   +/-   ##
=======================================
  Coverage   91.48%   91.48%           
=======================================
  Files         615      615           
  Lines       16418    16424    +6     
=======================================
+ Hits        15020    15026    +6     
  Misses       1398     1398           
Flag Coverage Δ
unit 91.48% <100.00%> (+<0.01%) ⬆️
unit-latest-uploader 91.48% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
api/internal/owner/views.py 99.05% <100.00%> (+<0.01%) ⬆️
services/billing.py 92.44% <100.00%> (+0.13%) ⬆️

📣 Codecov offers a browser extension for seamless coverage viewing on GitHub. Try it in Chrome or Firefox today!

@codecov-notifications
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.48%. Comparing base (128e122) to head (2160484).

✅ All tests successful. No failed tests found ☺️

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #621   +/-   ##
=======================================
  Coverage   91.48%   91.48%           
=======================================
  Files         615      615           
  Lines       16418    16424    +6     
=======================================
+ Hits        15020    15026    +6     
  Misses       1398     1398           
Flag Coverage Δ
unit 91.48% <100.00%> (+<0.01%) ⬆️
unit-latest-uploader 91.48% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
api/internal/owner/views.py 99.05% <100.00%> (+<0.01%) ⬆️
services/billing.py 92.44% <100.00%> (+0.13%) ⬆️

Impacted file tree graph

Copy link

codecov bot commented Jun 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.92%. Comparing base (128e122) to head (2160484).

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff             @@
##               main       #621   +/-   ##
===========================================
  Coverage   95.92000   95.92000           
===========================================
  Files           793        793           
  Lines         17735      17741    +6     
===========================================
+ Hits          17012      17018    +6     
  Misses          723        723           
Flag Coverage Δ
unit 91.48% <100.00%> (+<0.01%) ⬆️
unit-latest-uploader 91.48% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -113,8 +113,18 @@ def update_billing_address(self, request, *args, **kwargs):
if not billing_address:
raise ValidationError(detail="No billing_address sent")
owner = self.get_object()

formatted_address = {
"line1": billing_address["line_1"],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are line1/2 camel? Shouldn't it be snake?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah yeah this is what I was mentioning on the applications channel; stripe considers line1 and line2 to be the correct key format instead of line_1 and line_2, which is different than our snakeify method. This seemed to be the most painless way to isolate that "rewrapping"

f"Stripe successfully updated billing address for owner {owner.ownerid} by user #{self.requesting_user.ownerid}"
)

try:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic makes sense, but I find it weird we were originally doing it w/ subscription an not customer_id; can you think why that was the case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was on me and my lack of understanding of where the address / billing details lay among the stripe objects. After actually doing the testing locally and gaining more context on what exactly we are changing and where made me realize this update had nothing to do with the stripe subscription and everything to do with the customer.

Namely, you can have a default payment method even without having a subscription, since that's tied to the customer through payment methods ultimately.

@ajay-sentry ajay-sentry added this pull request to the merge queue Jun 18, 2024
Merged via the queue into main with commit 6efefaf Jun 18, 2024
21 of 22 checks passed
@ajay-sentry ajay-sentry deleted the Ajay/address-testing-updates branch June 18, 2024 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants