-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add Update Billing Address service function (#611)
- Loading branch information
1 parent
ff7cbca
commit c5b388b
Showing
5 changed files
with
222 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
.../views/cassetes/test_account_viewset/AccountViewSetTests/test_update_billing_address.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
interactions: | ||
- request: | ||
body: null | ||
headers: | ||
Accept: | ||
- '*/*' | ||
Accept-Encoding: | ||
- gzip, deflate | ||
Connection: | ||
- keep-alive | ||
Stripe-Version: | ||
- '2024-04-10' | ||
User-Agent: | ||
- Stripe/v1 PythonBindings/9.6.0 | ||
X-Stripe-Client-User-Agent: | ||
- '{"bindings_version": "9.6.0", "lang": "python", "publisher": "stripe", "httplib": | ||
"requests", "lang_version": "3.12.3", "platform": "Linux-6.6.31-linuxkit-aarch64-with-glibc2.36", | ||
"uname": "Linux b0efe3849169 6.6.31-linuxkit #1 SMP Thu May 23 08:36:57 UTC | ||
2024 aarch64 "}' | ||
method: GET | ||
uri: https://api.stripe.com/v1/subscriptions/djfos?expand%5B0%5D=latest_invoice&expand%5B1%5D=customer&expand%5B2%5D=customer.invoice_settings.default_payment_method | ||
response: | ||
body: | ||
string: "{\n \"error\": {\n \"code\": \"resource_missing\",\n \"doc_url\": | ||
\"https://stripe.com/docs/error-codes/resource-missing\",\n \"message\": | ||
\"No such subscription: 'djfos'\",\n \"param\": \"id\",\n \"request_log_url\": | ||
\"https://dashboard.stripe.com/test/logs/req_4POjCjRMnbE5Wg?t=1718056644\",\n | ||
\ \"type\": \"invalid_request_error\"\n }\n}\n" | ||
headers: | ||
Access-Control-Allow-Credentials: | ||
- 'true' | ||
Access-Control-Allow-Methods: | ||
- GET,HEAD,PUT,PATCH,POST,DELETE | ||
Access-Control-Allow-Origin: | ||
- '*' | ||
Access-Control-Expose-Headers: | ||
- Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required, | ||
X-Stripe-Privileged-Session-Required | ||
Access-Control-Max-Age: | ||
- '300' | ||
Cache-Control: | ||
- no-cache, no-store | ||
Connection: | ||
- keep-alive | ||
Content-Length: | ||
- '324' | ||
Content-Security-Policy: | ||
- report-uri https://q.stripe.com/csp-report?p=v1%2Fsubscriptions%2F%3Asubscription_exposed_id; | ||
block-all-mixed-content; default-src 'none'; base-uri 'none'; form-action | ||
'none'; frame-ancestors 'none'; img-src 'self'; script-src 'self' 'report-sample'; | ||
style-src 'self' | ||
Content-Type: | ||
- application/json | ||
Cross-Origin-Opener-Policy-Report-Only: | ||
- same-origin; report-to="coop" | ||
Date: | ||
- Mon, 10 Jun 2024 21:57:24 GMT | ||
Report-To: | ||
- '{"group":"coop","max_age":8640,"endpoints":[{"url":"https://q.stripe.com/coop-report?s=billing-api-srv"}],"include_subdomains":true}' | ||
Reporting-Endpoints: | ||
- coop="https://q.stripe.com/coop-report?s=billing-api-srv" | ||
Request-Id: | ||
- req_4POjCjRMnbE5Wg | ||
Server: | ||
- nginx | ||
Strict-Transport-Security: | ||
- max-age=63072000; includeSubDomains; preload | ||
Stripe-Version: | ||
- '2024-04-10' | ||
Vary: | ||
- Origin | ||
X-Content-Type-Options: | ||
- nosniff | ||
X-Stripe-Routing-Context-Priority-Tier: | ||
- api-testmode | ||
status: | ||
code: 404 | ||
message: Not Found | ||
version: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1140,6 +1140,50 @@ def test_update_email_address(self, modify_customer_mock): | |
self.stripe.update_email_address(owner, "[email protected]") | ||
modify_customer_mock.assert_called_once_with(customer_id, email=email) | ||
|
||
def test_update_billing_address_with_invalid_email(self): | ||
owner = OwnerFactory(stripe_subscription_id=None) | ||
assert self.stripe.update_billing_address(owner, "gabagool") == None | ||
|
||
def test_update_billing_address_when_no_subscription(self): | ||
owner = OwnerFactory(stripe_subscription_id=None) | ||
assert ( | ||
self.stripe.update_billing_address( | ||
owner, | ||
billing_address={ | ||
"line_1": "45 Fremont St.", | ||
"line_2": "", | ||
"city": "San Francisco", | ||
"state": "CA", | ||
"country": "US", | ||
"postal_code": "94105", | ||
}, | ||
) | ||
== None | ||
) | ||
|
||
@patch("services.billing.stripe.Customer.modify") | ||
def test_update_billing_address(self, modify_customer_mock): | ||
subscription_id = "sub_abc" | ||
customer_id = "cus_abc" | ||
owner = OwnerFactory( | ||
stripe_subscription_id=subscription_id, stripe_customer_id=customer_id | ||
) | ||
billing_address = { | ||
"line_1": "45 Fremont St.", | ||
"line_2": "", | ||
"city": "San Francisco", | ||
"state": "CA", | ||
"country": "US", | ||
"postal_code": "94105", | ||
} | ||
self.stripe.update_billing_address( | ||
owner, | ||
billing_address=billing_address, | ||
) | ||
modify_customer_mock.assert_called_once_with( | ||
customer_id, address=billing_address | ||
) | ||
|
||
@patch("services.billing.stripe.Invoice.retrieve") | ||
def test_get_invoice_not_found(self, retrieve_invoice_mock): | ||
invoice_id = "abc" | ||
|