Skip to content

Commit b765f10

Browse files
feat(api): add card_authorization.challenge webhook event
1 parent 40d3bf0 commit b765f10

20 files changed

Lines changed: 991 additions & 546 deletions

.stats.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 192
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic/lithic-edd62262c633378b046a4c774cb9a824e2f6bf8f6c0cec613d3fb56e96ba1a29.yml
3-
openapi_spec_hash: e90bfadcd60afbaf9e0c9ebaea4e374e
4-
config_hash: 265a2b679964f4ad5706de101ad2a942
1+
configured_endpoints: 193
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic/lithic-19240135588c2012b39cde86218a05c471b3e7831b57c736704e3fbca109e3a9.yml
3+
openapi_spec_hash: c6a5c719b89e08de52aea005b39fd5a6
4+
config_hash: 1c5c139a2aa0d1d45c063f953a9bc803

api.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,18 @@ Methods:
260260
- <code title="get /v1/cards/{card_token}/financial_transactions/{financial_transaction_token}">client.cards.financial_transactions.<a href="./src/lithic/resources/cards/financial_transactions.py">retrieve</a>(financial_transaction_token, \*, card_token) -> <a href="./src/lithic/types/financial_transaction.py">FinancialTransaction</a></code>
261261
- <code title="get /v1/cards/{card_token}/financial_transactions">client.cards.financial_transactions.<a href="./src/lithic/resources/cards/financial_transactions.py">list</a>(card_token, \*\*<a href="src/lithic/types/cards/financial_transaction_list_params.py">params</a>) -> <a href="./src/lithic/types/financial_transaction.py">SyncSinglePage[FinancialTransaction]</a></code>
262262

263+
# CardAuthorizations
264+
265+
Types:
266+
267+
```python
268+
from lithic.types import CardAuthorization
269+
```
270+
271+
Methods:
272+
273+
- <code title="post /v1/card_authorizations/{event_token}/challenge_response">client.card_authorizations.<a href="./src/lithic/resources/card_authorizations.py">challenge_response</a>(event_token, \*\*<a href="src/lithic/types/card_authorization_challenge_response_params.py">params</a>) -> None</code>
274+
263275
# CardBulkOrders
264276

