From 8f3cb1bdbc1a661daea1d0644e2016d2f7fb78b4 Mon Sep 17 00:00:00 2001
From: "stainless-app[bot]"
<142633134+stainless-app[bot]@users.noreply.github.com>
Date: Wed, 29 May 2024 23:21:48 +0000
Subject: [PATCH] feat(api): add simulate_receipt and simulate_action endpoints
(#454)
---
.stats.yml | 2 +-
api.md | 4 +
src/lithic/resources/payments.py | 272 ++++++++++++++++++
src/lithic/types/__init__.py | 4 +
.../statements/line_item_list_response.py | 35 +--
src/lithic/types/financial_transaction.py | 49 ++--
.../types/payment_simulate_action_params.py | 30 ++
.../types/payment_simulate_action_response.py | 18 ++
.../types/payment_simulate_receipt_params.py | 24 ++
.../payment_simulate_receipt_response.py | 18 ++
.../types/payment_simulate_release_params.py | 1 +
.../payment_simulate_release_response.py | 10 +-
.../types/payment_simulate_return_params.py | 2 +
.../types/payment_simulate_return_response.py | 10 +-
tests/api_resources/test_payments.py | 212 +++++++++++++-
15 files changed, 640 insertions(+), 51 deletions(-)
create mode 100644 src/lithic/types/payment_simulate_action_params.py
create mode 100644 src/lithic/types/payment_simulate_action_response.py
create mode 100644 src/lithic/types/payment_simulate_receipt_params.py
create mode 100644 src/lithic/types/payment_simulate_receipt_response.py
diff --git a/.stats.yml b/.stats.yml
index 8bdf2ea0..93ea783d 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1 +1 @@
-configured_endpoints: 112
+configured_endpoints: 114
diff --git a/api.md b/api.md
index 5fb6ea78..a8a2d318 100644
--- a/api.md
+++ b/api.md
@@ -421,6 +421,8 @@ from lithic.types import (
Payment,
PaymentCreateResponse,
PaymentRetryResponse,
+ PaymentSimulateActionResponse,
+ PaymentSimulateReceiptResponse,
PaymentSimulateReleaseResponse,
PaymentSimulateReturnResponse,
)
@@ -432,6 +434,8 @@ Methods:
- client.payments.retrieve(payment_token) -> Payment
- client.payments.list(\*\*params) -> SyncCursorPage[Payment]
- client.payments.retry(payment_token) -> PaymentRetryResponse
+- client.payments.simulate_action(payment_token, \*\*params) -> PaymentSimulateActionResponse
+- client.payments.simulate_receipt(\*\*params) -> PaymentSimulateReceiptResponse
- client.payments.simulate_release(\*\*params) -> PaymentSimulateReleaseResponse
- client.payments.simulate_return(\*\*params) -> PaymentSimulateReturnResponse
diff --git a/src/lithic/resources/payments.py b/src/lithic/resources/payments.py
index f2e7776d..6e1385c0 100644
--- a/src/lithic/resources/payments.py
+++ b/src/lithic/resources/payments.py
@@ -12,7 +12,9 @@
from ..types import (
payment_list_params,
payment_create_params,
+ payment_simulate_action_params,
payment_simulate_return_params,
+ payment_simulate_receipt_params,
payment_simulate_release_params,
)
from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
@@ -31,7 +33,9 @@
from ..types.payment import Payment
from ..types.payment_retry_response import PaymentRetryResponse
from ..types.payment_create_response import PaymentCreateResponse
+from ..types.payment_simulate_action_response import PaymentSimulateActionResponse
from ..types.payment_simulate_return_response import PaymentSimulateReturnResponse
+from ..types.payment_simulate_receipt_response import PaymentSimulateReceiptResponse
from ..types.payment_simulate_release_response import PaymentSimulateReleaseResponse
__all__ = ["Payments", "AsyncPayments"]
@@ -237,6 +241,122 @@ def retry(
cast_to=PaymentRetryResponse,
)
+ def simulate_action(
+ self,
+ payment_token: str,
+ *,
+ event_type: Literal[
+ "ACH_ORIGINATION_REVIEWED",
+ "ACH_ORIGINATION_RELEASED",
+ "ACH_ORIGINATION_PROCESSED",
+ "ACH_ORIGINATION_SETTLED",
+ "ACH_RECEIPT_SETTLED",
+ "ACH_RETURN_INITIATED",
+ "ACH_RETURN_PROCESSED",
+ ],
+ decline_reason: Literal[
+ "PROGRAM_TRANSACTION_LIMITS_EXCEEDED", "PROGRAM_DAILY_LIMITS_EXCEEDED", "PROGRAM_MONTHLY_LIMITS_EXCEEDED"
+ ]
+ | NotGiven = NOT_GIVEN,
+ return_reason_code: str | NotGiven = NOT_GIVEN,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> PaymentSimulateActionResponse:
+ """
+ Simulate payment lifecycle event
+
+ Args:
+ event_type: Event Type
+
+ decline_reason: Decline reason
+
+ return_reason_code: Return Reason Code
+
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ if not payment_token:
+ raise ValueError(f"Expected a non-empty value for `payment_token` but received {payment_token!r}")
+ return self._post(
+ f"/simulate/payments/{payment_token}/action",
+ body=maybe_transform(
+ {
+ "event_type": event_type,
+ "decline_reason": decline_reason,
+ "return_reason_code": return_reason_code,
+ },
+ payment_simulate_action_params.PaymentSimulateActionParams,
+ ),
+ options=make_request_options(
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
+ ),
+ cast_to=PaymentSimulateActionResponse,
+ )
+
+ def simulate_receipt(
+ self,
+ *,
+ token: str,
+ amount: int,
+ financial_account_token: str,
+ receipt_type: Literal["RECEIPT_CREDIT", "RECEIPT_DEBIT"],
+ memo: str | NotGiven = NOT_GIVEN,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> PaymentSimulateReceiptResponse:
+ """
+ Simulates a receipt of a Payment.
+
+ Args:
+ token: Payment token
+
+ amount: Amount
+
+ financial_account_token: Financial Account Token
+
+ receipt_type: Receipt Type
+
+ memo: Memo
+
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ return self._post(
+ "/simulate/payments/receipt",
+ body=maybe_transform(
+ {
+ "token": token,
+ "amount": amount,
+ "financial_account_token": financial_account_token,
+ "receipt_type": receipt_type,
+ "memo": memo,
+ },
+ payment_simulate_receipt_params.PaymentSimulateReceiptParams,
+ ),
+ options=make_request_options(
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
+ ),
+ cast_to=PaymentSimulateReceiptResponse,
+ )
+
def simulate_release(
self,
*,
@@ -252,6 +372,8 @@ def simulate_release(
Simulates a release of a Payment.
Args:
+ payment_token: Payment Token
+
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
@@ -287,6 +409,10 @@ def simulate_return(
Simulates a return of a Payment.
Args:
+ payment_token: Payment Token
+
+ return_reason_code: Return Reason Code
+
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
@@ -511,6 +637,122 @@ async def retry(
cast_to=PaymentRetryResponse,
)
+ async def simulate_action(
+ self,
+ payment_token: str,
+ *,
+ event_type: Literal[
+ "ACH_ORIGINATION_REVIEWED",
+ "ACH_ORIGINATION_RELEASED",
+ "ACH_ORIGINATION_PROCESSED",
+ "ACH_ORIGINATION_SETTLED",
+ "ACH_RECEIPT_SETTLED",
+ "ACH_RETURN_INITIATED",
+ "ACH_RETURN_PROCESSED",
+ ],
+ decline_reason: Literal[
+ "PROGRAM_TRANSACTION_LIMITS_EXCEEDED", "PROGRAM_DAILY_LIMITS_EXCEEDED", "PROGRAM_MONTHLY_LIMITS_EXCEEDED"
+ ]
+ | NotGiven = NOT_GIVEN,
+ return_reason_code: str | NotGiven = NOT_GIVEN,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> PaymentSimulateActionResponse:
+ """
+ Simulate payment lifecycle event
+
+ Args:
+ event_type: Event Type
+
+ decline_reason: Decline reason
+
+ return_reason_code: Return Reason Code
+
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ if not payment_token:
+ raise ValueError(f"Expected a non-empty value for `payment_token` but received {payment_token!r}")
+ return await self._post(
+ f"/simulate/payments/{payment_token}/action",
+ body=await async_maybe_transform(
+ {
+ "event_type": event_type,
+ "decline_reason": decline_reason,
+ "return_reason_code": return_reason_code,
+ },
+ payment_simulate_action_params.PaymentSimulateActionParams,
+ ),
+ options=make_request_options(
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
+ ),
+ cast_to=PaymentSimulateActionResponse,
+ )
+
+ async def simulate_receipt(
+ self,
+ *,
+ token: str,
+ amount: int,
+ financial_account_token: str,
+ receipt_type: Literal["RECEIPT_CREDIT", "RECEIPT_DEBIT"],
+ memo: str | NotGiven = NOT_GIVEN,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> PaymentSimulateReceiptResponse:
+ """
+ Simulates a receipt of a Payment.
+
+ Args:
+ token: Payment token
+
+ amount: Amount
+
+ financial_account_token: Financial Account Token
+
+ receipt_type: Receipt Type
+
+ memo: Memo
+
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ return await self._post(
+ "/simulate/payments/receipt",
+ body=await async_maybe_transform(
+ {
+ "token": token,
+ "amount": amount,
+ "financial_account_token": financial_account_token,
+ "receipt_type": receipt_type,
+ "memo": memo,
+ },
+ payment_simulate_receipt_params.PaymentSimulateReceiptParams,
+ ),
+ options=make_request_options(
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
+ ),
+ cast_to=PaymentSimulateReceiptResponse,
+ )
+
async def simulate_release(
self,
*,
@@ -526,6 +768,8 @@ async def simulate_release(
Simulates a release of a Payment.
Args:
+ payment_token: Payment Token
+
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
@@ -561,6 +805,10 @@ async def simulate_return(
Simulates a return of a Payment.
Args:
+ payment_token: Payment Token
+
+ return_reason_code: Return Reason Code
+
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
@@ -601,6 +849,12 @@ def __init__(self, payments: Payments) -> None:
self.retry = _legacy_response.to_raw_response_wrapper(
payments.retry,
)
+ self.simulate_action = _legacy_response.to_raw_response_wrapper(
+ payments.simulate_action,
+ )
+ self.simulate_receipt = _legacy_response.to_raw_response_wrapper(
+ payments.simulate_receipt,
+ )
self.simulate_release = _legacy_response.to_raw_response_wrapper(
payments.simulate_release,
)
@@ -625,6 +879,12 @@ def __init__(self, payments: AsyncPayments) -> None:
self.retry = _legacy_response.async_to_raw_response_wrapper(
payments.retry,
)
+ self.simulate_action = _legacy_response.async_to_raw_response_wrapper(
+ payments.simulate_action,
+ )
+ self.simulate_receipt = _legacy_response.async_to_raw_response_wrapper(
+ payments.simulate_receipt,
+ )
self.simulate_release = _legacy_response.async_to_raw_response_wrapper(
payments.simulate_release,
)
@@ -649,6 +909,12 @@ def __init__(self, payments: Payments) -> None:
self.retry = to_streamed_response_wrapper(
payments.retry,
)
+ self.simulate_action = to_streamed_response_wrapper(
+ payments.simulate_action,
+ )
+ self.simulate_receipt = to_streamed_response_wrapper(
+ payments.simulate_receipt,
+ )
self.simulate_release = to_streamed_response_wrapper(
payments.simulate_release,
)
@@ -673,6 +939,12 @@ def __init__(self, payments: AsyncPayments) -> None:
self.retry = async_to_streamed_response_wrapper(
payments.retry,
)
+ self.simulate_action = async_to_streamed_response_wrapper(
+ payments.simulate_action,
+ )
+ self.simulate_receipt = async_to_streamed_response_wrapper(
+ payments.simulate_receipt,
+ )
self.simulate_release = async_to_streamed_response_wrapper(
payments.simulate_release,
)
diff --git a/src/lithic/types/__init__.py b/src/lithic/types/__init__.py
index 2268a3cf..9ab37144 100644
--- a/src/lithic/types/__init__.py
+++ b/src/lithic/types/__init__.py
@@ -82,17 +82,21 @@
from .account_holder_create_response import AccountHolderCreateResponse as AccountHolderCreateResponse
from .account_holder_resubmit_params import AccountHolderResubmitParams as AccountHolderResubmitParams
from .account_holder_update_response import AccountHolderUpdateResponse as AccountHolderUpdateResponse
+from .payment_simulate_action_params import PaymentSimulateActionParams as PaymentSimulateActionParams
from .payment_simulate_return_params import PaymentSimulateReturnParams as PaymentSimulateReturnParams
from .tokenization_retrieve_response import TokenizationRetrieveResponse as TokenizationRetrieveResponse
from .tokenization_simulate_response import TokenizationSimulateResponse as TokenizationSimulateResponse
from .financial_account_create_params import FinancialAccountCreateParams as FinancialAccountCreateParams
from .financial_account_update_params import FinancialAccountUpdateParams as FinancialAccountUpdateParams
+from .payment_simulate_receipt_params import PaymentSimulateReceiptParams as PaymentSimulateReceiptParams
from .payment_simulate_release_params import PaymentSimulateReleaseParams as PaymentSimulateReleaseParams
+from .payment_simulate_action_response import PaymentSimulateActionResponse as PaymentSimulateActionResponse
from .payment_simulate_return_response import PaymentSimulateReturnResponse as PaymentSimulateReturnResponse
from .responder_endpoint_create_params import ResponderEndpointCreateParams as ResponderEndpointCreateParams
from .responder_endpoint_delete_params import ResponderEndpointDeleteParams as ResponderEndpointDeleteParams
from .transaction_simulate_void_params import TransactionSimulateVoidParams as TransactionSimulateVoidParams
from .external_bank_account_list_params import ExternalBankAccountListParams as ExternalBankAccountListParams
+from .payment_simulate_receipt_response import PaymentSimulateReceiptResponse as PaymentSimulateReceiptResponse
from .payment_simulate_release_response import PaymentSimulateReleaseResponse as PaymentSimulateReleaseResponse
from .responder_endpoint_create_response import ResponderEndpointCreateResponse as ResponderEndpointCreateResponse
from .transaction_simulate_return_params import TransactionSimulateReturnParams as TransactionSimulateReturnParams
diff --git a/src/lithic/types/financial_accounts/statements/line_item_list_response.py b/src/lithic/types/financial_accounts/statements/line_item_list_response.py
index eaed2bc3..410b7abc 100644
--- a/src/lithic/types/financial_accounts/statements/line_item_list_response.py
+++ b/src/lithic/types/financial_accounts/statements/line_item_list_response.py
@@ -24,20 +24,16 @@ class LineItemListResponse(BaseModel):
"""3-digit alphabetic ISO 4217 code for the settling currency of the transaction"""
event_type: Literal[
- "ACH_EXCEEDED_THRESHOLD",
- "ACH_INSUFFICIENT_FUNDS",
- "ACH_INVALID_ACCOUNT",
- "ACH_ORIGINATION_PENDING",
- "ACH_ORIGINATION_APPROVED",
- "ACH_ORIGINATION_DECLINED",
"ACH_ORIGINATION_CANCELLED",
+ "ACH_ORIGINATION_INITIATED",
"ACH_ORIGINATION_PROCESSED",
"ACH_ORIGINATION_SETTLED",
"ACH_ORIGINATION_RELEASED",
- "ACH_RECEIPT_PENDING",
- "ACH_RECEIPT_RELEASED",
- "ACH_RETURN",
- "ACH_RETURN_PENDING",
+ "ACH_ORIGINATION_REVIEWED",
+ "ACH_RECEIPT_PROCESSED",
+ "ACH_RECEIPT_SETTLED",
+ "ACH_RETURN_INITIATED",
+ "ACH_RETURN_PROCESSED",
"AUTHORIZATION",
"AUTHORIZATION_ADVICE",
"AUTHORIZATION_EXPIRY",
@@ -57,23 +53,22 @@ class LineItemListResponse(BaseModel):
]
"""Event types:
- - `ACH_INSUFFICIENT_FUNDS` - Attempted ACH origination declined due to
- insufficient balance.
- - `ACH_ORIGINATION_PENDING` - ACH origination received and pending
+ - `ACH_ORIGINATION_INITIATED` - ACH origination received and pending
approval/release from an ACH hold.
- - `ACH_ORIGINATION_APPROVED` - ACH origination has been approved and pending
- processing.
- - `ACH_ORIGINATION_DECLINED` - ACH origination has been declined.
+ - `ACH_ORIGINATION_REVIEWED` - ACH origination has completed the review process.
- `ACH_ORIGINATION_CANCELLED` - ACH origination has been cancelled.
- - `ACH_ORIGINATION_PROCESSED` - ACH origination has been processed.
+ - `ACH_ORIGINATION_PROCESSED` - ACH origination has been processed and sent to
+ the fed.
- `ACH_ORIGINATION_SETTLED` - ACH origination has settled.
- `ACH_ORIGINATION_RELEASED` - ACH origination released from pending to
available balance.
- - `ACH_RECEIPT_PENDING` - ACH receipt pending release from an ACH holder.
+ - `ACH_RETURN_PROCESSED` - ACH origination returned by the Receiving Depository
+ Financial Institution.
+ - `ACH_RECEIPT_PROCESSED` - ACH receipt pending release from an ACH holder.
+ - `ACH_RETURN_INITIATED` - ACH initiated return for a ACH receipt.
+ - `ACH_RECEIPT_SETTLED` - ACH receipt funds have settled.
- `ACH_RECEIPT_RELEASED` - ACH receipt released from pending to available
balance.
- - `ACH_RETURN` - ACH origination returned by the Receiving Depository Financial
- Institution.
- `AUTHORIZATION` - Authorize a card transaction.
- `AUTHORIZATION_ADVICE` - Advice on a card transaction.
- `AUTHORIZATION_EXPIRY` - Card Authorization has expired and reversed by
diff --git a/src/lithic/types/financial_transaction.py b/src/lithic/types/financial_transaction.py
index 99e0779c..f67f4048 100644
--- a/src/lithic/types/financial_transaction.py
+++ b/src/lithic/types/financial_transaction.py
@@ -22,6 +22,20 @@ class Event(BaseModel):
created: Optional[datetime] = None
"""Date and time when the financial event occurred. UTC time zone."""
+ detailed_results: Optional[
+ List[
+ Literal[
+ "APPROVED",
+ "INSUFFICIENT_FUNDS",
+ "INVALID_ACCOUNT",
+ "PROGRAM_TRANSACTION_LIMITS_EXCEEDED",
+ "PROGRAM_DAILY_LIMITS_EXCEEDED",
+ "PROGRAM_MONTHLY_LIMITS_EXCEEDED",
+ ]
+ ]
+ ] = None
+ """More detailed reasons for the event"""
+
result: Optional[Literal["APPROVED", "DECLINED"]] = None
"""
APPROVED financial events were successful while DECLINED financial events were
@@ -30,20 +44,16 @@ class Event(BaseModel):
type: Optional[
Literal[
- "ACH_EXCEEDED_THRESHOLD",
- "ACH_INSUFFICIENT_FUNDS",
- "ACH_INVALID_ACCOUNT",
- "ACH_ORIGINATION_PENDING",
- "ACH_ORIGINATION_APPROVED",
- "ACH_ORIGINATION_DECLINED",
"ACH_ORIGINATION_CANCELLED",
+ "ACH_ORIGINATION_INITIATED",
"ACH_ORIGINATION_PROCESSED",
"ACH_ORIGINATION_SETTLED",
"ACH_ORIGINATION_RELEASED",
- "ACH_RECEIPT_PENDING",
- "ACH_RECEIPT_RELEASED",
- "ACH_RETURN",
- "ACH_RETURN_PENDING",
+ "ACH_ORIGINATION_REVIEWED",
+ "ACH_RECEIPT_PROCESSED",
+ "ACH_RECEIPT_SETTLED",
+ "ACH_RETURN_INITIATED",
+ "ACH_RETURN_PROCESSED",
"AUTHORIZATION",
"AUTHORIZATION_ADVICE",
"AUTHORIZATION_EXPIRY",
@@ -64,23 +74,22 @@ class Event(BaseModel):
] = None
"""Event types:
- - `ACH_INSUFFICIENT_FUNDS` - Attempted ACH origination declined due to
- insufficient balance.
- - `ACH_ORIGINATION_PENDING` - ACH origination received and pending
+ - `ACH_ORIGINATION_INITIATED` - ACH origination received and pending
approval/release from an ACH hold.
- - `ACH_ORIGINATION_APPROVED` - ACH origination has been approved and pending
- processing.
- - `ACH_ORIGINATION_DECLINED` - ACH origination has been declined.
+ - `ACH_ORIGINATION_REVIEWED` - ACH origination has completed the review process.
- `ACH_ORIGINATION_CANCELLED` - ACH origination has been cancelled.
- - `ACH_ORIGINATION_PROCESSED` - ACH origination has been processed.
+ - `ACH_ORIGINATION_PROCESSED` - ACH origination has been processed and sent to
+ the fed.
- `ACH_ORIGINATION_SETTLED` - ACH origination has settled.
- `ACH_ORIGINATION_RELEASED` - ACH origination released from pending to
available balance.
- - `ACH_RECEIPT_PENDING` - ACH receipt pending release from an ACH holder.
+ - `ACH_RETURN_PROCESSED` - ACH origination returned by the Receiving Depository
+ Financial Institution.
+ - `ACH_RECEIPT_PROCESSED` - ACH receipt pending release from an ACH holder.
+ - `ACH_RETURN_INITIATED` - ACH initiated return for a ACH receipt.
+ - `ACH_RECEIPT_SETTLED` - ACH receipt funds have settled.
- `ACH_RECEIPT_RELEASED` - ACH receipt released from pending to available
balance.
- - `ACH_RETURN` - ACH origination returned by the Receiving Depository Financial
- Institution.
- `AUTHORIZATION` - Authorize a card transaction.
- `AUTHORIZATION_ADVICE` - Advice on a card transaction.
- `AUTHORIZATION_EXPIRY` - Card Authorization has expired and reversed by
diff --git a/src/lithic/types/payment_simulate_action_params.py b/src/lithic/types/payment_simulate_action_params.py
new file mode 100644
index 00000000..39129b3a
--- /dev/null
+++ b/src/lithic/types/payment_simulate_action_params.py
@@ -0,0 +1,30 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from __future__ import annotations
+
+from typing_extensions import Literal, Required, TypedDict
+
+__all__ = ["PaymentSimulateActionParams"]
+
+
+class PaymentSimulateActionParams(TypedDict, total=False):
+ event_type: Required[
+ Literal[
+ "ACH_ORIGINATION_REVIEWED",
+ "ACH_ORIGINATION_RELEASED",
+ "ACH_ORIGINATION_PROCESSED",
+ "ACH_ORIGINATION_SETTLED",
+ "ACH_RECEIPT_SETTLED",
+ "ACH_RETURN_INITIATED",
+ "ACH_RETURN_PROCESSED",
+ ]
+ ]
+ """Event Type"""
+
+ decline_reason: Literal[
+ "PROGRAM_TRANSACTION_LIMITS_EXCEEDED", "PROGRAM_DAILY_LIMITS_EXCEEDED", "PROGRAM_MONTHLY_LIMITS_EXCEEDED"
+ ]
+ """Decline reason"""
+
+ return_reason_code: str
+ """Return Reason Code"""
diff --git a/src/lithic/types/payment_simulate_action_response.py b/src/lithic/types/payment_simulate_action_response.py
new file mode 100644
index 00000000..15a8fe99
--- /dev/null
+++ b/src/lithic/types/payment_simulate_action_response.py
@@ -0,0 +1,18 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from typing_extensions import Literal
+
+from .._models import BaseModel
+
+__all__ = ["PaymentSimulateActionResponse"]
+
+
+class PaymentSimulateActionResponse(BaseModel):
+ debugging_request_id: str
+ """Debugging Request Id"""
+
+ result: Literal["APPROVED", "DECLINED"]
+ """Request Result"""
+
+ transaction_event_token: str
+ """Transaction Event Token"""
diff --git a/src/lithic/types/payment_simulate_receipt_params.py b/src/lithic/types/payment_simulate_receipt_params.py
new file mode 100644
index 00000000..86618fc1
--- /dev/null
+++ b/src/lithic/types/payment_simulate_receipt_params.py
@@ -0,0 +1,24 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from __future__ import annotations
+
+from typing_extensions import Literal, Required, TypedDict
+
+__all__ = ["PaymentSimulateReceiptParams"]
+
+
+class PaymentSimulateReceiptParams(TypedDict, total=False):
+ token: Required[str]
+ """Payment token"""
+
+ amount: Required[int]
+ """Amount"""
+
+ financial_account_token: Required[str]
+ """Financial Account Token"""
+
+ receipt_type: Required[Literal["RECEIPT_CREDIT", "RECEIPT_DEBIT"]]
+ """Receipt Type"""
+
+ memo: str
+ """Memo"""
diff --git a/src/lithic/types/payment_simulate_receipt_response.py b/src/lithic/types/payment_simulate_receipt_response.py
new file mode 100644
index 00000000..e7dffe2d
--- /dev/null
+++ b/src/lithic/types/payment_simulate_receipt_response.py
@@ -0,0 +1,18 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from typing_extensions import Literal
+
+from .._models import BaseModel
+
+__all__ = ["PaymentSimulateReceiptResponse"]
+
+
+class PaymentSimulateReceiptResponse(BaseModel):
+ debugging_request_id: str
+ """Debugging Request Id"""
+
+ result: Literal["APPROVED", "DECLINED"]
+ """Request Result"""
+
+ transaction_event_token: str
+ """Transaction Event Token"""
diff --git a/src/lithic/types/payment_simulate_release_params.py b/src/lithic/types/payment_simulate_release_params.py
index ce1c7330..cec89e02 100644
--- a/src/lithic/types/payment_simulate_release_params.py
+++ b/src/lithic/types/payment_simulate_release_params.py
@@ -9,3 +9,4 @@
class PaymentSimulateReleaseParams(TypedDict, total=False):
payment_token: Required[str]
+ """Payment Token"""
diff --git a/src/lithic/types/payment_simulate_release_response.py b/src/lithic/types/payment_simulate_release_response.py
index 8a00d46b..2d7be0f7 100644
--- a/src/lithic/types/payment_simulate_release_response.py
+++ b/src/lithic/types/payment_simulate_release_response.py
@@ -1,6 +1,5 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-from typing import Optional
from typing_extensions import Literal
from .._models import BaseModel
@@ -9,8 +8,11 @@
class PaymentSimulateReleaseResponse(BaseModel):
- debugging_request_id: Optional[str] = None
+ debugging_request_id: str
+ """Debugging Request Id"""
- result: Optional[Literal["APPROVED", "DECLINED"]] = None
+ result: Literal["APPROVED", "DECLINED"]
+ """Request Result"""
- transaction_event_token: Optional[str] = None
+ transaction_event_token: str
+ """Transaction Event Token"""
diff --git a/src/lithic/types/payment_simulate_return_params.py b/src/lithic/types/payment_simulate_return_params.py
index a378e21f..3a880585 100644
--- a/src/lithic/types/payment_simulate_return_params.py
+++ b/src/lithic/types/payment_simulate_return_params.py
@@ -9,5 +9,7 @@
class PaymentSimulateReturnParams(TypedDict, total=False):
payment_token: Required[str]
+ """Payment Token"""
return_reason_code: str
+ """Return Reason Code"""
diff --git a/src/lithic/types/payment_simulate_return_response.py b/src/lithic/types/payment_simulate_return_response.py
index 2be6d12e..14043ff6 100644
--- a/src/lithic/types/payment_simulate_return_response.py
+++ b/src/lithic/types/payment_simulate_return_response.py
@@ -1,6 +1,5 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-from typing import Optional
from typing_extensions import Literal
from .._models import BaseModel
@@ -9,8 +8,11 @@
class PaymentSimulateReturnResponse(BaseModel):
- debugging_request_id: Optional[str] = None
+ debugging_request_id: str
+ """Debugging Request Id"""
- result: Optional[Literal["APPROVED", "DECLINED"]] = None
+ result: Literal["APPROVED", "DECLINED"]
+ """Request Result"""
- transaction_event_token: Optional[str] = None
+ transaction_event_token: str
+ """Transaction Event Token"""
diff --git a/tests/api_resources/test_payments.py b/tests/api_resources/test_payments.py
index 4f14c899..d5747ce1 100644
--- a/tests/api_resources/test_payments.py
+++ b/tests/api_resources/test_payments.py
@@ -13,7 +13,9 @@
Payment,
PaymentRetryResponse,
PaymentCreateResponse,
+ PaymentSimulateActionResponse,
PaymentSimulateReturnResponse,
+ PaymentSimulateReceiptResponse,
PaymentSimulateReleaseResponse,
)
from lithic._utils import parse_datetime
@@ -225,6 +227,109 @@ def test_path_params_retry(self, client: Lithic) -> None:
"",
)
+ @parametrize
+ def test_method_simulate_action(self, client: Lithic) -> None:
+ payment = client.payments.simulate_action(
+ "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ event_type="ACH_ORIGINATION_REVIEWED",
+ )
+ assert_matches_type(PaymentSimulateActionResponse, payment, path=["response"])
+
+ @parametrize
+ def test_method_simulate_action_with_all_params(self, client: Lithic) -> None:
+ payment = client.payments.simulate_action(
+ "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ event_type="ACH_ORIGINATION_REVIEWED",
+ decline_reason="PROGRAM_TRANSACTION_LIMITS_EXCEEDED",
+ return_reason_code="string",
+ )
+ assert_matches_type(PaymentSimulateActionResponse, payment, path=["response"])
+
+ @parametrize
+ def test_raw_response_simulate_action(self, client: Lithic) -> None:
+ response = client.payments.with_raw_response.simulate_action(
+ "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ event_type="ACH_ORIGINATION_REVIEWED",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ payment = response.parse()
+ assert_matches_type(PaymentSimulateActionResponse, payment, path=["response"])
+
+ @parametrize
+ def test_streaming_response_simulate_action(self, client: Lithic) -> None:
+ with client.payments.with_streaming_response.simulate_action(
+ "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ event_type="ACH_ORIGINATION_REVIEWED",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ payment = response.parse()
+ assert_matches_type(PaymentSimulateActionResponse, payment, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ def test_path_params_simulate_action(self, client: Lithic) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `payment_token` but received ''"):
+ client.payments.with_raw_response.simulate_action(
+ "",
+ event_type="ACH_ORIGINATION_REVIEWED",
+ )
+
+ @parametrize
+ def test_method_simulate_receipt(self, client: Lithic) -> None:
+ payment = client.payments.simulate_receipt(
+ token="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ amount=0,
+ financial_account_token="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ receipt_type="RECEIPT_CREDIT",
+ )
+ assert_matches_type(PaymentSimulateReceiptResponse, payment, path=["response"])
+
+ @parametrize
+ def test_method_simulate_receipt_with_all_params(self, client: Lithic) -> None:
+ payment = client.payments.simulate_receipt(
+ token="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ amount=0,
+ financial_account_token="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ receipt_type="RECEIPT_CREDIT",
+ memo="string",
+ )
+ assert_matches_type(PaymentSimulateReceiptResponse, payment, path=["response"])
+
+ @parametrize
+ def test_raw_response_simulate_receipt(self, client: Lithic) -> None:
+ response = client.payments.with_raw_response.simulate_receipt(
+ token="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ amount=0,
+ financial_account_token="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ receipt_type="RECEIPT_CREDIT",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ payment = response.parse()
+ assert_matches_type(PaymentSimulateReceiptResponse, payment, path=["response"])
+
+ @parametrize
+ def test_streaming_response_simulate_receipt(self, client: Lithic) -> None:
+ with client.payments.with_streaming_response.simulate_receipt(
+ token="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ amount=0,
+ financial_account_token="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ receipt_type="RECEIPT_CREDIT",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ payment = response.parse()
+ assert_matches_type(PaymentSimulateReceiptResponse, payment, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
@parametrize
def test_method_simulate_release(self, client: Lithic) -> None:
payment = client.payments.simulate_release(
@@ -267,7 +372,7 @@ def test_method_simulate_return(self, client: Lithic) -> None:
def test_method_simulate_return_with_all_params(self, client: Lithic) -> None:
payment = client.payments.simulate_return(
payment_token="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
- return_reason_code="string",
+ return_reason_code="R12",
)
assert_matches_type(PaymentSimulateReturnResponse, payment, path=["response"])
@@ -499,6 +604,109 @@ async def test_path_params_retry(self, async_client: AsyncLithic) -> None:
"",
)
+ @parametrize
+ async def test_method_simulate_action(self, async_client: AsyncLithic) -> None:
+ payment = await async_client.payments.simulate_action(
+ "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ event_type="ACH_ORIGINATION_REVIEWED",
+ )
+ assert_matches_type(PaymentSimulateActionResponse, payment, path=["response"])
+
+ @parametrize
+ async def test_method_simulate_action_with_all_params(self, async_client: AsyncLithic) -> None:
+ payment = await async_client.payments.simulate_action(
+ "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ event_type="ACH_ORIGINATION_REVIEWED",
+ decline_reason="PROGRAM_TRANSACTION_LIMITS_EXCEEDED",
+ return_reason_code="string",
+ )
+ assert_matches_type(PaymentSimulateActionResponse, payment, path=["response"])
+
+ @parametrize
+ async def test_raw_response_simulate_action(self, async_client: AsyncLithic) -> None:
+ response = await async_client.payments.with_raw_response.simulate_action(
+ "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ event_type="ACH_ORIGINATION_REVIEWED",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ payment = response.parse()
+ assert_matches_type(PaymentSimulateActionResponse, payment, path=["response"])
+
+ @parametrize
+ async def test_streaming_response_simulate_action(self, async_client: AsyncLithic) -> None:
+ async with async_client.payments.with_streaming_response.simulate_action(
+ "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ event_type="ACH_ORIGINATION_REVIEWED",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ payment = await response.parse()
+ assert_matches_type(PaymentSimulateActionResponse, payment, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ async def test_path_params_simulate_action(self, async_client: AsyncLithic) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `payment_token` but received ''"):
+ await async_client.payments.with_raw_response.simulate_action(
+ "",
+ event_type="ACH_ORIGINATION_REVIEWED",
+ )
+
+ @parametrize
+ async def test_method_simulate_receipt(self, async_client: AsyncLithic) -> None:
+ payment = await async_client.payments.simulate_receipt(
+ token="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ amount=0,
+ financial_account_token="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ receipt_type="RECEIPT_CREDIT",
+ )
+ assert_matches_type(PaymentSimulateReceiptResponse, payment, path=["response"])
+
+ @parametrize
+ async def test_method_simulate_receipt_with_all_params(self, async_client: AsyncLithic) -> None:
+ payment = await async_client.payments.simulate_receipt(
+ token="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ amount=0,
+ financial_account_token="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ receipt_type="RECEIPT_CREDIT",
+ memo="string",
+ )
+ assert_matches_type(PaymentSimulateReceiptResponse, payment, path=["response"])
+
+ @parametrize
+ async def test_raw_response_simulate_receipt(self, async_client: AsyncLithic) -> None:
+ response = await async_client.payments.with_raw_response.simulate_receipt(
+ token="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ amount=0,
+ financial_account_token="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ receipt_type="RECEIPT_CREDIT",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ payment = response.parse()
+ assert_matches_type(PaymentSimulateReceiptResponse, payment, path=["response"])
+
+ @parametrize
+ async def test_streaming_response_simulate_receipt(self, async_client: AsyncLithic) -> None:
+ async with async_client.payments.with_streaming_response.simulate_receipt(
+ token="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ amount=0,
+ financial_account_token="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ receipt_type="RECEIPT_CREDIT",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ payment = await response.parse()
+ assert_matches_type(PaymentSimulateReceiptResponse, payment, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
@parametrize
async def test_method_simulate_release(self, async_client: AsyncLithic) -> None:
payment = await async_client.payments.simulate_release(
@@ -541,7 +749,7 @@ async def test_method_simulate_return(self, async_client: AsyncLithic) -> None:
async def test_method_simulate_return_with_all_params(self, async_client: AsyncLithic) -> None:
payment = await async_client.payments.simulate_return(
payment_token="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
- return_reason_code="string",
+ return_reason_code="R12",
)
assert_matches_type(PaymentSimulateReturnResponse, payment, path=["response"])