diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 5056a444..a579a434 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.98.1" + ".": "0.99.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 315b0f37..ddb484b7 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 176 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic%2Flithic-abe6a4f82f696099fa8ecb1cc44f08979e17d56578ae7ea68b0e9182e21df508.yml -openapi_spec_hash: d2ce51592a9a234c6f34a1168a31f91f -config_hash: 2b2786c821f62db49cc630ba45329336 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic%2Flithic-4ecc06edca2cfad4eaf11573611e89823fda5f56370bac5cd02a498a6b277d09.yml +openapi_spec_hash: 8f4a30bec4348cbde85b1e65bef9189a +config_hash: 9dddee5f7af579864599849cb28a0770 diff --git a/CHANGELOG.md b/CHANGELOG.md index cce06fa1..c5ae044c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,39 @@ # Changelog +## 0.99.0 (2026-01-08) + +Full Changelog: [v0.98.1...v0.99.0](https://github.com/lithic-com/lithic-go/compare/v0.98.1...v0.99.0) + +### Features + +* **api:** Add card state attribute to tokenization rules ([d2a631a](https://github.com/lithic-com/lithic-go/commit/d2a631ab05d150bdb92e64b9852e7d2cac0ac2c4)) +* **api:** Add event_type to ASA request and 3DS decisioning request ([d2a631a](https://github.com/lithic-com/lithic-go/commit/d2a631ab05d150bdb92e64b9852e7d2cac0ac2c4)) +* **api:** add external_id to payment_event ([f42a314](https://github.com/lithic-com/lithic-go/commit/f42a31473d6cc020a3e7da98976258de4831883e)) +* **api:** add get /v1/transfer_limits endpoint ([f42a314](https://github.com/lithic-com/lithic-go/commit/f42a31473d6cc020a3e7da98976258de4831883e)) +* **api:** add post /v1/book_transfers/{book_transfer_token}/retry endpoint ([f42a314](https://github.com/lithic-com/lithic-go/commit/f42a31473d6cc020a3e7da98976258de4831883e)) +* **api:** Add user defined status to ledger accounts ([d2a631a](https://github.com/lithic-com/lithic-go/commit/d2a631ab05d150bdb92e64b9852e7d2cac0ac2c4)) +* **api:** add WIRE_DRAWDOWN_REQUEST transfer type ([9015ffc](https://github.com/lithic-com/lithic-go/commit/9015ffcce5361aa50cc171ce720b00adda0987ad)) +* **api:** Expose Payment Allocation Details ([d2a631a](https://github.com/lithic-com/lithic-go/commit/d2a631ab05d150bdb92e64b9852e7d2cac0ac2c4)) +* **api:** remove unnecessary X-Lithic-Pagination header ([9015ffc](https://github.com/lithic-com/lithic-go/commit/9015ffcce5361aa50cc171ce720b00adda0987ad)) +* **api:** remove v1/aggregate_balances and related models ([da86140](https://github.com/lithic-com/lithic-go/commit/da861407f17db3494fcbece040e8b695cc4ec7f4)) + + +### Bug Fixes + +* **api:** don't mark timestamp parsing as loose when a fallback format succeeds ([78776e3](https://github.com/lithic-com/lithic-go/commit/78776e39e5470b4951dd59da77f706f18ce14861)) + + +### Chores + +* **internal:** codegen related update ([0ddba7d](https://github.com/lithic-com/lithic-go/commit/0ddba7d03aaca11c6ee445ea81ce731421ff2aeb)) +* update code formatting ([d2a631a](https://github.com/lithic-com/lithic-go/commit/d2a631ab05d150bdb92e64b9852e7d2cac0ac2c4)) + + +### Documentation + +* **api:** clarify description of token / retry_token when it serves as idempotency key ([9015ffc](https://github.com/lithic-com/lithic-go/commit/9015ffcce5361aa50cc171ce720b00adda0987ad)) +* Update language for Google Web Push Provisioning docs ([d2a631a](https://github.com/lithic-com/lithic-go/commit/d2a631ab05d150bdb92e64b9852e7d2cac0ac2c4)) + ## 0.98.1 (2025-12-12) Full Changelog: [v0.98.0...v0.98.1](https://github.com/lithic-com/lithic-go/compare/v0.98.0...v0.98.1) diff --git a/LICENSE b/LICENSE index 06eee64e..9410347b 100644 --- a/LICENSE +++ b/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2025 Lithic + Copyright 2026 Lithic Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/README.md b/README.md index e82d02ec..6c604fd9 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Or to pin the version: ```sh -go get -u 'github.com/lithic-com/lithic-go@v0.98.1' +go get -u 'github.com/lithic-com/lithic-go@v0.99.0' ``` diff --git a/accountactivity.go b/accountactivity.go index 242c48b6..d763e048 100644 --- a/accountactivity.go +++ b/accountactivity.go @@ -794,11 +794,12 @@ const ( AccountActivityListResponseTypeWireInboundAdmin AccountActivityListResponseType = "WIRE_INBOUND_ADMIN" AccountActivityListResponseTypeWireOutboundPayment AccountActivityListResponseType = "WIRE_OUTBOUND_PAYMENT" AccountActivityListResponseTypeWireOutboundAdmin AccountActivityListResponseType = "WIRE_OUTBOUND_ADMIN" + AccountActivityListResponseTypeWireDrawdownRequest AccountActivityListResponseType = "WIRE_DRAWDOWN_REQUEST" ) func (r AccountActivityListResponseType) IsKnown() bool { switch r { - case AccountActivityListResponseTypeOriginationCredit, AccountActivityListResponseTypeOriginationDebit, AccountActivityListResponseTypeReceiptCredit, AccountActivityListResponseTypeReceiptDebit, AccountActivityListResponseTypeWireInboundPayment, AccountActivityListResponseTypeWireInboundAdmin, AccountActivityListResponseTypeWireOutboundPayment, AccountActivityListResponseTypeWireOutboundAdmin: + case AccountActivityListResponseTypeOriginationCredit, AccountActivityListResponseTypeOriginationDebit, AccountActivityListResponseTypeReceiptCredit, AccountActivityListResponseTypeReceiptDebit, AccountActivityListResponseTypeWireInboundPayment, AccountActivityListResponseTypeWireInboundAdmin, AccountActivityListResponseTypeWireOutboundPayment, AccountActivityListResponseTypeWireOutboundAdmin, AccountActivityListResponseTypeWireDrawdownRequest: return true } return false @@ -1494,11 +1495,12 @@ const ( AccountActivityGetTransactionResponseTypeWireInboundAdmin AccountActivityGetTransactionResponseType = "WIRE_INBOUND_ADMIN" AccountActivityGetTransactionResponseTypeWireOutboundPayment AccountActivityGetTransactionResponseType = "WIRE_OUTBOUND_PAYMENT" AccountActivityGetTransactionResponseTypeWireOutboundAdmin AccountActivityGetTransactionResponseType = "WIRE_OUTBOUND_ADMIN" + AccountActivityGetTransactionResponseTypeWireDrawdownRequest AccountActivityGetTransactionResponseType = "WIRE_DRAWDOWN_REQUEST" ) func (r AccountActivityGetTransactionResponseType) IsKnown() bool { switch r { - case AccountActivityGetTransactionResponseTypeOriginationCredit, AccountActivityGetTransactionResponseTypeOriginationDebit, AccountActivityGetTransactionResponseTypeReceiptCredit, AccountActivityGetTransactionResponseTypeReceiptDebit, AccountActivityGetTransactionResponseTypeWireInboundPayment, AccountActivityGetTransactionResponseTypeWireInboundAdmin, AccountActivityGetTransactionResponseTypeWireOutboundPayment, AccountActivityGetTransactionResponseTypeWireOutboundAdmin: + case AccountActivityGetTransactionResponseTypeOriginationCredit, AccountActivityGetTransactionResponseTypeOriginationDebit, AccountActivityGetTransactionResponseTypeReceiptCredit, AccountActivityGetTransactionResponseTypeReceiptDebit, AccountActivityGetTransactionResponseTypeWireInboundPayment, AccountActivityGetTransactionResponseTypeWireInboundAdmin, AccountActivityGetTransactionResponseTypeWireOutboundPayment, AccountActivityGetTransactionResponseTypeWireOutboundAdmin, AccountActivityGetTransactionResponseTypeWireDrawdownRequest: return true } return false diff --git a/aggregatebalance.go b/aggregatebalance.go deleted file mode 100644 index b8c6c087..00000000 --- a/aggregatebalance.go +++ /dev/null @@ -1,166 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -package lithic - -import ( - "context" - "net/http" - "net/url" - "slices" - "time" - - "github.com/lithic-com/lithic-go/internal/apijson" - "github.com/lithic-com/lithic-go/internal/apiquery" - "github.com/lithic-com/lithic-go/internal/param" - "github.com/lithic-com/lithic-go/internal/requestconfig" - "github.com/lithic-com/lithic-go/option" - "github.com/lithic-com/lithic-go/packages/pagination" -) - -// AggregateBalanceService contains methods and other services that help with -// interacting with the lithic API. -// -// Note, unlike clients, this service does not read variables from the environment -// automatically. You should not instantiate this service directly, and instead use -// the [NewAggregateBalanceService] method instead. -type AggregateBalanceService struct { - Options []option.RequestOption -} - -// NewAggregateBalanceService generates a new service that applies the given -// options to each request. These options are applied after the parent client's -// options (if there is one), and before any request-specific options. -func NewAggregateBalanceService(opts ...option.RequestOption) (r *AggregateBalanceService) { - r = &AggregateBalanceService{} - r.Options = opts - return -} - -// Get the aggregated balance across all end-user accounts by financial account -// type -func (r *AggregateBalanceService) List(ctx context.Context, query AggregateBalanceListParams, opts ...option.RequestOption) (res *pagination.SinglePage[AggregateBalance], err error) { - var raw *http.Response - opts = slices.Concat(r.Options, opts) - opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) - path := "v1/aggregate_balances" - cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) - if err != nil { - return nil, err - } - err = cfg.Execute() - if err != nil { - return nil, err - } - res.SetPageConfig(cfg, raw) - return res, nil -} - -// Get the aggregated balance across all end-user accounts by financial account -// type -func (r *AggregateBalanceService) ListAutoPaging(ctx context.Context, query AggregateBalanceListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[AggregateBalance] { - return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) -} - -// Aggregate Balance across all end-user accounts -type AggregateBalance struct { - // Funds available for spend in the currency's smallest unit (e.g., cents for USD) - AvailableAmount int64 `json:"available_amount,required"` - // Date and time for when the balance was first created. - Created time.Time `json:"created,required" format:"date-time"` - // 3-character alphabetic ISO 4217 code for the local currency of the balance. - Currency string `json:"currency,required"` - // Type of financial account - FinancialAccountType AggregateBalanceFinancialAccountType `json:"financial_account_type,required"` - // Globally unique identifier for the financial account that had its balance - // updated most recently - LastFinancialAccountToken string `json:"last_financial_account_token,required" format:"uuid"` - // Globally unique identifier for the last transaction event that impacted this - // balance - LastTransactionEventToken string `json:"last_transaction_event_token,required" format:"uuid"` - // Globally unique identifier for the last transaction that impacted this balance - LastTransactionToken string `json:"last_transaction_token,required" format:"uuid"` - // Funds not available for spend due to card authorizations or pending ACH release. - // Shown in the currency's smallest unit (e.g., cents for USD) - PendingAmount int64 `json:"pending_amount,required"` - // The sum of available and pending balance in the currency's smallest unit (e.g., - // cents for USD) - TotalAmount int64 `json:"total_amount,required"` - // Date and time for when the balance was last updated. - Updated time.Time `json:"updated,required" format:"date-time"` - JSON aggregateBalanceJSON `json:"-"` -} - -// aggregateBalanceJSON contains the JSON metadata for the struct -// [AggregateBalance] -type aggregateBalanceJSON struct { - AvailableAmount apijson.Field - Created apijson.Field - Currency apijson.Field - FinancialAccountType apijson.Field - LastFinancialAccountToken apijson.Field - LastTransactionEventToken apijson.Field - LastTransactionToken apijson.Field - PendingAmount apijson.Field - TotalAmount apijson.Field - Updated apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AggregateBalance) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r aggregateBalanceJSON) RawJSON() string { - return r.raw -} - -// Type of financial account -type AggregateBalanceFinancialAccountType string - -const ( - AggregateBalanceFinancialAccountTypeIssuing AggregateBalanceFinancialAccountType = "ISSUING" - AggregateBalanceFinancialAccountTypeOperating AggregateBalanceFinancialAccountType = "OPERATING" - AggregateBalanceFinancialAccountTypeReserve AggregateBalanceFinancialAccountType = "RESERVE" - AggregateBalanceFinancialAccountTypeSecurity AggregateBalanceFinancialAccountType = "SECURITY" -) - -func (r AggregateBalanceFinancialAccountType) IsKnown() bool { - switch r { - case AggregateBalanceFinancialAccountTypeIssuing, AggregateBalanceFinancialAccountTypeOperating, AggregateBalanceFinancialAccountTypeReserve, AggregateBalanceFinancialAccountTypeSecurity: - return true - } - return false -} - -type AggregateBalanceListParams struct { - // Get the aggregate balance for a given Financial Account type. - FinancialAccountType param.Field[AggregateBalanceListParamsFinancialAccountType] `query:"financial_account_type"` -} - -// URLQuery serializes [AggregateBalanceListParams]'s query parameters as -// `url.Values`. -func (r AggregateBalanceListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Get the aggregate balance for a given Financial Account type. -type AggregateBalanceListParamsFinancialAccountType string - -const ( - AggregateBalanceListParamsFinancialAccountTypeIssuing AggregateBalanceListParamsFinancialAccountType = "ISSUING" - AggregateBalanceListParamsFinancialAccountTypeOperating AggregateBalanceListParamsFinancialAccountType = "OPERATING" - AggregateBalanceListParamsFinancialAccountTypeReserve AggregateBalanceListParamsFinancialAccountType = "RESERVE" - AggregateBalanceListParamsFinancialAccountTypeSecurity AggregateBalanceListParamsFinancialAccountType = "SECURITY" -) - -func (r AggregateBalanceListParamsFinancialAccountType) IsKnown() bool { - switch r { - case AggregateBalanceListParamsFinancialAccountTypeIssuing, AggregateBalanceListParamsFinancialAccountTypeOperating, AggregateBalanceListParamsFinancialAccountTypeReserve, AggregateBalanceListParamsFinancialAccountTypeSecurity: - return true - } - return false -} diff --git a/api.md b/api.md index 02d74de2..905505d9 100644 --- a/api.md +++ b/api.md @@ -211,16 +211,6 @@ Methods: - client.Cards.GetEmbedHTML(ctx context.Context, params lithic.CardGetEmbedHTMLParams) ([]byte, error) - client.Cards.GetEmbedURL(ctx context.Context, params lithic.CardGetEmbedURLParams) (\*url.URL, error) -## AggregateBalances - -Response Types: - -- lithic.CardAggregateBalanceListResponse - -Methods: - -- client.Cards.AggregateBalances.List(ctx context.Context, query lithic.CardAggregateBalanceListParams) (pagination.SinglePage[lithic.CardAggregateBalanceListResponse], error) - ## Balances Methods: @@ -257,16 +247,6 @@ Methods: - client.Balances.List(ctx context.Context, query lithic.BalanceListParams) (pagination.SinglePage[lithic.Balance], error) -# AggregateBalances - -Response Types: - -- lithic.AggregateBalance - -Methods: - -- client.AggregateBalances.List(ctx context.Context, query lithic.AggregateBalanceListParams) (pagination.SinglePage[lithic.AggregateBalance], error) - # Disputes Response Types: @@ -651,6 +631,7 @@ Methods: - client.BookTransfers.New(ctx context.Context, body lithic.BookTransferNewParams) (lithic.BookTransferResponse, error) - client.BookTransfers.Get(ctx context.Context, bookTransferToken string) (lithic.BookTransferResponse, error) - client.BookTransfers.List(ctx context.Context, query lithic.BookTransferListParams) (pagination.CursorPage[lithic.BookTransferResponse], error) +- client.BookTransfers.Retry(ctx context.Context, bookTransferToken string, body lithic.BookTransferRetryParams) (lithic.BookTransferResponse, error) - client.BookTransfers.Reverse(ctx context.Context, bookTransferToken string, body lithic.BookTransferReverseParams) (lithic.BookTransferResponse, error) # CreditProducts @@ -764,6 +745,16 @@ Methods: - client.AccountActivity.List(ctx context.Context, query lithic.AccountActivityListParams) (pagination.CursorPage[lithic.AccountActivityListResponse], error) - client.AccountActivity.GetTransaction(ctx context.Context, transactionToken string) (lithic.AccountActivityGetTransactionResponse, error) +# TransferLimits + +Response Types: + +- lithic.TransferLimitsResponse + +Methods: + +- client.TransferLimits.List(ctx context.Context, query lithic.TransferLimitListParams) (pagination.SinglePage[lithic.TransferLimitsResponseData], error) + # Webhooks Response Types: @@ -772,7 +763,7 @@ Response Types: - lithic.AccountHolderUpdatedWebhookEvent - lithic.AccountHolderVerificationWebhookEvent - lithic.AccountHolderDocumentUpdatedWebhookEvent -- lithic.AsaRequestWebhookEvent +- lithic.CardAuthorizationApprovalRequestWebhookEvent - lithic.TokenizationDecisioningRequestWebhookEvent - lithic.AuthRulesBacktestReportCreatedWebhookEvent - lithic.BalanceUpdatedWebhookEvent @@ -820,6 +811,7 @@ Response Types: - lithic.TokenizationTwoFactorAuthenticationCodeWebhookEvent - lithic.TokenizationTwoFactorAuthenticationCodeSentWebhookEvent - lithic.TokenizationUpdatedWebhookEvent +- lithic.ThreeDSAuthenticationApprovalRequestWebhookEvent - lithic.DisputeTransactionCreatedWebhookEvent - lithic.DisputeTransactionUpdatedWebhookEvent - lithic.ParsedWebhookEvent diff --git a/authrulev2.go b/authrulev2.go index 8ebfaaa2..07c5b099 100644 --- a/authrulev2.go +++ b/authrulev2.go @@ -2014,6 +2014,8 @@ type ConditionalTokenizationActionParametersCondition struct { // `TOO_MANY_RECENT_TOKENS`, `UNABLE_TO_ASSESS`. // - `TOKEN_REQUESTOR_ID`: Unique identifier for the entity requesting the token. // - `WALLET_TOKEN_STATUS`: The current status of the wallet token. + // - `CARD_STATE`: The state of the card being tokenized. Valid values are + // `CLOSED`, `OPEN`, `PAUSED`, `PENDING_ACTIVATION`, `PENDING_FULFILLMENT`. Attribute ConditionalTokenizationActionParametersConditionsAttribute `json:"attribute,required"` // The operation to apply to the attribute Operation ConditionalOperation `json:"operation,required"` @@ -2072,6 +2074,8 @@ func (r conditionalTokenizationActionParametersConditionJSON) RawJSON() string { // `TOO_MANY_RECENT_TOKENS`, `UNABLE_TO_ASSESS`. // - `TOKEN_REQUESTOR_ID`: Unique identifier for the entity requesting the token. // - `WALLET_TOKEN_STATUS`: The current status of the wallet token. +// - `CARD_STATE`: The state of the card being tokenized. Valid values are +// `CLOSED`, `OPEN`, `PAUSED`, `PENDING_ACTIVATION`, `PENDING_FULFILLMENT`. type ConditionalTokenizationActionParametersConditionsAttribute string const ( @@ -2085,11 +2089,12 @@ const ( ConditionalTokenizationActionParametersConditionsAttributeWalletRecommendationReasons ConditionalTokenizationActionParametersConditionsAttribute = "WALLET_RECOMMENDATION_REASONS" ConditionalTokenizationActionParametersConditionsAttributeTokenRequestorID ConditionalTokenizationActionParametersConditionsAttribute = "TOKEN_REQUESTOR_ID" ConditionalTokenizationActionParametersConditionsAttributeWalletTokenStatus ConditionalTokenizationActionParametersConditionsAttribute = "WALLET_TOKEN_STATUS" + ConditionalTokenizationActionParametersConditionsAttributeCardState ConditionalTokenizationActionParametersConditionsAttribute = "CARD_STATE" ) func (r ConditionalTokenizationActionParametersConditionsAttribute) IsKnown() bool { switch r { - case ConditionalTokenizationActionParametersConditionsAttributeTimestamp, ConditionalTokenizationActionParametersConditionsAttributeTokenizationChannel, ConditionalTokenizationActionParametersConditionsAttributeTokenizationSource, ConditionalTokenizationActionParametersConditionsAttributeTokenRequestorName, ConditionalTokenizationActionParametersConditionsAttributeWalletAccountScore, ConditionalTokenizationActionParametersConditionsAttributeWalletDeviceScore, ConditionalTokenizationActionParametersConditionsAttributeWalletRecommendedDecision, ConditionalTokenizationActionParametersConditionsAttributeWalletRecommendationReasons, ConditionalTokenizationActionParametersConditionsAttributeTokenRequestorID, ConditionalTokenizationActionParametersConditionsAttributeWalletTokenStatus: + case ConditionalTokenizationActionParametersConditionsAttributeTimestamp, ConditionalTokenizationActionParametersConditionsAttributeTokenizationChannel, ConditionalTokenizationActionParametersConditionsAttributeTokenizationSource, ConditionalTokenizationActionParametersConditionsAttributeTokenRequestorName, ConditionalTokenizationActionParametersConditionsAttributeWalletAccountScore, ConditionalTokenizationActionParametersConditionsAttributeWalletDeviceScore, ConditionalTokenizationActionParametersConditionsAttributeWalletRecommendedDecision, ConditionalTokenizationActionParametersConditionsAttributeWalletRecommendationReasons, ConditionalTokenizationActionParametersConditionsAttributeTokenRequestorID, ConditionalTokenizationActionParametersConditionsAttributeWalletTokenStatus, ConditionalTokenizationActionParametersConditionsAttributeCardState: return true } return false diff --git a/booktransfer.go b/booktransfer.go index d6e37374..cd76032f 100644 --- a/booktransfer.go +++ b/booktransfer.go @@ -82,6 +82,18 @@ func (r *BookTransferService) ListAutoPaging(ctx context.Context, query BookTran return pagination.NewCursorPageAutoPager(r.List(ctx, query, opts...)) } +// Retry a book transfer that has been declined +func (r *BookTransferService) Retry(ctx context.Context, bookTransferToken string, body BookTransferRetryParams, opts ...option.RequestOption) (res *BookTransferResponse, err error) { + opts = slices.Concat(r.Options, opts) + if bookTransferToken == "" { + err = errors.New("missing required book_transfer_token parameter") + return + } + path := fmt.Sprintf("v1/book_transfers/%s/retry", bookTransferToken) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) + return +} + // Reverse a book transfer func (r *BookTransferService) Reverse(ctx context.Context, bookTransferToken string, body BookTransferReverseParams, opts ...option.RequestOption) (res *BookTransferResponse, err error) { opts = slices.Concat(r.Options, opts) @@ -604,6 +616,16 @@ func (r BookTransferListParamsStatus) IsKnown() bool { return false } +type BookTransferRetryParams struct { + // Customer-provided token that will serve as an idempotency token. This token will + // become the transaction token. + RetryToken param.Field[string] `json:"retry_token,required" format:"uuid"` +} + +func (r BookTransferRetryParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + type BookTransferReverseParams struct { // Optional descriptor for the reversal. Memo param.Field[string] `json:"memo"` diff --git a/booktransfer_test.go b/booktransfer_test.go index 2296af5a..8f97464e 100644 --- a/booktransfer_test.go +++ b/booktransfer_test.go @@ -103,6 +103,34 @@ func TestBookTransferListWithOptionalParams(t *testing.T) { } } +func TestBookTransferRetry(t *testing.T) { + baseURL := "http://localhost:4010" + if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { + baseURL = envURL + } + if !testutil.CheckTestServer(t, baseURL) { + return + } + client := lithic.NewClient( + option.WithBaseURL(baseURL), + option.WithAPIKey("My Lithic API Key"), + ) + _, err := client.BookTransfers.Retry( + context.TODO(), + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + lithic.BookTransferRetryParams{ + RetryToken: lithic.F("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"), + }, + ) + if err != nil { + var apierr *lithic.Error + if errors.As(err, &apierr) { + t.Log(string(apierr.DumpRequest(true))) + } + t.Fatalf("err should be nil: %s", err.Error()) + } +} + func TestBookTransferReverseWithOptionalParams(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { diff --git a/card.go b/card.go index 2a8fe962..92e5c209 100644 --- a/card.go +++ b/card.go @@ -33,7 +33,6 @@ import ( // the [NewCardService] method instead. type CardService struct { Options []option.RequestOption - AggregateBalances *CardAggregateBalanceService Balances *CardBalanceService FinancialTransactions *CardFinancialTransactionService } @@ -44,7 +43,6 @@ type CardService struct { func NewCardService(opts ...option.RequestOption) (r *CardService) { r = &CardService{} r.Options = opts - r.AggregateBalances = NewCardAggregateBalanceService(opts...) r.Balances = NewCardBalanceService(opts...) r.FinancialTransactions = NewCardFinancialTransactionService(opts...) return @@ -332,7 +330,7 @@ func (r *CardService) SearchByPan(ctx context.Context, body CardSearchByPanParam } // Allow your cardholders to directly add payment cards to the device's digital -// wallet from a browser on the web. Currently only suported for Apple Pay. +// wallet from a browser on the web. // // This requires some additional setup and configuration. Please // [Contact Us](https://lithic.com/contact) or your Customer Success representative diff --git a/cardaggregatebalance.go b/cardaggregatebalance.go deleted file mode 100644 index 5126a248..00000000 --- a/cardaggregatebalance.go +++ /dev/null @@ -1,127 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -package lithic - -import ( - "context" - "net/http" - "net/url" - "slices" - "time" - - "github.com/lithic-com/lithic-go/internal/apijson" - "github.com/lithic-com/lithic-go/internal/apiquery" - "github.com/lithic-com/lithic-go/internal/param" - "github.com/lithic-com/lithic-go/internal/requestconfig" - "github.com/lithic-com/lithic-go/option" - "github.com/lithic-com/lithic-go/packages/pagination" -) - -// CardAggregateBalanceService contains methods and other services that help with -// interacting with the lithic API. -// -// Note, unlike clients, this service does not read variables from the environment -// automatically. You should not instantiate this service directly, and instead use -// the [NewCardAggregateBalanceService] method instead. -type CardAggregateBalanceService struct { - Options []option.RequestOption -} - -// NewCardAggregateBalanceService generates a new service that applies the given -// options to each request. These options are applied after the parent client's -// options (if there is one), and before any request-specific options. -func NewCardAggregateBalanceService(opts ...option.RequestOption) (r *CardAggregateBalanceService) { - r = &CardAggregateBalanceService{} - r.Options = opts - return -} - -// Get the aggregated card balance across all end-user accounts. -func (r *CardAggregateBalanceService) List(ctx context.Context, query CardAggregateBalanceListParams, opts ...option.RequestOption) (res *pagination.SinglePage[CardAggregateBalanceListResponse], err error) { - var raw *http.Response - opts = slices.Concat(r.Options, opts) - opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) - path := "v1/cards/aggregate_balances" - cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) - if err != nil { - return nil, err - } - err = cfg.Execute() - if err != nil { - return nil, err - } - res.SetPageConfig(cfg, raw) - return res, nil -} - -// Get the aggregated card balance across all end-user accounts. -func (r *CardAggregateBalanceService) ListAutoPaging(ctx context.Context, query CardAggregateBalanceListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[CardAggregateBalanceListResponse] { - return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) -} - -// Card Aggregate Balance across all end-user accounts -type CardAggregateBalanceListResponse struct { - // Funds available for spend in the currency's smallest unit (e.g., cents for USD) - AvailableAmount int64 `json:"available_amount,required"` - // Date and time for when the balance was first created. - Created time.Time `json:"created,required" format:"date-time"` - // 3-character alphabetic ISO 4217 code for the local currency of the balance. - Currency string `json:"currency,required"` - // Globally unique identifier for the card that had its balance updated most - // recently - LastCardToken string `json:"last_card_token,required" format:"uuid"` - // Globally unique identifier for the last transaction event that impacted this - // balance - LastTransactionEventToken string `json:"last_transaction_event_token,required" format:"uuid"` - // Globally unique identifier for the last transaction that impacted this balance - LastTransactionToken string `json:"last_transaction_token,required" format:"uuid"` - // Funds not available for spend due to card authorizations or pending ACH release. - // Shown in the currency's smallest unit (e.g., cents for USD) - PendingAmount int64 `json:"pending_amount,required"` - // The sum of available and pending balance in the currency's smallest unit (e.g., - // cents for USD) - TotalAmount int64 `json:"total_amount,required"` - // Date and time for when the balance was last updated. - Updated time.Time `json:"updated,required" format:"date-time"` - JSON cardAggregateBalanceListResponseJSON `json:"-"` -} - -// cardAggregateBalanceListResponseJSON contains the JSON metadata for the struct -// [CardAggregateBalanceListResponse] -type cardAggregateBalanceListResponseJSON struct { - AvailableAmount apijson.Field - Created apijson.Field - Currency apijson.Field - LastCardToken apijson.Field - LastTransactionEventToken apijson.Field - LastTransactionToken apijson.Field - PendingAmount apijson.Field - TotalAmount apijson.Field - Updated apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CardAggregateBalanceListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cardAggregateBalanceListResponseJSON) RawJSON() string { - return r.raw -} - -type CardAggregateBalanceListParams struct { - // Cardholder to retrieve aggregate balances for. - AccountToken param.Field[string] `query:"account_token"` - // Business to retrieve aggregate balances for. - BusinessAccountToken param.Field[string] `query:"business_account_token"` -} - -// URLQuery serializes [CardAggregateBalanceListParams]'s query parameters as -// `url.Values`. -func (r CardAggregateBalanceListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} diff --git a/cardaggregatebalance_test.go b/cardaggregatebalance_test.go deleted file mode 100644 index 809f4ce0..00000000 --- a/cardaggregatebalance_test.go +++ /dev/null @@ -1,39 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -package lithic_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/lithic-com/lithic-go" - "github.com/lithic-com/lithic-go/internal/testutil" - "github.com/lithic-com/lithic-go/option" -) - -func TestCardAggregateBalanceListWithOptionalParams(t *testing.T) { - baseURL := "http://localhost:4010" - if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { - baseURL = envURL - } - if !testutil.CheckTestServer(t, baseURL) { - return - } - client := lithic.NewClient( - option.WithBaseURL(baseURL), - option.WithAPIKey("My Lithic API Key"), - ) - _, err := client.Cards.AggregateBalances.List(context.TODO(), lithic.CardAggregateBalanceListParams{ - AccountToken: lithic.F("account_token"), - BusinessAccountToken: lithic.F("business_account_token"), - }) - if err != nil { - var apierr *lithic.Error - if errors.As(err, &apierr) { - t.Log(string(apierr.DumpRequest(true))) - } - t.Fatalf("err should be nil: %s", err.Error()) - } -} diff --git a/client.go b/client.go index e0387255..fefe246c 100644 --- a/client.go +++ b/client.go @@ -26,7 +26,6 @@ type Client struct { Cards *CardService CardBulkOrders *CardBulkOrderService Balances *BalanceService - AggregateBalances *AggregateBalanceService Disputes *DisputeService DisputesV2 *DisputesV2Service Events *EventService @@ -49,6 +48,7 @@ type Client struct { Fraud *FraudService NetworkPrograms *NetworkProgramService AccountActivity *AccountActivityService + TransferLimits *TransferLimitService Webhooks *WebhookService } @@ -87,7 +87,6 @@ func NewClient(opts ...option.RequestOption) (r *Client) { r.Cards = NewCardService(opts...) r.CardBulkOrders = NewCardBulkOrderService(opts...) r.Balances = NewBalanceService(opts...) - r.AggregateBalances = NewAggregateBalanceService(opts...) r.Disputes = NewDisputeService(opts...) r.DisputesV2 = NewDisputesV2Service(opts...) r.Events = NewEventService(opts...) @@ -110,6 +109,7 @@ func NewClient(opts ...option.RequestOption) (r *Client) { r.Fraud = NewFraudService(opts...) r.NetworkPrograms = NewNetworkProgramService(opts...) r.AccountActivity = NewAccountActivityService(opts...) + r.TransferLimits = NewTransferLimitService(opts...) r.Webhooks = NewWebhookService(opts...) return diff --git a/externalpayment.go b/externalpayment.go index c5077cea..851371ea 100644 --- a/externalpayment.go +++ b/externalpayment.go @@ -382,10 +382,12 @@ type ExternalPaymentNewParams struct { EffectiveDate param.Field[time.Time] `json:"effective_date,required" format:"date"` FinancialAccountToken param.Field[string] `json:"financial_account_token,required" format:"uuid"` PaymentType param.Field[ExternalPaymentNewParamsPaymentType] `json:"payment_type,required"` - Token param.Field[string] `json:"token" format:"uuid"` - Memo param.Field[string] `json:"memo"` - ProgressTo param.Field[ExternalPaymentNewParamsProgressTo] `json:"progress_to"` - UserDefinedID param.Field[string] `json:"user_defined_id"` + // Customer-provided token that will serve as an idempotency token. This token will + // become the transaction token. + Token param.Field[string] `json:"token" format:"uuid"` + Memo param.Field[string] `json:"memo"` + ProgressTo param.Field[ExternalPaymentNewParamsProgressTo] `json:"progress_to"` + UserDefinedID param.Field[string] `json:"user_defined_id"` } func (r ExternalPaymentNewParams) MarshalJSON() (data []byte, err error) { diff --git a/financialaccount.go b/financialaccount.go index 802a7a63..4d0c0fd9 100644 --- a/financialaccount.go +++ b/financialaccount.go @@ -168,14 +168,16 @@ type FinancialAccount struct { IsForBenefitOf bool `json:"is_for_benefit_of,required"` Nickname string `json:"nickname,required,nullable"` // Status of the financial account - Status FinancialAccountStatus `json:"status,required"` - Type FinancialAccountType `json:"type,required"` - Updated time.Time `json:"updated,required" format:"date-time"` - AccountNumber string `json:"account_number,nullable"` - RoutingNumber string `json:"routing_number,nullable"` + Status FinancialAccountStatus `json:"status,required"` // Substatus for the financial account - Substatus FinancialAccountSubstatus `json:"substatus,nullable"` - JSON financialAccountJSON `json:"-"` + Substatus FinancialAccountSubstatus `json:"substatus,required,nullable"` + Type FinancialAccountType `json:"type,required"` + Updated time.Time `json:"updated,required" format:"date-time"` + // User-defined status for the financial account + UserDefinedStatus string `json:"user_defined_status,required,nullable"` + AccountNumber string `json:"account_number,nullable"` + RoutingNumber string `json:"routing_number,nullable"` + JSON financialAccountJSON `json:"-"` } // financialAccountJSON contains the JSON metadata for the struct @@ -188,11 +190,12 @@ type financialAccountJSON struct { IsForBenefitOf apijson.Field Nickname apijson.Field Status apijson.Field + Substatus apijson.Field Type apijson.Field Updated apijson.Field + UserDefinedStatus apijson.Field AccountNumber apijson.Field RoutingNumber apijson.Field - Substatus apijson.Field raw string ExtraFields map[string]apijson.Field } @@ -277,6 +280,25 @@ func (r FinancialAccountStatus) IsKnown() bool { return false } +// Substatus for the financial account +type FinancialAccountSubstatus string + +const ( + FinancialAccountSubstatusChargedOffDelinquent FinancialAccountSubstatus = "CHARGED_OFF_DELINQUENT" + FinancialAccountSubstatusChargedOffFraud FinancialAccountSubstatus = "CHARGED_OFF_FRAUD" + FinancialAccountSubstatusEndUserRequest FinancialAccountSubstatus = "END_USER_REQUEST" + FinancialAccountSubstatusBankRequest FinancialAccountSubstatus = "BANK_REQUEST" + FinancialAccountSubstatusDelinquent FinancialAccountSubstatus = "DELINQUENT" +) + +func (r FinancialAccountSubstatus) IsKnown() bool { + switch r { + case FinancialAccountSubstatusChargedOffDelinquent, FinancialAccountSubstatusChargedOffFraud, FinancialAccountSubstatusEndUserRequest, FinancialAccountSubstatusBankRequest, FinancialAccountSubstatusDelinquent: + return true + } + return false +} + type FinancialAccountType string const ( @@ -300,25 +322,6 @@ func (r FinancialAccountType) IsKnown() bool { return false } -// Substatus for the financial account -type FinancialAccountSubstatus string - -const ( - FinancialAccountSubstatusChargedOffDelinquent FinancialAccountSubstatus = "CHARGED_OFF_DELINQUENT" - FinancialAccountSubstatusChargedOffFraud FinancialAccountSubstatus = "CHARGED_OFF_FRAUD" - FinancialAccountSubstatusEndUserRequest FinancialAccountSubstatus = "END_USER_REQUEST" - FinancialAccountSubstatusBankRequest FinancialAccountSubstatus = "BANK_REQUEST" - FinancialAccountSubstatusDelinquent FinancialAccountSubstatus = "DELINQUENT" -) - -func (r FinancialAccountSubstatus) IsKnown() bool { - switch r { - case FinancialAccountSubstatusChargedOffDelinquent, FinancialAccountSubstatusChargedOffFraud, FinancialAccountSubstatusEndUserRequest, FinancialAccountSubstatusBankRequest, FinancialAccountSubstatusDelinquent: - return true - } - return false -} - // Balance of a Financial Account type FinancialAccountBalance struct { // Globally unique identifier for the financial account that holds this balance. @@ -667,6 +670,8 @@ type FinancialAccountUpdateStatusParams struct { Status param.Field[FinancialAccountUpdateStatusParamsStatus] `json:"status,required"` // Substatus for the financial account Substatus param.Field[FinancialAccountUpdateStatusParamsSubstatus] `json:"substatus,required"` + // User-defined status for the financial account + UserDefinedStatus param.Field[string] `json:"user_defined_status"` } func (r FinancialAccountUpdateStatusParams) MarshalJSON() (data []byte, err error) { diff --git a/financialaccount_test.go b/financialaccount_test.go index 5f75dd7f..716200b4 100644 --- a/financialaccount_test.go +++ b/financialaccount_test.go @@ -145,7 +145,7 @@ func TestFinancialAccountRegisterAccountNumber(t *testing.T) { } } -func TestFinancialAccountUpdateStatus(t *testing.T) { +func TestFinancialAccountUpdateStatusWithOptionalParams(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -161,8 +161,9 @@ func TestFinancialAccountUpdateStatus(t *testing.T) { context.TODO(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", lithic.FinancialAccountUpdateStatusParams{ - Status: lithic.F(lithic.FinancialAccountUpdateStatusParamsStatusOpen), - Substatus: lithic.F(lithic.FinancialAccountUpdateStatusParamsSubstatusChargedOffFraud), + Status: lithic.F(lithic.FinancialAccountUpdateStatusParamsStatusOpen), + Substatus: lithic.F(lithic.FinancialAccountUpdateStatusParamsSubstatusChargedOffFraud), + UserDefinedStatus: lithic.F("26"), }, ) if err != nil { diff --git a/financialaccountloantape.go b/financialaccountloantape.go index 5ef574a2..a0898ced 100644 --- a/financialaccountloantape.go +++ b/financialaccountloantape.go @@ -134,7 +134,7 @@ type LoanTape struct { FinancialAccountToken string `json:"financial_account_token,required" format:"uuid"` InterestDetails LoanTapeInterestDetails `json:"interest_details,required,nullable"` MinimumPaymentBalance LoanTapeMinimumPaymentBalance `json:"minimum_payment_balance,required"` - PaymentAllocation CategoryBalances `json:"payment_allocation,required"` + PaymentAllocation LoanTapePaymentAllocation `json:"payment_allocation,required"` PeriodTotals StatementTotals `json:"period_totals,required"` PreviousStatementBalance LoanTapePreviousStatementBalance `json:"previous_statement_balance,required"` // Balance at the start of the day @@ -411,6 +411,40 @@ func (r loanTapeMinimumPaymentBalanceJSON) RawJSON() string { return r.raw } +type LoanTapePaymentAllocation struct { + FeeDetails CategoryDetails `json:"fee_details,required,nullable"` + // Amount allocated to fees in cents + Fees int64 `json:"fees,required"` + // Amount allocated to interest in cents + Interest int64 `json:"interest,required"` + InterestDetails CategoryDetails `json:"interest_details,required,nullable"` + // Amount allocated to principal in cents + Principal int64 `json:"principal,required"` + PrincipalDetails CategoryDetails `json:"principal_details,required,nullable"` + JSON loanTapePaymentAllocationJSON `json:"-"` +} + +// loanTapePaymentAllocationJSON contains the JSON metadata for the struct +// [LoanTapePaymentAllocation] +type loanTapePaymentAllocationJSON struct { + FeeDetails apijson.Field + Fees apijson.Field + Interest apijson.Field + InterestDetails apijson.Field + Principal apijson.Field + PrincipalDetails apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoanTapePaymentAllocation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loanTapePaymentAllocationJSON) RawJSON() string { + return r.raw +} + type LoanTapePreviousStatementBalance struct { Amount int64 `json:"amount,required"` Remaining int64 `json:"remaining,required"` diff --git a/internal/apijson/decoder.go b/internal/apijson/decoder.go index bf01bf6b..290dd27f 100644 --- a/internal/apijson/decoder.go +++ b/internal/apijson/decoder.go @@ -614,9 +614,11 @@ func (d *decoderBuilder) newTimeTypeDecoder(t reflect.Type) decoderFunc { return nil } - if guardStrict(state, true) { - return err - } + // NOTE: we don't use guardStrict here because we want to try + // alternative layouts - these produce semantically identical time.Time + // values - only the string representation differs. Since the parsed value + // is the same, we don't mark this as "loose" (which would affect union + // discrimination) layouts := []string{ "2006-01-02", diff --git a/internal/requestconfig/requestconfig.go b/internal/requestconfig/requestconfig.go index 479b4721..22997557 100644 --- a/internal/requestconfig/requestconfig.go +++ b/internal/requestconfig/requestconfig.go @@ -156,7 +156,7 @@ func NewRequestConfig(ctx context.Context, method string, u string, body interfa for k, v := range getDefaultHeaders() { req.Header.Add(k, v) } - req.Header.Set("X-Lithic-Pagination", "cursor") + for k, v := range getPlatformProperties() { req.Header.Add(k, v) } diff --git a/internal/version.go b/internal/version.go index a87bf824..44a2a342 100644 --- a/internal/version.go +++ b/internal/version.go @@ -2,4 +2,4 @@ package internal -const PackageVersion = "0.98.1" // x-release-please-version +const PackageVersion = "0.99.0" // x-release-please-version diff --git a/managementoperation.go b/managementoperation.go index e8cf1aa1..c431b6fb 100644 --- a/managementoperation.go +++ b/managementoperation.go @@ -421,8 +421,10 @@ type ManagementOperationNewParams struct { EffectiveDate param.Field[time.Time] `json:"effective_date,required" format:"date"` EventType param.Field[ManagementOperationNewParamsEventType] `json:"event_type,required"` FinancialAccountToken param.Field[string] `json:"financial_account_token,required" format:"uuid"` - Token param.Field[string] `json:"token" format:"uuid"` - Memo param.Field[string] `json:"memo"` + // Customer-provided token that will serve as an idempotency token. This token will + // become the transaction token. + Token param.Field[string] `json:"token" format:"uuid"` + Memo param.Field[string] `json:"memo"` // What to do if the financial account is closed when posting an operation OnClosedAccount param.Field[ManagementOperationNewParamsOnClosedAccount] `json:"on_closed_account"` Subtype param.Field[string] `json:"subtype"` diff --git a/payment.go b/payment.go index 95d209c8..03f95834 100644 --- a/payment.go +++ b/payment.go @@ -333,7 +333,9 @@ type PaymentEvent struct { Type PaymentEventsType `json:"type,required"` // More detailed reasons for the event DetailedResults []PaymentEventsDetailedResult `json:"detailed_results"` - JSON paymentEventJSON `json:"-"` + // Payment event external ID, for example, ACH trace number. + ExternalID string `json:"external_id,nullable"` + JSON paymentEventJSON `json:"-"` } // paymentEventJSON contains the JSON metadata for the struct [PaymentEvent] @@ -344,6 +346,7 @@ type paymentEventJSON struct { Result apijson.Field Type apijson.Field DetailedResults apijson.Field + ExternalID apijson.Field raw string ExtraFields map[string]apijson.Field } @@ -821,11 +824,12 @@ const ( PaymentTypeWireInboundAdmin PaymentType = "WIRE_INBOUND_ADMIN" PaymentTypeWireOutboundPayment PaymentType = "WIRE_OUTBOUND_PAYMENT" PaymentTypeWireOutboundAdmin PaymentType = "WIRE_OUTBOUND_ADMIN" + PaymentTypeWireDrawdownRequest PaymentType = "WIRE_DRAWDOWN_REQUEST" ) func (r PaymentType) IsKnown() bool { switch r { - case PaymentTypeOriginationCredit, PaymentTypeOriginationDebit, PaymentTypeReceiptCredit, PaymentTypeReceiptDebit, PaymentTypeWireInboundPayment, PaymentTypeWireInboundAdmin, PaymentTypeWireOutboundPayment, PaymentTypeWireOutboundAdmin: + case PaymentTypeOriginationCredit, PaymentTypeOriginationDebit, PaymentTypeReceiptCredit, PaymentTypeReceiptDebit, PaymentTypeWireInboundPayment, PaymentTypeWireInboundAdmin, PaymentTypeWireOutboundPayment, PaymentTypeWireOutboundAdmin, PaymentTypeWireDrawdownRequest: return true } return false diff --git a/threeds.go b/threeds.go index 8f187bf7..7d683302 100644 --- a/threeds.go +++ b/threeds.go @@ -146,8 +146,6 @@ func (r threeDSAuthenticationJSON) RawJSON() string { return r.raw } -func (r ThreeDSAuthentication) implementsParsedWebhookEvent() {} - // Type of account/card that is being used for the transaction. Maps to EMV 3DS // field `acctType`. type ThreeDSAuthenticationAccountType string diff --git a/transaction.go b/transaction.go index 9a87c6aa..52e4f276 100644 --- a/transaction.go +++ b/transaction.go @@ -1134,6 +1134,7 @@ const ( TransactionEventsDetailedResultAuthRuleAllowedMcc TransactionEventsDetailedResult = "AUTH_RULE_ALLOWED_MCC" TransactionEventsDetailedResultAuthRuleBlockedCountry TransactionEventsDetailedResult = "AUTH_RULE_BLOCKED_COUNTRY" TransactionEventsDetailedResultAuthRuleBlockedMcc TransactionEventsDetailedResult = "AUTH_RULE_BLOCKED_MCC" + TransactionEventsDetailedResultAuthRule TransactionEventsDetailedResult = "AUTH_RULE" TransactionEventsDetailedResultCardClosed TransactionEventsDetailedResult = "CARD_CLOSED" TransactionEventsDetailedResultCardCryptogramValidationFailure TransactionEventsDetailedResult = "CARD_CRYPTOGRAM_VALIDATION_FAILURE" TransactionEventsDetailedResultCardExpired TransactionEventsDetailedResult = "CARD_EXPIRED" @@ -1181,7 +1182,7 @@ const ( func (r TransactionEventsDetailedResult) IsKnown() bool { switch r { - case TransactionEventsDetailedResultAccountDailySpendLimitExceeded, TransactionEventsDetailedResultAccountDelinquent, TransactionEventsDetailedResultAccountInactive, TransactionEventsDetailedResultAccountLifetimeSpendLimitExceeded, TransactionEventsDetailedResultAccountMonthlySpendLimitExceeded, TransactionEventsDetailedResultAccountPaused, TransactionEventsDetailedResultAccountUnderReview, TransactionEventsDetailedResultAddressIncorrect, TransactionEventsDetailedResultApproved, TransactionEventsDetailedResultAuthRuleAllowedCountry, TransactionEventsDetailedResultAuthRuleAllowedMcc, TransactionEventsDetailedResultAuthRuleBlockedCountry, TransactionEventsDetailedResultAuthRuleBlockedMcc, TransactionEventsDetailedResultCardClosed, TransactionEventsDetailedResultCardCryptogramValidationFailure, TransactionEventsDetailedResultCardExpired, TransactionEventsDetailedResultCardExpiryDateIncorrect, TransactionEventsDetailedResultCardInvalid, TransactionEventsDetailedResultCardNotActivated, TransactionEventsDetailedResultCardPaused, TransactionEventsDetailedResultCardPinIncorrect, TransactionEventsDetailedResultCardRestricted, TransactionEventsDetailedResultCardSecurityCodeIncorrect, TransactionEventsDetailedResultCardSpendLimitExceeded, TransactionEventsDetailedResultContactCardIssuer, TransactionEventsDetailedResultCustomerAsaTimeout, TransactionEventsDetailedResultCustomAsaResult, TransactionEventsDetailedResultDeclined, TransactionEventsDetailedResultDoNotHonor, TransactionEventsDetailedResultDriverNumberInvalid, TransactionEventsDetailedResultFormatError, TransactionEventsDetailedResultInsufficientFundingSourceBalance, TransactionEventsDetailedResultInsufficientFunds, TransactionEventsDetailedResultLithicSystemError, TransactionEventsDetailedResultLithicSystemRateLimit, TransactionEventsDetailedResultMalformedAsaResponse, TransactionEventsDetailedResultMerchantInvalid, TransactionEventsDetailedResultMerchantLockedCardAttemptedElsewhere, TransactionEventsDetailedResultMerchantNotPermitted, TransactionEventsDetailedResultOverReversalAttempted, TransactionEventsDetailedResultPinBlocked, TransactionEventsDetailedResultProgramCardSpendLimitExceeded, TransactionEventsDetailedResultProgramSuspended, TransactionEventsDetailedResultProgramUsageRestriction, TransactionEventsDetailedResultReversalUnmatched, TransactionEventsDetailedResultSecurityViolation, TransactionEventsDetailedResultSingleUseCardReattempted, TransactionEventsDetailedResultSuspectedFraud, TransactionEventsDetailedResultTransactionInvalid, TransactionEventsDetailedResultTransactionNotPermittedToAcquirerOrTerminal, TransactionEventsDetailedResultTransactionNotPermittedToIssuerOrCardholder, TransactionEventsDetailedResultTransactionPreviouslyCompleted, TransactionEventsDetailedResultUnauthorizedMerchant, TransactionEventsDetailedResultVehicleNumberInvalid, TransactionEventsDetailedResultCardholderChallenged, TransactionEventsDetailedResultCardholderChallengeFailed: + case TransactionEventsDetailedResultAccountDailySpendLimitExceeded, TransactionEventsDetailedResultAccountDelinquent, TransactionEventsDetailedResultAccountInactive, TransactionEventsDetailedResultAccountLifetimeSpendLimitExceeded, TransactionEventsDetailedResultAccountMonthlySpendLimitExceeded, TransactionEventsDetailedResultAccountPaused, TransactionEventsDetailedResultAccountUnderReview, TransactionEventsDetailedResultAddressIncorrect, TransactionEventsDetailedResultApproved, TransactionEventsDetailedResultAuthRuleAllowedCountry, TransactionEventsDetailedResultAuthRuleAllowedMcc, TransactionEventsDetailedResultAuthRuleBlockedCountry, TransactionEventsDetailedResultAuthRuleBlockedMcc, TransactionEventsDetailedResultAuthRule, TransactionEventsDetailedResultCardClosed, TransactionEventsDetailedResultCardCryptogramValidationFailure, TransactionEventsDetailedResultCardExpired, TransactionEventsDetailedResultCardExpiryDateIncorrect, TransactionEventsDetailedResultCardInvalid, TransactionEventsDetailedResultCardNotActivated, TransactionEventsDetailedResultCardPaused, TransactionEventsDetailedResultCardPinIncorrect, TransactionEventsDetailedResultCardRestricted, TransactionEventsDetailedResultCardSecurityCodeIncorrect, TransactionEventsDetailedResultCardSpendLimitExceeded, TransactionEventsDetailedResultContactCardIssuer, TransactionEventsDetailedResultCustomerAsaTimeout, TransactionEventsDetailedResultCustomAsaResult, TransactionEventsDetailedResultDeclined, TransactionEventsDetailedResultDoNotHonor, TransactionEventsDetailedResultDriverNumberInvalid, TransactionEventsDetailedResultFormatError, TransactionEventsDetailedResultInsufficientFundingSourceBalance, TransactionEventsDetailedResultInsufficientFunds, TransactionEventsDetailedResultLithicSystemError, TransactionEventsDetailedResultLithicSystemRateLimit, TransactionEventsDetailedResultMalformedAsaResponse, TransactionEventsDetailedResultMerchantInvalid, TransactionEventsDetailedResultMerchantLockedCardAttemptedElsewhere, TransactionEventsDetailedResultMerchantNotPermitted, TransactionEventsDetailedResultOverReversalAttempted, TransactionEventsDetailedResultPinBlocked, TransactionEventsDetailedResultProgramCardSpendLimitExceeded, TransactionEventsDetailedResultProgramSuspended, TransactionEventsDetailedResultProgramUsageRestriction, TransactionEventsDetailedResultReversalUnmatched, TransactionEventsDetailedResultSecurityViolation, TransactionEventsDetailedResultSingleUseCardReattempted, TransactionEventsDetailedResultSuspectedFraud, TransactionEventsDetailedResultTransactionInvalid, TransactionEventsDetailedResultTransactionNotPermittedToAcquirerOrTerminal, TransactionEventsDetailedResultTransactionNotPermittedToIssuerOrCardholder, TransactionEventsDetailedResultTransactionPreviouslyCompleted, TransactionEventsDetailedResultUnauthorizedMerchant, TransactionEventsDetailedResultVehicleNumberInvalid, TransactionEventsDetailedResultCardholderChallenged, TransactionEventsDetailedResultCardholderChallengeFailed: return true } return false @@ -1462,6 +1463,7 @@ const ( TransactionEventsRuleResultsResultAuthRuleAllowedMcc TransactionEventsRuleResultsResult = "AUTH_RULE_ALLOWED_MCC" TransactionEventsRuleResultsResultAuthRuleBlockedCountry TransactionEventsRuleResultsResult = "AUTH_RULE_BLOCKED_COUNTRY" TransactionEventsRuleResultsResultAuthRuleBlockedMcc TransactionEventsRuleResultsResult = "AUTH_RULE_BLOCKED_MCC" + TransactionEventsRuleResultsResultAuthRule TransactionEventsRuleResultsResult = "AUTH_RULE" TransactionEventsRuleResultsResultCardClosed TransactionEventsRuleResultsResult = "CARD_CLOSED" TransactionEventsRuleResultsResultCardCryptogramValidationFailure TransactionEventsRuleResultsResult = "CARD_CRYPTOGRAM_VALIDATION_FAILURE" TransactionEventsRuleResultsResultCardExpired TransactionEventsRuleResultsResult = "CARD_EXPIRED" @@ -1509,7 +1511,7 @@ const ( func (r TransactionEventsRuleResultsResult) IsKnown() bool { switch r { - case TransactionEventsRuleResultsResultAccountDailySpendLimitExceeded, TransactionEventsRuleResultsResultAccountDelinquent, TransactionEventsRuleResultsResultAccountInactive, TransactionEventsRuleResultsResultAccountLifetimeSpendLimitExceeded, TransactionEventsRuleResultsResultAccountMonthlySpendLimitExceeded, TransactionEventsRuleResultsResultAccountPaused, TransactionEventsRuleResultsResultAccountUnderReview, TransactionEventsRuleResultsResultAddressIncorrect, TransactionEventsRuleResultsResultApproved, TransactionEventsRuleResultsResultAuthRuleAllowedCountry, TransactionEventsRuleResultsResultAuthRuleAllowedMcc, TransactionEventsRuleResultsResultAuthRuleBlockedCountry, TransactionEventsRuleResultsResultAuthRuleBlockedMcc, TransactionEventsRuleResultsResultCardClosed, TransactionEventsRuleResultsResultCardCryptogramValidationFailure, TransactionEventsRuleResultsResultCardExpired, TransactionEventsRuleResultsResultCardExpiryDateIncorrect, TransactionEventsRuleResultsResultCardInvalid, TransactionEventsRuleResultsResultCardNotActivated, TransactionEventsRuleResultsResultCardPaused, TransactionEventsRuleResultsResultCardPinIncorrect, TransactionEventsRuleResultsResultCardRestricted, TransactionEventsRuleResultsResultCardSecurityCodeIncorrect, TransactionEventsRuleResultsResultCardSpendLimitExceeded, TransactionEventsRuleResultsResultContactCardIssuer, TransactionEventsRuleResultsResultCustomerAsaTimeout, TransactionEventsRuleResultsResultCustomAsaResult, TransactionEventsRuleResultsResultDeclined, TransactionEventsRuleResultsResultDoNotHonor, TransactionEventsRuleResultsResultDriverNumberInvalid, TransactionEventsRuleResultsResultFormatError, TransactionEventsRuleResultsResultInsufficientFundingSourceBalance, TransactionEventsRuleResultsResultInsufficientFunds, TransactionEventsRuleResultsResultLithicSystemError, TransactionEventsRuleResultsResultLithicSystemRateLimit, TransactionEventsRuleResultsResultMalformedAsaResponse, TransactionEventsRuleResultsResultMerchantInvalid, TransactionEventsRuleResultsResultMerchantLockedCardAttemptedElsewhere, TransactionEventsRuleResultsResultMerchantNotPermitted, TransactionEventsRuleResultsResultOverReversalAttempted, TransactionEventsRuleResultsResultPinBlocked, TransactionEventsRuleResultsResultProgramCardSpendLimitExceeded, TransactionEventsRuleResultsResultProgramSuspended, TransactionEventsRuleResultsResultProgramUsageRestriction, TransactionEventsRuleResultsResultReversalUnmatched, TransactionEventsRuleResultsResultSecurityViolation, TransactionEventsRuleResultsResultSingleUseCardReattempted, TransactionEventsRuleResultsResultSuspectedFraud, TransactionEventsRuleResultsResultTransactionInvalid, TransactionEventsRuleResultsResultTransactionNotPermittedToAcquirerOrTerminal, TransactionEventsRuleResultsResultTransactionNotPermittedToIssuerOrCardholder, TransactionEventsRuleResultsResultTransactionPreviouslyCompleted, TransactionEventsRuleResultsResultUnauthorizedMerchant, TransactionEventsRuleResultsResultVehicleNumberInvalid, TransactionEventsRuleResultsResultCardholderChallenged, TransactionEventsRuleResultsResultCardholderChallengeFailed: + case TransactionEventsRuleResultsResultAccountDailySpendLimitExceeded, TransactionEventsRuleResultsResultAccountDelinquent, TransactionEventsRuleResultsResultAccountInactive, TransactionEventsRuleResultsResultAccountLifetimeSpendLimitExceeded, TransactionEventsRuleResultsResultAccountMonthlySpendLimitExceeded, TransactionEventsRuleResultsResultAccountPaused, TransactionEventsRuleResultsResultAccountUnderReview, TransactionEventsRuleResultsResultAddressIncorrect, TransactionEventsRuleResultsResultApproved, TransactionEventsRuleResultsResultAuthRuleAllowedCountry, TransactionEventsRuleResultsResultAuthRuleAllowedMcc, TransactionEventsRuleResultsResultAuthRuleBlockedCountry, TransactionEventsRuleResultsResultAuthRuleBlockedMcc, TransactionEventsRuleResultsResultAuthRule, TransactionEventsRuleResultsResultCardClosed, TransactionEventsRuleResultsResultCardCryptogramValidationFailure, TransactionEventsRuleResultsResultCardExpired, TransactionEventsRuleResultsResultCardExpiryDateIncorrect, TransactionEventsRuleResultsResultCardInvalid, TransactionEventsRuleResultsResultCardNotActivated, TransactionEventsRuleResultsResultCardPaused, TransactionEventsRuleResultsResultCardPinIncorrect, TransactionEventsRuleResultsResultCardRestricted, TransactionEventsRuleResultsResultCardSecurityCodeIncorrect, TransactionEventsRuleResultsResultCardSpendLimitExceeded, TransactionEventsRuleResultsResultContactCardIssuer, TransactionEventsRuleResultsResultCustomerAsaTimeout, TransactionEventsRuleResultsResultCustomAsaResult, TransactionEventsRuleResultsResultDeclined, TransactionEventsRuleResultsResultDoNotHonor, TransactionEventsRuleResultsResultDriverNumberInvalid, TransactionEventsRuleResultsResultFormatError, TransactionEventsRuleResultsResultInsufficientFundingSourceBalance, TransactionEventsRuleResultsResultInsufficientFunds, TransactionEventsRuleResultsResultLithicSystemError, TransactionEventsRuleResultsResultLithicSystemRateLimit, TransactionEventsRuleResultsResultMalformedAsaResponse, TransactionEventsRuleResultsResultMerchantInvalid, TransactionEventsRuleResultsResultMerchantLockedCardAttemptedElsewhere, TransactionEventsRuleResultsResultMerchantNotPermitted, TransactionEventsRuleResultsResultOverReversalAttempted, TransactionEventsRuleResultsResultPinBlocked, TransactionEventsRuleResultsResultProgramCardSpendLimitExceeded, TransactionEventsRuleResultsResultProgramSuspended, TransactionEventsRuleResultsResultProgramUsageRestriction, TransactionEventsRuleResultsResultReversalUnmatched, TransactionEventsRuleResultsResultSecurityViolation, TransactionEventsRuleResultsResultSingleUseCardReattempted, TransactionEventsRuleResultsResultSuspectedFraud, TransactionEventsRuleResultsResultTransactionInvalid, TransactionEventsRuleResultsResultTransactionNotPermittedToAcquirerOrTerminal, TransactionEventsRuleResultsResultTransactionNotPermittedToIssuerOrCardholder, TransactionEventsRuleResultsResultTransactionPreviouslyCompleted, TransactionEventsRuleResultsResultUnauthorizedMerchant, TransactionEventsRuleResultsResultVehicleNumberInvalid, TransactionEventsRuleResultsResultCardholderChallenged, TransactionEventsRuleResultsResultCardholderChallengeFailed: return true } return false diff --git a/transferlimit.go b/transferlimit.go new file mode 100644 index 00000000..abf43f19 --- /dev/null +++ b/transferlimit.go @@ -0,0 +1,372 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package lithic + +import ( + "context" + "net/http" + "net/url" + "slices" + "time" + + "github.com/lithic-com/lithic-go/internal/apijson" + "github.com/lithic-com/lithic-go/internal/apiquery" + "github.com/lithic-com/lithic-go/internal/param" + "github.com/lithic-com/lithic-go/internal/requestconfig" + "github.com/lithic-com/lithic-go/option" + "github.com/lithic-com/lithic-go/packages/pagination" +) + +// TransferLimitService contains methods and other services that help with +// interacting with the lithic API. +// +// Note, unlike clients, this service does not read variables from the environment +// automatically. You should not instantiate this service directly, and instead use +// the [NewTransferLimitService] method instead. +type TransferLimitService struct { + Options []option.RequestOption +} + +// NewTransferLimitService generates a new service that applies the given options +// to each request. These options are applied after the parent client's options (if +// there is one), and before any request-specific options. +func NewTransferLimitService(opts ...option.RequestOption) (r *TransferLimitService) { + r = &TransferLimitService{} + r.Options = opts + return +} + +// Get transfer limits for a specified date +func (r *TransferLimitService) List(ctx context.Context, query TransferLimitListParams, opts ...option.RequestOption) (res *pagination.SinglePage[TransferLimitsResponseData], err error) { + var raw *http.Response + opts = slices.Concat(r.Options, opts) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + path := "v1/transfer_limits" + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// Get transfer limits for a specified date +func (r *TransferLimitService) ListAutoPaging(ctx context.Context, query TransferLimitListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[TransferLimitsResponseData] { + return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) +} + +type TransferLimitsResponse struct { + // List of transfer limits + Data []TransferLimitsResponseData `json:"data,required"` + // Whether there are more transfer limits + HasMore bool `json:"has_more,required"` + JSON transferLimitsResponseJSON `json:"-"` +} + +// transferLimitsResponseJSON contains the JSON metadata for the struct +// [TransferLimitsResponse] +type transferLimitsResponseJSON struct { + Data apijson.Field + HasMore apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TransferLimitsResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r transferLimitsResponseJSON) RawJSON() string { + return r.raw +} + +type TransferLimitsResponseData struct { + // Company ID + CompanyID string `json:"company_id,required"` + // Daily limits with progress + DailyLimit TransferLimitsResponseDataDailyLimit `json:"daily_limit,required"` + // The date for the limit view (ISO format) + Date time.Time `json:"date,required" format:"date"` + // Whether the company is a FBO; based on the company ID prefix + IsFbo bool `json:"is_fbo,required"` + // Monthly limits with progress + MonthlyLimit TransferLimitsResponseDataMonthlyLimit `json:"monthly_limit,required"` + // Program transaction limits + ProgramLimitPerTransaction TransferLimitsResponseDataProgramLimitPerTransaction `json:"program_limit_per_transaction,required"` + JSON transferLimitsResponseDataJSON `json:"-"` +} + +// transferLimitsResponseDataJSON contains the JSON metadata for the struct +// [TransferLimitsResponseData] +type transferLimitsResponseDataJSON struct { + CompanyID apijson.Field + DailyLimit apijson.Field + Date apijson.Field + IsFbo apijson.Field + MonthlyLimit apijson.Field + ProgramLimitPerTransaction apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TransferLimitsResponseData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r transferLimitsResponseDataJSON) RawJSON() string { + return r.raw +} + +// Daily limits with progress +type TransferLimitsResponseDataDailyLimit struct { + // Credit limits + Credit TransferLimitsResponseDataDailyLimitCredit `json:"credit,required"` + // Debit limits + Debit TransferLimitsResponseDataDailyLimitDebit `json:"debit,required"` + JSON transferLimitsResponseDataDailyLimitJSON `json:"-"` +} + +// transferLimitsResponseDataDailyLimitJSON contains the JSON metadata for the +// struct [TransferLimitsResponseDataDailyLimit] +type transferLimitsResponseDataDailyLimitJSON struct { + Credit apijson.Field + Debit apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TransferLimitsResponseDataDailyLimit) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r transferLimitsResponseDataDailyLimitJSON) RawJSON() string { + return r.raw +} + +// Credit limits +type TransferLimitsResponseDataDailyLimitCredit struct { + // The limit amount + Limit int64 `json:"limit,required"` + // Amount originated towards limit + AmountOriginated int64 `json:"amount_originated"` + JSON transferLimitsResponseDataDailyLimitCreditJSON `json:"-"` +} + +// transferLimitsResponseDataDailyLimitCreditJSON contains the JSON metadata for +// the struct [TransferLimitsResponseDataDailyLimitCredit] +type transferLimitsResponseDataDailyLimitCreditJSON struct { + Limit apijson.Field + AmountOriginated apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TransferLimitsResponseDataDailyLimitCredit) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r transferLimitsResponseDataDailyLimitCreditJSON) RawJSON() string { + return r.raw +} + +// Debit limits +type TransferLimitsResponseDataDailyLimitDebit struct { + // The limit amount + Limit int64 `json:"limit,required"` + // Amount originated towards limit + AmountOriginated int64 `json:"amount_originated"` + JSON transferLimitsResponseDataDailyLimitDebitJSON `json:"-"` +} + +// transferLimitsResponseDataDailyLimitDebitJSON contains the JSON metadata for the +// struct [TransferLimitsResponseDataDailyLimitDebit] +type transferLimitsResponseDataDailyLimitDebitJSON struct { + Limit apijson.Field + AmountOriginated apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TransferLimitsResponseDataDailyLimitDebit) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r transferLimitsResponseDataDailyLimitDebitJSON) RawJSON() string { + return r.raw +} + +// Monthly limits with progress +type TransferLimitsResponseDataMonthlyLimit struct { + // Credit limits + Credit TransferLimitsResponseDataMonthlyLimitCredit `json:"credit,required"` + // Debit limits + Debit TransferLimitsResponseDataMonthlyLimitDebit `json:"debit,required"` + JSON transferLimitsResponseDataMonthlyLimitJSON `json:"-"` +} + +// transferLimitsResponseDataMonthlyLimitJSON contains the JSON metadata for the +// struct [TransferLimitsResponseDataMonthlyLimit] +type transferLimitsResponseDataMonthlyLimitJSON struct { + Credit apijson.Field + Debit apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TransferLimitsResponseDataMonthlyLimit) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r transferLimitsResponseDataMonthlyLimitJSON) RawJSON() string { + return r.raw +} + +// Credit limits +type TransferLimitsResponseDataMonthlyLimitCredit struct { + // The limit amount + Limit int64 `json:"limit,required"` + // Amount originated towards limit + AmountOriginated int64 `json:"amount_originated"` + JSON transferLimitsResponseDataMonthlyLimitCreditJSON `json:"-"` +} + +// transferLimitsResponseDataMonthlyLimitCreditJSON contains the JSON metadata for +// the struct [TransferLimitsResponseDataMonthlyLimitCredit] +type transferLimitsResponseDataMonthlyLimitCreditJSON struct { + Limit apijson.Field + AmountOriginated apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TransferLimitsResponseDataMonthlyLimitCredit) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r transferLimitsResponseDataMonthlyLimitCreditJSON) RawJSON() string { + return r.raw +} + +// Debit limits +type TransferLimitsResponseDataMonthlyLimitDebit struct { + // The limit amount + Limit int64 `json:"limit,required"` + // Amount originated towards limit + AmountOriginated int64 `json:"amount_originated"` + JSON transferLimitsResponseDataMonthlyLimitDebitJSON `json:"-"` +} + +// transferLimitsResponseDataMonthlyLimitDebitJSON contains the JSON metadata for +// the struct [TransferLimitsResponseDataMonthlyLimitDebit] +type transferLimitsResponseDataMonthlyLimitDebitJSON struct { + Limit apijson.Field + AmountOriginated apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TransferLimitsResponseDataMonthlyLimitDebit) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r transferLimitsResponseDataMonthlyLimitDebitJSON) RawJSON() string { + return r.raw +} + +// Program transaction limits +type TransferLimitsResponseDataProgramLimitPerTransaction struct { + // Credit limits + Credit TransferLimitsResponseDataProgramLimitPerTransactionCredit `json:"credit,required"` + // Debit limits + Debit TransferLimitsResponseDataProgramLimitPerTransactionDebit `json:"debit,required"` + JSON transferLimitsResponseDataProgramLimitPerTransactionJSON `json:"-"` +} + +// transferLimitsResponseDataProgramLimitPerTransactionJSON contains the JSON +// metadata for the struct [TransferLimitsResponseDataProgramLimitPerTransaction] +type transferLimitsResponseDataProgramLimitPerTransactionJSON struct { + Credit apijson.Field + Debit apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TransferLimitsResponseDataProgramLimitPerTransaction) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r transferLimitsResponseDataProgramLimitPerTransactionJSON) RawJSON() string { + return r.raw +} + +// Credit limits +type TransferLimitsResponseDataProgramLimitPerTransactionCredit struct { + // The limit amount + Limit int64 `json:"limit,required"` + // Amount originated towards limit + AmountOriginated int64 `json:"amount_originated"` + JSON transferLimitsResponseDataProgramLimitPerTransactionCreditJSON `json:"-"` +} + +// transferLimitsResponseDataProgramLimitPerTransactionCreditJSON contains the JSON +// metadata for the struct +// [TransferLimitsResponseDataProgramLimitPerTransactionCredit] +type transferLimitsResponseDataProgramLimitPerTransactionCreditJSON struct { + Limit apijson.Field + AmountOriginated apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TransferLimitsResponseDataProgramLimitPerTransactionCredit) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r transferLimitsResponseDataProgramLimitPerTransactionCreditJSON) RawJSON() string { + return r.raw +} + +// Debit limits +type TransferLimitsResponseDataProgramLimitPerTransactionDebit struct { + // The limit amount + Limit int64 `json:"limit,required"` + // Amount originated towards limit + AmountOriginated int64 `json:"amount_originated"` + JSON transferLimitsResponseDataProgramLimitPerTransactionDebitJSON `json:"-"` +} + +// transferLimitsResponseDataProgramLimitPerTransactionDebitJSON contains the JSON +// metadata for the struct +// [TransferLimitsResponseDataProgramLimitPerTransactionDebit] +type transferLimitsResponseDataProgramLimitPerTransactionDebitJSON struct { + Limit apijson.Field + AmountOriginated apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TransferLimitsResponseDataProgramLimitPerTransactionDebit) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r transferLimitsResponseDataProgramLimitPerTransactionDebitJSON) RawJSON() string { + return r.raw +} + +type TransferLimitListParams struct { + // Date for which to retrieve transfer limits (ISO 8601 format) + Date param.Field[time.Time] `query:"date" format:"date"` +} + +// URLQuery serializes [TransferLimitListParams]'s query parameters as +// `url.Values`. +func (r TransferLimitListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} diff --git a/aggregatebalance_test.go b/transferlimit_test.go similarity index 74% rename from aggregatebalance_test.go rename to transferlimit_test.go index a98da214..83f4a097 100644 --- a/aggregatebalance_test.go +++ b/transferlimit_test.go @@ -7,13 +7,14 @@ import ( "errors" "os" "testing" + "time" "github.com/lithic-com/lithic-go" "github.com/lithic-com/lithic-go/internal/testutil" "github.com/lithic-com/lithic-go/option" ) -func TestAggregateBalanceListWithOptionalParams(t *testing.T) { +func TestTransferLimitListWithOptionalParams(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -25,8 +26,8 @@ func TestAggregateBalanceListWithOptionalParams(t *testing.T) { option.WithBaseURL(baseURL), option.WithAPIKey("My Lithic API Key"), ) - _, err := client.AggregateBalances.List(context.TODO(), lithic.AggregateBalanceListParams{ - FinancialAccountType: lithic.F(lithic.AggregateBalanceListParamsFinancialAccountTypeIssuing), + _, err := client.TransferLimits.List(context.TODO(), lithic.TransferLimitListParams{ + Date: lithic.F(time.Now()), }) if err != nil { var apierr *lithic.Error diff --git a/webhook.go b/webhook.go index 81998ed9..86b43896 100644 --- a/webhook.go +++ b/webhook.go @@ -1020,8 +1020,7 @@ func (r AccountHolderDocumentUpdatedWebhookEventRequiredDocumentUploadsStatus) I return false } -// The Auth Stream Access request payload that was sent to the ASA responder. -type AsaRequestWebhookEvent struct { +type CardAuthorizationApprovalRequestWebhookEvent struct { // The provisional transaction group uuid associated with the authorization Token string `json:"token,required" format:"uuid"` // Fee (in cents) assessed by the merchant and paid for by the cardholder. Will be @@ -1034,10 +1033,10 @@ type AsaRequestWebhookEvent struct { // The base transaction amount (in cents) plus the acquirer fee field. This is the // amount the issuer should authorize against unless the issuer is paying the // acquirer fee on behalf of the cardholder. - AuthorizationAmount int64 `json:"authorization_amount,required"` - Avs AsaRequestWebhookEventAvs `json:"avs,required"` + AuthorizationAmount int64 `json:"authorization_amount,required"` + Avs CardAuthorizationApprovalRequestWebhookEventAvs `json:"avs,required"` // Card object in ASA - Card AsaRequestWebhookEventCard `json:"card,required"` + Card CardAuthorizationApprovalRequestWebhookEventCard `json:"card,required"` // 3-character alphabetic ISO 4217 code for cardholder's billing currency. CardholderCurrency string `json:"cardholder_currency,required"` // The portion of the transaction requested as cash back by the cardholder, and @@ -1048,8 +1047,9 @@ type AsaRequestWebhookEvent struct { // will always be present. CashAmount int64 `json:"cash_amount,required"` // Date and time when the transaction first occurred in UTC. - Created time.Time `json:"created,required" format:"date-time"` - Merchant shared.Merchant `json:"merchant,required"` + Created time.Time `json:"created,required" format:"date-time"` + EventType CardAuthorizationApprovalRequestWebhookEventEventType `json:"event_type,required"` + Merchant shared.Merchant `json:"merchant,required"` // The amount that the merchant will receive, denominated in `merchant_currency` // and in the smallest currency unit. Note the amount includes `acquirer_fee`, // similar to `authorization_amount`. It will be different from @@ -1064,11 +1064,11 @@ type AsaRequestWebhookEvent struct { // The type of authorization request that this request is for. Note that // `CREDIT_AUTHORIZATION` and `FINANCIAL_CREDIT_AUTHORIZATION` is only available to // users with credit decisioning via ASA enabled. - Status AsaRequestWebhookEventStatus `json:"status,required"` + Status CardAuthorizationApprovalRequestWebhookEventStatus `json:"status,required"` // The entity that initiated the transaction. - TransactionInitiator AsaRequestWebhookEventTransactionInitiator `json:"transaction_initiator,required"` - AccountType AsaRequestWebhookEventAccountType `json:"account_type"` - CardholderAuthentication CardholderAuthentication `json:"cardholder_authentication"` + TransactionInitiator CardAuthorizationApprovalRequestWebhookEventTransactionInitiator `json:"transaction_initiator,required"` + AccountType CardAuthorizationApprovalRequestWebhookEventAccountType `json:"account_type"` + CardholderAuthentication CardholderAuthentication `json:"cardholder_authentication"` // Deprecated, use `cash_amount`. Cashback int64 `json:"cashback"` // If the transaction was requested in a currency other than the settlement @@ -1082,12 +1082,12 @@ type AsaRequestWebhookEvent struct { EventToken string `json:"event_token" format:"uuid"` // Optional Object containing information if the Card is a part of a Fleet managed // program - FleetInfo AsaRequestWebhookEventFleetInfo `json:"fleet_info,nullable"` + FleetInfo CardAuthorizationApprovalRequestWebhookEventFleetInfo `json:"fleet_info,nullable"` // The latest Authorization Challenge that was issued to the cardholder for this // merchant. - LatestChallenge AsaRequestWebhookEventLatestChallenge `json:"latest_challenge"` + LatestChallenge CardAuthorizationApprovalRequestWebhookEventLatestChallenge `json:"latest_challenge"` // Card network of the authorization. - Network AsaRequestWebhookEventNetwork `json:"network"` + Network CardAuthorizationApprovalRequestWebhookEventNetwork `json:"network"` // Network-provided score assessing risk level associated with a given // authorization. Scores are on a range of 0-999, with 0 representing the lowest // risk and 999 representing the highest risk. For Visa transactions, where the raw @@ -1100,17 +1100,17 @@ type AsaRequestWebhookEvent struct { // Please consult the official network documentation for more details about these // values and how to use them. This object is only available to certain programs- // contact your Customer Success Manager to discuss enabling access. - NetworkSpecificData AsaRequestWebhookEventNetworkSpecificData `json:"network_specific_data,nullable"` - Pos AsaRequestWebhookEventPos `json:"pos"` - TokenInfo TokenInfo `json:"token_info,nullable"` + NetworkSpecificData CardAuthorizationApprovalRequestWebhookEventNetworkSpecificData `json:"network_specific_data,nullable"` + Pos CardAuthorizationApprovalRequestWebhookEventPos `json:"pos"` + TokenInfo TokenInfo `json:"token_info,nullable"` // Deprecated: approximate time-to-live for the authorization. - Ttl time.Time `json:"ttl" format:"date-time"` - JSON asaRequestWebhookEventJSON `json:"-"` + Ttl time.Time `json:"ttl" format:"date-time"` + JSON cardAuthorizationApprovalRequestWebhookEventJSON `json:"-"` } -// asaRequestWebhookEventJSON contains the JSON metadata for the struct -// [AsaRequestWebhookEvent] -type asaRequestWebhookEventJSON struct { +// cardAuthorizationApprovalRequestWebhookEventJSON contains the JSON metadata for +// the struct [CardAuthorizationApprovalRequestWebhookEvent] +type cardAuthorizationApprovalRequestWebhookEventJSON struct { Token apijson.Field AcquirerFee apijson.Field Amount apijson.Field @@ -1120,6 +1120,7 @@ type asaRequestWebhookEventJSON struct { CardholderCurrency apijson.Field CashAmount apijson.Field Created apijson.Field + EventType apijson.Field Merchant apijson.Field MerchantAmount apijson.Field MerchantCurrency apijson.Field @@ -1143,32 +1144,32 @@ type asaRequestWebhookEventJSON struct { ExtraFields map[string]apijson.Field } -func (r *AsaRequestWebhookEvent) UnmarshalJSON(data []byte) (err error) { +func (r *CardAuthorizationApprovalRequestWebhookEvent) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r asaRequestWebhookEventJSON) RawJSON() string { +func (r cardAuthorizationApprovalRequestWebhookEventJSON) RawJSON() string { return r.raw } -func (r AsaRequestWebhookEvent) implementsParsedWebhookEvent() {} +func (r CardAuthorizationApprovalRequestWebhookEvent) implementsParsedWebhookEvent() {} -type AsaRequestWebhookEventAvs struct { +type CardAuthorizationApprovalRequestWebhookEventAvs struct { // Cardholder address Address string `json:"address,required"` // Lithic's evaluation result comparing the transaction's address data with the // cardholder KYC data if it exists. In the event Lithic does not have any // Cardholder KYC data, or the transaction does not contain any address data, // NOT_PRESENT will be returned - AddressOnFileMatch AsaRequestWebhookEventAvsAddressOnFileMatch `json:"address_on_file_match,required"` + AddressOnFileMatch CardAuthorizationApprovalRequestWebhookEventAvsAddressOnFileMatch `json:"address_on_file_match,required"` // Cardholder ZIP code - Zipcode string `json:"zipcode,required"` - JSON asaRequestWebhookEventAvsJSON `json:"-"` + Zipcode string `json:"zipcode,required"` + JSON cardAuthorizationApprovalRequestWebhookEventAvsJSON `json:"-"` } -// asaRequestWebhookEventAvsJSON contains the JSON metadata for the struct -// [AsaRequestWebhookEventAvs] -type asaRequestWebhookEventAvsJSON struct { +// cardAuthorizationApprovalRequestWebhookEventAvsJSON contains the JSON metadata +// for the struct [CardAuthorizationApprovalRequestWebhookEventAvs] +type cardAuthorizationApprovalRequestWebhookEventAvsJSON struct { Address apijson.Field AddressOnFileMatch apijson.Field Zipcode apijson.Field @@ -1176,11 +1177,11 @@ type asaRequestWebhookEventAvsJSON struct { ExtraFields map[string]apijson.Field } -func (r *AsaRequestWebhookEventAvs) UnmarshalJSON(data []byte) (err error) { +func (r *CardAuthorizationApprovalRequestWebhookEventAvs) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r asaRequestWebhookEventAvsJSON) RawJSON() string { +func (r cardAuthorizationApprovalRequestWebhookEventAvsJSON) RawJSON() string { return r.raw } @@ -1188,26 +1189,26 @@ func (r asaRequestWebhookEventAvsJSON) RawJSON() string { // cardholder KYC data if it exists. In the event Lithic does not have any // Cardholder KYC data, or the transaction does not contain any address data, // NOT_PRESENT will be returned -type AsaRequestWebhookEventAvsAddressOnFileMatch string +type CardAuthorizationApprovalRequestWebhookEventAvsAddressOnFileMatch string const ( - AsaRequestWebhookEventAvsAddressOnFileMatchMatch AsaRequestWebhookEventAvsAddressOnFileMatch = "MATCH" - AsaRequestWebhookEventAvsAddressOnFileMatchMatchAddressOnly AsaRequestWebhookEventAvsAddressOnFileMatch = "MATCH_ADDRESS_ONLY" - AsaRequestWebhookEventAvsAddressOnFileMatchMatchZipOnly AsaRequestWebhookEventAvsAddressOnFileMatch = "MATCH_ZIP_ONLY" - AsaRequestWebhookEventAvsAddressOnFileMatchMismatch AsaRequestWebhookEventAvsAddressOnFileMatch = "MISMATCH" - AsaRequestWebhookEventAvsAddressOnFileMatchNotPresent AsaRequestWebhookEventAvsAddressOnFileMatch = "NOT_PRESENT" + CardAuthorizationApprovalRequestWebhookEventAvsAddressOnFileMatchMatch CardAuthorizationApprovalRequestWebhookEventAvsAddressOnFileMatch = "MATCH" + CardAuthorizationApprovalRequestWebhookEventAvsAddressOnFileMatchMatchAddressOnly CardAuthorizationApprovalRequestWebhookEventAvsAddressOnFileMatch = "MATCH_ADDRESS_ONLY" + CardAuthorizationApprovalRequestWebhookEventAvsAddressOnFileMatchMatchZipOnly CardAuthorizationApprovalRequestWebhookEventAvsAddressOnFileMatch = "MATCH_ZIP_ONLY" + CardAuthorizationApprovalRequestWebhookEventAvsAddressOnFileMatchMismatch CardAuthorizationApprovalRequestWebhookEventAvsAddressOnFileMatch = "MISMATCH" + CardAuthorizationApprovalRequestWebhookEventAvsAddressOnFileMatchNotPresent CardAuthorizationApprovalRequestWebhookEventAvsAddressOnFileMatch = "NOT_PRESENT" ) -func (r AsaRequestWebhookEventAvsAddressOnFileMatch) IsKnown() bool { +func (r CardAuthorizationApprovalRequestWebhookEventAvsAddressOnFileMatch) IsKnown() bool { switch r { - case AsaRequestWebhookEventAvsAddressOnFileMatchMatch, AsaRequestWebhookEventAvsAddressOnFileMatchMatchAddressOnly, AsaRequestWebhookEventAvsAddressOnFileMatchMatchZipOnly, AsaRequestWebhookEventAvsAddressOnFileMatchMismatch, AsaRequestWebhookEventAvsAddressOnFileMatchNotPresent: + case CardAuthorizationApprovalRequestWebhookEventAvsAddressOnFileMatchMatch, CardAuthorizationApprovalRequestWebhookEventAvsAddressOnFileMatchMatchAddressOnly, CardAuthorizationApprovalRequestWebhookEventAvsAddressOnFileMatchMatchZipOnly, CardAuthorizationApprovalRequestWebhookEventAvsAddressOnFileMatchMismatch, CardAuthorizationApprovalRequestWebhookEventAvsAddressOnFileMatchNotPresent: return true } return false } // Card object in ASA -type AsaRequestWebhookEventCard struct { +type CardAuthorizationApprovalRequestWebhookEventCard struct { // Globally unique identifier for the card. Token string `json:"token" format:"uuid"` // Hostname of card’s locked merchant (will be empty if not applicable) @@ -1229,15 +1230,15 @@ type AsaRequestWebhookEventCard struct { // Note that to support recurring monthly payments, which can occur on different // day every month, the time window we consider for MONTHLY velocity starts 6 days // after the current calendar date one month prior. - SpendLimitDuration AsaRequestWebhookEventCardSpendLimitDuration `json:"spend_limit_duration"` - State AsaRequestWebhookEventCardState `json:"state"` - Type AsaRequestWebhookEventCardType `json:"type"` - JSON asaRequestWebhookEventCardJSON `json:"-"` + SpendLimitDuration CardAuthorizationApprovalRequestWebhookEventCardSpendLimitDuration `json:"spend_limit_duration"` + State CardAuthorizationApprovalRequestWebhookEventCardState `json:"state"` + Type CardAuthorizationApprovalRequestWebhookEventCardType `json:"type"` + JSON cardAuthorizationApprovalRequestWebhookEventCardJSON `json:"-"` } -// asaRequestWebhookEventCardJSON contains the JSON metadata for the struct -// [AsaRequestWebhookEventCard] -type asaRequestWebhookEventCardJSON struct { +// cardAuthorizationApprovalRequestWebhookEventCardJSON contains the JSON metadata +// for the struct [CardAuthorizationApprovalRequestWebhookEventCard] +type cardAuthorizationApprovalRequestWebhookEventCardJSON struct { Token apijson.Field Hostname apijson.Field LastFour apijson.Field @@ -1250,66 +1251,80 @@ type asaRequestWebhookEventCardJSON struct { ExtraFields map[string]apijson.Field } -func (r *AsaRequestWebhookEventCard) UnmarshalJSON(data []byte) (err error) { +func (r *CardAuthorizationApprovalRequestWebhookEventCard) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r asaRequestWebhookEventCardJSON) RawJSON() string { +func (r cardAuthorizationApprovalRequestWebhookEventCardJSON) RawJSON() string { return r.raw } // Note that to support recurring monthly payments, which can occur on different // day every month, the time window we consider for MONTHLY velocity starts 6 days // after the current calendar date one month prior. -type AsaRequestWebhookEventCardSpendLimitDuration string +type CardAuthorizationApprovalRequestWebhookEventCardSpendLimitDuration string const ( - AsaRequestWebhookEventCardSpendLimitDurationAnnually AsaRequestWebhookEventCardSpendLimitDuration = "ANNUALLY" - AsaRequestWebhookEventCardSpendLimitDurationForever AsaRequestWebhookEventCardSpendLimitDuration = "FOREVER" - AsaRequestWebhookEventCardSpendLimitDurationMonthly AsaRequestWebhookEventCardSpendLimitDuration = "MONTHLY" - AsaRequestWebhookEventCardSpendLimitDurationTransaction AsaRequestWebhookEventCardSpendLimitDuration = "TRANSACTION" + CardAuthorizationApprovalRequestWebhookEventCardSpendLimitDurationAnnually CardAuthorizationApprovalRequestWebhookEventCardSpendLimitDuration = "ANNUALLY" + CardAuthorizationApprovalRequestWebhookEventCardSpendLimitDurationForever CardAuthorizationApprovalRequestWebhookEventCardSpendLimitDuration = "FOREVER" + CardAuthorizationApprovalRequestWebhookEventCardSpendLimitDurationMonthly CardAuthorizationApprovalRequestWebhookEventCardSpendLimitDuration = "MONTHLY" + CardAuthorizationApprovalRequestWebhookEventCardSpendLimitDurationTransaction CardAuthorizationApprovalRequestWebhookEventCardSpendLimitDuration = "TRANSACTION" ) -func (r AsaRequestWebhookEventCardSpendLimitDuration) IsKnown() bool { +func (r CardAuthorizationApprovalRequestWebhookEventCardSpendLimitDuration) IsKnown() bool { switch r { - case AsaRequestWebhookEventCardSpendLimitDurationAnnually, AsaRequestWebhookEventCardSpendLimitDurationForever, AsaRequestWebhookEventCardSpendLimitDurationMonthly, AsaRequestWebhookEventCardSpendLimitDurationTransaction: + case CardAuthorizationApprovalRequestWebhookEventCardSpendLimitDurationAnnually, CardAuthorizationApprovalRequestWebhookEventCardSpendLimitDurationForever, CardAuthorizationApprovalRequestWebhookEventCardSpendLimitDurationMonthly, CardAuthorizationApprovalRequestWebhookEventCardSpendLimitDurationTransaction: return true } return false } -type AsaRequestWebhookEventCardState string +type CardAuthorizationApprovalRequestWebhookEventCardState string const ( - AsaRequestWebhookEventCardStateClosed AsaRequestWebhookEventCardState = "CLOSED" - AsaRequestWebhookEventCardStateOpen AsaRequestWebhookEventCardState = "OPEN" - AsaRequestWebhookEventCardStatePaused AsaRequestWebhookEventCardState = "PAUSED" - AsaRequestWebhookEventCardStatePendingActivation AsaRequestWebhookEventCardState = "PENDING_ACTIVATION" - AsaRequestWebhookEventCardStatePendingFulfillment AsaRequestWebhookEventCardState = "PENDING_FULFILLMENT" + CardAuthorizationApprovalRequestWebhookEventCardStateClosed CardAuthorizationApprovalRequestWebhookEventCardState = "CLOSED" + CardAuthorizationApprovalRequestWebhookEventCardStateOpen CardAuthorizationApprovalRequestWebhookEventCardState = "OPEN" + CardAuthorizationApprovalRequestWebhookEventCardStatePaused CardAuthorizationApprovalRequestWebhookEventCardState = "PAUSED" + CardAuthorizationApprovalRequestWebhookEventCardStatePendingActivation CardAuthorizationApprovalRequestWebhookEventCardState = "PENDING_ACTIVATION" + CardAuthorizationApprovalRequestWebhookEventCardStatePendingFulfillment CardAuthorizationApprovalRequestWebhookEventCardState = "PENDING_FULFILLMENT" ) -func (r AsaRequestWebhookEventCardState) IsKnown() bool { +func (r CardAuthorizationApprovalRequestWebhookEventCardState) IsKnown() bool { switch r { - case AsaRequestWebhookEventCardStateClosed, AsaRequestWebhookEventCardStateOpen, AsaRequestWebhookEventCardStatePaused, AsaRequestWebhookEventCardStatePendingActivation, AsaRequestWebhookEventCardStatePendingFulfillment: + case CardAuthorizationApprovalRequestWebhookEventCardStateClosed, CardAuthorizationApprovalRequestWebhookEventCardStateOpen, CardAuthorizationApprovalRequestWebhookEventCardStatePaused, CardAuthorizationApprovalRequestWebhookEventCardStatePendingActivation, CardAuthorizationApprovalRequestWebhookEventCardStatePendingFulfillment: return true } return false } -type AsaRequestWebhookEventCardType string +type CardAuthorizationApprovalRequestWebhookEventCardType string const ( - AsaRequestWebhookEventCardTypeSingleUse AsaRequestWebhookEventCardType = "SINGLE_USE" - AsaRequestWebhookEventCardTypeMerchantLocked AsaRequestWebhookEventCardType = "MERCHANT_LOCKED" - AsaRequestWebhookEventCardTypeUnlocked AsaRequestWebhookEventCardType = "UNLOCKED" - AsaRequestWebhookEventCardTypePhysical AsaRequestWebhookEventCardType = "PHYSICAL" - AsaRequestWebhookEventCardTypeDigitalWallet AsaRequestWebhookEventCardType = "DIGITAL_WALLET" - AsaRequestWebhookEventCardTypeVirtual AsaRequestWebhookEventCardType = "VIRTUAL" + CardAuthorizationApprovalRequestWebhookEventCardTypeSingleUse CardAuthorizationApprovalRequestWebhookEventCardType = "SINGLE_USE" + CardAuthorizationApprovalRequestWebhookEventCardTypeMerchantLocked CardAuthorizationApprovalRequestWebhookEventCardType = "MERCHANT_LOCKED" + CardAuthorizationApprovalRequestWebhookEventCardTypeUnlocked CardAuthorizationApprovalRequestWebhookEventCardType = "UNLOCKED" + CardAuthorizationApprovalRequestWebhookEventCardTypePhysical CardAuthorizationApprovalRequestWebhookEventCardType = "PHYSICAL" + CardAuthorizationApprovalRequestWebhookEventCardTypeDigitalWallet CardAuthorizationApprovalRequestWebhookEventCardType = "DIGITAL_WALLET" + CardAuthorizationApprovalRequestWebhookEventCardTypeVirtual CardAuthorizationApprovalRequestWebhookEventCardType = "VIRTUAL" ) -func (r AsaRequestWebhookEventCardType) IsKnown() bool { +func (r CardAuthorizationApprovalRequestWebhookEventCardType) IsKnown() bool { switch r { - case AsaRequestWebhookEventCardTypeSingleUse, AsaRequestWebhookEventCardTypeMerchantLocked, AsaRequestWebhookEventCardTypeUnlocked, AsaRequestWebhookEventCardTypePhysical, AsaRequestWebhookEventCardTypeDigitalWallet, AsaRequestWebhookEventCardTypeVirtual: + case CardAuthorizationApprovalRequestWebhookEventCardTypeSingleUse, CardAuthorizationApprovalRequestWebhookEventCardTypeMerchantLocked, CardAuthorizationApprovalRequestWebhookEventCardTypeUnlocked, CardAuthorizationApprovalRequestWebhookEventCardTypePhysical, CardAuthorizationApprovalRequestWebhookEventCardTypeDigitalWallet, CardAuthorizationApprovalRequestWebhookEventCardTypeVirtual: + return true + } + return false +} + +type CardAuthorizationApprovalRequestWebhookEventEventType string + +const ( + CardAuthorizationApprovalRequestWebhookEventEventTypeCardAuthorizationApprovalRequest CardAuthorizationApprovalRequestWebhookEventEventType = "card_authorization.approval_request" +) + +func (r CardAuthorizationApprovalRequestWebhookEventEventType) IsKnown() bool { + switch r { + case CardAuthorizationApprovalRequestWebhookEventEventTypeCardAuthorizationApprovalRequest: return true } return false @@ -1318,51 +1333,51 @@ func (r AsaRequestWebhookEventCardType) IsKnown() bool { // The type of authorization request that this request is for. Note that // `CREDIT_AUTHORIZATION` and `FINANCIAL_CREDIT_AUTHORIZATION` is only available to // users with credit decisioning via ASA enabled. -type AsaRequestWebhookEventStatus string +type CardAuthorizationApprovalRequestWebhookEventStatus string const ( - AsaRequestWebhookEventStatusAuthorization AsaRequestWebhookEventStatus = "AUTHORIZATION" - AsaRequestWebhookEventStatusCreditAuthorization AsaRequestWebhookEventStatus = "CREDIT_AUTHORIZATION" - AsaRequestWebhookEventStatusFinancialAuthorization AsaRequestWebhookEventStatus = "FINANCIAL_AUTHORIZATION" - AsaRequestWebhookEventStatusFinancialCreditAuthorization AsaRequestWebhookEventStatus = "FINANCIAL_CREDIT_AUTHORIZATION" - AsaRequestWebhookEventStatusBalanceInquiry AsaRequestWebhookEventStatus = "BALANCE_INQUIRY" + CardAuthorizationApprovalRequestWebhookEventStatusAuthorization CardAuthorizationApprovalRequestWebhookEventStatus = "AUTHORIZATION" + CardAuthorizationApprovalRequestWebhookEventStatusCreditAuthorization CardAuthorizationApprovalRequestWebhookEventStatus = "CREDIT_AUTHORIZATION" + CardAuthorizationApprovalRequestWebhookEventStatusFinancialAuthorization CardAuthorizationApprovalRequestWebhookEventStatus = "FINANCIAL_AUTHORIZATION" + CardAuthorizationApprovalRequestWebhookEventStatusFinancialCreditAuthorization CardAuthorizationApprovalRequestWebhookEventStatus = "FINANCIAL_CREDIT_AUTHORIZATION" + CardAuthorizationApprovalRequestWebhookEventStatusBalanceInquiry CardAuthorizationApprovalRequestWebhookEventStatus = "BALANCE_INQUIRY" ) -func (r AsaRequestWebhookEventStatus) IsKnown() bool { +func (r CardAuthorizationApprovalRequestWebhookEventStatus) IsKnown() bool { switch r { - case AsaRequestWebhookEventStatusAuthorization, AsaRequestWebhookEventStatusCreditAuthorization, AsaRequestWebhookEventStatusFinancialAuthorization, AsaRequestWebhookEventStatusFinancialCreditAuthorization, AsaRequestWebhookEventStatusBalanceInquiry: + case CardAuthorizationApprovalRequestWebhookEventStatusAuthorization, CardAuthorizationApprovalRequestWebhookEventStatusCreditAuthorization, CardAuthorizationApprovalRequestWebhookEventStatusFinancialAuthorization, CardAuthorizationApprovalRequestWebhookEventStatusFinancialCreditAuthorization, CardAuthorizationApprovalRequestWebhookEventStatusBalanceInquiry: return true } return false } // The entity that initiated the transaction. -type AsaRequestWebhookEventTransactionInitiator string +type CardAuthorizationApprovalRequestWebhookEventTransactionInitiator string const ( - AsaRequestWebhookEventTransactionInitiatorCardholder AsaRequestWebhookEventTransactionInitiator = "CARDHOLDER" - AsaRequestWebhookEventTransactionInitiatorMerchant AsaRequestWebhookEventTransactionInitiator = "MERCHANT" - AsaRequestWebhookEventTransactionInitiatorUnknown AsaRequestWebhookEventTransactionInitiator = "UNKNOWN" + CardAuthorizationApprovalRequestWebhookEventTransactionInitiatorCardholder CardAuthorizationApprovalRequestWebhookEventTransactionInitiator = "CARDHOLDER" + CardAuthorizationApprovalRequestWebhookEventTransactionInitiatorMerchant CardAuthorizationApprovalRequestWebhookEventTransactionInitiator = "MERCHANT" + CardAuthorizationApprovalRequestWebhookEventTransactionInitiatorUnknown CardAuthorizationApprovalRequestWebhookEventTransactionInitiator = "UNKNOWN" ) -func (r AsaRequestWebhookEventTransactionInitiator) IsKnown() bool { +func (r CardAuthorizationApprovalRequestWebhookEventTransactionInitiator) IsKnown() bool { switch r { - case AsaRequestWebhookEventTransactionInitiatorCardholder, AsaRequestWebhookEventTransactionInitiatorMerchant, AsaRequestWebhookEventTransactionInitiatorUnknown: + case CardAuthorizationApprovalRequestWebhookEventTransactionInitiatorCardholder, CardAuthorizationApprovalRequestWebhookEventTransactionInitiatorMerchant, CardAuthorizationApprovalRequestWebhookEventTransactionInitiatorUnknown: return true } return false } -type AsaRequestWebhookEventAccountType string +type CardAuthorizationApprovalRequestWebhookEventAccountType string const ( - AsaRequestWebhookEventAccountTypeChecking AsaRequestWebhookEventAccountType = "CHECKING" - AsaRequestWebhookEventAccountTypeSavings AsaRequestWebhookEventAccountType = "SAVINGS" + CardAuthorizationApprovalRequestWebhookEventAccountTypeChecking CardAuthorizationApprovalRequestWebhookEventAccountType = "CHECKING" + CardAuthorizationApprovalRequestWebhookEventAccountTypeSavings CardAuthorizationApprovalRequestWebhookEventAccountType = "SAVINGS" ) -func (r AsaRequestWebhookEventAccountType) IsKnown() bool { +func (r CardAuthorizationApprovalRequestWebhookEventAccountType) IsKnown() bool { switch r { - case AsaRequestWebhookEventAccountTypeChecking, AsaRequestWebhookEventAccountTypeSavings: + case CardAuthorizationApprovalRequestWebhookEventAccountTypeChecking, CardAuthorizationApprovalRequestWebhookEventAccountTypeSavings: return true } return false @@ -1370,25 +1385,25 @@ func (r AsaRequestWebhookEventAccountType) IsKnown() bool { // Optional Object containing information if the Card is a part of a Fleet managed // program -type AsaRequestWebhookEventFleetInfo struct { +type CardAuthorizationApprovalRequestWebhookEventFleetInfo struct { // Code indicating what the driver was prompted to enter at time of purchase. This // is configured at a program level and is a static configuration, and does not // change on a request to request basis - FleetPromptCode AsaRequestWebhookEventFleetInfoFleetPromptCode `json:"fleet_prompt_code,required"` + FleetPromptCode CardAuthorizationApprovalRequestWebhookEventFleetInfoFleetPromptCode `json:"fleet_prompt_code,required"` // Code indicating which restrictions, if any, there are on purchase. This is // configured at a program level and is a static configuration, and does not change // on a request to request basis - FleetRestrictionCode AsaRequestWebhookEventFleetInfoFleetRestrictionCode `json:"fleet_restriction_code,required"` + FleetRestrictionCode CardAuthorizationApprovalRequestWebhookEventFleetInfoFleetRestrictionCode `json:"fleet_restriction_code,required"` // Number representing the driver DriverNumber string `json:"driver_number,nullable"` // Number associated with the vehicle - VehicleNumber string `json:"vehicle_number,nullable"` - JSON asaRequestWebhookEventFleetInfoJSON `json:"-"` + VehicleNumber string `json:"vehicle_number,nullable"` + JSON cardAuthorizationApprovalRequestWebhookEventFleetInfoJSON `json:"-"` } -// asaRequestWebhookEventFleetInfoJSON contains the JSON metadata for the struct -// [AsaRequestWebhookEventFleetInfo] -type asaRequestWebhookEventFleetInfoJSON struct { +// cardAuthorizationApprovalRequestWebhookEventFleetInfoJSON contains the JSON +// metadata for the struct [CardAuthorizationApprovalRequestWebhookEventFleetInfo] +type cardAuthorizationApprovalRequestWebhookEventFleetInfoJSON struct { FleetPromptCode apijson.Field FleetRestrictionCode apijson.Field DriverNumber apijson.Field @@ -1397,28 +1412,28 @@ type asaRequestWebhookEventFleetInfoJSON struct { ExtraFields map[string]apijson.Field } -func (r *AsaRequestWebhookEventFleetInfo) UnmarshalJSON(data []byte) (err error) { +func (r *CardAuthorizationApprovalRequestWebhookEventFleetInfo) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r asaRequestWebhookEventFleetInfoJSON) RawJSON() string { +func (r cardAuthorizationApprovalRequestWebhookEventFleetInfoJSON) RawJSON() string { return r.raw } // Code indicating what the driver was prompted to enter at time of purchase. This // is configured at a program level and is a static configuration, and does not // change on a request to request basis -type AsaRequestWebhookEventFleetInfoFleetPromptCode string +type CardAuthorizationApprovalRequestWebhookEventFleetInfoFleetPromptCode string const ( - AsaRequestWebhookEventFleetInfoFleetPromptCodeNoPrompt AsaRequestWebhookEventFleetInfoFleetPromptCode = "NO_PROMPT" - AsaRequestWebhookEventFleetInfoFleetPromptCodeVehicleNumber AsaRequestWebhookEventFleetInfoFleetPromptCode = "VEHICLE_NUMBER" - AsaRequestWebhookEventFleetInfoFleetPromptCodeDriverNumber AsaRequestWebhookEventFleetInfoFleetPromptCode = "DRIVER_NUMBER" + CardAuthorizationApprovalRequestWebhookEventFleetInfoFleetPromptCodeNoPrompt CardAuthorizationApprovalRequestWebhookEventFleetInfoFleetPromptCode = "NO_PROMPT" + CardAuthorizationApprovalRequestWebhookEventFleetInfoFleetPromptCodeVehicleNumber CardAuthorizationApprovalRequestWebhookEventFleetInfoFleetPromptCode = "VEHICLE_NUMBER" + CardAuthorizationApprovalRequestWebhookEventFleetInfoFleetPromptCodeDriverNumber CardAuthorizationApprovalRequestWebhookEventFleetInfoFleetPromptCode = "DRIVER_NUMBER" ) -func (r AsaRequestWebhookEventFleetInfoFleetPromptCode) IsKnown() bool { +func (r CardAuthorizationApprovalRequestWebhookEventFleetInfoFleetPromptCode) IsKnown() bool { switch r { - case AsaRequestWebhookEventFleetInfoFleetPromptCodeNoPrompt, AsaRequestWebhookEventFleetInfoFleetPromptCodeVehicleNumber, AsaRequestWebhookEventFleetInfoFleetPromptCodeDriverNumber: + case CardAuthorizationApprovalRequestWebhookEventFleetInfoFleetPromptCodeNoPrompt, CardAuthorizationApprovalRequestWebhookEventFleetInfoFleetPromptCodeVehicleNumber, CardAuthorizationApprovalRequestWebhookEventFleetInfoFleetPromptCodeDriverNumber: return true } return false @@ -1427,16 +1442,16 @@ func (r AsaRequestWebhookEventFleetInfoFleetPromptCode) IsKnown() bool { // Code indicating which restrictions, if any, there are on purchase. This is // configured at a program level and is a static configuration, and does not change // on a request to request basis -type AsaRequestWebhookEventFleetInfoFleetRestrictionCode string +type CardAuthorizationApprovalRequestWebhookEventFleetInfoFleetRestrictionCode string const ( - AsaRequestWebhookEventFleetInfoFleetRestrictionCodeNoRestrictions AsaRequestWebhookEventFleetInfoFleetRestrictionCode = "NO_RESTRICTIONS" - AsaRequestWebhookEventFleetInfoFleetRestrictionCodeFuelOnly AsaRequestWebhookEventFleetInfoFleetRestrictionCode = "FUEL_ONLY" + CardAuthorizationApprovalRequestWebhookEventFleetInfoFleetRestrictionCodeNoRestrictions CardAuthorizationApprovalRequestWebhookEventFleetInfoFleetRestrictionCode = "NO_RESTRICTIONS" + CardAuthorizationApprovalRequestWebhookEventFleetInfoFleetRestrictionCodeFuelOnly CardAuthorizationApprovalRequestWebhookEventFleetInfoFleetRestrictionCode = "FUEL_ONLY" ) -func (r AsaRequestWebhookEventFleetInfoFleetRestrictionCode) IsKnown() bool { +func (r CardAuthorizationApprovalRequestWebhookEventFleetInfoFleetRestrictionCode) IsKnown() bool { switch r { - case AsaRequestWebhookEventFleetInfoFleetRestrictionCodeNoRestrictions, AsaRequestWebhookEventFleetInfoFleetRestrictionCodeFuelOnly: + case CardAuthorizationApprovalRequestWebhookEventFleetInfoFleetRestrictionCodeNoRestrictions, CardAuthorizationApprovalRequestWebhookEventFleetInfoFleetRestrictionCodeFuelOnly: return true } return false @@ -1444,7 +1459,7 @@ func (r AsaRequestWebhookEventFleetInfoFleetRestrictionCode) IsKnown() bool { // The latest Authorization Challenge that was issued to the cardholder for this // merchant. -type AsaRequestWebhookEventLatestChallenge struct { +type CardAuthorizationApprovalRequestWebhookEventLatestChallenge struct { // The phone number used for sending Authorization Challenge SMS. PhoneNumber string `json:"phone_number,required"` // The status of the Authorization Challenge @@ -1453,16 +1468,17 @@ type AsaRequestWebhookEventLatestChallenge struct { // - `PENDING` - Challenge is still open // - `EXPIRED` - Challenge has expired without being completed // - `ERROR` - There was an error processing the challenge - Status AsaRequestWebhookEventLatestChallengeStatus `json:"status,required"` + Status CardAuthorizationApprovalRequestWebhookEventLatestChallengeStatus `json:"status,required"` // The date and time when the Authorization Challenge was completed in UTC. Present // only if the status is `COMPLETED`. - CompletedAt time.Time `json:"completed_at" format:"date-time"` - JSON asaRequestWebhookEventLatestChallengeJSON `json:"-"` + CompletedAt time.Time `json:"completed_at" format:"date-time"` + JSON cardAuthorizationApprovalRequestWebhookEventLatestChallengeJSON `json:"-"` } -// asaRequestWebhookEventLatestChallengeJSON contains the JSON metadata for the -// struct [AsaRequestWebhookEventLatestChallenge] -type asaRequestWebhookEventLatestChallengeJSON struct { +// cardAuthorizationApprovalRequestWebhookEventLatestChallengeJSON contains the +// JSON metadata for the struct +// [CardAuthorizationApprovalRequestWebhookEventLatestChallenge] +type cardAuthorizationApprovalRequestWebhookEventLatestChallengeJSON struct { PhoneNumber apijson.Field Status apijson.Field CompletedAt apijson.Field @@ -1470,11 +1486,11 @@ type asaRequestWebhookEventLatestChallengeJSON struct { ExtraFields map[string]apijson.Field } -func (r *AsaRequestWebhookEventLatestChallenge) UnmarshalJSON(data []byte) (err error) { +func (r *CardAuthorizationApprovalRequestWebhookEventLatestChallenge) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r asaRequestWebhookEventLatestChallengeJSON) RawJSON() string { +func (r cardAuthorizationApprovalRequestWebhookEventLatestChallengeJSON) RawJSON() string { return r.raw } @@ -1484,38 +1500,38 @@ func (r asaRequestWebhookEventLatestChallengeJSON) RawJSON() string { // - `PENDING` - Challenge is still open // - `EXPIRED` - Challenge has expired without being completed // - `ERROR` - There was an error processing the challenge -type AsaRequestWebhookEventLatestChallengeStatus string +type CardAuthorizationApprovalRequestWebhookEventLatestChallengeStatus string const ( - AsaRequestWebhookEventLatestChallengeStatusCompleted AsaRequestWebhookEventLatestChallengeStatus = "COMPLETED" - AsaRequestWebhookEventLatestChallengeStatusPending AsaRequestWebhookEventLatestChallengeStatus = "PENDING" - AsaRequestWebhookEventLatestChallengeStatusExpired AsaRequestWebhookEventLatestChallengeStatus = "EXPIRED" - AsaRequestWebhookEventLatestChallengeStatusError AsaRequestWebhookEventLatestChallengeStatus = "ERROR" + CardAuthorizationApprovalRequestWebhookEventLatestChallengeStatusCompleted CardAuthorizationApprovalRequestWebhookEventLatestChallengeStatus = "COMPLETED" + CardAuthorizationApprovalRequestWebhookEventLatestChallengeStatusPending CardAuthorizationApprovalRequestWebhookEventLatestChallengeStatus = "PENDING" + CardAuthorizationApprovalRequestWebhookEventLatestChallengeStatusExpired CardAuthorizationApprovalRequestWebhookEventLatestChallengeStatus = "EXPIRED" + CardAuthorizationApprovalRequestWebhookEventLatestChallengeStatusError CardAuthorizationApprovalRequestWebhookEventLatestChallengeStatus = "ERROR" ) -func (r AsaRequestWebhookEventLatestChallengeStatus) IsKnown() bool { +func (r CardAuthorizationApprovalRequestWebhookEventLatestChallengeStatus) IsKnown() bool { switch r { - case AsaRequestWebhookEventLatestChallengeStatusCompleted, AsaRequestWebhookEventLatestChallengeStatusPending, AsaRequestWebhookEventLatestChallengeStatusExpired, AsaRequestWebhookEventLatestChallengeStatusError: + case CardAuthorizationApprovalRequestWebhookEventLatestChallengeStatusCompleted, CardAuthorizationApprovalRequestWebhookEventLatestChallengeStatusPending, CardAuthorizationApprovalRequestWebhookEventLatestChallengeStatusExpired, CardAuthorizationApprovalRequestWebhookEventLatestChallengeStatusError: return true } return false } // Card network of the authorization. -type AsaRequestWebhookEventNetwork string +type CardAuthorizationApprovalRequestWebhookEventNetwork string const ( - AsaRequestWebhookEventNetworkAmex AsaRequestWebhookEventNetwork = "AMEX" - AsaRequestWebhookEventNetworkInterlink AsaRequestWebhookEventNetwork = "INTERLINK" - AsaRequestWebhookEventNetworkMaestro AsaRequestWebhookEventNetwork = "MAESTRO" - AsaRequestWebhookEventNetworkMastercard AsaRequestWebhookEventNetwork = "MASTERCARD" - AsaRequestWebhookEventNetworkUnknown AsaRequestWebhookEventNetwork = "UNKNOWN" - AsaRequestWebhookEventNetworkVisa AsaRequestWebhookEventNetwork = "VISA" + CardAuthorizationApprovalRequestWebhookEventNetworkAmex CardAuthorizationApprovalRequestWebhookEventNetwork = "AMEX" + CardAuthorizationApprovalRequestWebhookEventNetworkInterlink CardAuthorizationApprovalRequestWebhookEventNetwork = "INTERLINK" + CardAuthorizationApprovalRequestWebhookEventNetworkMaestro CardAuthorizationApprovalRequestWebhookEventNetwork = "MAESTRO" + CardAuthorizationApprovalRequestWebhookEventNetworkMastercard CardAuthorizationApprovalRequestWebhookEventNetwork = "MASTERCARD" + CardAuthorizationApprovalRequestWebhookEventNetworkUnknown CardAuthorizationApprovalRequestWebhookEventNetwork = "UNKNOWN" + CardAuthorizationApprovalRequestWebhookEventNetworkVisa CardAuthorizationApprovalRequestWebhookEventNetwork = "VISA" ) -func (r AsaRequestWebhookEventNetwork) IsKnown() bool { +func (r CardAuthorizationApprovalRequestWebhookEventNetwork) IsKnown() bool { switch r { - case AsaRequestWebhookEventNetworkAmex, AsaRequestWebhookEventNetworkInterlink, AsaRequestWebhookEventNetworkMaestro, AsaRequestWebhookEventNetworkMastercard, AsaRequestWebhookEventNetworkUnknown, AsaRequestWebhookEventNetworkVisa: + case CardAuthorizationApprovalRequestWebhookEventNetworkAmex, CardAuthorizationApprovalRequestWebhookEventNetworkInterlink, CardAuthorizationApprovalRequestWebhookEventNetworkMaestro, CardAuthorizationApprovalRequestWebhookEventNetworkMastercard, CardAuthorizationApprovalRequestWebhookEventNetworkUnknown, CardAuthorizationApprovalRequestWebhookEventNetworkVisa: return true } return false @@ -1527,44 +1543,46 @@ func (r AsaRequestWebhookEventNetwork) IsKnown() bool { // Please consult the official network documentation for more details about these // values and how to use them. This object is only available to certain programs- // contact your Customer Success Manager to discuss enabling access. -type AsaRequestWebhookEventNetworkSpecificData struct { - Mastercard AsaRequestWebhookEventNetworkSpecificDataMastercard `json:"mastercard,nullable"` - Visa AsaRequestWebhookEventNetworkSpecificDataVisa `json:"visa,nullable"` - JSON asaRequestWebhookEventNetworkSpecificDataJSON `json:"-"` +type CardAuthorizationApprovalRequestWebhookEventNetworkSpecificData struct { + Mastercard CardAuthorizationApprovalRequestWebhookEventNetworkSpecificDataMastercard `json:"mastercard,nullable"` + Visa CardAuthorizationApprovalRequestWebhookEventNetworkSpecificDataVisa `json:"visa,nullable"` + JSON cardAuthorizationApprovalRequestWebhookEventNetworkSpecificDataJSON `json:"-"` } -// asaRequestWebhookEventNetworkSpecificDataJSON contains the JSON metadata for the -// struct [AsaRequestWebhookEventNetworkSpecificData] -type asaRequestWebhookEventNetworkSpecificDataJSON struct { +// cardAuthorizationApprovalRequestWebhookEventNetworkSpecificDataJSON contains the +// JSON metadata for the struct +// [CardAuthorizationApprovalRequestWebhookEventNetworkSpecificData] +type cardAuthorizationApprovalRequestWebhookEventNetworkSpecificDataJSON struct { Mastercard apijson.Field Visa apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *AsaRequestWebhookEventNetworkSpecificData) UnmarshalJSON(data []byte) (err error) { +func (r *CardAuthorizationApprovalRequestWebhookEventNetworkSpecificData) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r asaRequestWebhookEventNetworkSpecificDataJSON) RawJSON() string { +func (r cardAuthorizationApprovalRequestWebhookEventNetworkSpecificDataJSON) RawJSON() string { return r.raw } -type AsaRequestWebhookEventNetworkSpecificDataMastercard struct { +type CardAuthorizationApprovalRequestWebhookEventNetworkSpecificDataMastercard struct { // Indicates the electronic commerce security level and UCAF collection. EcommerceSecurityLevelIndicator string `json:"ecommerce_security_level_indicator,nullable"` // The On-behalf Service performed on the transaction and the results. Contains all // applicable, on-behalf service results that were performed on a given // transaction. - OnBehalfServiceResult []AsaRequestWebhookEventNetworkSpecificDataMastercardOnBehalfServiceResult `json:"on_behalf_service_result,nullable"` + OnBehalfServiceResult []CardAuthorizationApprovalRequestWebhookEventNetworkSpecificDataMastercardOnBehalfServiceResult `json:"on_behalf_service_result,nullable"` // Indicates the type of additional transaction purpose. - TransactionTypeIdentifier string `json:"transaction_type_identifier,nullable"` - JSON asaRequestWebhookEventNetworkSpecificDataMastercardJSON `json:"-"` + TransactionTypeIdentifier string `json:"transaction_type_identifier,nullable"` + JSON cardAuthorizationApprovalRequestWebhookEventNetworkSpecificDataMastercardJSON `json:"-"` } -// asaRequestWebhookEventNetworkSpecificDataMastercardJSON contains the JSON -// metadata for the struct [AsaRequestWebhookEventNetworkSpecificDataMastercard] -type asaRequestWebhookEventNetworkSpecificDataMastercardJSON struct { +// cardAuthorizationApprovalRequestWebhookEventNetworkSpecificDataMastercardJSON +// contains the JSON metadata for the struct +// [CardAuthorizationApprovalRequestWebhookEventNetworkSpecificDataMastercard] +type cardAuthorizationApprovalRequestWebhookEventNetworkSpecificDataMastercardJSON struct { EcommerceSecurityLevelIndicator apijson.Field OnBehalfServiceResult apijson.Field TransactionTypeIdentifier apijson.Field @@ -1572,28 +1590,28 @@ type asaRequestWebhookEventNetworkSpecificDataMastercardJSON struct { ExtraFields map[string]apijson.Field } -func (r *AsaRequestWebhookEventNetworkSpecificDataMastercard) UnmarshalJSON(data []byte) (err error) { +func (r *CardAuthorizationApprovalRequestWebhookEventNetworkSpecificDataMastercard) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r asaRequestWebhookEventNetworkSpecificDataMastercardJSON) RawJSON() string { +func (r cardAuthorizationApprovalRequestWebhookEventNetworkSpecificDataMastercardJSON) RawJSON() string { return r.raw } -type AsaRequestWebhookEventNetworkSpecificDataMastercardOnBehalfServiceResult struct { +type CardAuthorizationApprovalRequestWebhookEventNetworkSpecificDataMastercardOnBehalfServiceResult struct { // Indicates the results of the service processing. Result1 string `json:"result_1,required"` // Identifies the results of the service processing. Result2 string `json:"result_2,required"` // Indicates the service performed on the transaction. - Service string `json:"service,required"` - JSON asaRequestWebhookEventNetworkSpecificDataMastercardOnBehalfServiceResultJSON `json:"-"` + Service string `json:"service,required"` + JSON cardAuthorizationApprovalRequestWebhookEventNetworkSpecificDataMastercardOnBehalfServiceResultJSON `json:"-"` } -// asaRequestWebhookEventNetworkSpecificDataMastercardOnBehalfServiceResultJSON +// cardAuthorizationApprovalRequestWebhookEventNetworkSpecificDataMastercardOnBehalfServiceResultJSON // contains the JSON metadata for the struct -// [AsaRequestWebhookEventNetworkSpecificDataMastercardOnBehalfServiceResult] -type asaRequestWebhookEventNetworkSpecificDataMastercardOnBehalfServiceResultJSON struct { +// [CardAuthorizationApprovalRequestWebhookEventNetworkSpecificDataMastercardOnBehalfServiceResult] +type cardAuthorizationApprovalRequestWebhookEventNetworkSpecificDataMastercardOnBehalfServiceResultJSON struct { Result1 apijson.Field Result2 apijson.Field Service apijson.Field @@ -1601,77 +1619,79 @@ type asaRequestWebhookEventNetworkSpecificDataMastercardOnBehalfServiceResultJSO ExtraFields map[string]apijson.Field } -func (r *AsaRequestWebhookEventNetworkSpecificDataMastercardOnBehalfServiceResult) UnmarshalJSON(data []byte) (err error) { +func (r *CardAuthorizationApprovalRequestWebhookEventNetworkSpecificDataMastercardOnBehalfServiceResult) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r asaRequestWebhookEventNetworkSpecificDataMastercardOnBehalfServiceResultJSON) RawJSON() string { +func (r cardAuthorizationApprovalRequestWebhookEventNetworkSpecificDataMastercardOnBehalfServiceResultJSON) RawJSON() string { return r.raw } -type AsaRequestWebhookEventNetworkSpecificDataVisa struct { +type CardAuthorizationApprovalRequestWebhookEventNetworkSpecificDataVisa struct { // Identifies the purpose or category of a transaction, used to classify and // process transactions according to Visa’s rules. - BusinessApplicationIdentifier string `json:"business_application_identifier,nullable"` - JSON asaRequestWebhookEventNetworkSpecificDataVisaJSON `json:"-"` + BusinessApplicationIdentifier string `json:"business_application_identifier,nullable"` + JSON cardAuthorizationApprovalRequestWebhookEventNetworkSpecificDataVisaJSON `json:"-"` } -// asaRequestWebhookEventNetworkSpecificDataVisaJSON contains the JSON metadata for -// the struct [AsaRequestWebhookEventNetworkSpecificDataVisa] -type asaRequestWebhookEventNetworkSpecificDataVisaJSON struct { +// cardAuthorizationApprovalRequestWebhookEventNetworkSpecificDataVisaJSON contains +// the JSON metadata for the struct +// [CardAuthorizationApprovalRequestWebhookEventNetworkSpecificDataVisa] +type cardAuthorizationApprovalRequestWebhookEventNetworkSpecificDataVisaJSON struct { BusinessApplicationIdentifier apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *AsaRequestWebhookEventNetworkSpecificDataVisa) UnmarshalJSON(data []byte) (err error) { +func (r *CardAuthorizationApprovalRequestWebhookEventNetworkSpecificDataVisa) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r asaRequestWebhookEventNetworkSpecificDataVisaJSON) RawJSON() string { +func (r cardAuthorizationApprovalRequestWebhookEventNetworkSpecificDataVisaJSON) RawJSON() string { return r.raw } -type AsaRequestWebhookEventPos struct { +type CardAuthorizationApprovalRequestWebhookEventPos struct { // POS > Entry Mode object in ASA - EntryMode AsaRequestWebhookEventPosEntryMode `json:"entry_mode"` - Terminal AsaRequestWebhookEventPosTerminal `json:"terminal"` - JSON asaRequestWebhookEventPosJSON `json:"-"` + EntryMode CardAuthorizationApprovalRequestWebhookEventPosEntryMode `json:"entry_mode"` + Terminal CardAuthorizationApprovalRequestWebhookEventPosTerminal `json:"terminal"` + JSON cardAuthorizationApprovalRequestWebhookEventPosJSON `json:"-"` } -// asaRequestWebhookEventPosJSON contains the JSON metadata for the struct -// [AsaRequestWebhookEventPos] -type asaRequestWebhookEventPosJSON struct { +// cardAuthorizationApprovalRequestWebhookEventPosJSON contains the JSON metadata +// for the struct [CardAuthorizationApprovalRequestWebhookEventPos] +type cardAuthorizationApprovalRequestWebhookEventPosJSON struct { EntryMode apijson.Field Terminal apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *AsaRequestWebhookEventPos) UnmarshalJSON(data []byte) (err error) { +func (r *CardAuthorizationApprovalRequestWebhookEventPos) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r asaRequestWebhookEventPosJSON) RawJSON() string { +func (r cardAuthorizationApprovalRequestWebhookEventPosJSON) RawJSON() string { return r.raw } // POS > Entry Mode object in ASA -type AsaRequestWebhookEventPosEntryMode struct { +type CardAuthorizationApprovalRequestWebhookEventPosEntryMode struct { // Card Presence Indicator - Card AsaRequestWebhookEventPosEntryModeCard `json:"card"` + Card CardAuthorizationApprovalRequestWebhookEventPosEntryModeCard `json:"card"` // Cardholder Presence Indicator - Cardholder AsaRequestWebhookEventPosEntryModeCardholder `json:"cardholder"` + Cardholder CardAuthorizationApprovalRequestWebhookEventPosEntryModeCardholder `json:"cardholder"` // Method of entry for the PAN - Pan AsaRequestWebhookEventPosEntryModePan `json:"pan"` + Pan CardAuthorizationApprovalRequestWebhookEventPosEntryModePan `json:"pan"` // Indicates whether the cardholder entered the PIN. True if the PIN was entered. - PinEntered bool `json:"pin_entered"` - JSON asaRequestWebhookEventPosEntryModeJSON `json:"-"` + PinEntered bool `json:"pin_entered"` + JSON cardAuthorizationApprovalRequestWebhookEventPosEntryModeJSON `json:"-"` } -// asaRequestWebhookEventPosEntryModeJSON contains the JSON metadata for the struct -// [AsaRequestWebhookEventPosEntryMode] -type asaRequestWebhookEventPosEntryModeJSON struct { +// cardAuthorizationApprovalRequestWebhookEventPosEntryModeJSON contains the JSON +// metadata for the struct +// [CardAuthorizationApprovalRequestWebhookEventPosEntryMode] +type cardAuthorizationApprovalRequestWebhookEventPosEntryModeJSON struct { Card apijson.Field Cardholder apijson.Field Pan apijson.Field @@ -1680,84 +1700,84 @@ type asaRequestWebhookEventPosEntryModeJSON struct { ExtraFields map[string]apijson.Field } -func (r *AsaRequestWebhookEventPosEntryMode) UnmarshalJSON(data []byte) (err error) { +func (r *CardAuthorizationApprovalRequestWebhookEventPosEntryMode) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r asaRequestWebhookEventPosEntryModeJSON) RawJSON() string { +func (r cardAuthorizationApprovalRequestWebhookEventPosEntryModeJSON) RawJSON() string { return r.raw } // Card Presence Indicator -type AsaRequestWebhookEventPosEntryModeCard string +type CardAuthorizationApprovalRequestWebhookEventPosEntryModeCard string const ( - AsaRequestWebhookEventPosEntryModeCardPresent AsaRequestWebhookEventPosEntryModeCard = "PRESENT" - AsaRequestWebhookEventPosEntryModeCardNotPresent AsaRequestWebhookEventPosEntryModeCard = "NOT_PRESENT" - AsaRequestWebhookEventPosEntryModeCardUnknown AsaRequestWebhookEventPosEntryModeCard = "UNKNOWN" + CardAuthorizationApprovalRequestWebhookEventPosEntryModeCardPresent CardAuthorizationApprovalRequestWebhookEventPosEntryModeCard = "PRESENT" + CardAuthorizationApprovalRequestWebhookEventPosEntryModeCardNotPresent CardAuthorizationApprovalRequestWebhookEventPosEntryModeCard = "NOT_PRESENT" + CardAuthorizationApprovalRequestWebhookEventPosEntryModeCardUnknown CardAuthorizationApprovalRequestWebhookEventPosEntryModeCard = "UNKNOWN" ) -func (r AsaRequestWebhookEventPosEntryModeCard) IsKnown() bool { +func (r CardAuthorizationApprovalRequestWebhookEventPosEntryModeCard) IsKnown() bool { switch r { - case AsaRequestWebhookEventPosEntryModeCardPresent, AsaRequestWebhookEventPosEntryModeCardNotPresent, AsaRequestWebhookEventPosEntryModeCardUnknown: + case CardAuthorizationApprovalRequestWebhookEventPosEntryModeCardPresent, CardAuthorizationApprovalRequestWebhookEventPosEntryModeCardNotPresent, CardAuthorizationApprovalRequestWebhookEventPosEntryModeCardUnknown: return true } return false } // Cardholder Presence Indicator -type AsaRequestWebhookEventPosEntryModeCardholder string +type CardAuthorizationApprovalRequestWebhookEventPosEntryModeCardholder string const ( - AsaRequestWebhookEventPosEntryModeCardholderDeferredBilling AsaRequestWebhookEventPosEntryModeCardholder = "DEFERRED_BILLING" - AsaRequestWebhookEventPosEntryModeCardholderElectronicOrder AsaRequestWebhookEventPosEntryModeCardholder = "ELECTRONIC_ORDER" - AsaRequestWebhookEventPosEntryModeCardholderInstallment AsaRequestWebhookEventPosEntryModeCardholder = "INSTALLMENT" - AsaRequestWebhookEventPosEntryModeCardholderMailOrder AsaRequestWebhookEventPosEntryModeCardholder = "MAIL_ORDER" - AsaRequestWebhookEventPosEntryModeCardholderNotPresent AsaRequestWebhookEventPosEntryModeCardholder = "NOT_PRESENT" - AsaRequestWebhookEventPosEntryModeCardholderPresent AsaRequestWebhookEventPosEntryModeCardholder = "PRESENT" - AsaRequestWebhookEventPosEntryModeCardholderReoccurring AsaRequestWebhookEventPosEntryModeCardholder = "REOCCURRING" - AsaRequestWebhookEventPosEntryModeCardholderTelephoneOrder AsaRequestWebhookEventPosEntryModeCardholder = "TELEPHONE_ORDER" - AsaRequestWebhookEventPosEntryModeCardholderUnknown AsaRequestWebhookEventPosEntryModeCardholder = "UNKNOWN" + CardAuthorizationApprovalRequestWebhookEventPosEntryModeCardholderDeferredBilling CardAuthorizationApprovalRequestWebhookEventPosEntryModeCardholder = "DEFERRED_BILLING" + CardAuthorizationApprovalRequestWebhookEventPosEntryModeCardholderElectronicOrder CardAuthorizationApprovalRequestWebhookEventPosEntryModeCardholder = "ELECTRONIC_ORDER" + CardAuthorizationApprovalRequestWebhookEventPosEntryModeCardholderInstallment CardAuthorizationApprovalRequestWebhookEventPosEntryModeCardholder = "INSTALLMENT" + CardAuthorizationApprovalRequestWebhookEventPosEntryModeCardholderMailOrder CardAuthorizationApprovalRequestWebhookEventPosEntryModeCardholder = "MAIL_ORDER" + CardAuthorizationApprovalRequestWebhookEventPosEntryModeCardholderNotPresent CardAuthorizationApprovalRequestWebhookEventPosEntryModeCardholder = "NOT_PRESENT" + CardAuthorizationApprovalRequestWebhookEventPosEntryModeCardholderPresent CardAuthorizationApprovalRequestWebhookEventPosEntryModeCardholder = "PRESENT" + CardAuthorizationApprovalRequestWebhookEventPosEntryModeCardholderReoccurring CardAuthorizationApprovalRequestWebhookEventPosEntryModeCardholder = "REOCCURRING" + CardAuthorizationApprovalRequestWebhookEventPosEntryModeCardholderTelephoneOrder CardAuthorizationApprovalRequestWebhookEventPosEntryModeCardholder = "TELEPHONE_ORDER" + CardAuthorizationApprovalRequestWebhookEventPosEntryModeCardholderUnknown CardAuthorizationApprovalRequestWebhookEventPosEntryModeCardholder = "UNKNOWN" ) -func (r AsaRequestWebhookEventPosEntryModeCardholder) IsKnown() bool { +func (r CardAuthorizationApprovalRequestWebhookEventPosEntryModeCardholder) IsKnown() bool { switch r { - case AsaRequestWebhookEventPosEntryModeCardholderDeferredBilling, AsaRequestWebhookEventPosEntryModeCardholderElectronicOrder, AsaRequestWebhookEventPosEntryModeCardholderInstallment, AsaRequestWebhookEventPosEntryModeCardholderMailOrder, AsaRequestWebhookEventPosEntryModeCardholderNotPresent, AsaRequestWebhookEventPosEntryModeCardholderPresent, AsaRequestWebhookEventPosEntryModeCardholderReoccurring, AsaRequestWebhookEventPosEntryModeCardholderTelephoneOrder, AsaRequestWebhookEventPosEntryModeCardholderUnknown: + case CardAuthorizationApprovalRequestWebhookEventPosEntryModeCardholderDeferredBilling, CardAuthorizationApprovalRequestWebhookEventPosEntryModeCardholderElectronicOrder, CardAuthorizationApprovalRequestWebhookEventPosEntryModeCardholderInstallment, CardAuthorizationApprovalRequestWebhookEventPosEntryModeCardholderMailOrder, CardAuthorizationApprovalRequestWebhookEventPosEntryModeCardholderNotPresent, CardAuthorizationApprovalRequestWebhookEventPosEntryModeCardholderPresent, CardAuthorizationApprovalRequestWebhookEventPosEntryModeCardholderReoccurring, CardAuthorizationApprovalRequestWebhookEventPosEntryModeCardholderTelephoneOrder, CardAuthorizationApprovalRequestWebhookEventPosEntryModeCardholderUnknown: return true } return false } // Method of entry for the PAN -type AsaRequestWebhookEventPosEntryModePan string +type CardAuthorizationApprovalRequestWebhookEventPosEntryModePan string const ( - AsaRequestWebhookEventPosEntryModePanAutoEntry AsaRequestWebhookEventPosEntryModePan = "AUTO_ENTRY" - AsaRequestWebhookEventPosEntryModePanBarCode AsaRequestWebhookEventPosEntryModePan = "BAR_CODE" - AsaRequestWebhookEventPosEntryModePanContactless AsaRequestWebhookEventPosEntryModePan = "CONTACTLESS" - AsaRequestWebhookEventPosEntryModePanEcommerce AsaRequestWebhookEventPosEntryModePan = "ECOMMERCE" - AsaRequestWebhookEventPosEntryModePanErrorKeyed AsaRequestWebhookEventPosEntryModePan = "ERROR_KEYED" - AsaRequestWebhookEventPosEntryModePanErrorMagneticStripe AsaRequestWebhookEventPosEntryModePan = "ERROR_MAGNETIC_STRIPE" - AsaRequestWebhookEventPosEntryModePanIcc AsaRequestWebhookEventPosEntryModePan = "ICC" - AsaRequestWebhookEventPosEntryModePanKeyEntered AsaRequestWebhookEventPosEntryModePan = "KEY_ENTERED" - AsaRequestWebhookEventPosEntryModePanMagneticStripe AsaRequestWebhookEventPosEntryModePan = "MAGNETIC_STRIPE" - AsaRequestWebhookEventPosEntryModePanManual AsaRequestWebhookEventPosEntryModePan = "MANUAL" - AsaRequestWebhookEventPosEntryModePanOcr AsaRequestWebhookEventPosEntryModePan = "OCR" - AsaRequestWebhookEventPosEntryModePanSecureCardless AsaRequestWebhookEventPosEntryModePan = "SECURE_CARDLESS" - AsaRequestWebhookEventPosEntryModePanUnspecified AsaRequestWebhookEventPosEntryModePan = "UNSPECIFIED" - AsaRequestWebhookEventPosEntryModePanUnknown AsaRequestWebhookEventPosEntryModePan = "UNKNOWN" - AsaRequestWebhookEventPosEntryModePanCredentialOnFile AsaRequestWebhookEventPosEntryModePan = "CREDENTIAL_ON_FILE" + CardAuthorizationApprovalRequestWebhookEventPosEntryModePanAutoEntry CardAuthorizationApprovalRequestWebhookEventPosEntryModePan = "AUTO_ENTRY" + CardAuthorizationApprovalRequestWebhookEventPosEntryModePanBarCode CardAuthorizationApprovalRequestWebhookEventPosEntryModePan = "BAR_CODE" + CardAuthorizationApprovalRequestWebhookEventPosEntryModePanContactless CardAuthorizationApprovalRequestWebhookEventPosEntryModePan = "CONTACTLESS" + CardAuthorizationApprovalRequestWebhookEventPosEntryModePanEcommerce CardAuthorizationApprovalRequestWebhookEventPosEntryModePan = "ECOMMERCE" + CardAuthorizationApprovalRequestWebhookEventPosEntryModePanErrorKeyed CardAuthorizationApprovalRequestWebhookEventPosEntryModePan = "ERROR_KEYED" + CardAuthorizationApprovalRequestWebhookEventPosEntryModePanErrorMagneticStripe CardAuthorizationApprovalRequestWebhookEventPosEntryModePan = "ERROR_MAGNETIC_STRIPE" + CardAuthorizationApprovalRequestWebhookEventPosEntryModePanIcc CardAuthorizationApprovalRequestWebhookEventPosEntryModePan = "ICC" + CardAuthorizationApprovalRequestWebhookEventPosEntryModePanKeyEntered CardAuthorizationApprovalRequestWebhookEventPosEntryModePan = "KEY_ENTERED" + CardAuthorizationApprovalRequestWebhookEventPosEntryModePanMagneticStripe CardAuthorizationApprovalRequestWebhookEventPosEntryModePan = "MAGNETIC_STRIPE" + CardAuthorizationApprovalRequestWebhookEventPosEntryModePanManual CardAuthorizationApprovalRequestWebhookEventPosEntryModePan = "MANUAL" + CardAuthorizationApprovalRequestWebhookEventPosEntryModePanOcr CardAuthorizationApprovalRequestWebhookEventPosEntryModePan = "OCR" + CardAuthorizationApprovalRequestWebhookEventPosEntryModePanSecureCardless CardAuthorizationApprovalRequestWebhookEventPosEntryModePan = "SECURE_CARDLESS" + CardAuthorizationApprovalRequestWebhookEventPosEntryModePanUnspecified CardAuthorizationApprovalRequestWebhookEventPosEntryModePan = "UNSPECIFIED" + CardAuthorizationApprovalRequestWebhookEventPosEntryModePanUnknown CardAuthorizationApprovalRequestWebhookEventPosEntryModePan = "UNKNOWN" + CardAuthorizationApprovalRequestWebhookEventPosEntryModePanCredentialOnFile CardAuthorizationApprovalRequestWebhookEventPosEntryModePan = "CREDENTIAL_ON_FILE" ) -func (r AsaRequestWebhookEventPosEntryModePan) IsKnown() bool { +func (r CardAuthorizationApprovalRequestWebhookEventPosEntryModePan) IsKnown() bool { switch r { - case AsaRequestWebhookEventPosEntryModePanAutoEntry, AsaRequestWebhookEventPosEntryModePanBarCode, AsaRequestWebhookEventPosEntryModePanContactless, AsaRequestWebhookEventPosEntryModePanEcommerce, AsaRequestWebhookEventPosEntryModePanErrorKeyed, AsaRequestWebhookEventPosEntryModePanErrorMagneticStripe, AsaRequestWebhookEventPosEntryModePanIcc, AsaRequestWebhookEventPosEntryModePanKeyEntered, AsaRequestWebhookEventPosEntryModePanMagneticStripe, AsaRequestWebhookEventPosEntryModePanManual, AsaRequestWebhookEventPosEntryModePanOcr, AsaRequestWebhookEventPosEntryModePanSecureCardless, AsaRequestWebhookEventPosEntryModePanUnspecified, AsaRequestWebhookEventPosEntryModePanUnknown, AsaRequestWebhookEventPosEntryModePanCredentialOnFile: + case CardAuthorizationApprovalRequestWebhookEventPosEntryModePanAutoEntry, CardAuthorizationApprovalRequestWebhookEventPosEntryModePanBarCode, CardAuthorizationApprovalRequestWebhookEventPosEntryModePanContactless, CardAuthorizationApprovalRequestWebhookEventPosEntryModePanEcommerce, CardAuthorizationApprovalRequestWebhookEventPosEntryModePanErrorKeyed, CardAuthorizationApprovalRequestWebhookEventPosEntryModePanErrorMagneticStripe, CardAuthorizationApprovalRequestWebhookEventPosEntryModePanIcc, CardAuthorizationApprovalRequestWebhookEventPosEntryModePanKeyEntered, CardAuthorizationApprovalRequestWebhookEventPosEntryModePanMagneticStripe, CardAuthorizationApprovalRequestWebhookEventPosEntryModePanManual, CardAuthorizationApprovalRequestWebhookEventPosEntryModePanOcr, CardAuthorizationApprovalRequestWebhookEventPosEntryModePanSecureCardless, CardAuthorizationApprovalRequestWebhookEventPosEntryModePanUnspecified, CardAuthorizationApprovalRequestWebhookEventPosEntryModePanUnknown, CardAuthorizationApprovalRequestWebhookEventPosEntryModePanCredentialOnFile: return true } return false } -type AsaRequestWebhookEventPosTerminal struct { +type CardAuthorizationApprovalRequestWebhookEventPosTerminal struct { // True if a clerk is present at the sale. Attended bool `json:"attended,required"` // True if the terminal is capable of retaining the card. @@ -1765,7 +1785,7 @@ type AsaRequestWebhookEventPosTerminal struct { // True if the sale was made at the place of business (vs. mobile). OnPremise bool `json:"on_premise,required"` // The person that is designated to swipe the card - Operator AsaRequestWebhookEventPosTerminalOperator `json:"operator,required"` + Operator CardAuthorizationApprovalRequestWebhookEventPosTerminalOperator `json:"operator,required"` // True if the terminal is capable of partial approval. Partial approval is when // part of a transaction is approved and another payment must be used for the // remainder. Example scenario: A $40 transaction is attempted on a prepaid card @@ -1773,18 +1793,19 @@ type AsaRequestWebhookEventPosTerminal struct { // which point the POS will prompt the user for an additional payment of $15. PartialApprovalCapable bool `json:"partial_approval_capable,required"` // Status of whether the POS is able to accept PINs - PinCapability AsaRequestWebhookEventPosTerminalPinCapability `json:"pin_capability,required"` + PinCapability CardAuthorizationApprovalRequestWebhookEventPosTerminalPinCapability `json:"pin_capability,required"` // POS Type - Type AsaRequestWebhookEventPosTerminalType `json:"type,required"` + Type CardAuthorizationApprovalRequestWebhookEventPosTerminalType `json:"type,required"` // Uniquely identifies a terminal at the card acceptor location of acquiring // institutions or merchant POS Systems. Left justified with trailing spaces. - AcceptorTerminalID string `json:"acceptor_terminal_id,nullable"` - JSON asaRequestWebhookEventPosTerminalJSON `json:"-"` + AcceptorTerminalID string `json:"acceptor_terminal_id,nullable"` + JSON cardAuthorizationApprovalRequestWebhookEventPosTerminalJSON `json:"-"` } -// asaRequestWebhookEventPosTerminalJSON contains the JSON metadata for the struct -// [AsaRequestWebhookEventPosTerminal] -type asaRequestWebhookEventPosTerminalJSON struct { +// cardAuthorizationApprovalRequestWebhookEventPosTerminalJSON contains the JSON +// metadata for the struct +// [CardAuthorizationApprovalRequestWebhookEventPosTerminal] +type cardAuthorizationApprovalRequestWebhookEventPosTerminalJSON struct { Attended apijson.Field CardRetentionCapable apijson.Field OnPremise apijson.Field @@ -1797,83 +1818,83 @@ type asaRequestWebhookEventPosTerminalJSON struct { ExtraFields map[string]apijson.Field } -func (r *AsaRequestWebhookEventPosTerminal) UnmarshalJSON(data []byte) (err error) { +func (r *CardAuthorizationApprovalRequestWebhookEventPosTerminal) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r asaRequestWebhookEventPosTerminalJSON) RawJSON() string { +func (r cardAuthorizationApprovalRequestWebhookEventPosTerminalJSON) RawJSON() string { return r.raw } // The person that is designated to swipe the card -type AsaRequestWebhookEventPosTerminalOperator string +type CardAuthorizationApprovalRequestWebhookEventPosTerminalOperator string const ( - AsaRequestWebhookEventPosTerminalOperatorAdministrative AsaRequestWebhookEventPosTerminalOperator = "ADMINISTRATIVE" - AsaRequestWebhookEventPosTerminalOperatorCardholder AsaRequestWebhookEventPosTerminalOperator = "CARDHOLDER" - AsaRequestWebhookEventPosTerminalOperatorCardAcceptor AsaRequestWebhookEventPosTerminalOperator = "CARD_ACCEPTOR" - AsaRequestWebhookEventPosTerminalOperatorUnknown AsaRequestWebhookEventPosTerminalOperator = "UNKNOWN" + CardAuthorizationApprovalRequestWebhookEventPosTerminalOperatorAdministrative CardAuthorizationApprovalRequestWebhookEventPosTerminalOperator = "ADMINISTRATIVE" + CardAuthorizationApprovalRequestWebhookEventPosTerminalOperatorCardholder CardAuthorizationApprovalRequestWebhookEventPosTerminalOperator = "CARDHOLDER" + CardAuthorizationApprovalRequestWebhookEventPosTerminalOperatorCardAcceptor CardAuthorizationApprovalRequestWebhookEventPosTerminalOperator = "CARD_ACCEPTOR" + CardAuthorizationApprovalRequestWebhookEventPosTerminalOperatorUnknown CardAuthorizationApprovalRequestWebhookEventPosTerminalOperator = "UNKNOWN" ) -func (r AsaRequestWebhookEventPosTerminalOperator) IsKnown() bool { +func (r CardAuthorizationApprovalRequestWebhookEventPosTerminalOperator) IsKnown() bool { switch r { - case AsaRequestWebhookEventPosTerminalOperatorAdministrative, AsaRequestWebhookEventPosTerminalOperatorCardholder, AsaRequestWebhookEventPosTerminalOperatorCardAcceptor, AsaRequestWebhookEventPosTerminalOperatorUnknown: + case CardAuthorizationApprovalRequestWebhookEventPosTerminalOperatorAdministrative, CardAuthorizationApprovalRequestWebhookEventPosTerminalOperatorCardholder, CardAuthorizationApprovalRequestWebhookEventPosTerminalOperatorCardAcceptor, CardAuthorizationApprovalRequestWebhookEventPosTerminalOperatorUnknown: return true } return false } // Status of whether the POS is able to accept PINs -type AsaRequestWebhookEventPosTerminalPinCapability string +type CardAuthorizationApprovalRequestWebhookEventPosTerminalPinCapability string const ( - AsaRequestWebhookEventPosTerminalPinCapabilityCapable AsaRequestWebhookEventPosTerminalPinCapability = "CAPABLE" - AsaRequestWebhookEventPosTerminalPinCapabilityInoperative AsaRequestWebhookEventPosTerminalPinCapability = "INOPERATIVE" - AsaRequestWebhookEventPosTerminalPinCapabilityNotCapable AsaRequestWebhookEventPosTerminalPinCapability = "NOT_CAPABLE" - AsaRequestWebhookEventPosTerminalPinCapabilityUnspecified AsaRequestWebhookEventPosTerminalPinCapability = "UNSPECIFIED" + CardAuthorizationApprovalRequestWebhookEventPosTerminalPinCapabilityCapable CardAuthorizationApprovalRequestWebhookEventPosTerminalPinCapability = "CAPABLE" + CardAuthorizationApprovalRequestWebhookEventPosTerminalPinCapabilityInoperative CardAuthorizationApprovalRequestWebhookEventPosTerminalPinCapability = "INOPERATIVE" + CardAuthorizationApprovalRequestWebhookEventPosTerminalPinCapabilityNotCapable CardAuthorizationApprovalRequestWebhookEventPosTerminalPinCapability = "NOT_CAPABLE" + CardAuthorizationApprovalRequestWebhookEventPosTerminalPinCapabilityUnspecified CardAuthorizationApprovalRequestWebhookEventPosTerminalPinCapability = "UNSPECIFIED" ) -func (r AsaRequestWebhookEventPosTerminalPinCapability) IsKnown() bool { +func (r CardAuthorizationApprovalRequestWebhookEventPosTerminalPinCapability) IsKnown() bool { switch r { - case AsaRequestWebhookEventPosTerminalPinCapabilityCapable, AsaRequestWebhookEventPosTerminalPinCapabilityInoperative, AsaRequestWebhookEventPosTerminalPinCapabilityNotCapable, AsaRequestWebhookEventPosTerminalPinCapabilityUnspecified: + case CardAuthorizationApprovalRequestWebhookEventPosTerminalPinCapabilityCapable, CardAuthorizationApprovalRequestWebhookEventPosTerminalPinCapabilityInoperative, CardAuthorizationApprovalRequestWebhookEventPosTerminalPinCapabilityNotCapable, CardAuthorizationApprovalRequestWebhookEventPosTerminalPinCapabilityUnspecified: return true } return false } // POS Type -type AsaRequestWebhookEventPosTerminalType string +type CardAuthorizationApprovalRequestWebhookEventPosTerminalType string const ( - AsaRequestWebhookEventPosTerminalTypeAdministrative AsaRequestWebhookEventPosTerminalType = "ADMINISTRATIVE" - AsaRequestWebhookEventPosTerminalTypeAtm AsaRequestWebhookEventPosTerminalType = "ATM" - AsaRequestWebhookEventPosTerminalTypeAuthorization AsaRequestWebhookEventPosTerminalType = "AUTHORIZATION" - AsaRequestWebhookEventPosTerminalTypeCouponMachine AsaRequestWebhookEventPosTerminalType = "COUPON_MACHINE" - AsaRequestWebhookEventPosTerminalTypeDialTerminal AsaRequestWebhookEventPosTerminalType = "DIAL_TERMINAL" - AsaRequestWebhookEventPosTerminalTypeEcommerce AsaRequestWebhookEventPosTerminalType = "ECOMMERCE" - AsaRequestWebhookEventPosTerminalTypeEcr AsaRequestWebhookEventPosTerminalType = "ECR" - AsaRequestWebhookEventPosTerminalTypeFuelMachine AsaRequestWebhookEventPosTerminalType = "FUEL_MACHINE" - AsaRequestWebhookEventPosTerminalTypeHomeTerminal AsaRequestWebhookEventPosTerminalType = "HOME_TERMINAL" - AsaRequestWebhookEventPosTerminalTypeMicr AsaRequestWebhookEventPosTerminalType = "MICR" - AsaRequestWebhookEventPosTerminalTypeOffPremise AsaRequestWebhookEventPosTerminalType = "OFF_PREMISE" - AsaRequestWebhookEventPosTerminalTypePayment AsaRequestWebhookEventPosTerminalType = "PAYMENT" - AsaRequestWebhookEventPosTerminalTypePda AsaRequestWebhookEventPosTerminalType = "PDA" - AsaRequestWebhookEventPosTerminalTypePhone AsaRequestWebhookEventPosTerminalType = "PHONE" - AsaRequestWebhookEventPosTerminalTypePoint AsaRequestWebhookEventPosTerminalType = "POINT" - AsaRequestWebhookEventPosTerminalTypePosTerminal AsaRequestWebhookEventPosTerminalType = "POS_TERMINAL" - AsaRequestWebhookEventPosTerminalTypePublicUtility AsaRequestWebhookEventPosTerminalType = "PUBLIC_UTILITY" - AsaRequestWebhookEventPosTerminalTypeSelfService AsaRequestWebhookEventPosTerminalType = "SELF_SERVICE" - AsaRequestWebhookEventPosTerminalTypeTelevision AsaRequestWebhookEventPosTerminalType = "TELEVISION" - AsaRequestWebhookEventPosTerminalTypeTeller AsaRequestWebhookEventPosTerminalType = "TELLER" - AsaRequestWebhookEventPosTerminalTypeTravelersCheckMachine AsaRequestWebhookEventPosTerminalType = "TRAVELERS_CHECK_MACHINE" - AsaRequestWebhookEventPosTerminalTypeVending AsaRequestWebhookEventPosTerminalType = "VENDING" - AsaRequestWebhookEventPosTerminalTypeVoice AsaRequestWebhookEventPosTerminalType = "VOICE" - AsaRequestWebhookEventPosTerminalTypeUnknown AsaRequestWebhookEventPosTerminalType = "UNKNOWN" + CardAuthorizationApprovalRequestWebhookEventPosTerminalTypeAdministrative CardAuthorizationApprovalRequestWebhookEventPosTerminalType = "ADMINISTRATIVE" + CardAuthorizationApprovalRequestWebhookEventPosTerminalTypeAtm CardAuthorizationApprovalRequestWebhookEventPosTerminalType = "ATM" + CardAuthorizationApprovalRequestWebhookEventPosTerminalTypeAuthorization CardAuthorizationApprovalRequestWebhookEventPosTerminalType = "AUTHORIZATION" + CardAuthorizationApprovalRequestWebhookEventPosTerminalTypeCouponMachine CardAuthorizationApprovalRequestWebhookEventPosTerminalType = "COUPON_MACHINE" + CardAuthorizationApprovalRequestWebhookEventPosTerminalTypeDialTerminal CardAuthorizationApprovalRequestWebhookEventPosTerminalType = "DIAL_TERMINAL" + CardAuthorizationApprovalRequestWebhookEventPosTerminalTypeEcommerce CardAuthorizationApprovalRequestWebhookEventPosTerminalType = "ECOMMERCE" + CardAuthorizationApprovalRequestWebhookEventPosTerminalTypeEcr CardAuthorizationApprovalRequestWebhookEventPosTerminalType = "ECR" + CardAuthorizationApprovalRequestWebhookEventPosTerminalTypeFuelMachine CardAuthorizationApprovalRequestWebhookEventPosTerminalType = "FUEL_MACHINE" + CardAuthorizationApprovalRequestWebhookEventPosTerminalTypeHomeTerminal CardAuthorizationApprovalRequestWebhookEventPosTerminalType = "HOME_TERMINAL" + CardAuthorizationApprovalRequestWebhookEventPosTerminalTypeMicr CardAuthorizationApprovalRequestWebhookEventPosTerminalType = "MICR" + CardAuthorizationApprovalRequestWebhookEventPosTerminalTypeOffPremise CardAuthorizationApprovalRequestWebhookEventPosTerminalType = "OFF_PREMISE" + CardAuthorizationApprovalRequestWebhookEventPosTerminalTypePayment CardAuthorizationApprovalRequestWebhookEventPosTerminalType = "PAYMENT" + CardAuthorizationApprovalRequestWebhookEventPosTerminalTypePda CardAuthorizationApprovalRequestWebhookEventPosTerminalType = "PDA" + CardAuthorizationApprovalRequestWebhookEventPosTerminalTypePhone CardAuthorizationApprovalRequestWebhookEventPosTerminalType = "PHONE" + CardAuthorizationApprovalRequestWebhookEventPosTerminalTypePoint CardAuthorizationApprovalRequestWebhookEventPosTerminalType = "POINT" + CardAuthorizationApprovalRequestWebhookEventPosTerminalTypePosTerminal CardAuthorizationApprovalRequestWebhookEventPosTerminalType = "POS_TERMINAL" + CardAuthorizationApprovalRequestWebhookEventPosTerminalTypePublicUtility CardAuthorizationApprovalRequestWebhookEventPosTerminalType = "PUBLIC_UTILITY" + CardAuthorizationApprovalRequestWebhookEventPosTerminalTypeSelfService CardAuthorizationApprovalRequestWebhookEventPosTerminalType = "SELF_SERVICE" + CardAuthorizationApprovalRequestWebhookEventPosTerminalTypeTelevision CardAuthorizationApprovalRequestWebhookEventPosTerminalType = "TELEVISION" + CardAuthorizationApprovalRequestWebhookEventPosTerminalTypeTeller CardAuthorizationApprovalRequestWebhookEventPosTerminalType = "TELLER" + CardAuthorizationApprovalRequestWebhookEventPosTerminalTypeTravelersCheckMachine CardAuthorizationApprovalRequestWebhookEventPosTerminalType = "TRAVELERS_CHECK_MACHINE" + CardAuthorizationApprovalRequestWebhookEventPosTerminalTypeVending CardAuthorizationApprovalRequestWebhookEventPosTerminalType = "VENDING" + CardAuthorizationApprovalRequestWebhookEventPosTerminalTypeVoice CardAuthorizationApprovalRequestWebhookEventPosTerminalType = "VOICE" + CardAuthorizationApprovalRequestWebhookEventPosTerminalTypeUnknown CardAuthorizationApprovalRequestWebhookEventPosTerminalType = "UNKNOWN" ) -func (r AsaRequestWebhookEventPosTerminalType) IsKnown() bool { +func (r CardAuthorizationApprovalRequestWebhookEventPosTerminalType) IsKnown() bool { switch r { - case AsaRequestWebhookEventPosTerminalTypeAdministrative, AsaRequestWebhookEventPosTerminalTypeAtm, AsaRequestWebhookEventPosTerminalTypeAuthorization, AsaRequestWebhookEventPosTerminalTypeCouponMachine, AsaRequestWebhookEventPosTerminalTypeDialTerminal, AsaRequestWebhookEventPosTerminalTypeEcommerce, AsaRequestWebhookEventPosTerminalTypeEcr, AsaRequestWebhookEventPosTerminalTypeFuelMachine, AsaRequestWebhookEventPosTerminalTypeHomeTerminal, AsaRequestWebhookEventPosTerminalTypeMicr, AsaRequestWebhookEventPosTerminalTypeOffPremise, AsaRequestWebhookEventPosTerminalTypePayment, AsaRequestWebhookEventPosTerminalTypePda, AsaRequestWebhookEventPosTerminalTypePhone, AsaRequestWebhookEventPosTerminalTypePoint, AsaRequestWebhookEventPosTerminalTypePosTerminal, AsaRequestWebhookEventPosTerminalTypePublicUtility, AsaRequestWebhookEventPosTerminalTypeSelfService, AsaRequestWebhookEventPosTerminalTypeTelevision, AsaRequestWebhookEventPosTerminalTypeTeller, AsaRequestWebhookEventPosTerminalTypeTravelersCheckMachine, AsaRequestWebhookEventPosTerminalTypeVending, AsaRequestWebhookEventPosTerminalTypeVoice, AsaRequestWebhookEventPosTerminalTypeUnknown: + case CardAuthorizationApprovalRequestWebhookEventPosTerminalTypeAdministrative, CardAuthorizationApprovalRequestWebhookEventPosTerminalTypeAtm, CardAuthorizationApprovalRequestWebhookEventPosTerminalTypeAuthorization, CardAuthorizationApprovalRequestWebhookEventPosTerminalTypeCouponMachine, CardAuthorizationApprovalRequestWebhookEventPosTerminalTypeDialTerminal, CardAuthorizationApprovalRequestWebhookEventPosTerminalTypeEcommerce, CardAuthorizationApprovalRequestWebhookEventPosTerminalTypeEcr, CardAuthorizationApprovalRequestWebhookEventPosTerminalTypeFuelMachine, CardAuthorizationApprovalRequestWebhookEventPosTerminalTypeHomeTerminal, CardAuthorizationApprovalRequestWebhookEventPosTerminalTypeMicr, CardAuthorizationApprovalRequestWebhookEventPosTerminalTypeOffPremise, CardAuthorizationApprovalRequestWebhookEventPosTerminalTypePayment, CardAuthorizationApprovalRequestWebhookEventPosTerminalTypePda, CardAuthorizationApprovalRequestWebhookEventPosTerminalTypePhone, CardAuthorizationApprovalRequestWebhookEventPosTerminalTypePoint, CardAuthorizationApprovalRequestWebhookEventPosTerminalTypePosTerminal, CardAuthorizationApprovalRequestWebhookEventPosTerminalTypePublicUtility, CardAuthorizationApprovalRequestWebhookEventPosTerminalTypeSelfService, CardAuthorizationApprovalRequestWebhookEventPosTerminalTypeTelevision, CardAuthorizationApprovalRequestWebhookEventPosTerminalTypeTeller, CardAuthorizationApprovalRequestWebhookEventPosTerminalTypeTravelersCheckMachine, CardAuthorizationApprovalRequestWebhookEventPosTerminalTypeVending, CardAuthorizationApprovalRequestWebhookEventPosTerminalTypeVoice, CardAuthorizationApprovalRequestWebhookEventPosTerminalTypeUnknown: return true } return false @@ -4694,6 +4715,45 @@ func (r TokenizationUpdatedWebhookEventEventType) IsKnown() bool { return false } +// Represents a 3DS authentication +type ThreeDSAuthenticationApprovalRequestWebhookEvent struct { + EventType ThreeDSAuthenticationApprovalRequestWebhookEventEventType `json:"event_type,required"` + JSON threeDSAuthenticationApprovalRequestWebhookEventJSON `json:"-"` + ThreeDSAuthentication +} + +// threeDSAuthenticationApprovalRequestWebhookEventJSON contains the JSON metadata +// for the struct [ThreeDSAuthenticationApprovalRequestWebhookEvent] +type threeDSAuthenticationApprovalRequestWebhookEventJSON struct { + EventType apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ThreeDSAuthenticationApprovalRequestWebhookEvent) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r threeDSAuthenticationApprovalRequestWebhookEventJSON) RawJSON() string { + return r.raw +} + +func (r ThreeDSAuthenticationApprovalRequestWebhookEvent) implementsParsedWebhookEvent() {} + +type ThreeDSAuthenticationApprovalRequestWebhookEventEventType string + +const ( + ThreeDSAuthenticationApprovalRequestWebhookEventEventTypeThreeDSAuthenticationApprovalRequest ThreeDSAuthenticationApprovalRequestWebhookEventEventType = "three_ds_authentication.approval_request" +) + +func (r ThreeDSAuthenticationApprovalRequestWebhookEventEventType) IsKnown() bool { + switch r { + case ThreeDSAuthenticationApprovalRequestWebhookEventEventTypeThreeDSAuthenticationApprovalRequest: + return true + } + return false +} + // The Dispute object tracks the progression of a dispute throughout its lifecycle. type DisputeTransactionCreatedWebhookEvent struct { // The type of event that occurred. @@ -4840,8 +4900,8 @@ type ParsedWebhookEvent struct { AuthorizationCode string `json:"authorization_code,nullable"` // Amount of credit available to spend in cents AvailableCredit int64 `json:"available_credit"` - // This field can have the runtime type of [AsaRequestWebhookEventAvs], - // [TransactionAvs]. + // This field can have the runtime type of + // [CardAuthorizationApprovalRequestWebhookEventAvs], [TransactionAvs]. Avs interface{} `json:"avs"` // Auth Rule Backtest Token BacktestToken string `json:"backtest_token" format:"uuid"` @@ -4854,7 +4914,8 @@ type ParsedWebhookEvent struct { // If applicable, represents the business account token associated with the // account_holder. BusinessAccountToken string `json:"business_account_token,nullable" format:"uuid"` - // This field can have the runtime type of [AsaRequestWebhookEventCard]. + // This field can have the runtime type of + // [CardAuthorizationApprovalRequestWebhookEventCard]. Card interface{} `json:"card"` // Indicates whether the expiration date provided by the cardholder during checkout // matches Lithic's record of the card's expiration date. @@ -5012,7 +5073,8 @@ type ParsedWebhookEvent struct { FirstName string `json:"first_name"` // This field can have the runtime type of [[]EnhancedDataFleet]. Fleet interface{} `json:"fleet"` - // This field can have the runtime type of [AsaRequestWebhookEventFleetInfo]. + // This field can have the runtime type of + // [CardAuthorizationApprovalRequestWebhookEventFleetInfo]. FleetInfo interface{} `json:"fleet_info"` // Globally unique identifier for the financial account or card that will send the // funds. Accepted type dependent on the program's use case @@ -5045,7 +5107,8 @@ type ParsedWebhookEvent struct { LastFour string `json:"last_four"` // If applicable, represents the account_holder's last name. LastName string `json:"last_name"` - // This field can have the runtime type of [AsaRequestWebhookEventLatestChallenge]. + // This field can have the runtime type of + // [CardAuthorizationApprovalRequestWebhookEventLatestChallenge]. LatestChallenge interface{} `json:"latest_challenge"` // If applicable, represents the account_holder's business name. LegalBusinessName string `json:"legal_business_name"` @@ -5099,7 +5162,7 @@ type ParsedWebhookEvent struct { // [[]FundingEventNetworkSettlementSummary]. NetworkSettlementSummary interface{} `json:"network_settlement_summary"` // This field can have the runtime type of - // [AsaRequestWebhookEventNetworkSpecificData]. + // [CardAuthorizationApprovalRequestWebhookEventNetworkSpecificData]. NetworkSpecificData interface{} `json:"network_specific_data"` // Date when the next payment is due NextPaymentDueDate time.Time `json:"next_payment_due_date" format:"date"` @@ -5117,8 +5180,9 @@ type ParsedWebhookEvent struct { // will appear in statements Owner string `json:"owner"` // Owner Type - OwnerType OwnerType `json:"owner_type"` - PaymentAllocation CategoryBalances `json:"payment_allocation"` + OwnerType OwnerType `json:"owner_type"` + // This field can have the runtime type of [LoanTapePaymentAllocation]. + PaymentAllocation interface{} `json:"payment_allocation"` // Date when the payment is due PaymentDueDate time.Time `json:"payment_due_date,nullable" format:"date"` PaymentType ParsedWebhookEventPaymentType `json:"payment_type"` @@ -5134,8 +5198,8 @@ type ParsedWebhookEvent struct { // If updated, the newly updated phone_number associated with the account_holder // otherwise the existing phone_number is provided. PhoneNumber string `json:"phone_number"` - // This field can have the runtime type of [AsaRequestWebhookEventPos], - // [TransactionPos]. + // This field can have the runtime type of + // [CardAuthorizationApprovalRequestWebhookEventPos], [TransactionPos]. Pos interface{} `json:"pos"` // Date dispute entered pre-arbitration. PrearbitrationDate time.Time `json:"prearbitration_date,nullable" format:"date-time"` @@ -5331,6 +5395,8 @@ type ParsedWebhookEvent struct { UploadURL string `json:"upload_url"` // User Defined ID UserDefinedID string `json:"user_defined_id,nullable"` + // User-defined status for the financial account + UserDefinedStatus string `json:"user_defined_status,nullable"` // The number of attempts at verification VerificationAttempts int64 `json:"verification_attempts"` // Optional free text description of the reason for the failed verification. For @@ -5553,6 +5619,7 @@ type parsedWebhookEventJSON struct { UploadStatus apijson.Field UploadURL apijson.Field UserDefinedID apijson.Field + UserDefinedStatus apijson.Field VerificationAttempts apijson.Field VerificationFailedReason apijson.Field VerificationMethod apijson.Field @@ -5584,7 +5651,8 @@ func (r *ParsedWebhookEvent) UnmarshalJSON(data []byte) (err error) { // Possible runtime types of the union are [AccountHolderCreatedWebhookEvent], // [ParsedWebhookEventKYBPayload], [ParsedWebhookEventKYCPayload], // [ParsedWebhookEventLegacyPayload], [AccountHolderVerificationWebhookEvent], -// [AccountHolderDocumentUpdatedWebhookEvent], [AsaRequestWebhookEvent], +// [AccountHolderDocumentUpdatedWebhookEvent], +// [CardAuthorizationApprovalRequestWebhookEvent], // [TokenizationDecisioningRequestWebhookEvent], // [AuthRulesBacktestReportCreatedWebhookEvent], [BalanceUpdatedWebhookEvent], // [BookTransferTransactionCreatedWebhookEvent], @@ -5617,7 +5685,8 @@ func (r *ParsedWebhookEvent) UnmarshalJSON(data []byte) (err error) { // [TokenizationApprovalRequestWebhookEvent], [TokenizationResultWebhookEvent], // [TokenizationTwoFactorAuthenticationCodeWebhookEvent], // [TokenizationTwoFactorAuthenticationCodeSentWebhookEvent], -// [TokenizationUpdatedWebhookEvent], [ThreeDSAuthentication], +// [TokenizationUpdatedWebhookEvent], +// [ThreeDSAuthenticationApprovalRequestWebhookEvent], // [DisputeTransactionCreatedWebhookEvent], // [DisputeTransactionUpdatedWebhookEvent]. func (r ParsedWebhookEvent) AsUnion() ParsedWebhookEventUnion { @@ -5629,7 +5698,8 @@ func (r ParsedWebhookEvent) AsUnion() ParsedWebhookEventUnion { // Union satisfied by [AccountHolderCreatedWebhookEvent], // [ParsedWebhookEventKYBPayload], [ParsedWebhookEventKYCPayload], // [ParsedWebhookEventLegacyPayload], [AccountHolderVerificationWebhookEvent], -// [AccountHolderDocumentUpdatedWebhookEvent], [AsaRequestWebhookEvent], +// [AccountHolderDocumentUpdatedWebhookEvent], +// [CardAuthorizationApprovalRequestWebhookEvent], // [TokenizationDecisioningRequestWebhookEvent], // [AuthRulesBacktestReportCreatedWebhookEvent], [BalanceUpdatedWebhookEvent], // [BookTransferTransactionCreatedWebhookEvent], @@ -5662,7 +5732,8 @@ func (r ParsedWebhookEvent) AsUnion() ParsedWebhookEventUnion { // [TokenizationApprovalRequestWebhookEvent], [TokenizationResultWebhookEvent], // [TokenizationTwoFactorAuthenticationCodeWebhookEvent], // [TokenizationTwoFactorAuthenticationCodeSentWebhookEvent], -// [TokenizationUpdatedWebhookEvent], [ThreeDSAuthentication], +// [TokenizationUpdatedWebhookEvent], +// [ThreeDSAuthenticationApprovalRequestWebhookEvent], // [DisputeTransactionCreatedWebhookEvent] or // [DisputeTransactionUpdatedWebhookEvent]. type ParsedWebhookEventUnion interface { @@ -5699,7 +5770,7 @@ func init() { }, apijson.UnionVariant{ TypeFilter: gjson.JSON, - Type: reflect.TypeOf(AsaRequestWebhookEvent{}), + Type: reflect.TypeOf(CardAuthorizationApprovalRequestWebhookEvent{}), }, apijson.UnionVariant{ TypeFilter: gjson.JSON, @@ -5891,7 +5962,7 @@ func init() { }, apijson.UnionVariant{ TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ThreeDSAuthentication{}), + Type: reflect.TypeOf(ThreeDSAuthenticationApprovalRequestWebhookEvent{}), }, apijson.UnionVariant{ TypeFilter: gjson.JSON, @@ -6674,6 +6745,7 @@ const ( ParsedWebhookEventEventTypeAccountHolderUpdated ParsedWebhookEventEventType = "account_holder.updated" ParsedWebhookEventEventTypeAccountHolderVerification ParsedWebhookEventEventType = "account_holder.verification" ParsedWebhookEventEventTypeAccountHolderDocumentUpdated ParsedWebhookEventEventType = "account_holder_document.updated" + ParsedWebhookEventEventTypeCardAuthorizationApprovalRequest ParsedWebhookEventEventType = "card_authorization.approval_request" ParsedWebhookEventEventTypeDigitalWalletTokenizationApprovalRequest ParsedWebhookEventEventType = "digital_wallet.tokenization_approval_request" ParsedWebhookEventEventTypeAuthRulesBacktestReportCreated ParsedWebhookEventEventType = "auth_rules.backtest_report.created" ParsedWebhookEventEventTypeBalanceUpdated ParsedWebhookEventEventType = "balance.updated" @@ -6720,13 +6792,14 @@ const ( ParsedWebhookEventEventTypeTokenizationTwoFactorAuthenticationCode ParsedWebhookEventEventType = "tokenization.two_factor_authentication_code" ParsedWebhookEventEventTypeTokenizationTwoFactorAuthenticationCodeSent ParsedWebhookEventEventType = "tokenization.two_factor_authentication_code_sent" ParsedWebhookEventEventTypeTokenizationUpdated ParsedWebhookEventEventType = "tokenization.updated" + ParsedWebhookEventEventTypeThreeDSAuthenticationApprovalRequest ParsedWebhookEventEventType = "three_ds_authentication.approval_request" ParsedWebhookEventEventTypeDisputeTransactionCreated ParsedWebhookEventEventType = "dispute_transaction.created" ParsedWebhookEventEventTypeDisputeTransactionUpdated ParsedWebhookEventEventType = "dispute_transaction.updated" ) func (r ParsedWebhookEventEventType) IsKnown() bool { switch r { - case ParsedWebhookEventEventTypeAccountHolderCreated, ParsedWebhookEventEventTypeAccountHolderUpdated, ParsedWebhookEventEventTypeAccountHolderVerification, ParsedWebhookEventEventTypeAccountHolderDocumentUpdated, ParsedWebhookEventEventTypeDigitalWalletTokenizationApprovalRequest, ParsedWebhookEventEventTypeAuthRulesBacktestReportCreated, ParsedWebhookEventEventTypeBalanceUpdated, ParsedWebhookEventEventTypeBookTransferTransactionCreated, ParsedWebhookEventEventTypeBookTransferTransactionUpdated, ParsedWebhookEventEventTypeCardCreated, ParsedWebhookEventEventTypeCardConverted, ParsedWebhookEventEventTypeCardRenewed, ParsedWebhookEventEventTypeCardReissued, ParsedWebhookEventEventTypeCardShipped, ParsedWebhookEventEventTypeCardTransactionUpdated, ParsedWebhookEventEventTypeCardTransactionEnhancedDataCreated, ParsedWebhookEventEventTypeCardTransactionEnhancedDataUpdated, ParsedWebhookEventEventTypeDigitalWalletTokenizationResult, ParsedWebhookEventEventTypeDigitalWalletTokenizationTwoFactorAuthenticationCode, ParsedWebhookEventEventTypeDigitalWalletTokenizationTwoFactorAuthenticationCodeSent, ParsedWebhookEventEventTypeDigitalWalletTokenizationUpdated, ParsedWebhookEventEventTypeDisputeUpdated, ParsedWebhookEventEventTypeDisputeEvidenceUploadFailed, ParsedWebhookEventEventTypeExternalBankAccountCreated, ParsedWebhookEventEventTypeExternalBankAccountUpdated, ParsedWebhookEventEventTypeExternalPaymentCreated, ParsedWebhookEventEventTypeExternalPaymentUpdated, ParsedWebhookEventEventTypeFinancialAccountCreated, ParsedWebhookEventEventTypeFinancialAccountUpdated, ParsedWebhookEventEventTypeFundingEventCreated, ParsedWebhookEventEventTypeLoanTapeCreated, ParsedWebhookEventEventTypeLoanTapeUpdated, ParsedWebhookEventEventTypeManagementOperationCreated, ParsedWebhookEventEventTypeManagementOperationUpdated, ParsedWebhookEventEventTypeInternalTransactionCreated, ParsedWebhookEventEventTypeInternalTransactionUpdated, ParsedWebhookEventEventTypeNetworkTotalCreated, ParsedWebhookEventEventTypeNetworkTotalUpdated, ParsedWebhookEventEventTypePaymentTransactionCreated, ParsedWebhookEventEventTypePaymentTransactionUpdated, ParsedWebhookEventEventTypeSettlementReportUpdated, ParsedWebhookEventEventTypeStatementsCreated, ParsedWebhookEventEventTypeThreeDSAuthenticationCreated, ParsedWebhookEventEventTypeThreeDSAuthenticationUpdated, ParsedWebhookEventEventTypeThreeDSAuthenticationChallenge, ParsedWebhookEventEventTypeTokenizationApprovalRequest, ParsedWebhookEventEventTypeTokenizationResult, ParsedWebhookEventEventTypeTokenizationTwoFactorAuthenticationCode, ParsedWebhookEventEventTypeTokenizationTwoFactorAuthenticationCodeSent, ParsedWebhookEventEventTypeTokenizationUpdated, ParsedWebhookEventEventTypeDisputeTransactionCreated, ParsedWebhookEventEventTypeDisputeTransactionUpdated: + case ParsedWebhookEventEventTypeAccountHolderCreated, ParsedWebhookEventEventTypeAccountHolderUpdated, ParsedWebhookEventEventTypeAccountHolderVerification, ParsedWebhookEventEventTypeAccountHolderDocumentUpdated, ParsedWebhookEventEventTypeCardAuthorizationApprovalRequest, ParsedWebhookEventEventTypeDigitalWalletTokenizationApprovalRequest, ParsedWebhookEventEventTypeAuthRulesBacktestReportCreated, ParsedWebhookEventEventTypeBalanceUpdated, ParsedWebhookEventEventTypeBookTransferTransactionCreated, ParsedWebhookEventEventTypeBookTransferTransactionUpdated, ParsedWebhookEventEventTypeCardCreated, ParsedWebhookEventEventTypeCardConverted, ParsedWebhookEventEventTypeCardRenewed, ParsedWebhookEventEventTypeCardReissued, ParsedWebhookEventEventTypeCardShipped, ParsedWebhookEventEventTypeCardTransactionUpdated, ParsedWebhookEventEventTypeCardTransactionEnhancedDataCreated, ParsedWebhookEventEventTypeCardTransactionEnhancedDataUpdated, ParsedWebhookEventEventTypeDigitalWalletTokenizationResult, ParsedWebhookEventEventTypeDigitalWalletTokenizationTwoFactorAuthenticationCode, ParsedWebhookEventEventTypeDigitalWalletTokenizationTwoFactorAuthenticationCodeSent, ParsedWebhookEventEventTypeDigitalWalletTokenizationUpdated, ParsedWebhookEventEventTypeDisputeUpdated, ParsedWebhookEventEventTypeDisputeEvidenceUploadFailed, ParsedWebhookEventEventTypeExternalBankAccountCreated, ParsedWebhookEventEventTypeExternalBankAccountUpdated, ParsedWebhookEventEventTypeExternalPaymentCreated, ParsedWebhookEventEventTypeExternalPaymentUpdated, ParsedWebhookEventEventTypeFinancialAccountCreated, ParsedWebhookEventEventTypeFinancialAccountUpdated, ParsedWebhookEventEventTypeFundingEventCreated, ParsedWebhookEventEventTypeLoanTapeCreated, ParsedWebhookEventEventTypeLoanTapeUpdated, ParsedWebhookEventEventTypeManagementOperationCreated, ParsedWebhookEventEventTypeManagementOperationUpdated, ParsedWebhookEventEventTypeInternalTransactionCreated, ParsedWebhookEventEventTypeInternalTransactionUpdated, ParsedWebhookEventEventTypeNetworkTotalCreated, ParsedWebhookEventEventTypeNetworkTotalUpdated, ParsedWebhookEventEventTypePaymentTransactionCreated, ParsedWebhookEventEventTypePaymentTransactionUpdated, ParsedWebhookEventEventTypeSettlementReportUpdated, ParsedWebhookEventEventTypeStatementsCreated, ParsedWebhookEventEventTypeThreeDSAuthenticationCreated, ParsedWebhookEventEventTypeThreeDSAuthenticationUpdated, ParsedWebhookEventEventTypeThreeDSAuthenticationChallenge, ParsedWebhookEventEventTypeTokenizationApprovalRequest, ParsedWebhookEventEventTypeTokenizationResult, ParsedWebhookEventEventTypeTokenizationTwoFactorAuthenticationCode, ParsedWebhookEventEventTypeTokenizationTwoFactorAuthenticationCodeSent, ParsedWebhookEventEventTypeTokenizationUpdated, ParsedWebhookEventEventTypeThreeDSAuthenticationApprovalRequest, ParsedWebhookEventEventTypeDisputeTransactionCreated, ParsedWebhookEventEventTypeDisputeTransactionUpdated: return true } return false @@ -7247,11 +7320,12 @@ const ( ParsedWebhookEventTypeWireInboundAdmin ParsedWebhookEventType = "WIRE_INBOUND_ADMIN" ParsedWebhookEventTypeWireOutboundPayment ParsedWebhookEventType = "WIRE_OUTBOUND_PAYMENT" ParsedWebhookEventTypeWireOutboundAdmin ParsedWebhookEventType = "WIRE_OUTBOUND_ADMIN" + ParsedWebhookEventTypeWireDrawdownRequest ParsedWebhookEventType = "WIRE_DRAWDOWN_REQUEST" ) func (r ParsedWebhookEventType) IsKnown() bool { switch r { - case ParsedWebhookEventTypeChecking, ParsedWebhookEventTypeSavings, ParsedWebhookEventTypeIssuing, ParsedWebhookEventTypeReserve, ParsedWebhookEventTypeOperating, ParsedWebhookEventTypeChargedOffFees, ParsedWebhookEventTypeChargedOffInterest, ParsedWebhookEventTypeChargedOffPrincipal, ParsedWebhookEventTypeSecurity, ParsedWebhookEventTypeProgramReceivables, ParsedWebhookEventTypeCollection, ParsedWebhookEventTypeProgramBankAccountsPayable, ParsedWebhookEventTypeOriginationCredit, ParsedWebhookEventTypeOriginationDebit, ParsedWebhookEventTypeReceiptCredit, ParsedWebhookEventTypeReceiptDebit, ParsedWebhookEventTypeWireInboundPayment, ParsedWebhookEventTypeWireInboundAdmin, ParsedWebhookEventTypeWireOutboundPayment, ParsedWebhookEventTypeWireOutboundAdmin: + case ParsedWebhookEventTypeChecking, ParsedWebhookEventTypeSavings, ParsedWebhookEventTypeIssuing, ParsedWebhookEventTypeReserve, ParsedWebhookEventTypeOperating, ParsedWebhookEventTypeChargedOffFees, ParsedWebhookEventTypeChargedOffInterest, ParsedWebhookEventTypeChargedOffPrincipal, ParsedWebhookEventTypeSecurity, ParsedWebhookEventTypeProgramReceivables, ParsedWebhookEventTypeCollection, ParsedWebhookEventTypeProgramBankAccountsPayable, ParsedWebhookEventTypeOriginationCredit, ParsedWebhookEventTypeOriginationDebit, ParsedWebhookEventTypeReceiptCredit, ParsedWebhookEventTypeReceiptDebit, ParsedWebhookEventTypeWireInboundPayment, ParsedWebhookEventTypeWireInboundAdmin, ParsedWebhookEventTypeWireOutboundPayment, ParsedWebhookEventTypeWireOutboundAdmin, ParsedWebhookEventTypeWireDrawdownRequest: return true } return false diff --git a/webhook_test.go b/webhook_test.go index b9a0efc9..e13df7fa 100644 --- a/webhook_test.go +++ b/webhook_test.go @@ -42,84 +42,106 @@ func TestVerifySignature(t *testing.T) { } } -func TestWebhookParsed(t *testing.T) { - client := lithic.NewClient( - option.WithWebhookSecret("whsec_c2VjcmV0Cg=="), - option.WithAPIKey("My Lithic API Key"), - ) - payload := []byte(`{"event_type":"account_holder.created","token":"00000000-0000-0000-0000-000000000001","account_token":"00000000-0000-0000-0000-000000000001","created":"2019-12-27T18:11:19.117Z","required_documents":[{"entity_token":"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e","status_reasons":["string"],"valid_documents":["string"]}],"status":"ACCEPTED","status_reason":["string"]}`) - wh, err := standardwebhooks.NewWebhook("whsec_c2VjcmV0Cg==") - if err != nil { - t.Error("Failed to sign test webhook message") - } - msgID := "1" - now := time.Now() - sig, err := wh.Sign(msgID, now, payload) - if err != nil { - t.Error("Failed to sign test webhook message:", err) - } - headers := make(http.Header) - headers.Set("webhook-signature", sig) - headers.Set("webhook-id", msgID) - headers.Set("webhook-timestamp", strconv.FormatInt(now.Unix(), 10)) - event, err := client.Webhooks.Parse(payload, headers) - if err != nil { - t.Error("Failed to unwrap webhook:", err) +func TestWebhookParsing(t *testing.T) { + tests := []struct { + name string + payload string + check func(t *testing.T, event *lithic.ParsedWebhookEvent) + }{ + { + name: "account_holder.created with RFC3339 timestamp", + payload: `{"event_type":"account_holder.created","token":"00000000-0000-0000-0000-000000000001","account_token":"00000000-0000-0000-0000-000000000001","created":"2019-12-27T18:11:19.117Z","required_documents":[{"entity_token":"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e","status_reasons":["string"],"valid_documents":["string"]}],"status":"ACCEPTED","status_reason":["string"]}`, + check: func(t *testing.T, event *lithic.ParsedWebhookEvent) { + e, ok := event.AsUnion().(lithic.AccountHolderCreatedWebhookEvent) + if !ok { + t.Fatalf("Expected AccountHolderCreatedWebhookEvent, got %T", event.AsUnion()) + } + if e.Token != "00000000-0000-0000-0000-000000000001" { + t.Errorf("Expected token 00000000-0000-0000-0000-000000000001, got %s", e.Token) + } + if e.EventType != lithic.AccountHolderCreatedWebhookEventEventTypeAccountHolderCreated { + t.Errorf("Expected event type account_holder.created, got %s", e.EventType) + } + }, + }, + { + name: "card.created", + payload: `{"event_type":"card.created","card_token":"00000000-0000-0000-0000-000000000002"}`, + check: func(t *testing.T, event *lithic.ParsedWebhookEvent) { + e, ok := event.AsUnion().(lithic.CardCreatedWebhookEvent) + if !ok { + t.Fatalf("Expected CardCreatedWebhookEvent, got %T", event.AsUnion()) + } + if e.CardToken != "00000000-0000-0000-0000-000000000002" { + t.Errorf("Expected card token 00000000-0000-0000-0000-000000000002, got %s", e.CardToken) + } + if e.EventType != lithic.CardCreatedWebhookEventEventTypeCardCreated { + t.Errorf("Expected event type card.created, got %s", e.EventType) + } + }, + }, + { + name: "account_holder.verification with space-separated timestamp", + payload: `{"event_type":"account_holder.verification","token":"00000000-0000-0000-0000-000000000003","account_token":"00000000-0000-0000-0000-000000000004","created":"2025-12-09 16:19:40.228000+00:00","status":"ACCEPTED","status_reasons":["KYC_PASSED"]}`, + check: func(t *testing.T, event *lithic.ParsedWebhookEvent) { + e, ok := event.AsUnion().(lithic.AccountHolderVerificationWebhookEvent) + if !ok { + t.Fatalf("Expected AccountHolderVerificationWebhookEvent, got %T", event.AsUnion()) + } + if e.Token != "00000000-0000-0000-0000-000000000003" { + t.Errorf("Expected token 00000000-0000-0000-0000-000000000003, got %s", e.Token) + } + if e.AccountToken != "00000000-0000-0000-0000-000000000004" { + t.Errorf("Expected account token 00000000-0000-0000-0000-000000000004, got %s", e.AccountToken) + } + if e.EventType != lithic.AccountHolderVerificationWebhookEventEventTypeAccountHolderVerification { + t.Errorf("Expected event type account_holder.verification, got %s", e.EventType) + } + if e.Status != lithic.AccountHolderVerificationWebhookEventStatusAccepted { + t.Errorf("Expected status ACCEPTED, got %s", e.Status) + } + }, + }, } - // Demonstrate type switching on AsUnion() to distinguish event types - switch e := event.AsUnion().(type) { - case lithic.AccountHolderCreatedWebhookEvent: - if e.Token != "00000000-0000-0000-0000-000000000001" { - t.Errorf("Expected token 00000000-0000-0000-0000-000000000001, got %s", e.Token) - } - if e.EventType != lithic.AccountHolderCreatedWebhookEventEventTypeAccountHolderCreated { - t.Errorf("Expected event type account_holder.created, got %s", e.EventType) - } - case lithic.CardCreatedWebhookEvent: - t.Error("Unexpected CardCreatedWebhookEvent") - default: - t.Errorf("Unexpected event type: %T", e) + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + event := parseWebhookPayload(t, []byte(tt.payload)) + tt.check(t, event) + }) } } -func TestWebhookCardCreatedParsed(t *testing.T) { +func parseWebhookPayload(t *testing.T, payload []byte) *lithic.ParsedWebhookEvent { + t.Helper() + + secret := "whsec_c2VjcmV0Cg==" client := lithic.NewClient( - option.WithWebhookSecret("whsec_c2VjcmV0Cg=="), - option.WithAPIKey("My Lithic API Key"), + option.WithWebhookSecret(secret), + option.WithAPIKey("test-api-key"), ) - payload := []byte(`{"event_type":"card.created","card_token":"00000000-0000-0000-0000-000000000002"}`) - wh, err := standardwebhooks.NewWebhook("whsec_c2VjcmV0Cg==") + + wh, err := standardwebhooks.NewWebhook(secret) if err != nil { - t.Fatal("Failed to create webhook signer") + t.Fatalf("Failed to create webhook signer: %v", err) } - msgID := "2" + + msgID := "msg_test" now := time.Now() sig, err := wh.Sign(msgID, now, payload) if err != nil { - t.Fatal("Failed to sign test webhook message:", err) + t.Fatalf("Failed to sign webhook payload: %v", err) } + headers := make(http.Header) - headers.Set("webhook-signature", sig) headers.Set("webhook-id", msgID) headers.Set("webhook-timestamp", strconv.FormatInt(now.Unix(), 10)) + headers.Set("webhook-signature", sig) + event, err := client.Webhooks.Parse(payload, headers) if err != nil { - t.Fatal("Failed to unwrap webhook:", err) + t.Fatalf("Failed to parse webhook: %v", err) } - // Demonstrate type switching on AsUnion() for a different event type - switch e := event.AsUnion().(type) { - case lithic.CardCreatedWebhookEvent: - if e.CardToken != "00000000-0000-0000-0000-000000000002" { - t.Errorf("Expected card token 00000000-0000-0000-0000-000000000002, got %s", e.CardToken) - } - if e.EventType != lithic.CardCreatedWebhookEventEventTypeCardCreated { - t.Errorf("Expected event type card.created, got %s", e.EventType) - } - case lithic.AccountHolderCreatedWebhookEvent: - t.Error("Unexpected AccountHolderCreatedWebhookEvent") - default: - t.Errorf("Unexpected event type: %T", e) - } + return event }