Skip to content

Commit f39b036

Browse files
fix(payment-setups): use payment_method_name for confirm endpoint path param (#235)
The confirm_payment_setup path param was named payment_method_option_id, which is not a valid API concept. The real path is /payments/setups/{id}/confirm/{payment_method_name}, so the param and its usage in URL building are renamed accordingly. Also aligns the (currently skipped) integration test's expected confirm response fields with the full PaymentSetup schema, which is what the confirm endpoint actually returns.
1 parent 187fb57 commit f39b036

3 files changed

Lines changed: 14 additions & 9 deletions

File tree

checkout_sdk/payments/setups/setups_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ def get_payment_setup(self, setup_id: str):
4646
self._sdk_authorization()
4747
)
4848

49-
def confirm_payment_setup(self, setup_id: str, payment_method_option_id: str):
49+
def confirm_payment_setup(self, setup_id: str, payment_method_name: str):
5050
"""
5151
Confirms a Payment Setup
5252
"""
5353
return self._api_client.post(
5454
self.build_path(self.__PAYMENTS_PATH, self.__SETUPS_PATH, setup_id,
55-
self.__CONFIRM_PATH, payment_method_option_id),
55+
self.__CONFIRM_PATH, payment_method_name),
5656
self._sdk_authorization()
5757
)

tests/payments/setups/payment_setups_client_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ def test_should_get_payment_setup(self, mocker, client: PaymentSetupsClient):
3535
def test_should_confirm_payment_setup(self, mocker, client: PaymentSetupsClient):
3636
mock = mocker.patch('checkout_sdk.api_client.ApiClient.post', return_value='response')
3737

38-
assert client.confirm_payment_setup('setup_id', 'payment_method_option_id') == 'response'
39-
assert_api_call(mock, 'payments/setups/setup_id/confirm/payment_method_option_id')
38+
assert client.confirm_payment_setup('setup_id', 'card') == 'response'
39+
assert_api_call(mock, 'payments/setups/setup_id/confirm/card')

tests/payments/setups/payment_setups_integration_test.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,28 +137,33 @@ def test_should_create_payment_setup_with_additional_payment_methods(default_api
137137
assert response.currency == request.currency
138138

139139

140-
@pytest.mark.skip(reason="Integration test - requires valid payment method option")
140+
@pytest.mark.skip(reason="Integration test - requires a payment setup ready to be confirmed")
141141
def test_should_confirm_payment_setup(default_api):
142142
"""Test confirming a payment setup"""
143143
# Arrange
144144
create_request = create_payment_setups_request()
145145
create_response = default_api.setups.create_payment_setup(create_request)
146146

147-
payment_method_option_id = "opt_test_12345"
147+
payment_method_name = "klarna"
148148

149149
# Act
150150
response = default_api.setups.confirm_payment_setup(
151151
create_response.id,
152-
payment_method_option_id
152+
payment_method_name
153153
)
154154

155155
# Assert
156+
# The confirm endpoint's response is the full PaymentSetup schema
157+
# (same shape as create/update/get), not a slimmer payments-style response.
156158
assert_response(response,
159+
'http_metadata',
157160
'id',
158-
'action_id',
161+
'processing_channel_id',
159162
'amount',
160163
'currency',
161-
'processed_on')
164+
'payment_type',
165+
'reference',
166+
'description')
162167

163168
assert response.amount == create_request.amount
164169
assert response.currency == create_request.currency

0 commit comments

Comments
 (0)