diff --git a/.stats.yml b/.stats.yml index 1151d16c..c3319fa4 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1 +1 @@ -configured_endpoints: 74 +configured_endpoints: 83 diff --git a/api.md b/api.md index e481199b..73c01725 100644 --- a/api.md +++ b/api.md @@ -267,3 +267,47 @@ Methods: - client.webhooks.unwrap(...args) -> Object - client.webhooks.verifySignature(...args) -> void + +# ExternalBankAccounts + +Types: + +- ExternalBankAccountAddress +- OwnerType +- VerificationMethod +- ExternalBankAccountCreateResponse +- ExternalBankAccountRetrieveResponse +- ExternalBankAccountUpdateResponse +- ExternalBankAccountListResponse + +Methods: + +- client.externalBankAccounts.create({ ...params }) -> ExternalBankAccountCreateResponse +- client.externalBankAccounts.retrieve(externalBankAccountToken) -> ExternalBankAccountRetrieveResponse +- client.externalBankAccounts.update(externalBankAccountToken, { ...params }) -> ExternalBankAccountUpdateResponse +- client.externalBankAccounts.list({ ...params }) -> ExternalBankAccountListResponsesCursorPage + +## MicroDeposits + +Types: + +- MicroDepositCreateResponse + +Methods: + +- client.externalBankAccounts.microDeposits.create(externalBankAccountToken, { ...params }) -> MicroDepositCreateResponse + +# Payments + +Types: + +- Payment +- PaymentCreateResponse +- PaymentSimulateReleaseResponse + +Methods: + +- client.payments.create({ ...params }) -> PaymentCreateResponse +- client.payments.retrieve(paymentToken) -> Payment +- client.payments.list({ ...params }) -> PaymentsCursorPage +- client.payments.simulateRelease({ ...params }) -> PaymentSimulateReleaseResponse diff --git a/src/index.ts b/src/index.ts index e7352944..ed2671d3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -134,6 +134,8 @@ export class Lithic extends Core.APIClient { transactions: API.Transactions = new API.Transactions(this); responderEndpoints: API.ResponderEndpoints = new API.ResponderEndpoints(this); webhooks: API.Webhooks = new API.Webhooks(this); + externalBankAccounts: API.ExternalBankAccounts = new API.ExternalBankAccounts(this); + payments: API.Payments = new API.Payments(this); /** * API status check @@ -344,6 +346,28 @@ export namespace Lithic { export import Webhooks = API.Webhooks; + export import ExternalBankAccounts = API.ExternalBankAccounts; + export import ExternalBankAccountAddress = API.ExternalBankAccountAddress; + export import OwnerType = API.OwnerType; + export import VerificationMethod = API.VerificationMethod; + export import ExternalBankAccountCreateResponse = API.ExternalBankAccountCreateResponse; + export import ExternalBankAccountRetrieveResponse = API.ExternalBankAccountRetrieveResponse; + export import ExternalBankAccountUpdateResponse = API.ExternalBankAccountUpdateResponse; + export import ExternalBankAccountListResponse = API.ExternalBankAccountListResponse; + export import ExternalBankAccountListResponsesCursorPage = API.ExternalBankAccountListResponsesCursorPage; + export import ExternalBankAccountCreateParams = API.ExternalBankAccountCreateParams; + export import ExternalBankAccountUpdateParams = API.ExternalBankAccountUpdateParams; + export import ExternalBankAccountListParams = API.ExternalBankAccountListParams; + + export import Payments = API.Payments; + export import Payment = API.Payment; + export import PaymentCreateResponse = API.PaymentCreateResponse; + export import PaymentSimulateReleaseResponse = API.PaymentSimulateReleaseResponse; + export import PaymentsCursorPage = API.PaymentsCursorPage; + export import PaymentCreateParams = API.PaymentCreateParams; + export import PaymentListParams = API.PaymentListParams; + export import PaymentSimulateReleaseParams = API.PaymentSimulateReleaseParams; + export import Address = API.Address; export import ShippingAddress = API.ShippingAddress; } diff --git a/src/resources/external-bank-accounts/external-bank-accounts.ts b/src/resources/external-bank-accounts/external-bank-accounts.ts new file mode 100644 index 00000000..9688d3f9 --- /dev/null +++ b/src/resources/external-bank-accounts/external-bank-accounts.ts @@ -0,0 +1,541 @@ +// File generated from our OpenAPI spec by Stainless. + +import * as Core from 'lithic/core'; +import { APIResource } from 'lithic/resource'; +import { isRequestOptions } from 'lithic/core'; +import { MicroDeposits } from './micro-deposits'; +import * as API from './'; +import { CursorPage, CursorPageParams } from 'lithic/pagination'; + +export class ExternalBankAccounts extends APIResource { + microDeposits: MicroDeposits = new MicroDeposits(this.client); + + /** + * Creates an external bank account within a program or Lithic account. + */ + create( + body: ExternalBankAccountCreateParams, + options?: Core.RequestOptions, + ): Promise> { + return this.post('/external_bank_accounts', { body, ...options }); + } + + /** + * Get the external bank account by token. + */ + retrieve( + externalBankAccountToken: string, + options?: Core.RequestOptions, + ): Promise> { + return this.get(`/external_bank_accounts/${externalBankAccountToken}`, options); + } + + /** + * Update the external bank account by token. + */ + update( + externalBankAccountToken: string, + body: ExternalBankAccountUpdateParams, + options?: Core.RequestOptions, + ): Promise> { + return this.patch(`/external_bank_accounts/${externalBankAccountToken}`, { body, ...options }); + } + + /** + * List all the external bank accounts for the provided search criteria. + */ + list( + query?: ExternalBankAccountListParams, + options?: Core.RequestOptions, + ): Core.PagePromise; + list(options?: Core.RequestOptions): Core.PagePromise; + list( + query: ExternalBankAccountListParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.PagePromise { + if (isRequestOptions(query)) { + return this.list({}, query); + } + return this.getAPIList('/external_bank_accounts', ExternalBankAccountListResponsesCursorPage, { + query, + ...options, + }); + } +} + +export class ExternalBankAccountListResponsesCursorPage extends CursorPage {} +// alias so we can export it in the namespace +type _ExternalBankAccountListResponsesCursorPage = ExternalBankAccountListResponsesCursorPage; + +/** + * Address used during Address Verification Service (AVS) checks during + * transactions if enabled via Auth Rules. + */ +export interface ExternalBankAccountAddress { + address1: string; + + city: string; + + country: string; + + postal_code: string; + + state: string; + + address2?: string; +} + +export type OwnerType = 'INDIVIDUAL' | 'BUSINESS'; + +export type VerificationMethod = 'MANUAL' | 'MICRO_DEPOSIT' | 'PLAID'; + +export interface ExternalBankAccountCreateResponse { + /** + * A globally unique identifier for this record of an external bank account + * association. If a program links an external bank account to more than one + * end-user or to both the program and the end-user, then Lithic will return each + * record of the association + */ + token: string; + + /** + * The country that the bank account is located in using ISO 3166-1. We will only + * accept US bank accounts e.g., US + */ + country: string; + + /** + * An ISO 8601 string representing when this funding source was added to the Lithic + * account. + */ + created: string; + + /** + * currency of the external account 3-digit alphabetic ISO 4217 code + */ + currency: string; + + /** + * The last 4 digits of the bank account. Derived by Lithic from the account number + * passed + */ + last_four: string; + + /** + * Legal Name of the business or individual who owns the external account. This + * will appear in statements + */ + owner: string; + + owner_type: 'INDIVIDUAL' | 'BUSINESS'; + + routing_number: string; + + state: 'ENABLED' | 'CLOSED' | 'PAUSED'; + + type: 'CHECKING' | 'SAVINGS'; + + verification_method: 'MANUAL' | 'MICRO_DEPOSIT' | 'PLAID'; + + verification_state: 'PENDING' | 'ENABLED' | 'FAILED_VERIFICATION'; + + /** + * Indicates which Lithic account the external account is associated with. For + * external accounts that are associated with the program, account_token field + * returned will be null + */ + account_token?: string; + + /** + * Address used during Address Verification Service (AVS) checks during + * transactions if enabled via Auth Rules. + */ + address?: ExternalBankAccountAddress; + + /** + * Optional field that helps identify bank accounts in receipts + */ + company_id?: string; + + /** + * Date of Birth of the Individual that owns the external bank account + */ + dob?: string; + + doing_business_as?: string; + + /** + * The nickname given to this record of External Bank Account + */ + name?: string; +} + +export interface ExternalBankAccountRetrieveResponse { + /** + * A globally unique identifier for this record of an external bank account + * association. If a program links an external bank account to more than one + * end-user or to both the program and the end-user, then Lithic will return each + * record of the association + */ + token: string; + + /** + * The country that the bank account is located in using ISO 3166-1. We will only + * accept US bank accounts e.g., US + */ + country: string; + + /** + * An ISO 8601 string representing when this funding source was added to the Lithic + * account. + */ + created: string; + + /** + * currency of the external account 3-digit alphabetic ISO 4217 code + */ + currency: string; + + /** + * The last 4 digits of the bank account. Derived by Lithic from the account number + * passed + */ + last_four: string; + + /** + * Legal Name of the business or individual who owns the external account. This + * will appear in statements + */ + owner: string; + + owner_type: 'INDIVIDUAL' | 'BUSINESS'; + + routing_number: string; + + state: 'ENABLED' | 'CLOSED' | 'PAUSED'; + + type: 'CHECKING' | 'SAVINGS'; + + verification_method: 'MANUAL' | 'MICRO_DEPOSIT' | 'PLAID'; + + verification_state: 'PENDING' | 'ENABLED' | 'FAILED_VERIFICATION'; + + /** + * Indicates which Lithic account the external account is associated with. For + * external accounts that are associated with the program, account_token field + * returned will be null + */ + account_token?: string; + + /** + * Address used during Address Verification Service (AVS) checks during + * transactions if enabled via Auth Rules. + */ + address?: ExternalBankAccountAddress; + + /** + * Optional field that helps identify bank accounts in receipts + */ + company_id?: string; + + /** + * Date of Birth of the Individual that owns the external bank account + */ + dob?: string; + + doing_business_as?: string; + + /** + * The nickname given to this record of External Bank Account + */ + name?: string; +} + +export interface ExternalBankAccountUpdateResponse { + /** + * A globally unique identifier for this record of an external bank account + * association. If a program links an external bank account to more than one + * end-user or to both the program and the end-user, then Lithic will return each + * record of the association + */ + token: string; + + /** + * The country that the bank account is located in using ISO 3166-1. We will only + * accept US bank accounts e.g., US + */ + country: string; + + /** + * An ISO 8601 string representing when this funding source was added to the Lithic + * account. + */ + created: string; + + /** + * currency of the external account 3-digit alphabetic ISO 4217 code + */ + currency: string; + + /** + * The last 4 digits of the bank account. Derived by Lithic from the account number + * passed + */ + last_four: string; + + /** + * Legal Name of the business or individual who owns the external account. This + * will appear in statements + */ + owner: string; + + owner_type: 'INDIVIDUAL' | 'BUSINESS'; + + routing_number: string; + + state: 'ENABLED' | 'CLOSED' | 'PAUSED'; + + type: 'CHECKING' | 'SAVINGS'; + + verification_method: 'MANUAL' | 'MICRO_DEPOSIT' | 'PLAID'; + + verification_state: 'PENDING' | 'ENABLED' | 'FAILED_VERIFICATION'; + + /** + * Indicates which Lithic account the external account is associated with. For + * external accounts that are associated with the program, account_token field + * returned will be null + */ + account_token?: string; + + /** + * Address used during Address Verification Service (AVS) checks during + * transactions if enabled via Auth Rules. + */ + address?: ExternalBankAccountAddress; + + /** + * Optional field that helps identify bank accounts in receipts + */ + company_id?: string; + + /** + * Date of Birth of the Individual that owns the external bank account + */ + dob?: string; + + doing_business_as?: string; + + /** + * The nickname given to this record of External Bank Account + */ + name?: string; +} + +export interface ExternalBankAccountListResponse { + /** + * A globally unique identifier for this record of an external bank account + * association. If a program links an external bank account to more than one + * end-user or to both the program and the end-user, then Lithic will return each + * record of the association + */ + token: string; + + /** + * The country that the bank account is located in using ISO 3166-1. We will only + * accept US bank accounts e.g., US + */ + country: string; + + /** + * An ISO 8601 string representing when this funding source was added to the Lithic + * account. + */ + created: string; + + /** + * currency of the external account 3-digit alphabetic ISO 4217 code + */ + currency: string; + + /** + * The last 4 digits of the bank account. Derived by Lithic from the account number + * passed + */ + last_four: string; + + /** + * Legal Name of the business or individual who owns the external account. This + * will appear in statements + */ + owner: string; + + owner_type: 'INDIVIDUAL' | 'BUSINESS'; + + routing_number: string; + + state: 'ENABLED' | 'CLOSED' | 'PAUSED'; + + type: 'CHECKING' | 'SAVINGS'; + + verification_method: 'MANUAL' | 'MICRO_DEPOSIT' | 'PLAID'; + + verification_state: 'PENDING' | 'ENABLED' | 'FAILED_VERIFICATION'; + + /** + * Indicates which Lithic account the external account is associated with. For + * external accounts that are associated with the program, account_token field + * returned will be null + */ + account_token?: string; + + /** + * Address used during Address Verification Service (AVS) checks during + * transactions if enabled via Auth Rules. + */ + address?: ExternalBankAccountAddress; + + /** + * Optional field that helps identify bank accounts in receipts + */ + company_id?: string; + + /** + * Date of Birth of the Individual that owns the external bank account + */ + dob?: string; + + doing_business_as?: string; + + /** + * The nickname given to this record of External Bank Account + */ + name?: string; +} + +export type ExternalBankAccountCreateParams = + | ExternalBankAccountCreateParams.PlaidCreateBankAccountAPIRequest + | ExternalBankAccountCreateParams.BankVerifiedCreateBankAccountAPIRequest; + +export namespace ExternalBankAccountCreateParams { + export interface PlaidCreateBankAccountAPIRequest { + owner: string; + + owner_type: OwnerType; + + processor_token: string; + + verification_method: VerificationMethod; + + account_token?: string; + + company_id?: string; + + /** + * Date of Birth of the Individual that owns the external bank account + */ + dob?: string; + + doing_business_as?: string; + } + + export interface BankVerifiedCreateBankAccountAPIRequest { + account_number: string; + + country: string; + + currency: string; + + owner: string; + + owner_type: OwnerType; + + routing_number: string; + + type: 'CHECKING' | 'SAVINGS'; + + verification_method: VerificationMethod; + + account_token?: string; + + /** + * Address used during Address Verification Service (AVS) checks during + * transactions if enabled via Auth Rules. + */ + address?: ExternalBankAccountAddress; + + company_id?: string; + + /** + * Date of Birth of the Individual that owns the external bank account + */ + dob?: string; + + doing_business_as?: string; + + name?: string; + + /** + * Indicates whether verification was enforced for a given association record. For + * MICRO_DEPOSIT, option to disable verification if the external bank account has + * already been verified before. By default, verification will be required unless + * users pass in a value of false + */ + verification_enforcement?: boolean; + } +} + +export interface ExternalBankAccountUpdateParams { + /** + * Address used during Address Verification Service (AVS) checks during + * transactions if enabled via Auth Rules. + */ + address?: ExternalBankAccountAddress; + + company_id?: string; + + /** + * Date of Birth of the Individual that owns the external bank account + */ + dob?: string; + + doing_business_as?: string; + + name?: string; + + owner?: string; + + owner_type?: OwnerType; +} + +export interface ExternalBankAccountListParams extends CursorPageParams { + account_token?: string; + + account_types?: Array<'CHECKING' | 'SAVINGS'>; + + countries?: Array; + + owner_types?: Array; + + states?: Array<'ENABLED' | 'CLOSED' | 'PAUSED'>; + + verification_states?: Array<'PENDING' | 'ENABLED' | 'FAILED_VERIFICATION'>; +} + +export namespace ExternalBankAccounts { + export import ExternalBankAccountAddress = API.ExternalBankAccountAddress; + export import OwnerType = API.OwnerType; + export import VerificationMethod = API.VerificationMethod; + export import ExternalBankAccountCreateResponse = API.ExternalBankAccountCreateResponse; + export import ExternalBankAccountRetrieveResponse = API.ExternalBankAccountRetrieveResponse; + export import ExternalBankAccountUpdateResponse = API.ExternalBankAccountUpdateResponse; + export import ExternalBankAccountListResponse = API.ExternalBankAccountListResponse; + export type ExternalBankAccountListResponsesCursorPage = _ExternalBankAccountListResponsesCursorPage; + export import ExternalBankAccountCreateParams = API.ExternalBankAccountCreateParams; + export import ExternalBankAccountUpdateParams = API.ExternalBankAccountUpdateParams; + export import ExternalBankAccountListParams = API.ExternalBankAccountListParams; + + export import MicroDeposits = API.MicroDeposits; + export import MicroDepositCreateResponse = API.MicroDepositCreateResponse; + export import MicroDepositCreateParams = API.MicroDepositCreateParams; +} diff --git a/src/resources/external-bank-accounts/index.ts b/src/resources/external-bank-accounts/index.ts new file mode 100644 index 00000000..3b49eb2d --- /dev/null +++ b/src/resources/external-bank-accounts/index.ts @@ -0,0 +1,17 @@ +// File generated from our OpenAPI spec by Stainless. + +export { + ExternalBankAccountAddress, + OwnerType, + VerificationMethod, + ExternalBankAccountCreateResponse, + ExternalBankAccountRetrieveResponse, + ExternalBankAccountUpdateResponse, + ExternalBankAccountListResponse, + ExternalBankAccountCreateParams, + ExternalBankAccountUpdateParams, + ExternalBankAccountListParams, + ExternalBankAccountListResponsesCursorPage, + ExternalBankAccounts, +} from './external-bank-accounts'; +export { MicroDepositCreateResponse, MicroDepositCreateParams, MicroDeposits } from './micro-deposits'; diff --git a/src/resources/external-bank-accounts/micro-deposits.ts b/src/resources/external-bank-accounts/micro-deposits.ts new file mode 100644 index 00000000..86a9822d --- /dev/null +++ b/src/resources/external-bank-accounts/micro-deposits.ts @@ -0,0 +1,112 @@ +// File generated from our OpenAPI spec by Stainless. + +import * as Core from 'lithic/core'; +import { APIResource } from 'lithic/resource'; +import * as ExternalBankAccounts from 'lithic/resources/external-bank-accounts/index'; +import * as API from './'; + +export class MicroDeposits extends APIResource { + /** + * Verify the external bank account by providing the micro deposit amounts. + */ + create( + externalBankAccountToken: string, + body: MicroDepositCreateParams, + options?: Core.RequestOptions, + ): Promise> { + return this.post(`/external_bank_accounts/${externalBankAccountToken}/micro_deposits`, { + body, + ...options, + }); + } +} + +export interface MicroDepositCreateResponse { + /** + * A globally unique identifier for this record of an external bank account + * association. If a program links an external bank account to more than one + * end-user or to both the program and the end-user, then Lithic will return each + * record of the association + */ + token: string; + + /** + * The country that the bank account is located in using ISO 3166-1. We will only + * accept US bank accounts e.g., US + */ + country: string; + + /** + * An ISO 8601 string representing when this funding source was added to the Lithic + * account. + */ + created: string; + + /** + * currency of the external account 3-digit alphabetic ISO 4217 code + */ + currency: string; + + /** + * The last 4 digits of the bank account. Derived by Lithic from the account number + * passed + */ + last_four: string; + + /** + * Legal Name of the business or individual who owns the external account. This + * will appear in statements + */ + owner: string; + + owner_type: 'INDIVIDUAL' | 'BUSINESS'; + + routing_number: string; + + state: 'ENABLED' | 'CLOSED' | 'PAUSED'; + + type: 'CHECKING' | 'SAVINGS'; + + verification_method: 'MANUAL' | 'MICRO_DEPOSIT' | 'PLAID'; + + verification_state: 'PENDING' | 'ENABLED' | 'FAILED_VERIFICATION'; + + /** + * Indicates which Lithic account the external account is associated with. For + * external accounts that are associated with the program, account_token field + * returned will be null + */ + account_token?: string; + + /** + * Address used during Address Verification Service (AVS) checks during + * transactions if enabled via Auth Rules. + */ + address?: ExternalBankAccounts.ExternalBankAccountAddress; + + /** + * Optional field that helps identify bank accounts in receipts + */ + company_id?: string; + + /** + * Date of Birth of the Individual that owns the external bank account + */ + dob?: string; + + doing_business_as?: string; + + /** + * The nickname given to this record of External Bank Account + */ + name?: string; +} + +export interface MicroDepositCreateParams { + micro_deposits: Array; +} + +export namespace MicroDeposits { + export import MicroDepositCreateResponse = API.MicroDepositCreateResponse; + export import MicroDepositCreateParams = API.MicroDepositCreateParams; +} diff --git a/src/resources/financial-accounts/financial-accounts.ts b/src/resources/financial-accounts/financial-accounts.ts index de402202..ef4dbe77 100644 --- a/src/resources/financial-accounts/financial-accounts.ts +++ b/src/resources/financial-accounts/financial-accounts.ts @@ -79,7 +79,7 @@ export interface FinancialTransaction { /** * Globally unique identifier. */ - token?: string; + token: string; /** * Status types: @@ -89,47 +89,47 @@ export interface FinancialTransaction { * - `TRANSFER` - Internal transfer of funds between financial accounts in your * program. */ - category?: 'CARD' | 'ACH' | 'TRANSFER'; + category: 'CARD' | 'ACH' | 'TRANSFER'; /** * Date and time when the financial transaction first occurred. UTC time zone. */ - created?: string; + created: string; /** * 3-digit alphabetic ISO 4217 code for the settling currency of the transaction. */ - currency?: string; + currency: string; /** * A string that provides a description of the financial transaction; may be useful * to display to users. */ - descriptor?: string; + descriptor: string; /** * A list of all financial events that have modified this financial transaction. */ - events?: Array; + events: Array; /** * Pending amount of the transaction in the currency's smallest unit (e.g., cents), * including any acquirer fees. The value of this field will go to zero over time * once the financial transaction is settled. */ - pending_amount?: number; + pending_amount: number; /** * APPROVED transactions were successful while DECLINED transactions were declined * by user, Lithic, or the network. */ - result?: 'APPROVED' | 'DECLINED'; + result: 'APPROVED' | 'DECLINED'; /** * Amount of the transaction that has been settled in the currency's smallest unit * (e.g., cents), including any acquirer fees. This may change over time. */ - settled_amount?: number; + settled_amount: number; /** * Status types: @@ -142,12 +142,12 @@ export interface FinancialTransaction { * - `SETTLED` - The financial transaction is completed. * - `VOIDED` - The merchant has voided the previously pending card authorization. */ - status?: 'DECLINED' | 'EXPIRED' | 'PENDING' | 'SETTLED' | 'VOIDED'; + status: 'DECLINED' | 'EXPIRED' | 'PENDING' | 'SETTLED' | 'VOIDED'; /** * Date and time when the financial transaction was last updated. UTC time zone. */ - updated?: string; + updated: string; } export namespace FinancialTransaction { diff --git a/src/resources/index.ts b/src/resources/index.ts index a5f3595d..44f1c5f9 100644 --- a/src/resources/index.ts +++ b/src/resources/index.ts @@ -89,6 +89,20 @@ export { EventsCursorPage, Events, } from './events/events'; +export { + ExternalBankAccountAddress, + OwnerType, + VerificationMethod, + ExternalBankAccountCreateResponse, + ExternalBankAccountRetrieveResponse, + ExternalBankAccountUpdateResponse, + ExternalBankAccountListResponse, + ExternalBankAccountCreateParams, + ExternalBankAccountUpdateParams, + ExternalBankAccountListParams, + ExternalBankAccountListResponsesCursorPage, + ExternalBankAccounts, +} from './external-bank-accounts/external-bank-accounts'; export { FinancialAccount, FinancialTransaction, @@ -97,6 +111,16 @@ export { FinancialAccountsSinglePage, FinancialAccounts, } from './financial-accounts/financial-accounts'; +export { + Payment, + PaymentCreateResponse, + PaymentSimulateReleaseResponse, + PaymentCreateParams, + PaymentListParams, + PaymentSimulateReleaseParams, + PaymentsCursorPage, + Payments, +} from './payments'; export { ResponderEndpointStatus, ResponderEndpointCreateResponse, diff --git a/src/resources/payments.ts b/src/resources/payments.ts new file mode 100644 index 00000000..6ed0157b --- /dev/null +++ b/src/resources/payments.ts @@ -0,0 +1,158 @@ +// File generated from our OpenAPI spec by Stainless. + +import * as Core from 'lithic/core'; +import { APIResource } from 'lithic/resource'; +import { isRequestOptions } from 'lithic/core'; +import * as FinancialAccounts from 'lithic/resources/financial-accounts/index'; +import * as Balances from 'lithic/resources/balances'; +import * as API from './'; +import { CursorPage, CursorPageParams } from 'lithic/pagination'; + +export class Payments extends APIResource { + /** + * Initiates a payment between a financial account and an external bank account. + */ + create( + body: PaymentCreateParams, + options?: Core.RequestOptions, + ): Promise> { + return this.post('/payments', { body, ...options }); + } + + /** + * Get the payment by token. + */ + retrieve(paymentToken: string, options?: Core.RequestOptions): Promise> { + return this.get(`/payments/${paymentToken}`, options); + } + + /** + * List all the payments for the provided search criteria. + */ + list(query?: PaymentListParams, options?: Core.RequestOptions): Core.PagePromise; + list(options?: Core.RequestOptions): Core.PagePromise; + list( + query: PaymentListParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.PagePromise { + if (isRequestOptions(query)) { + return this.list({}, query); + } + return this.getAPIList('/payments', PaymentsCursorPage, { query, ...options }); + } + + /** + * Simulates a release of a Payment. + */ + simulateRelease( + body: PaymentSimulateReleaseParams, + options?: Core.RequestOptions, + ): Promise> { + return this.post('/simulate/payments/release', { body, ...options }); + } +} + +export class PaymentsCursorPage extends CursorPage {} +// alias so we can export it in the namespace +type _PaymentsCursorPage = PaymentsCursorPage; + +export interface Payment extends FinancialAccounts.FinancialTransaction { + direction: 'CREDIT' | 'DEBIT'; + + method: 'ACH_NEXT_DAY' | 'ACH_SAME_DAY'; + + method_attributes: Payment.MethodAttributes; + + source: 'LITHIC' | 'CUSTOMER'; + + external_bank_account_token?: string; + + user_defined_id?: string; +} + +export namespace Payment { + export interface MethodAttributes { + sec_code: 'PPD' | 'CCD' | 'WEB'; + } +} + +export interface PaymentCreateResponse extends FinancialAccounts.FinancialTransaction { + direction: 'CREDIT' | 'DEBIT'; + + method: 'ACH_NEXT_DAY' | 'ACH_SAME_DAY'; + + method_attributes: PaymentCreateResponse.MethodAttributes; + + source: 'LITHIC' | 'CUSTOMER'; + + /** + * Balance of a Financial Account + */ + balance?: Balances.Balance; + + external_bank_account_token?: string; + + user_defined_id?: string; +} + +export namespace PaymentCreateResponse { + export interface MethodAttributes { + sec_code: 'PPD' | 'CCD' | 'WEB'; + } +} + +export interface PaymentSimulateReleaseResponse { + debugging_request_id?: string; + + result?: 'APPROVED' | 'DECLINED'; + + transaction_event_token?: string; +} + +export interface PaymentCreateParams { + amount: number; + + external_bank_account_token: string; + + financial_account_token: string; + + method: 'ACH_NEXT_DAY' | 'ACH_SAME_DAY'; + + method_attributes: PaymentCreateParams.MethodAttributes; + + type: 'PAYMENT' | 'COLLECTION'; + + token?: string; + + memo?: string; + + user_defined_id?: string; +} + +export namespace PaymentCreateParams { + export interface MethodAttributes { + sec_code: 'PPD' | 'CCD' | 'WEB'; + } +} + +export interface PaymentListParams extends CursorPageParams { + financial_account_token?: string; + + result?: 'APPROVED' | 'DECLINED'; + + status?: 'PENDING' | 'VOIDED' | 'SETTLED' | 'DECLINED' | 'EXPIRED'; +} + +export interface PaymentSimulateReleaseParams { + payment_token: string; +} + +export namespace Payments { + export import Payment = API.Payment; + export import PaymentCreateResponse = API.PaymentCreateResponse; + export import PaymentSimulateReleaseResponse = API.PaymentSimulateReleaseResponse; + export type PaymentsCursorPage = _PaymentsCursorPage; + export import PaymentCreateParams = API.PaymentCreateParams; + export import PaymentListParams = API.PaymentListParams; + export import PaymentSimulateReleaseParams = API.PaymentSimulateReleaseParams; +} diff --git a/src/resources/transactions.ts b/src/resources/transactions.ts index c7b5d1eb..412800a1 100644 --- a/src/resources/transactions.ts +++ b/src/resources/transactions.ts @@ -242,7 +242,7 @@ export interface Transaction { * - `SETTLED` - The transaction is complete. * - `VOIDED` - The merchant has voided the previously pending authorization. */ - status: 'BOUNCED' | 'DECLINED' | 'EXPIRED' | 'PENDING' | 'SETTLED' | 'SETTLING' | 'VOIDED'; + status: 'BOUNCED' | 'DECLINED' | 'EXPIRED' | 'PENDING' | 'SETTLED' | 'VOIDED'; cardholder_authentication?: Transaction.CardholderAuthentication | null; } diff --git a/tests/api-resources/external-bank-accounts/external-bank-accounts.test.ts b/tests/api-resources/external-bank-accounts/external-bank-accounts.test.ts new file mode 100644 index 00000000..76577814 --- /dev/null +++ b/tests/api-resources/external-bank-accounts/external-bank-accounts.test.ts @@ -0,0 +1,77 @@ +// File generated from our OpenAPI spec by Stainless. + +import Lithic from 'lithic'; + +const lithic = new Lithic({ apiKey: 'something1234', baseURL: 'http://127.0.0.1:4010' }); + +describe('resource externalBankAccounts', () => { + test('create: only required params', async () => { + const response = await lithic.externalBankAccounts.create({ + owner: 'x', + owner_type: 'INDIVIDUAL', + processor_token: 'x', + verification_method: 'MANUAL', + }); + }); + + test('create: required and optional params', async () => { + const response = await lithic.externalBankAccounts.create({ + owner: 'x', + owner_type: 'INDIVIDUAL', + processor_token: 'x', + verification_method: 'MANUAL', + account_token: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + company_id: 'x', + dob: '2019-12-27', + doing_business_as: 'string', + }); + }); + + test('retrieve', async () => { + const response = await lithic.externalBankAccounts.retrieve('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'); + }); + + test('retrieve: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + lithic.externalBankAccounts.retrieve('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { + path: '/_stainless_unknown_path', + }), + ).rejects.toThrow(Lithic.NotFoundError); + }); + + test('update', async () => { + const response = await lithic.externalBankAccounts.update('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {}); + }); + + test('list', async () => { + const response = await lithic.externalBankAccounts.list(); + }); + + test('list: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect(lithic.externalBankAccounts.list({ path: '/_stainless_unknown_path' })).rejects.toThrow( + Lithic.NotFoundError, + ); + }); + + test('list: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + lithic.externalBankAccounts.list( + { + account_token: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + account_types: ['CHECKING', 'CHECKING', 'CHECKING'], + countries: ['string', 'string', 'string'], + ending_before: 'string', + owner_types: ['INDIVIDUAL', 'INDIVIDUAL', 'INDIVIDUAL'], + page_size: 1, + starting_after: 'string', + states: ['ENABLED', 'ENABLED', 'ENABLED'], + verification_states: ['PENDING', 'PENDING', 'PENDING'], + }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Lithic.NotFoundError); + }); +}); diff --git a/tests/api-resources/external-bank-accounts/micro-deposits.test.ts b/tests/api-resources/external-bank-accounts/micro-deposits.test.ts new file mode 100644 index 00000000..66a016bc --- /dev/null +++ b/tests/api-resources/external-bank-accounts/micro-deposits.test.ts @@ -0,0 +1,21 @@ +// File generated from our OpenAPI spec by Stainless. + +import Lithic from 'lithic'; + +const lithic = new Lithic({ apiKey: 'something1234', baseURL: 'http://127.0.0.1:4010' }); + +describe('resource microDeposits', () => { + test('create: only required params', async () => { + const response = await lithic.externalBankAccounts.microDeposits.create( + '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + { micro_deposits: [0, 0, 0] }, + ); + }); + + test('create: required and optional params', async () => { + const response = await lithic.externalBankAccounts.microDeposits.create( + '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + { micro_deposits: [0, 0, 0] }, + ); + }); +}); diff --git a/tests/api-resources/payments.test.ts b/tests/api-resources/payments.test.ts new file mode 100644 index 00000000..c5a17508 --- /dev/null +++ b/tests/api-resources/payments.test.ts @@ -0,0 +1,83 @@ +// File generated from our OpenAPI spec by Stainless. + +import Lithic from 'lithic'; + +const lithic = new Lithic({ apiKey: 'something1234', baseURL: 'http://127.0.0.1:4010' }); + +describe('resource payments', () => { + test('create: only required params', async () => { + const response = await lithic.payments.create({ + amount: 1, + external_bank_account_token: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + financial_account_token: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + method: 'ACH_NEXT_DAY', + method_attributes: { sec_code: 'PPD' }, + type: 'PAYMENT', + }); + }); + + test('create: required and optional params', async () => { + const response = await lithic.payments.create({ + amount: 1, + external_bank_account_token: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + financial_account_token: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + method: 'ACH_NEXT_DAY', + method_attributes: { sec_code: 'PPD' }, + type: 'PAYMENT', + token: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + memo: 'string', + user_defined_id: 'string', + }); + }); + + test('retrieve', async () => { + const response = await lithic.payments.retrieve('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'); + }); + + test('retrieve: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + lithic.payments.retrieve('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Lithic.NotFoundError); + }); + + test('list', async () => { + const response = await lithic.payments.list(); + }); + + test('list: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect(lithic.payments.list({ path: '/_stainless_unknown_path' })).rejects.toThrow( + Lithic.NotFoundError, + ); + }); + + test('list: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + lithic.payments.list( + { + ending_before: 'string', + financial_account_token: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + page_size: 1, + result: 'APPROVED', + starting_after: 'string', + status: 'PENDING', + }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Lithic.NotFoundError); + }); + + test('simulateRelease: only required params', async () => { + const response = await lithic.payments.simulateRelease({ + payment_token: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + }); + }); + + test('simulateRelease: required and optional params', async () => { + const response = await lithic.payments.simulateRelease({ + payment_token: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + }); + }); +});