265277
Types:
@@ -900,6 +912,7 @@ from lithic.types import (
900912
AccountHolderVerificationWebhookEvent,
901913
AccountHolderDocumentUpdatedWebhookEvent,
902914
CardAuthorizationApprovalRequestWebhookEvent,
915+
CardAuthorizationChallengeWebhookEvent,
903916
CardAuthorizationChallengeResponseWebhookEvent,
904917
AuthRulesBacktestReportCreatedWebhookEvent,
905918
BalanceUpdatedWebhookEvent,

src/lithic/_client.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
network_programs,
6969
external_payments,
7070
financial_accounts,
71+
card_authorizations,
7172
responder_endpoints,
7273
management_operations,
7374
auth_stream_enrollment,
@@ -96,6 +97,7 @@
9697
from .resources.network_programs import NetworkPrograms, AsyncNetworkPrograms
9798
from .resources.external_payments import ExternalPayments, AsyncExternalPayments
9899
from .resources.three_ds.three_ds import ThreeDS, AsyncThreeDS
100+
from .resources.card_authorizations import CardAuthorizations, AsyncCardAuthorizations
99101
from .resources.responder_endpoints import ResponderEndpoints, AsyncResponderEndpoints
100102
from .resources.auth_rules.auth_rules import AuthRules, AsyncAuthRules
101103
from .resources.management_operations import ManagementOperations, AsyncManagementOperations
@@ -263,6 +265,12 @@ def cards(self) -> Cards:
263265

264266
return Cards(self)
265267

268+
@cached_property
269+
def card_authorizations(self) -> CardAuthorizations:
270+
from .resources.card_authorizations import CardAuthorizations
271+
272+
return CardAuthorizations(self)
273+
266274
@cached_property
267275
def card_bulk_orders(self) -> CardBulkOrders:
268276
from .resources.card_bulk_orders import CardBulkOrders
@@ -687,6 +695,12 @@ def cards(self) -> AsyncCards:
687695

688696
return AsyncCards(self)
689697

698+
@cached_property
699+
def card_authorizations(self) -> AsyncCardAuthorizations:
700+
from .resources.card_authorizations import AsyncCardAuthorizations
701+
702+
return AsyncCardAuthorizations(self)
703+
690704
@cached_property
691705
def card_bulk_orders(self) -> AsyncCardBulkOrders:
692706
from .resources.card_bulk_orders import AsyncCardBulkOrders
@@ -1025,6 +1039,12 @@ def cards(self) -> cards.CardsWithRawResponse:
10251039

10261040
return CardsWithRawResponse(self._client.cards)
10271041

1042+
@cached_property
1043+
def card_authorizations(self) -> card_authorizations.CardAuthorizationsWithRawResponse:
1044+
from .resources.card_authorizations import CardAuthorizationsWithRawResponse
1045+
1046+
return CardAuthorizationsWithRawResponse(self._client.card_authorizations)
1047+
10281048
@cached_property
10291049
def card_bulk_orders(self) -> card_bulk_orders.CardBulkOrdersWithRawResponse:
10301050
from .resources.card_bulk_orders import CardBulkOrdersWithRawResponse
@@ -1222,6 +1242,12 @@ def cards(self) -> cards.AsyncCardsWithRawResponse:
12221242

12231243
return AsyncCardsWithRawResponse(self._client.cards)
12241244

1245+
@cached_property
1246+
def card_authorizations(self) -> card_authorizations.AsyncCardAuthorizationsWithRawResponse:
1247+
from .resources.card_authorizations import AsyncCardAuthorizationsWithRawResponse
1248+
1249+
return AsyncCardAuthorizationsWithRawResponse(self._client.card_authorizations)
1250+
12251251
@cached_property
12261252
def card_bulk_orders(self) -> card_bulk_orders.AsyncCardBulkOrdersWithRawResponse:
12271253
from .resources.card_bulk_orders import AsyncCardBulkOrdersWithRawResponse
@@ -1419,6 +1445,12 @@ def cards(self) -> cards.CardsWithStreamingResponse:
14191445

14201446
return CardsWithStreamingResponse(self._client.cards)
14211447

1448+
@cached_property
1449+
def card_authorizations(self) -> card_authorizations.CardAuthorizationsWithStreamingResponse:
1450+
from .resources.card_authorizations import CardAuthorizationsWithStreamingResponse
1451+
1452+
return CardAuthorizationsWithStreamingResponse(self._client.card_authorizations)
1453+
14221454
@cached_property
14231455
def card_bulk_orders(self) -> card_bulk_orders.CardBulkOrdersWithStreamingResponse:
14241456
from .resources.card_bulk_orders import CardBulkOrdersWithStreamingResponse
@@ -1616,6 +1648,12 @@ def cards(self) -> cards.AsyncCardsWithStreamingResponse:
16161648

16171649
return AsyncCardsWithStreamingResponse(self._client.cards)
16181650

1651+
@cached_property
1652+
def card_authorizations(self) -> card_authorizations.AsyncCardAuthorizationsWithStreamingResponse:
1653+
from .resources.card_authorizations import AsyncCardAuthorizationsWithStreamingResponse
1654+
1655+
return AsyncCardAuthorizationsWithStreamingResponse(self._client.card_authorizations)
1656+
16191657
@cached_property
16201658
def card_bulk_orders(self) -> card_bulk_orders.AsyncCardBulkOrdersWithStreamingResponse:
16211659
from .resources.card_bulk_orders import AsyncCardBulkOrdersWithStreamingResponse

src/lithic/resources/__init__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,14 @@
209209
FinancialAccountsWithStreamingResponse,
210210
AsyncFinancialAccountsWithStreamingResponse,
211211
)
212+
from .card_authorizations import (
213+
CardAuthorizations,
214+
AsyncCardAuthorizations,
215+
CardAuthorizationsWithRawResponse,
216+
AsyncCardAuthorizationsWithRawResponse,
217+
CardAuthorizationsWithStreamingResponse,
218+
AsyncCardAuthorizationsWithStreamingResponse,
219+
)
212220
from .responder_endpoints import (
213221
ResponderEndpoints,
214222
AsyncResponderEndpoints,
@@ -293,6 +301,12 @@
293301
"AsyncCardsWithRawResponse",
294302
"CardsWithStreamingResponse",
295303
"AsyncCardsWithStreamingResponse",
304+
"CardAuthorizations",
305+
"AsyncCardAuthorizations",
306+
"CardAuthorizationsWithRawResponse",
307+
"AsyncCardAuthorizationsWithRawResponse",
308+
"CardAuthorizationsWithStreamingResponse",
309+
"AsyncCardAuthorizationsWithStreamingResponse",
296310
"CardBulkOrders",
297311
"AsyncCardBulkOrders",
298312
"CardBulkOrdersWithRawResponse",
Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from __future__ import annotations
4+
5+
from typing_extensions import Literal
6+
7+
import httpx
8+
9+
from .. import _legacy_response
10+
from ..types import card_authorization_challenge_response_params
11+
from .._types import Body, Query, Headers, NoneType, NotGiven, not_given
12+
from .._utils import path_template, maybe_transform, async_maybe_transform
13+
from .._compat import cached_property
14+
from .._resource import SyncAPIResource, AsyncAPIResource
15+
from .._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper
16+
from .._base_client import make_request_options
17+
18+
__all__ = ["CardAuthorizations", "AsyncCardAuthorizations"]
19+
20+
21+
class CardAuthorizations(SyncAPIResource):
22+
@cached_property
23+
def with_raw_response(self) -> CardAuthorizationsWithRawResponse:
24+
"""
25+
This property can be used as a prefix for any HTTP method call to return
26+
the raw response object instead of the parsed content.
27+
28+
For more information, see https://www.github.com/lithic-com/lithic-python#accessing-raw-response-data-eg-headers
29+
"""
30+
return CardAuthorizationsWithRawResponse(self)
31+
32+
@cached_property
33+
def with_streaming_response(self) -> CardAuthorizationsWithStreamingResponse:
34+
"""
35+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
36+
37+
For more information, see https://www.github.com/lithic-com/lithic-python#with_streaming_response
38+
"""
39+
return CardAuthorizationsWithStreamingResponse(self)
40+
41+
def challenge_response(
42+
self,
43+
event_token: str,
44+
*,
45+
response: Literal["APPROVE", "DECLINE"],
46+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
47+
# The extra values given here take precedence over values defined on the client or passed to this method.
48+
extra_headers: Headers | None = None,
49+
extra_query: Query | None = None,
50+
extra_body: Body | None = None,
51+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
52+
) -> None:
53+
"""Card program's response to Authorization Challenge.
54+
55+
Programs that have
56+
Authorization Challenges configured as Out of Band receive a
57+
[card_authorization.challenge](https://docs.lithic.com/reference/post_card-authorization-challenge)
58+
webhook when an authorization attempt triggers a challenge. The card program
59+
should respond using this endpoint after the cardholder completes the challenge.
60+
61+
Args:
62+
response: Whether the cardholder has approved or declined the issued challenge
63+
64+
extra_headers: Send extra headers
65+
66+
extra_query: Add additional query parameters to the request
67+
68+
extra_body: Add additional JSON properties to the request
69+
70+
timeout: Override the client-level default timeout for this request, in seconds
71+
"""
72+
if not event_token:
73+
raise ValueError(f"Expected a non-empty value for `event_token` but received {event_token!r}")
74+
return self._post(
75+
path_template("/v1/card_authorizations/{event_token}/challenge_response", event_token=event_token),
76+
body=maybe_transform(
77+
{"response": response},
78+
card_authorization_challenge_response_params.CardAuthorizationChallengeResponseParams,
79+
),
80+
options=make_request_options(
81+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
82+
),
83+
cast_to=NoneType,
84+
)
85+
86+
87+
class AsyncCardAuthorizations(AsyncAPIResource):
88+
@cached_property
89+
def with_raw_response(self) -> AsyncCardAuthorizationsWithRawResponse:
90+
"""
91+
This property can be used as a prefix for any HTTP method call to return
92+
the raw response object instead of the parsed content.
93+
94+
For more information, see https://www.github.com/lithic-com/lithic-python#accessing-raw-response-data-eg-headers
95+
"""
96+
return AsyncCardAuthorizationsWithRawResponse(self)
97+
98+
@cached_property
99+
def with_streaming_response(self) -> AsyncCardAuthorizationsWithStreamingResponse:
100+
"""
101+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
102+
103+
For more information, see https://www.github.com/lithic-com/lithic-python#with_streaming_response
104+
"""
105+
return AsyncCardAuthorizationsWithStreamingResponse(self)
106+
107+
async def challenge_response(
108+
self,
109+
event_token: str,
110+
*,
111+
response: Literal["APPROVE", "DECLINE"],
112+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
113+
# The extra values given here take precedence over values defined on the client or passed to this method.
114+
extra_headers: Headers | None = None,
115+
extra_query: Query | None = None,
116+
extra_body: Body | None = None,
117+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
118+
) -> None:
119+
"""Card program's response to Authorization Challenge.
120+
121+
Programs that have
122+
Authorization Challenges configured as Out of Band receive a
123+
[card_authorization.challenge](https://docs.lithic.com/reference/post_card-authorization-challenge)
124+
webhook when an authorization attempt triggers a challenge. The card program
125+
should respond using this endpoint after the cardholder completes the challenge.
126+
127+
Args:
128+
response: Whether the cardholder has approved or declined the issued challenge
129+
130+
extra_headers: Send extra headers
131+
132+
extra_query: Add additional query parameters to the request
133+
134+
extra_body: Add additional JSON properties to the request
135+
136+
timeout: Override the client-level default timeout for this request, in seconds
137+
"""
138+
if not event_token:
139+
raise ValueError(f"Expected a non-empty value for `event_token` but received {event_token!r}")
140+
return await self._post(
141+
path_template("/v1/card_authorizations/{event_token}/challenge_response", event_token=event_token),
142+
body=await async_maybe_transform(
143+
{"response": response},
144+
card_authorization_challenge_response_params.CardAuthorizationChallengeResponseParams,
145+
),
146+
options=make_request_options(
147+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
148+
),
149+
cast_to=NoneType,
150+
)
151+
152+
153+
class CardAuthorizationsWithRawResponse:
154+
def __init__(self, card_authorizations: CardAuthorizations) -> None:
155+
self._card_authorizations = card_authorizations
156+
157+
self.challenge_response = _legacy_response.to_raw_response_wrapper(
158+
card_authorizations.challenge_response,
159+
)
160+
161+
162+
class AsyncCardAuthorizationsWithRawResponse:
163+
def __init__(self, card_authorizations: AsyncCardAuthorizations) -> None:
164+
self._card_authorizations = card_authorizations
165+
166+
self.challenge_response = _legacy_response.async_to_raw_response_wrapper(
167+
card_authorizations.challenge_response,
168+
)
169+
170+
171+
class CardAuthorizationsWithStreamingResponse:
172+
def __init__(self, card_authorizations: CardAuthorizations) -> None:
173+
self._card_authorizations = card_authorizations
174+
175+
self.challenge_response = to_streamed_response_wrapper(
176+
card_authorizations.challenge_response,
177+
)
178+
179+
180+
class AsyncCardAuthorizationsWithStreamingResponse:
181+
def __init__(self, card_authorizations: AsyncCardAuthorizations) -> None:
182+
self._card_authorizations = card_authorizations
183+
184+
self.challenge_response = async_to_streamed_response_wrapper(
185+
card_authorizations.challenge_response,
186+
)

src/lithic/resources/events/events.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ def list(
116116
"balance.updated",
117117
"book_transfer_transaction.created",
118118
"book_transfer_transaction.updated",
119+
"card_authorization.challenge",
119120
"card_authorization.challenge_response",
120121
"card_transaction.enhanced_data.created",
121122
"card_transaction.enhanced_data.updated",
@@ -391,6 +392,7 @@ def list(
391392
"balance.updated",
392393
"book_transfer_transaction.created",
393394
"book_transfer_transaction.updated",
395+
"card_authorization.challenge",
394396
"card_authorization.challenge_response",
395397
"card_transaction.enhanced_data.created",
396398
"card_transaction.enhanced_data.updated",

0 commit comments

Comments
 (0)