@@ -24,26 +24,26 @@ def test_billing_fund_wallet(mock_request, mock_get_payment_info, prod_client):
2424
2525@patch (
2626 "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 " }},
2828)
2929@patch ("easypost.services.billing_service.Requestor.request" , return_value = {"mock" : "response" })
3030def test_billing_payment_method_delete_credit_card (mock_request , mock_payment_methods , prod_client ):
3131 """Tests we make a valid call to delete a credit card."""
3232 prod_client .billing .delete_payment_method (priority = "primary" )
3333
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 " )
3535
3636
3737@patch (
3838 "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 " }},
4040)
4141@patch ("easypost.services.billing_service.Requestor.request" , return_value = {"mock" : "response" })
4242def test_billing_payment_method_delete_bank_account (mock_request , mock_payment_methods , prod_client ):
4343 """Tests we make a valid call to delete a bank account."""
4444 prod_client .billing .delete_payment_method (priority = "primary" )
4545
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 " )
4747
4848
4949@patch (
@@ -85,3 +85,23 @@ def test_billing_retrieve_payment_methods_no_billing_setup(mock_request, prod_cl
8585
8686 mock_request .assert_called_once ()
8787 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