@@ -24,26 +24,26 @@ def test_billing_fund_wallet(mock_request, mock_get_payment_info, prod_client):
24
24
25
25
@patch (
26
26
"easypost.services.billing_service.BillingService.retrieve_payment_methods" ,
27
- return_value = {"primary_payment_method" : {"id" : "card_123 " }},
27
+ return_value = {"primary_payment_method" : {"id" : "pm_123" , "object" : "CreditCard " }},
28
28
)
29
29
@patch ("easypost.services.billing_service.Requestor.request" , return_value = {"mock" : "response" })
30
30
def test_billing_payment_method_delete_credit_card (mock_request , mock_payment_methods , prod_client ):
31
31
"""Tests we make a valid call to delete a credit card."""
32
32
prod_client .billing .delete_payment_method (priority = "primary" )
33
33
34
- mock_request .assert_called_once_with (method = easypost .requestor .RequestMethod .DELETE , url = "/credit_cards/card_123 " )
34
+ mock_request .assert_called_once_with (method = easypost .requestor .RequestMethod .DELETE , url = "/credit_cards/pm_123 " )
35
35
36
36
37
37
@patch (
38
38
"easypost.services.billing_service.BillingService.retrieve_payment_methods" ,
39
- return_value = {"primary_payment_method" : {"id" : "bank_123 " }},
39
+ return_value = {"primary_payment_method" : {"id" : "pm_123" , "object" : "BankAccount " }},
40
40
)
41
41
@patch ("easypost.services.billing_service.Requestor.request" , return_value = {"mock" : "response" })
42
42
def test_billing_payment_method_delete_bank_account (mock_request , mock_payment_methods , prod_client ):
43
43
"""Tests we make a valid call to delete a bank account."""
44
44
prod_client .billing .delete_payment_method (priority = "primary" )
45
45
46
- mock_request .assert_called_once_with (method = easypost .requestor .RequestMethod .DELETE , url = "/bank_accounts/bank_123 " )
46
+ mock_request .assert_called_once_with (method = easypost .requestor .RequestMethod .DELETE , url = "/bank_accounts/pm_123 " )
47
47
48
48
49
49
@patch (
@@ -85,3 +85,23 @@ def test_billing_retrieve_payment_methods_no_billing_setup(mock_request, prod_cl
85
85
86
86
mock_request .assert_called_once ()
87
87
assert str (error .value ) == "Billing has not been setup for this user. Please add a payment method."
88
+
89
+
90
+ @patch (
91
+ "easypost.services.billing_service.BillingService.retrieve_payment_methods" ,
92
+ return_value = {
93
+ "primary_payment_method" : {"id" : "pm_123" , "object" : "CreditCard" },
94
+ "secondary_payment_method" : {"id" : "pm_456" , "object" : "BankAccount" },
95
+ },
96
+ )
97
+ def test_billing__get_payment_method_info_by_object_type (mock_request , prod_client ):
98
+ """Tests we can determine the payment method type/endpoint by object type."""
99
+ endpoint , payment_method_id = prod_client .billing ._get_payment_method_info (priority = "primary" )
100
+
101
+ assert endpoint == "/credit_cards"
102
+ assert payment_method_id == "pm_123"
103
+
104
+ endpoint , payment_method_id = prod_client .billing ._get_payment_method_info (priority = "secondary" )
105
+
106
+ assert endpoint == "/bank_accounts"
107
+ assert payment_method_id == "pm_456"
0 commit comments