diff --git a/.github/workflows/codegen.yml b/.github/workflows/codegen.yml index c744906c..4b3f1ae8 100644 --- a/.github/workflows/codegen.yml +++ b/.github/workflows/codegen.yml @@ -75,6 +75,9 @@ jobs: mix local.rebar --force mix local.hex --force mix deps.get + - name: Test generated code + run: | + mix stripe.generate - name: Test generated code run: | mix test @@ -89,6 +92,7 @@ jobs: git config --local user.email "noreply@github.com" git config --local user.name "github-actions[bot]" git add priv/openapi + git add lib/generated git add .latest-tag-stripe-openapi-sdk echo "Update services based on ${{ env.LATEST_STRIPE_SDK_TAG }} of Stripe OpenApi SDK" >> commit-msg echo >> commit-msg diff --git a/lib/generated/account.ex b/lib/generated/account.ex new file mode 100644 index 00000000..a39f27b2 --- /dev/null +++ b/lib/generated/account.ex @@ -0,0 +1,920 @@ +defmodule Stripe.Account do + use Stripe.Entity + + @moduledoc "This is an object representing a Stripe account. You can retrieve it to see\nproperties on the account like its current requirements or if the account is\nenabled to make live charges or receive payouts.\n\nFor Custom accounts, the properties below are always returned. For other accounts, some properties are returned until that\naccount has started to go through Connect Onboarding. Once you create an [Account Link](https://stripe.com/docs/api/account_links)\nfor a Standard or Express account, some parameters are no longer returned. These are marked as **Custom Only** or **Custom and Express**\nbelow. Learn about the differences [between accounts](https://stripe.com/docs/connect/accounts)." + ( + defstruct [ + :business_profile, + :business_type, + :capabilities, + :charges_enabled, + :company, + :controller, + :country, + :created, + :default_currency, + :details_submitted, + :email, + :external_accounts, + :future_requirements, + :id, + :individual, + :metadata, + :object, + :payouts_enabled, + :requirements, + :settings, + :tos_acceptance, + :type + ] + + @typedoc "The `account` type.\n\n * `business_profile` Business information about the account.\n * `business_type` The business type.\n * `capabilities` \n * `charges_enabled` Whether the account can create live charges.\n * `company` \n * `controller` \n * `country` The account's country.\n * `created` Time at which the account was connected. Measured in seconds since the Unix epoch.\n * `default_currency` Three-letter ISO currency code representing the default currency for the account. This must be a currency that [Stripe supports in the account's country](https://stripe.com/docs/payouts).\n * `details_submitted` Whether account details have been submitted. Standard accounts cannot receive payouts before this is true.\n * `email` An email address associated with the account. It's not used for authentication and Stripe doesn't market to this field without explicit approval from the platform.\n * `external_accounts` External accounts (bank accounts and debit cards) currently attached to this account\n * `future_requirements` \n * `id` Unique identifier for the object.\n * `individual` \n * `metadata` Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `payouts_enabled` Whether Stripe can send payouts to this account.\n * `requirements` \n * `settings` Options for customizing how the account functions within Stripe.\n * `tos_acceptance` \n * `type` The Stripe account type. Can be `standard`, `express`, or `custom`.\n" + @type t :: %__MODULE__{ + business_profile: term | nil, + business_type: binary | nil, + capabilities: term, + charges_enabled: boolean, + company: term, + controller: term, + country: binary, + created: integer, + default_currency: binary, + details_submitted: boolean, + email: binary | nil, + external_accounts: term, + future_requirements: term, + id: binary, + individual: Stripe.Person.t(), + metadata: term, + object: binary, + payouts_enabled: boolean, + requirements: term, + settings: term | nil, + tos_acceptance: term, + type: binary + } + ) + + ( + @typedoc "The acss_debit_payments capability." + @type acss_debit_payments :: %{optional(:requested) => boolean} + ) + + ( + @typedoc "A document showing address, either a passport, local ID card, or utility bill from a well-known utility company." + @type additional_document :: %{optional(:back) => binary, optional(:front) => binary} + ) + + ( + @typedoc "The company's primary address." + @type address :: %{ + optional(:city) => binary, + optional(:country) => binary, + optional(:line1) => binary, + optional(:line2) => binary, + optional(:postal_code) => binary, + optional(:state) => binary + } + ) + + ( + @typedoc "The Kana variation of the company's primary address (Japan only)." + @type address_kana :: %{ + optional(:city) => binary, + optional(:country) => binary, + optional(:line1) => binary, + optional(:line2) => binary, + optional(:postal_code) => binary, + optional(:state) => binary, + optional(:town) => binary + } + ) + + ( + @typedoc "The Kanji variation of the the individual's primary address (Japan only)." + @type address_kanji :: %{ + optional(:city) => binary, + optional(:country) => binary, + optional(:line1) => binary, + optional(:line2) => binary, + optional(:postal_code) => binary, + optional(:state) => binary, + optional(:town) => binary + } + ) + + ( + @typedoc "The affirm_payments capability." + @type affirm_payments :: %{optional(:requested) => boolean} + ) + + ( + @typedoc "The afterpay_clearpay_payments capability." + @type afterpay_clearpay_payments :: %{optional(:requested) => boolean} + ) + + ( + @typedoc "The au_becs_debit_payments capability." + @type au_becs_debit_payments :: %{optional(:requested) => boolean} + ) + + ( + @typedoc "The bacs_debit_payments capability." + @type bacs_debit_payments :: %{optional(:requested) => boolean} + ) + + ( + @typedoc "The bancontact_payments capability." + @type bancontact_payments :: %{optional(:requested) => boolean} + ) + + ( + @typedoc "One or more documents that support the [Bank account ownership verification](https://support.stripe.com/questions/bank-account-ownership-verification) requirement. Must be a document associated with the account’s primary active bank account that displays the last 4 digits of the account number, either a statement or a voided check." + @type bank_account_ownership_verification :: %{optional(:files) => list(binary)} + ) + + ( + @typedoc "The bank_transfer_payments capability." + @type bank_transfer_payments :: %{optional(:requested) => boolean} + ) + + ( + @typedoc "The blik_payments capability." + @type blik_payments :: %{optional(:requested) => boolean} + ) + + ( + @typedoc "The boleto_payments capability." + @type boleto_payments :: %{optional(:requested) => boolean} + ) + + ( + @typedoc "Settings used to apply the account's branding to email receipts, invoices, Checkout, and other products." + @type branding :: %{ + optional(:icon) => binary, + optional(:logo) => binary, + optional(:primary_color) => binary, + optional(:secondary_color) => binary + } + ) + + ( + @typedoc "Business information about the account." + @type business_profile :: %{ + optional(:mcc) => binary, + optional(:monthly_estimated_revenue) => monthly_estimated_revenue, + optional(:name) => binary, + optional(:product_description) => binary, + optional(:support_address) => support_address, + optional(:support_email) => binary, + optional(:support_phone) => binary, + optional(:support_url) => binary | binary, + optional(:url) => binary + } + ) + + ( + @typedoc "Each key of the dictionary represents a capability, and each capability maps to its settings (e.g. whether it has been requested or not). Each capability will be inactive until you have provided its specific requirements and Stripe has verified them. An account may have some of its requested capabilities be active and some be inactive." + @type capabilities :: %{ + optional(:link_payments) => link_payments, + optional(:card_issuing) => card_issuing, + optional(:treasury) => treasury, + optional(:oxxo_payments) => oxxo_payments, + optional(:affirm_payments) => affirm_payments, + optional(:promptpay_payments) => promptpay_payments, + optional(:bank_transfer_payments) => bank_transfer_payments, + optional(:sofort_payments) => sofort_payments, + optional(:acss_debit_payments) => acss_debit_payments, + optional(:cashapp_payments) => cashapp_payments, + optional(:cartes_bancaires_payments) => cartes_bancaires_payments, + optional(:india_international_payments) => india_international_payments, + optional(:bacs_debit_payments) => bacs_debit_payments, + optional(:tax_reporting_us_1099_misc) => tax_reporting_us_1099_misc, + optional(:paynow_payments) => paynow_payments, + optional(:klarna_payments) => klarna_payments, + optional(:us_bank_account_ach_payments) => us_bank_account_ach_payments, + optional(:card_payments) => card_payments, + optional(:p24_payments) => p24_payments, + optional(:boleto_payments) => boleto_payments, + optional(:fpx_payments) => fpx_payments, + optional(:au_becs_debit_payments) => au_becs_debit_payments, + optional(:konbini_payments) => konbini_payments, + optional(:ideal_payments) => ideal_payments, + optional(:afterpay_clearpay_payments) => afterpay_clearpay_payments, + optional(:blik_payments) => blik_payments, + optional(:zip_payments) => zip_payments, + optional(:bancontact_payments) => bancontact_payments, + optional(:giropay_payments) => giropay_payments, + optional(:legacy_payments) => legacy_payments, + optional(:sepa_debit_payments) => sepa_debit_payments, + optional(:transfers) => transfers, + optional(:eps_payments) => eps_payments, + optional(:grabpay_payments) => grabpay_payments, + optional(:tax_reporting_us_1099_k) => tax_reporting_us_1099_k, + optional(:jcb_payments) => jcb_payments + } + ) + + ( + @typedoc "Settings specific to the account's use of the Card Issuing product." + @type card_issuing :: %{optional(:tos_acceptance) => tos_acceptance} + ) + + ( + @typedoc "The card_payments capability." + @type card_payments :: %{optional(:requested) => boolean} + ) + + ( + @typedoc "The cartes_bancaires_payments capability." + @type cartes_bancaires_payments :: %{optional(:requested) => boolean} + ) + + ( + @typedoc "The cashapp_payments capability." + @type cashapp_payments :: %{optional(:requested) => boolean} + ) + + ( + @typedoc "Information about the company or business. This field is available for any `business_type`." + @type company :: %{ + optional(:address) => address, + optional(:address_kana) => address_kana, + optional(:address_kanji) => address_kanji, + optional(:directors_provided) => boolean, + optional(:executives_provided) => boolean, + optional(:export_license_id) => binary, + optional(:export_purpose_code) => binary, + optional(:name) => binary, + optional(:name_kana) => binary, + optional(:name_kanji) => binary, + optional(:owners_provided) => boolean, + optional(:ownership_declaration) => ownership_declaration, + optional(:phone) => binary, + optional(:registration_number) => binary, + optional(:structure) => + :free_zone_establishment + | :free_zone_llc + | :government_instrumentality + | :governmental_unit + | :incorporated_non_profit + | :limited_liability_partnership + | :llc + | :multi_member_llc + | :private_company + | :private_corporation + | :private_partnership + | :public_company + | :public_corporation + | :public_partnership + | :single_member_llc + | :sole_establishment + | :sole_proprietorship + | :tax_exempt_government_instrumentality + | :unincorporated_association + | :unincorporated_non_profit, + optional(:tax_id) => binary, + optional(:tax_id_registrar) => binary, + optional(:vat_id) => binary, + optional(:verification) => verification + } + ) + + ( + @typedoc "One or more documents that demonstrate proof of a company's license to operate." + @type company_license :: %{optional(:files) => list(binary)} + ) + + ( + @typedoc "One or more documents showing the company's Memorandum of Association." + @type company_memorandum_of_association :: %{optional(:files) => list(binary)} + ) + + ( + @typedoc "(Certain countries only) One or more documents showing the ministerial decree legalizing the company's establishment." + @type company_ministerial_decree :: %{optional(:files) => list(binary)} + ) + + ( + @typedoc "One or more documents that demonstrate proof of a company's registration with the appropriate local authorities." + @type company_registration_verification :: %{optional(:files) => list(binary)} + ) + + ( + @typedoc "One or more documents that demonstrate proof of a company's tax ID." + @type company_tax_id_verification :: %{optional(:files) => list(binary)} + ) + + ( + @typedoc nil + @type created :: %{ + optional(:gt) => integer, + optional(:gte) => integer, + optional(:lt) => integer, + optional(:lte) => integer + } + ) + + ( + @typedoc "Automatically declines certain charge types regardless of whether the card issuer accepted or declined the charge." + @type decline_on :: %{optional(:avs_failure) => boolean, optional(:cvc_failure) => boolean} + ) + + ( + @typedoc nil + @type dob :: %{ + optional(:day) => integer, + optional(:month) => integer, + optional(:year) => integer + } + ) + + ( + @typedoc "A document verifying the business." + @type document :: %{optional(:back) => binary, optional(:front) => binary} + ) + + ( + @typedoc "Documents that may be submitted to satisfy various informational requests." + @type documents :: %{ + optional(:bank_account_ownership_verification) => bank_account_ownership_verification, + optional(:company_license) => company_license, + optional(:company_memorandum_of_association) => company_memorandum_of_association, + optional(:company_ministerial_decree) => company_ministerial_decree, + optional(:company_registration_verification) => company_registration_verification, + optional(:company_tax_id_verification) => company_tax_id_verification, + optional(:proof_of_registration) => proof_of_registration + } + ) + + ( + @typedoc "The eps_payments capability." + @type eps_payments :: %{optional(:requested) => boolean} + ) + + ( + @typedoc "The fpx_payments capability." + @type fpx_payments :: %{optional(:requested) => boolean} + ) + + ( + @typedoc "The giropay_payments capability." + @type giropay_payments :: %{optional(:requested) => boolean} + ) + + ( + @typedoc "The grabpay_payments capability." + @type grabpay_payments :: %{optional(:requested) => boolean} + ) + + ( + @typedoc "The ideal_payments capability." + @type ideal_payments :: %{optional(:requested) => boolean} + ) + + ( + @typedoc "The india_international_payments capability." + @type india_international_payments :: %{optional(:requested) => boolean} + ) + + ( + @typedoc "Information about the person represented by the account. This field is null unless `business_type` is set to `individual`." + @type individual :: %{ + optional(:address) => address, + optional(:address_kana) => address_kana, + optional(:address_kanji) => address_kanji, + optional(:dob) => dob | binary, + optional(:email) => binary, + optional(:first_name) => binary, + optional(:first_name_kana) => binary, + optional(:first_name_kanji) => binary, + optional(:full_name_aliases) => list(binary) | binary, + optional(:gender) => binary, + optional(:id_number) => binary, + optional(:id_number_secondary) => binary, + optional(:last_name) => binary, + optional(:last_name_kana) => binary, + optional(:last_name_kanji) => binary, + optional(:maiden_name) => binary, + optional(:metadata) => %{optional(binary) => binary} | binary, + optional(:phone) => binary, + optional(:political_exposure) => :existing | :none, + optional(:registered_address) => registered_address, + optional(:ssn_last_4) => binary, + optional(:verification) => verification + } + ) + + ( + @typedoc "The jcb_payments capability." + @type jcb_payments :: %{optional(:requested) => boolean} + ) + + ( + @typedoc "The klarna_payments capability." + @type klarna_payments :: %{optional(:requested) => boolean} + ) + + ( + @typedoc "The konbini_payments capability." + @type konbini_payments :: %{optional(:requested) => boolean} + ) + + ( + @typedoc "The legacy_payments capability." + @type legacy_payments :: %{optional(:requested) => boolean} + ) + + ( + @typedoc "The link_payments capability." + @type link_payments :: %{optional(:requested) => boolean} + ) + + ( + @typedoc "An estimate of the monthly revenue of the business. Only accepted for accounts in Brazil and India." + @type monthly_estimated_revenue :: %{ + optional(:amount) => integer, + optional(:currency) => binary + } + ) + + ( + @typedoc "This hash is used to attest that the beneficial owner information provided to Stripe is both current and correct." + @type ownership_declaration :: %{ + optional(:date) => integer, + optional(:ip) => binary, + optional(:user_agent) => binary + } + ) + + ( + @typedoc "The oxxo_payments capability." + @type oxxo_payments :: %{optional(:requested) => boolean} + ) + + ( + @typedoc "The p24_payments capability." + @type p24_payments :: %{optional(:requested) => boolean} + ) + + ( + @typedoc "Settings that apply across payment methods for charging on the account." + @type payments :: %{ + optional(:statement_descriptor) => binary, + optional(:statement_descriptor_kana) => binary, + optional(:statement_descriptor_kanji) => binary + } + ) + + ( + @typedoc "The paynow_payments capability." + @type paynow_payments :: %{optional(:requested) => boolean} + ) + + ( + @typedoc "Settings specific to the account's payouts." + @type payouts :: %{ + optional(:debit_negative_balances) => boolean, + optional(:schedule) => schedule, + optional(:statement_descriptor) => binary + } + ) + + ( + @typedoc "The promptpay_payments capability." + @type promptpay_payments :: %{optional(:requested) => boolean} + ) + + ( + @typedoc "One or more documents showing the company’s proof of registration with the national business registry." + @type proof_of_registration :: %{optional(:files) => list(binary)} + ) + + ( + @typedoc "The individual's registered address." + @type registered_address :: %{ + optional(:city) => binary, + optional(:country) => binary, + optional(:line1) => binary, + optional(:line2) => binary, + optional(:postal_code) => binary, + optional(:state) => binary + } + ) + + ( + @typedoc nil + @type relationship :: %{ + optional(:director) => boolean, + optional(:executive) => boolean, + optional(:owner) => boolean, + optional(:representative) => boolean + } + ) + + ( + @typedoc "Details on when funds from charges are available, and when they are paid out to an external account. For details, see our [Setting Bank and Debit Card Payouts](https://stripe.com/docs/connect/bank-transfers#payout-information) documentation." + @type schedule :: %{ + optional(:delay_days) => :minimum | integer, + optional(:interval) => :daily | :manual | :monthly | :weekly, + optional(:monthly_anchor) => integer, + optional(:weekly_anchor) => + :friday | :monday | :saturday | :sunday | :thursday | :tuesday | :wednesday + } + ) + + ( + @typedoc "The sepa_debit_payments capability." + @type sepa_debit_payments :: %{optional(:requested) => boolean} + ) + + ( + @typedoc "Options for customizing how the account functions within Stripe." + @type settings :: %{ + optional(:branding) => branding, + optional(:card_issuing) => card_issuing, + optional(:card_payments) => card_payments, + optional(:payments) => payments, + optional(:payouts) => payouts, + optional(:treasury) => treasury + } + ) + + ( + @typedoc "The sofort_payments capability." + @type sofort_payments :: %{optional(:requested) => boolean} + ) + + ( + @typedoc "A publicly available mailing address for sending support issues to." + @type support_address :: %{ + optional(:city) => binary, + optional(:country) => binary, + optional(:line1) => binary, + optional(:line2) => binary, + optional(:postal_code) => binary, + optional(:state) => binary + } + ) + + ( + @typedoc "The tax_reporting_us_1099_k capability." + @type tax_reporting_us_1099_k :: %{optional(:requested) => boolean} + ) + + ( + @typedoc "The tax_reporting_us_1099_misc capability." + @type tax_reporting_us_1099_misc :: %{optional(:requested) => boolean} + ) + + ( + @typedoc "Details on the account's acceptance of the Stripe Treasury Services Agreement." + @type tos_acceptance :: %{ + optional(:date) => integer, + optional(:ip) => binary, + optional(:user_agent) => binary + } + ) + + ( + @typedoc "The transfers capability." + @type transfers :: %{optional(:requested) => boolean} + ) + + ( + @typedoc "Settings specific to the account's Treasury FinancialAccounts." + @type treasury :: %{optional(:tos_acceptance) => tos_acceptance} + ) + + ( + @typedoc "The us_bank_account_ach_payments capability." + @type us_bank_account_ach_payments :: %{optional(:requested) => boolean} + ) + + ( + @typedoc "Information on the verification state of the company." + @type verification :: %{optional(:document) => document} + ) + + ( + @typedoc "The zip_payments capability." + @type zip_payments :: %{optional(:requested) => boolean} + ) + + ( + nil + + @doc "

Retrieves the details of an account.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/account`\n" + ( + @spec retrieve(params :: %{optional(:expand) => list(binary)}, opts :: Keyword.t()) :: + {:ok, Stripe.Account.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def retrieve(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/account", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Updates a connected account by setting the values of the parameters passed. Any parameters not provided are\nleft unchanged.

\n\n

For Custom accounts, you can update any information on the account. For other accounts, you can update all information until that\naccount has started to go through Connect Onboarding. Once you create an Account Link\nfor a Standard or Express account, some parameters can no longer be changed. These are marked as Custom Only or Custom and Express\nbelow.

\n\n

To update your own account, use the Dashboard. Refer to our\nConnect documentation to learn more about updating accounts.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/accounts/{account}`\n" + ( + @spec update( + account :: binary(), + params :: %{ + optional(:account_token) => binary, + optional(:business_profile) => business_profile, + optional(:business_type) => + :company | :government_entity | :individual | :non_profit, + optional(:capabilities) => capabilities, + optional(:company) => company, + optional(:default_currency) => binary, + optional(:documents) => documents, + optional(:email) => binary, + optional(:expand) => list(binary), + optional(:external_account) => binary, + optional(:individual) => individual, + optional(:metadata) => %{optional(binary) => binary} | binary, + optional(:settings) => settings, + optional(:tos_acceptance) => tos_acceptance + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.Account.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def update(account, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/accounts/{account}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "account", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "account", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [account] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Returns a list of accounts connected to your platform via Connect. If you’re not a platform, the list is empty.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/accounts`\n" + ( + @spec list( + params :: %{ + optional(:created) => created | integer, + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.Account.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/accounts", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

With Connect, you can create Stripe accounts for your users.\nTo do this, you’ll first need to register your platform.

\n\n

If you’ve already collected information for your connected accounts, you can prefill that information when\ncreating the account. Connect Onboarding won’t ask for the prefilled information during account onboarding.\nYou can prefill any information on the account.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/accounts`\n" + ( + @spec create( + params :: %{ + optional(:account_token) => binary, + optional(:business_profile) => business_profile, + optional(:business_type) => + :company | :government_entity | :individual | :non_profit, + optional(:capabilities) => capabilities, + optional(:company) => company, + optional(:country) => binary, + optional(:default_currency) => binary, + optional(:documents) => documents, + optional(:email) => binary, + optional(:expand) => list(binary), + optional(:external_account) => binary, + optional(:individual) => individual, + optional(:metadata) => %{optional(binary) => binary} | binary, + optional(:settings) => settings, + optional(:tos_acceptance) => tos_acceptance, + optional(:type) => :custom | :express | :standard + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.Account.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/accounts", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

With Connect, you can delete accounts you manage.

\n\n

Accounts created using test-mode keys can be deleted at any time. Standard accounts created using live-mode keys cannot be deleted. Custom or Express accounts created using live-mode keys can only be deleted once all balances are zero.

\n\n

If you want to delete your own account, use the account information tab in your account settings instead.

\n\n#### Details\n\n * Method: `delete`\n * Path: `/v1/accounts/{account}`\n" + ( + @spec delete(account :: binary(), opts :: Keyword.t()) :: + {:ok, Stripe.DeletedAccount.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def delete(account, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/accounts/{account}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "account", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "account", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [account] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_method(:delete) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

With Connect, you may flag accounts as suspicious.

\n\n

Test-mode Custom and Express accounts can be rejected at any time. Accounts created using live-mode keys may only be rejected once all balances are zero.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/accounts/{account}/reject`\n" + ( + @spec reject( + account :: binary(), + params :: %{optional(:expand) => list(binary), optional(:reason) => binary}, + opts :: Keyword.t() + ) :: {:ok, Stripe.Account.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def reject(account, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/accounts/{account}/reject", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "account", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "account", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [account] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Returns a list of people associated with the account’s legal entity. The people are returned sorted by creation date, with the most recent people appearing first.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/accounts/{account}/persons`\n" + ( + @spec persons( + account :: binary(), + params :: %{ + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:relationship) => relationship, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.Person.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def persons(account, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/accounts/{account}/persons", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "account", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "account", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [account] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Returns a list of capabilities associated with the account. The capabilities are returned sorted by creation date, with the most recent capability appearing first.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/accounts/{account}/capabilities`\n" + ( + @spec capabilities( + account :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.Capability.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def capabilities(account, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/accounts/{account}/capabilities", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "account", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "account", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [account] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/account_link.ex b/lib/generated/account_link.ex new file mode 100644 index 00000000..6bc96c4c --- /dev/null +++ b/lib/generated/account_link.ex @@ -0,0 +1,43 @@ +defmodule Stripe.AccountLink do + use Stripe.Entity + + @moduledoc "Account Links are the means by which a Connect platform grants a connected account permission to access\nStripe-hosted applications, such as Connect Onboarding.\n\nRelated guide: [Connect Onboarding](https://stripe.com/docs/connect/connect-onboarding)" + ( + defstruct [:created, :expires_at, :object, :url] + + @typedoc "The `account_link` type.\n\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `expires_at` The timestamp at which this account link will expire.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `url` The URL for the account link.\n" + @type t :: %__MODULE__{created: integer, expires_at: integer, object: binary, url: binary} + ) + + ( + nil + + @doc "

Creates an AccountLink object that includes a single-use Stripe URL that the platform can redirect their user to in order to take them through the Connect Onboarding flow.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/account_links`\n" + ( + @spec create( + params :: %{ + optional(:account) => binary, + optional(:collect) => :currently_due | :eventually_due, + optional(:expand) => list(binary), + optional(:refresh_url) => binary, + optional(:return_url) => binary, + optional(:type) => + :account_onboarding + | :account_update + | :custom_account_update + | :custom_account_verification + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.AccountLink.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/account_links", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/api_errors.ex b/lib/generated/api_errors.ex new file mode 100644 index 00000000..f130b9b7 --- /dev/null +++ b/lib/generated/api_errors.ex @@ -0,0 +1,38 @@ +defmodule Stripe.ApiErrors do + use Stripe.Entity + @moduledoc "" + ( + defstruct [ + :charge, + :code, + :decline_code, + :doc_url, + :message, + :param, + :payment_intent, + :payment_method, + :payment_method_type, + :request_log_url, + :setup_intent, + :source, + :type + ] + + @typedoc "The `api_errors` type.\n\n * `charge` For card errors, the ID of the failed charge.\n * `code` For some errors that could be handled programmatically, a short string indicating the [error code](https://stripe.com/docs/error-codes) reported.\n * `decline_code` For card errors resulting from a card issuer decline, a short string indicating the [card issuer's reason for the decline](https://stripe.com/docs/declines#issuer-declines) if they provide one.\n * `doc_url` A URL to more information about the [error code](https://stripe.com/docs/error-codes) reported.\n * `message` A human-readable message providing more details about the error. For card errors, these messages can be shown to your users.\n * `param` If the error is parameter-specific, the parameter related to the error. For example, you can use this to display a message near the correct form field.\n * `payment_intent` \n * `payment_method` \n * `payment_method_type` If the error is specific to the type of payment method, the payment method type that had a problem. This field is only populated for invoice-related errors.\n * `request_log_url` A URL to the request log entry in your dashboard.\n * `setup_intent` \n * `source` \n * `type` The type of error returned. One of `api_error`, `card_error`, `idempotency_error`, or `invalid_request_error`\n" + @type t :: %__MODULE__{ + charge: binary, + code: binary, + decline_code: binary, + doc_url: binary, + message: binary, + param: binary, + payment_intent: Stripe.PaymentIntent.t(), + payment_method: Stripe.PaymentMethod.t(), + payment_method_type: binary, + request_log_url: binary, + setup_intent: Stripe.SetupIntent.t(), + source: Stripe.PaymentSource.t(), + type: binary + } + ) +end \ No newline at end of file diff --git a/lib/generated/apple_pay_domain.ex b/lib/generated/apple_pay_domain.ex new file mode 100644 index 00000000..869b7558 --- /dev/null +++ b/lib/generated/apple_pay_domain.ex @@ -0,0 +1,149 @@ +defmodule Stripe.ApplePayDomain do + use Stripe.Entity + @moduledoc "" + ( + defstruct [:created, :domain_name, :id, :livemode, :object] + + @typedoc "The `apple_pay_domain` type.\n\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `domain_name` \n * `id` Unique identifier for the object.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `object` String representing the object's type. Objects of the same type share the same value.\n" + @type t :: %__MODULE__{ + created: integer, + domain_name: binary, + id: binary, + livemode: boolean, + object: binary + } + ) + + ( + nil + + @doc "

List apple pay domains.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/apple_pay/domains`\n" + ( + @spec list( + params :: %{ + optional(:domain_name) => binary, + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.ApplePayDomain.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/apple_pay/domains", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Create an apple pay domain.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/apple_pay/domains`\n" + ( + @spec create( + params :: %{optional(:domain_name) => binary, optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.ApplePayDomain.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/apple_pay/domains", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieve an apple pay domain.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/apple_pay/domains/{domain}`\n" + ( + @spec retrieve( + domain :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.ApplePayDomain.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def retrieve(domain, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/apple_pay/domains/{domain}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "domain", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "domain", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [domain] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Delete an apple pay domain.

\n\n#### Details\n\n * Method: `delete`\n * Path: `/v1/apple_pay/domains/{domain}`\n" + ( + @spec delete(domain :: binary(), opts :: Keyword.t()) :: + {:ok, Stripe.DeletedApplePayDomain.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def delete(domain, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/apple_pay/domains/{domain}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "domain", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "domain", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [domain] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_method(:delete) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/application_fee.ex b/lib/generated/application_fee.ex new file mode 100644 index 00000000..da284d20 --- /dev/null +++ b/lib/generated/application_fee.ex @@ -0,0 +1,123 @@ +defmodule Stripe.ApplicationFee do + use Stripe.Entity + @moduledoc "" + ( + defstruct [ + :account, + :amount, + :amount_refunded, + :application, + :balance_transaction, + :charge, + :created, + :currency, + :id, + :livemode, + :object, + :originating_transaction, + :refunded, + :refunds + ] + + @typedoc "The `application_fee` type.\n\n * `account` ID of the Stripe account this fee was taken from.\n * `amount` Amount earned, in %s.\n * `amount_refunded` Amount in %s refunded (can be less than the amount attribute on the fee if a partial refund was issued)\n * `application` ID of the Connect application that earned the fee.\n * `balance_transaction` Balance transaction that describes the impact of this collected application fee on your account balance (not including refunds).\n * `charge` ID of the charge that the application fee was taken from.\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `currency` Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).\n * `id` Unique identifier for the object.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `originating_transaction` ID of the corresponding charge on the platform account, if this fee was the result of a charge using the `destination` parameter.\n * `refunded` Whether the fee has been fully refunded. If the fee is only partially refunded, this attribute will still be false.\n * `refunds` A list of refunds that have been applied to the fee.\n" + @type t :: %__MODULE__{ + account: binary | Stripe.Account.t(), + amount: integer, + amount_refunded: integer, + application: binary | term, + balance_transaction: (binary | Stripe.BalanceTransaction.t()) | nil, + charge: binary | Stripe.Charge.t(), + created: integer, + currency: binary, + id: binary, + livemode: boolean, + object: binary, + originating_transaction: (binary | Stripe.Charge.t()) | nil, + refunded: boolean, + refunds: term + } + ) + + ( + @typedoc nil + @type created :: %{ + optional(:gt) => integer, + optional(:gte) => integer, + optional(:lt) => integer, + optional(:lte) => integer + } + ) + + ( + nil + + @doc "

Returns a list of application fees you’ve previously collected. The application fees are returned in sorted order, with the most recent fees appearing first.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/application_fees`\n" + ( + @spec list( + params :: %{ + optional(:charge) => binary, + optional(:created) => created | integer, + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.ApplicationFee.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/application_fees", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves the details of an application fee that your account has collected. The same information is returned when refunding the application fee.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/application_fees/{id}`\n" + ( + @spec retrieve( + id :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.ApplicationFee.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def retrieve(id, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/application_fees/{id}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "id", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "id", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [id] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/apps__secret.ex b/lib/generated/apps__secret.ex new file mode 100644 index 00000000..99a561a0 --- /dev/null +++ b/lib/generated/apps__secret.ex @@ -0,0 +1,133 @@ +defmodule Stripe.Apps.Secret do + use Stripe.Entity + + @moduledoc "Secret Store is an API that allows Stripe Apps developers to securely persist secrets for use by UI Extensions and app backends.\n\nThe primary resource in Secret Store is a `secret`. Other apps can't view secrets created by an app. Additionally, secrets are scoped to provide further permission control.\n\nAll Dashboard users and the app backend share `account` scoped secrets. Use the `account` scope for secrets that don't change per-user, like a third-party API key.\n\nA `user` scoped secret is accessible by the app backend and one specific Dashboard user. Use the `user` scope for per-user secrets like per-user OAuth tokens, where different users might have different permissions.\n\nRelated guide: [Store data between page reloads](https://stripe.com/docs/stripe-apps/store-auth-data-custom-objects)" + ( + defstruct [:created, :deleted, :expires_at, :id, :livemode, :name, :object, :payload, :scope] + + @typedoc "The `apps.secret` type.\n\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `deleted` If true, indicates that this secret has been deleted\n * `expires_at` The Unix timestamp for the expiry time of the secret, after which the secret deletes.\n * `id` Unique identifier for the object.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `name` A name for the secret that's unique within the scope.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `payload` The plaintext secret value to be stored.\n * `scope` \n" + @type t :: %__MODULE__{ + created: integer, + deleted: boolean, + expires_at: integer | nil, + id: binary, + livemode: boolean, + name: binary, + object: binary, + payload: binary | nil, + scope: term + } + ) + + ( + @typedoc nil + @type scope :: %{optional(:type) => :account | :user, optional(:user) => binary} + ) + + ( + nil + + @doc "

Finds a secret in the secret store by name and scope.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/apps/secrets/find`\n" + ( + @spec find( + params :: %{ + optional(:expand) => list(binary), + optional(:name) => binary, + optional(:scope) => scope + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.Apps.Secret.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def find(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/apps/secrets/find", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Create or replace a secret in the secret store.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/apps/secrets`\n" + ( + @spec create( + params :: %{ + optional(:expand) => list(binary), + optional(:expires_at) => integer, + optional(:name) => binary, + optional(:payload) => binary, + optional(:scope) => scope + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.Apps.Secret.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/apps/secrets", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Deletes a secret from the secret store by name and scope.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/apps/secrets/delete`\n" + ( + @spec delete_where( + params :: %{ + optional(:expand) => list(binary), + optional(:name) => binary, + optional(:scope) => scope + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.Apps.Secret.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def delete_where(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/apps/secrets/delete", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

List all secrets stored on the given scope.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/apps/secrets`\n" + ( + @spec list( + params :: %{ + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:scope) => scope, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.Apps.Secret.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/apps/secrets", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/balance.ex b/lib/generated/balance.ex new file mode 100644 index 00000000..bd95be69 --- /dev/null +++ b/lib/generated/balance.ex @@ -0,0 +1,46 @@ +defmodule Stripe.Balance do + use Stripe.Entity + + @moduledoc "This is an object representing your Stripe balance. You can retrieve it to see\nthe balance currently on your Stripe account.\n\nYou can also retrieve the balance history, which contains a list of\n[transactions](https://stripe.com/docs/reporting/balance-transaction-types) that contributed to the balance\n(charges, payouts, and so forth).\n\nThe available and pending amounts for each currency are broken down further by\npayment source types.\n\nRelated guide: [Understanding Connect account balances](https://stripe.com/docs/connect/account-balances)" + ( + defstruct [ + :available, + :connect_reserved, + :instant_available, + :issuing, + :livemode, + :object, + :pending + ] + + @typedoc "The `balance` type.\n\n * `available` Funds that are available to be transferred or paid out, whether automatically by Stripe or explicitly via the [Transfers API](https://stripe.com/docs/api#transfers) or [Payouts API](https://stripe.com/docs/api#payouts). The available balance for each currency and payment type can be found in the `source_types` property.\n * `connect_reserved` Funds held due to negative balances on connected Custom accounts. The connect reserve balance for each currency and payment type can be found in the `source_types` property.\n * `instant_available` Funds that can be paid out using Instant Payouts.\n * `issuing` \n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `pending` Funds that are not yet available in the balance. The pending balance for each currency, and for each payment type, can be found in the `source_types` property.\n" + @type t :: %__MODULE__{ + available: term, + connect_reserved: term, + instant_available: term, + issuing: term, + livemode: boolean, + object: binary, + pending: term + } + ) + + ( + nil + + @doc "

Retrieves the current account balance, based on the authentication that was used to make the request.\n For a sample request, see Accounting for negative balances.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/balance`\n" + ( + @spec retrieve(params :: %{optional(:expand) => list(binary)}, opts :: Keyword.t()) :: + {:ok, Stripe.Balance.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def retrieve(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/balance", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/balance_transaction.ex b/lib/generated/balance_transaction.ex new file mode 100644 index 00000000..2e070676 --- /dev/null +++ b/lib/generated/balance_transaction.ex @@ -0,0 +1,142 @@ +defmodule Stripe.BalanceTransaction do + use Stripe.Entity + + @moduledoc "Balance transactions represent funds moving through your Stripe account.\nThey're created for every type of transaction that comes into or flows out of your Stripe account balance.\n\nRelated guide: [Balance transaction types](https://stripe.com/docs/reports/balance-transaction-types)" + ( + defstruct [ + :amount, + :available_on, + :created, + :currency, + :description, + :exchange_rate, + :fee, + :fee_details, + :id, + :net, + :object, + :reporting_category, + :source, + :status, + :type + ] + + @typedoc "The `balance_transaction` type.\n\n * `amount` Gross amount of the transaction, in %s.\n * `available_on` The date the transaction's net funds will become available in the Stripe balance.\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `currency` Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).\n * `description` An arbitrary string attached to the object. Often useful for displaying to users.\n * `exchange_rate` The exchange rate used, if applicable, for this transaction. Specifically, if money was converted from currency A to currency B, then the `amount` in currency A, times `exchange_rate`, would be the `amount` in currency B. For example, suppose you charged a customer 10.00 EUR. Then the PaymentIntent's `amount` would be `1000` and `currency` would be `eur`. Suppose this was converted into 12.34 USD in your Stripe account. Then the BalanceTransaction's `amount` would be `1234`, `currency` would be `usd`, and `exchange_rate` would be `1.234`.\n * `fee` Fees (in %s) paid for this transaction.\n * `fee_details` Detailed breakdown of fees (in %s) paid for this transaction.\n * `id` Unique identifier for the object.\n * `net` Net amount of the transaction, in %s.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `reporting_category` [Learn more](https://stripe.com/docs/reports/reporting-categories) about how reporting categories can help you understand balance transactions from an accounting perspective.\n * `source` The Stripe object to which this transaction is related.\n * `status` If the transaction's net funds are available in the Stripe balance yet. Either `available` or `pending`.\n * `type` Transaction type: `adjustment`, `advance`, `advance_funding`, `anticipation_repayment`, `application_fee`, `application_fee_refund`, `charge`, `connect_collection_transfer`, `contribution`, `issuing_authorization_hold`, `issuing_authorization_release`, `issuing_dispute`, `issuing_transaction`, `payment`, `payment_failure_refund`, `payment_refund`, `payout`, `payout_cancel`, `payout_failure`, `refund`, `refund_failure`, `reserve_transaction`, `reserved_funds`, `stripe_fee`, `stripe_fx_fee`, `tax_fee`, `topup`, `topup_reversal`, `transfer`, `transfer_cancel`, `transfer_failure`, or `transfer_refund`. [Learn more](https://stripe.com/docs/reports/balance-transaction-types) about balance transaction types and what they represent. If you are looking to classify transactions for accounting purposes, you might want to consider `reporting_category` instead.\n" + @type t :: %__MODULE__{ + amount: integer, + available_on: integer, + created: integer, + currency: binary, + description: binary | nil, + exchange_rate: term | nil, + fee: integer, + fee_details: term, + id: binary, + net: integer, + object: binary, + reporting_category: binary, + source: (binary | term) | nil, + status: binary, + type: binary + } + ) + + ( + @typedoc nil + @type available_on :: %{ + optional(:gt) => integer, + optional(:gte) => integer, + optional(:lt) => integer, + optional(:lte) => integer + } + ) + + ( + @typedoc nil + @type created :: %{ + optional(:gt) => integer, + optional(:gte) => integer, + optional(:lt) => integer, + optional(:lte) => integer + } + ) + + ( + nil + + @doc "

Returns a list of transactions that have contributed to the Stripe account balance (e.g., charges, transfers, and so forth). The transactions are returned in sorted order, with the most recent transactions appearing first.

\n\n

Note that this endpoint was previously called “Balance history” and used the path /v1/balance/history.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/balance_transactions`\n" + ( + @spec list( + params :: %{ + optional(:available_on) => available_on | integer, + optional(:created) => created | integer, + optional(:currency) => binary, + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:payout) => binary, + optional(:source) => binary, + optional(:starting_after) => binary, + optional(:type) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.BalanceTransaction.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/balance_transactions", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves the balance transaction with the given ID.

\n\n

Note that this endpoint previously used the path /v1/balance/history/:id.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/balance_transactions/{id}`\n" + ( + @spec retrieve( + id :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.BalanceTransaction.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def retrieve(id, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/balance_transactions/{id}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "id", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "id", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [id] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/bank_account.ex b/lib/generated/bank_account.ex new file mode 100644 index 00000000..7beec3cd --- /dev/null +++ b/lib/generated/bank_account.ex @@ -0,0 +1,259 @@ +defmodule Stripe.BankAccount do + use Stripe.Entity + + @moduledoc "These bank accounts are payment methods on `Customer` objects.\n\nOn the other hand [External Accounts](https://stripe.com/docs/api#external_accounts) are transfer\ndestinations on `Account` objects for [Custom accounts](https://stripe.com/docs/connect/custom-accounts).\nThey can be bank accounts or debit cards as well, and are documented in the links above.\n\nRelated guide: [Bank debits and transfers](https://stripe.com/docs/payments/bank-debits-transfers)" + ( + defstruct [ + :account, + :account_holder_name, + :account_holder_type, + :account_type, + :available_payout_methods, + :bank_name, + :country, + :currency, + :customer, + :default_for_currency, + :fingerprint, + :future_requirements, + :id, + :last4, + :metadata, + :object, + :requirements, + :routing_number, + :status + ] + + @typedoc "The `bank_account` type.\n\n * `account` The ID of the account that the bank account is associated with.\n * `account_holder_name` The name of the person or business that owns the bank account.\n * `account_holder_type` The type of entity that holds the account. This can be either `individual` or `company`.\n * `account_type` The bank account type. This can only be `checking` or `savings` in most countries. In Japan, this can only be `futsu` or `toza`.\n * `available_payout_methods` A set of available payout methods for this bank account. Only values from this set should be passed as the `method` when creating a payout.\n * `bank_name` Name of the bank associated with the routing number (e.g., `WELLS FARGO`).\n * `country` Two-letter ISO code representing the country the bank account is located in.\n * `currency` Three-letter [ISO code for the currency](https://stripe.com/docs/payouts) paid out to the bank account.\n * `customer` The ID of the customer that the bank account is associated with.\n * `default_for_currency` Whether this bank account is the default external account for its currency.\n * `fingerprint` Uniquely identifies this particular bank account. You can use this attribute to check whether two bank accounts are the same.\n * `future_requirements` Information about upcoming new requirements for the bank account, including what information needs to be collected.\n * `id` Unique identifier for the object.\n * `last4` The last four digits of the bank account number.\n * `metadata` Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `requirements` Information about the requirements for the bank account, including what information needs to be collected.\n * `routing_number` The routing transit number for the bank account.\n * `status` For bank accounts, possible values are `new`, `validated`, `verified`, `verification_failed`, or `errored`. A bank account that hasn't had any activity or validation performed is `new`. If Stripe can determine that the bank account exists, its status will be `validated`. Note that there often isn’t enough information to know (e.g., for smaller credit unions), and the validation is not always run. If customer bank account verification has succeeded, the bank account status will be `verified`. If the verification failed for any reason, such as microdeposit failure, the status will be `verification_failed`. If a transfer sent to this bank account fails, we'll set the status to `errored` and will not continue to send transfers until the bank details are updated.\n\nFor external accounts, possible values are `new`, `errored` and `verification_failed`. If a transfer fails, the status is set to `errored` and transfers are stopped until account details are updated. In India, if we can't [verify the owner of the bank account](https://support.stripe.com/questions/bank-account-ownership-verification), we'll set the status to `verification_failed`. Other validations aren't run against external accounts because they're only used for payouts. This means the other statuses don't apply.\n" + @type t :: %__MODULE__{ + account: (binary | Stripe.Account.t()) | nil, + account_holder_name: binary | nil, + account_holder_type: binary | nil, + account_type: binary | nil, + available_payout_methods: term | nil, + bank_name: binary | nil, + country: binary, + currency: binary, + customer: (binary | Stripe.Customer.t() | Stripe.DeletedCustomer.t()) | nil, + default_for_currency: boolean | nil, + fingerprint: binary | nil, + future_requirements: term | nil, + id: binary, + last4: binary, + metadata: term | nil, + object: binary, + requirements: term | nil, + routing_number: binary | nil, + status: binary + } + ) + + ( + @typedoc "Owner's address." + @type address :: %{ + optional(:city) => binary, + optional(:country) => binary, + optional(:line1) => binary, + optional(:line2) => binary, + optional(:postal_code) => binary, + optional(:state) => binary + } + ) + + ( + @typedoc nil + @type owner :: %{ + optional(:address) => address, + optional(:email) => binary, + optional(:name) => binary, + optional(:phone) => binary + } + ) + + ( + nil + + @doc "

Update a specified source for a given customer.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/customers/{customer}/sources/{id}`\n" + ( + @spec update( + customer :: binary(), + id :: binary(), + params :: %{ + optional(:account_holder_name) => binary, + optional(:account_holder_type) => :company | :individual, + optional(:address_city) => binary, + optional(:address_country) => binary, + optional(:address_line1) => binary, + optional(:address_line2) => binary, + optional(:address_state) => binary, + optional(:address_zip) => binary, + optional(:exp_month) => binary, + optional(:exp_year) => binary, + optional(:expand) => list(binary), + optional(:metadata) => %{optional(binary) => binary} | binary, + optional(:name) => binary, + optional(:owner) => owner + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Card.t() | Stripe.BankAccount.t() | Stripe.Source.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def update(customer, id, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/customers/{customer}/sources/{id}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "customer", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "customer", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + }, + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "id", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "id", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [customer, id] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Delete a specified source for a given customer.

\n\n#### Details\n\n * Method: `delete`\n * Path: `/v1/customers/{customer}/sources/{id}`\n" + ( + @spec delete( + customer :: binary(), + id :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.PaymentSource.t() | Stripe.DeletedPaymentSource.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def delete(customer, id, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/customers/{customer}/sources/{id}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "customer", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "customer", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + }, + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "id", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "id", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [customer, id] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:delete) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Verify a specified bank account for a given customer.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/customers/{customer}/sources/{id}/verify`\n" + ( + @spec verify( + customer :: binary(), + id :: binary(), + params :: %{optional(:amounts) => list(integer), optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: {:ok, Stripe.BankAccount.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def verify(customer, id, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/customers/{customer}/sources/{id}/verify", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "customer", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "customer", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + }, + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "id", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "id", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [customer, id] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/billing_portal__configuration.ex b/lib/generated/billing_portal__configuration.ex new file mode 100644 index 00000000..de40d4f1 --- /dev/null +++ b/lib/generated/billing_portal__configuration.ex @@ -0,0 +1,294 @@ +defmodule Stripe.BillingPortal.Configuration do + use Stripe.Entity + + @moduledoc "A portal configuration describes the functionality and behavior of a portal session." + ( + defstruct [ + :active, + :application, + :business_profile, + :created, + :default_return_url, + :features, + :id, + :is_default, + :livemode, + :login_page, + :metadata, + :object, + :updated + ] + + @typedoc "The `billing_portal.configuration` type.\n\n * `active` Whether the configuration is active and can be used to create portal sessions.\n * `application` ID of the Connect Application that created the configuration.\n * `business_profile` \n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `default_return_url` The default URL to redirect customers to when they click on the portal's link to return to your website. This can be [overriden](https://stripe.com/docs/api/customer_portal/sessions/create#create_portal_session-return_url) when creating the session.\n * `features` \n * `id` Unique identifier for the object.\n * `is_default` Whether the configuration is the default. If `true`, this configuration can be managed in the Dashboard and portal sessions will use this configuration unless it is overriden when creating the session.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `login_page` \n * `metadata` Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `updated` Time at which the object was last updated. Measured in seconds since the Unix epoch.\n" + @type t :: %__MODULE__{ + active: boolean, + application: (binary | term | term) | nil, + business_profile: term, + created: integer, + default_return_url: binary | nil, + features: term, + id: binary, + is_default: boolean, + livemode: boolean, + login_page: term, + metadata: term | nil, + object: binary, + updated: integer + } + ) + + ( + @typedoc "The business information shown to customers in the portal." + @type business_profile :: %{ + optional(:headline) => binary, + optional(:privacy_policy_url) => binary, + optional(:terms_of_service_url) => binary + } + ) + + ( + @typedoc "Whether the cancellation reasons will be collected in the portal and which options are exposed to the customer" + @type cancellation_reason :: %{ + optional(:enabled) => boolean, + optional(:options) => + list( + :customer_service + | :low_quality + | :missing_features + | :other + | :switched_service + | :too_complex + | :too_expensive + | :unused + ) + | binary + } + ) + + ( + @typedoc "Information about updating the customer details in the portal." + @type customer_update :: %{ + optional(:allowed_updates) => + list(:address | :email | :name | :phone | :shipping | :tax_id) | binary, + optional(:enabled) => boolean + } + ) + + ( + @typedoc "Information about the features available in the portal." + @type features :: %{ + optional(:customer_update) => customer_update, + optional(:invoice_history) => invoice_history, + optional(:payment_method_update) => payment_method_update, + optional(:subscription_cancel) => subscription_cancel, + optional(:subscription_pause) => subscription_pause, + optional(:subscription_update) => subscription_update + } + ) + + ( + @typedoc "Information about showing the billing history in the portal." + @type invoice_history :: %{optional(:enabled) => boolean} + ) + + ( + @typedoc "The hosted login page for this configuration. Learn more about the portal login page in our [integration docs](https://stripe.com/docs/billing/subscriptions/integrating-customer-portal#share)." + @type login_page :: %{optional(:enabled) => boolean} + ) + + ( + @typedoc "Information about updating payment methods in the portal." + @type payment_method_update :: %{optional(:enabled) => boolean} + ) + + ( + @typedoc nil + @type products :: %{optional(:prices) => list(binary), optional(:product) => binary} + ) + + ( + @typedoc "Information about canceling subscriptions in the portal." + @type subscription_cancel :: %{ + optional(:cancellation_reason) => cancellation_reason, + optional(:enabled) => boolean, + optional(:mode) => :at_period_end | :immediately, + optional(:proration_behavior) => :always_invoice | :create_prorations | :none + } + ) + + ( + @typedoc "Information about pausing subscriptions in the portal." + @type subscription_pause :: %{optional(:enabled) => boolean} + ) + + ( + @typedoc "Information about updating subscriptions in the portal." + @type subscription_update :: %{ + optional(:default_allowed_updates) => + list(:price | :promotion_code | :quantity) | binary, + optional(:enabled) => boolean, + optional(:products) => list(products) | binary, + optional(:proration_behavior) => :always_invoice | :create_prorations | :none + } + ) + + ( + nil + + @doc "

Returns a list of configurations that describe the functionality of the customer portal.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/billing_portal/configurations`\n" + ( + @spec list( + params :: %{ + optional(:active) => boolean, + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:is_default) => boolean, + optional(:limit) => integer, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.BillingPortal.Configuration.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params("/v1/billing_portal/configurations", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Creates a configuration that describes the functionality and behavior of a PortalSession

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/billing_portal/configurations`\n" + ( + @spec create( + params :: %{ + optional(:business_profile) => business_profile, + optional(:default_return_url) => binary | binary, + optional(:expand) => list(binary), + optional(:features) => features, + optional(:login_page) => login_page, + optional(:metadata) => %{optional(binary) => binary} + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.BillingPortal.Configuration.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params("/v1/billing_portal/configurations", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Updates a configuration that describes the functionality of the customer portal.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/billing_portal/configurations/{configuration}`\n" + ( + @spec update( + configuration :: binary(), + params :: %{ + optional(:active) => boolean, + optional(:business_profile) => business_profile, + optional(:default_return_url) => binary | binary, + optional(:expand) => list(binary), + optional(:features) => features, + optional(:login_page) => login_page, + optional(:metadata) => %{optional(binary) => binary} | binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.BillingPortal.Configuration.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def update(configuration, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/billing_portal/configurations/{configuration}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "configuration", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "configuration", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [configuration] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves a configuration that describes the functionality of the customer portal.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/billing_portal/configurations/{configuration}`\n" + ( + @spec retrieve( + configuration :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.BillingPortal.Configuration.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def retrieve(configuration, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/billing_portal/configurations/{configuration}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "configuration", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "configuration", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [configuration] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/billing_portal__session.ex b/lib/generated/billing_portal__session.ex new file mode 100644 index 00000000..e3f8bdd4 --- /dev/null +++ b/lib/generated/billing_portal__session.ex @@ -0,0 +1,181 @@ +defmodule Stripe.BillingPortal.Session do + use Stripe.Entity + + @moduledoc "The Billing customer portal is a Stripe-hosted UI for subscription and\nbilling management.\n\nA portal configuration describes the functionality and features that you\nwant to provide to your customers through the portal.\n\nA portal session describes the instantiation of the customer portal for\na particular customer. By visiting the session's URL, the customer\ncan manage their subscriptions and billing details. For security reasons,\nsessions are short-lived and will expire if the customer does not visit the URL.\nCreate sessions on-demand when customers intend to manage their subscriptions\nand billing details.\n\nLearn more in the [integration guide](https://stripe.com/docs/billing/subscriptions/integrating-customer-portal)." + ( + defstruct [ + :configuration, + :created, + :customer, + :flow, + :id, + :livemode, + :locale, + :object, + :on_behalf_of, + :return_url, + :url + ] + + @typedoc "The `billing_portal.session` type.\n\n * `configuration` The configuration used by this session, describing the features available.\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `customer` The ID of the customer for this session.\n * `flow` Information about a specific flow for the customer to go through. See the [docs](https://stripe.com/docs/customer-management/portal-deep-links) to learn more about using customer portal deep links and flows.\n * `id` Unique identifier for the object.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `locale` The IETF language tag of the locale Customer Portal is displayed in. If blank or auto, the customer’s `preferred_locales` or browser’s locale is used.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `on_behalf_of` The account for which the session was created on behalf of. When specified, only subscriptions and invoices with this `on_behalf_of` account appear in the portal. For more information, see the [docs](https://stripe.com/docs/connect/separate-charges-and-transfers#on-behalf-of). Use the [Accounts API](https://stripe.com/docs/api/accounts/object#account_object-settings-branding) to modify the `on_behalf_of` account's branding settings, which the portal displays.\n * `return_url` The URL to redirect customers to when they click on the portal's link to return to your website.\n * `url` The short-lived URL of the session that gives customers access to the customer portal.\n" + @type t :: %__MODULE__{ + configuration: binary | Stripe.BillingPortal.Configuration.t(), + created: integer, + customer: binary, + flow: term | nil, + id: binary, + livemode: boolean, + locale: binary | nil, + object: binary, + on_behalf_of: binary | nil, + return_url: binary | nil, + url: binary + } + ) + + ( + @typedoc "Behavior after the flow is completed." + @type after_completion :: %{ + optional(:hosted_confirmation) => hosted_confirmation, + optional(:redirect) => redirect, + optional(:type) => :hosted_confirmation | :portal_homepage | :redirect + } + ) + + ( + @typedoc nil + @type discounts :: %{optional(:coupon) => binary, optional(:promotion_code) => binary} + ) + + ( + @typedoc "Information about a specific flow for the customer to go through. See the [docs](https://stripe.com/docs/customer-management/portal-deep-links) to learn more about using customer portal deep links and flows." + @type flow_data :: %{ + optional(:after_completion) => after_completion, + optional(:subscription_cancel) => subscription_cancel, + optional(:subscription_update) => subscription_update, + optional(:subscription_update_confirm) => subscription_update_confirm, + optional(:type) => + :payment_method_update + | :subscription_cancel + | :subscription_update + | :subscription_update_confirm + } + ) + + ( + @typedoc "Configuration when `after_completion.type=hosted_confirmation`." + @type hosted_confirmation :: %{optional(:custom_message) => binary} + ) + + ( + @typedoc nil + @type items :: %{ + optional(:id) => binary, + optional(:price) => binary, + optional(:quantity) => integer + } + ) + + ( + @typedoc "Configuration when `after_completion.type=redirect`." + @type redirect :: %{optional(:return_url) => binary} + ) + + ( + @typedoc "Configuration when `flow_data.type=subscription_cancel`." + @type subscription_cancel :: %{optional(:subscription) => binary} + ) + + ( + @typedoc "Configuration when `flow_data.type=subscription_update`." + @type subscription_update :: %{optional(:subscription) => binary} + ) + + ( + @typedoc "Configuration when `flow_data.type=subscription_update_confirm`." + @type subscription_update_confirm :: %{ + optional(:discounts) => list(discounts), + optional(:items) => list(items), + optional(:subscription) => binary + } + ) + + ( + nil + + @doc "

Creates a session of the customer portal.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/billing_portal/sessions`\n" + ( + @spec create( + params :: %{ + optional(:configuration) => binary, + optional(:customer) => binary, + optional(:expand) => list(binary), + optional(:flow_data) => flow_data, + optional(:locale) => + :auto + | :bg + | :cs + | :da + | :de + | :el + | :en + | :"en-AU" + | :"en-CA" + | :"en-GB" + | :"en-IE" + | :"en-IN" + | :"en-NZ" + | :"en-SG" + | :es + | :"es-419" + | :et + | :fi + | :fil + | :fr + | :"fr-CA" + | :hr + | :hu + | :id + | :it + | :ja + | :ko + | :lt + | :lv + | :ms + | :mt + | :nb + | :nl + | :pl + | :pt + | :"pt-BR" + | :ro + | :ru + | :sk + | :sl + | :sv + | :th + | :tr + | :vi + | :zh + | :"zh-HK" + | :"zh-TW", + optional(:on_behalf_of) => binary, + optional(:return_url) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.BillingPortal.Session.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/billing_portal/sessions", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/capability.ex b/lib/generated/capability.ex new file mode 100644 index 00000000..a283431f --- /dev/null +++ b/lib/generated/capability.ex @@ -0,0 +1,183 @@ +defmodule Stripe.Capability do + use Stripe.Entity + + @moduledoc "This is an object representing a capability for a Stripe account.\n\nRelated guide: [Account capabilities](https://stripe.com/docs/connect/account-capabilities)" + ( + defstruct [ + :account, + :future_requirements, + :id, + :object, + :requested, + :requested_at, + :requirements, + :status + ] + + @typedoc "The `capability` type.\n\n * `account` The account for which the capability enables functionality.\n * `future_requirements` \n * `id` The identifier for the capability.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `requested` Whether the capability has been requested.\n * `requested_at` Time at which the capability was requested. Measured in seconds since the Unix epoch.\n * `requirements` \n * `status` The status of the capability. Can be `active`, `inactive`, `pending`, or `unrequested`.\n" + @type t :: %__MODULE__{ + account: binary | Stripe.Account.t(), + future_requirements: term, + id: binary, + object: binary, + requested: boolean, + requested_at: integer | nil, + requirements: term, + status: binary + } + ) + + ( + nil + + @doc "

Returns a list of capabilities associated with the account. The capabilities are returned sorted by creation date, with the most recent capability appearing first.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/accounts/{account}/capabilities`\n" + ( + @spec list( + account :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.Capability.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(account, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/accounts/{account}/capabilities", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "account", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "account", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [account] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves information about the specified Account Capability.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/accounts/{account}/capabilities/{capability}`\n" + ( + @spec retrieve( + account :: binary(), + capability :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: {:ok, Stripe.Capability.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def retrieve(account, capability, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/accounts/{account}/capabilities/{capability}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "account", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "account", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + }, + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "capability", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "capability", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [account, capability] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Updates an existing Account Capability.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/accounts/{account}/capabilities/{capability}`\n" + ( + @spec update( + account :: binary(), + capability :: binary(), + params :: %{optional(:expand) => list(binary), optional(:requested) => boolean}, + opts :: Keyword.t() + ) :: {:ok, Stripe.Capability.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def update(account, capability, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/accounts/{account}/capabilities/{capability}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "account", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "account", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + }, + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "capability", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "capability", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [account, capability] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/card.ex b/lib/generated/card.ex new file mode 100644 index 00000000..941fec27 --- /dev/null +++ b/lib/generated/card.ex @@ -0,0 +1,228 @@ +defmodule Stripe.Card do + use Stripe.Entity + + @moduledoc "You can store multiple cards on a customer in order to charge the customer\nlater. You can also store multiple debit cards on a recipient in order to\ntransfer to those cards later.\n\nRelated guide: [Card payments with Sources](https://stripe.com/docs/sources/cards)" + ( + defstruct [ + :account, + :address_city, + :address_country, + :address_line1, + :address_line1_check, + :address_line2, + :address_state, + :address_zip, + :address_zip_check, + :available_payout_methods, + :brand, + :country, + :currency, + :customer, + :cvc_check, + :default_for_currency, + :description, + :dynamic_last4, + :exp_month, + :exp_year, + :fingerprint, + :funding, + :id, + :iin, + :issuer, + :last4, + :metadata, + :name, + :object, + :status, + :tokenization_method + ] + + @typedoc "The `card` type.\n\n * `account` The account this card belongs to. This attribute will not be in the card object if the card belongs to a customer or recipient instead.\n * `address_city` City/District/Suburb/Town/Village.\n * `address_country` Billing address country, if provided when creating card.\n * `address_line1` Address line 1 (Street address/PO Box/Company name).\n * `address_line1_check` If `address_line1` was provided, results of the check: `pass`, `fail`, `unavailable`, or `unchecked`.\n * `address_line2` Address line 2 (Apartment/Suite/Unit/Building).\n * `address_state` State/County/Province/Region.\n * `address_zip` ZIP or postal code.\n * `address_zip_check` If `address_zip` was provided, results of the check: `pass`, `fail`, `unavailable`, or `unchecked`.\n * `available_payout_methods` A set of available payout methods for this card. Only values from this set should be passed as the `method` when creating a payout.\n * `brand` Card brand. Can be `American Express`, `Diners Club`, `Discover`, `Eftpos Australia`, `JCB`, `MasterCard`, `UnionPay`, `Visa`, or `Unknown`.\n * `country` Two-letter ISO code representing the country of the card. You could use this attribute to get a sense of the international breakdown of cards you've collected.\n * `currency` Three-letter [ISO code for currency](https://stripe.com/docs/payouts). Only applicable on accounts (not customers or recipients). The card can be used as a transfer destination for funds in this currency.\n * `customer` The customer that this card belongs to. This attribute will not be in the card object if the card belongs to an account or recipient instead.\n * `cvc_check` If a CVC was provided, results of the check: `pass`, `fail`, `unavailable`, or `unchecked`. A result of unchecked indicates that CVC was provided but hasn't been checked yet. Checks are typically performed when attaching a card to a Customer object, or when creating a charge. For more details, see [Check if a card is valid without a charge](https://support.stripe.com/questions/check-if-a-card-is-valid-without-a-charge).\n * `default_for_currency` Whether this card is the default external account for its currency.\n * `description` A high-level description of the type of cards issued in this range. (For internal use only and not typically available in standard API requests.)\n * `dynamic_last4` (For tokenized numbers only.) The last four digits of the device account number.\n * `exp_month` Two-digit number representing the card's expiration month.\n * `exp_year` Four-digit number representing the card's expiration year.\n * `fingerprint` Uniquely identifies this particular card number. You can use this attribute to check whether two customers who’ve signed up with you are using the same card number, for example. For payment methods that tokenize card information (Apple Pay, Google Pay), the tokenized number might be provided instead of the underlying card number.\n\n*Starting May 1, 2021, card fingerprint in India for Connect will change to allow two fingerprints for the same card --- one for India and one for the rest of the world.*\n * `funding` Card funding type. Can be `credit`, `debit`, `prepaid`, or `unknown`.\n * `id` Unique identifier for the object.\n * `iin` Issuer identification number of the card. (For internal use only and not typically available in standard API requests.)\n * `issuer` The name of the card's issuing bank. (For internal use only and not typically available in standard API requests.)\n * `last4` The last four digits of the card.\n * `metadata` Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.\n * `name` Cardholder name.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `status` For external accounts, possible values are `new` and `errored`. If a transfer fails, the status is set to `errored` and transfers are stopped until account details are updated.\n * `tokenization_method` If the card number is tokenized, this is the method that was used. Can be `android_pay` (includes Google Pay), `apple_pay`, `masterpass`, `visa_checkout`, or null.\n" + @type t :: %__MODULE__{ + account: (binary | Stripe.Account.t()) | nil, + address_city: binary | nil, + address_country: binary | nil, + address_line1: binary | nil, + address_line1_check: binary | nil, + address_line2: binary | nil, + address_state: binary | nil, + address_zip: binary | nil, + address_zip_check: binary | nil, + available_payout_methods: term | nil, + brand: binary, + country: binary | nil, + currency: binary | nil, + customer: (binary | Stripe.Customer.t() | Stripe.DeletedCustomer.t()) | nil, + cvc_check: binary | nil, + default_for_currency: boolean | nil, + description: binary, + dynamic_last4: binary | nil, + exp_month: integer, + exp_year: integer, + fingerprint: binary | nil, + funding: binary, + id: binary, + iin: binary, + issuer: binary, + last4: binary, + metadata: term | nil, + name: binary | nil, + object: binary, + status: binary | nil, + tokenization_method: binary | nil + } + ) + + ( + @typedoc "Owner's address." + @type address :: %{ + optional(:city) => binary, + optional(:country) => binary, + optional(:line1) => binary, + optional(:line2) => binary, + optional(:postal_code) => binary, + optional(:state) => binary + } + ) + + ( + @typedoc nil + @type owner :: %{ + optional(:address) => address, + optional(:email) => binary, + optional(:name) => binary, + optional(:phone) => binary + } + ) + + ( + nil + + @doc "

Update a specified source for a given customer.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/customers/{customer}/sources/{id}`\n" + ( + @spec update( + customer :: binary(), + id :: binary(), + params :: %{ + optional(:account_holder_name) => binary, + optional(:account_holder_type) => :company | :individual, + optional(:address_city) => binary, + optional(:address_country) => binary, + optional(:address_line1) => binary, + optional(:address_line2) => binary, + optional(:address_state) => binary, + optional(:address_zip) => binary, + optional(:exp_month) => binary, + optional(:exp_year) => binary, + optional(:expand) => list(binary), + optional(:metadata) => %{optional(binary) => binary} | binary, + optional(:name) => binary, + optional(:owner) => owner + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Card.t() | Stripe.BankAccount.t() | Stripe.Source.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def update(customer, id, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/customers/{customer}/sources/{id}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "customer", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "customer", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + }, + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "id", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "id", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [customer, id] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Delete a specified source for a given customer.

\n\n#### Details\n\n * Method: `delete`\n * Path: `/v1/customers/{customer}/sources/{id}`\n" + ( + @spec delete( + customer :: binary(), + id :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.PaymentSource.t() | Stripe.DeletedPaymentSource.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def delete(customer, id, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/customers/{customer}/sources/{id}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "customer", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "customer", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + }, + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "id", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "id", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [customer, id] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:delete) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/cash_balance.ex b/lib/generated/cash_balance.ex new file mode 100644 index 00000000..dab32ca7 --- /dev/null +++ b/lib/generated/cash_balance.ex @@ -0,0 +1,106 @@ +defmodule Stripe.CashBalance do + use Stripe.Entity + + @moduledoc "A customer's `Cash balance` represents real funds. Customers can add funds to their cash balance by sending a bank transfer. These funds can be used for payment and can eventually be paid out to your bank account." + ( + defstruct [:available, :customer, :livemode, :object, :settings] + + @typedoc "The `cash_balance` type.\n\n * `available` A hash of all cash balances available to this customer. You cannot delete a customer with any cash balances, even if the balance is 0. Amounts are represented in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal).\n * `customer` The ID of the customer whose cash balance this object represents.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `settings` \n" + @type t :: %__MODULE__{ + available: term | nil, + customer: binary, + livemode: boolean, + object: binary, + settings: term + } + ) + + ( + @typedoc "A hash of settings for this cash balance." + @type settings :: %{ + optional(:reconciliation_mode) => :automatic | :manual | :merchant_default + } + ) + + ( + nil + + @doc "

Retrieves a customer’s cash balance.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/customers/{customer}/cash_balance`\n" + ( + @spec retrieve( + customer :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: {:ok, Stripe.CashBalance.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def retrieve(customer, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/customers/{customer}/cash_balance", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "customer", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "customer", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [customer] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Changes the settings on a customer’s cash balance.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/customers/{customer}/cash_balance`\n" + ( + @spec update( + customer :: binary(), + params :: %{optional(:expand) => list(binary), optional(:settings) => settings}, + opts :: Keyword.t() + ) :: {:ok, Stripe.CashBalance.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def update(customer, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/customers/{customer}/cash_balance", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "customer", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "customer", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [customer] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/charge.ex b/lib/generated/charge.ex new file mode 100644 index 00000000..388c32e2 --- /dev/null +++ b/lib/generated/charge.ex @@ -0,0 +1,413 @@ +defmodule Stripe.Charge do + use Stripe.Entity + + @moduledoc "The `Charge` object represents a single attempt to move money into your Stripe account.\nPaymentIntent confirmation is the most common way to create Charges, but transferring\nmoney to a different Stripe account through Connect also creates Charges.\nSome legacy payment flows create Charges directly, which is not recommended for new integrations." + ( + defstruct [ + :shipping, + :id, + :transfer_data, + :statement_descriptor_suffix, + :application_fee_amount, + :disputed, + :transfer_group, + :status, + :source_transfer, + :destination, + :dispute, + :transfer, + :created, + :currency, + :refunded, + :amount_refunded, + :captured, + :source, + :authorization_code, + :level3, + :billing_details, + :amount_captured, + :object, + :failure_code, + :receipt_number, + :failure_balance_transaction, + :receipt_email, + :application, + :balance_transaction, + :statement_descriptor, + :payment_method_details, + :invoice, + :outcome, + :amount, + :fraud_details, + :customer, + :on_behalf_of, + :alternate_statement_descriptors, + :refunds, + :payment_intent, + :review, + :failure_message, + :application_fee, + :paid, + :description, + :metadata, + :radar_options, + :calculated_statement_descriptor, + :livemode, + :payment_method, + :receipt_url + ] + + @typedoc "The `charge` type.\n\n * `alternate_statement_descriptors` \n * `amount` Amount intended to be collected by this payment. A positive integer representing how much to charge in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). The minimum amount is $0.50 US or [equivalent in charge currency](https://stripe.com/docs/currencies#minimum-and-maximum-charge-amounts). The amount value supports up to eight digits (e.g., a value of 99999999 for a USD charge of $999,999.99).\n * `amount_captured` Amount in %s captured (can be less than the amount attribute on the charge if a partial capture was made).\n * `amount_refunded` Amount in %s refunded (can be less than the amount attribute on the charge if a partial refund was issued).\n * `application` ID of the Connect application that created the charge.\n * `application_fee` The application fee (if any) for the charge. [See the Connect documentation](https://stripe.com/docs/connect/direct-charges#collecting-fees) for details.\n * `application_fee_amount` The amount of the application fee (if any) requested for the charge. [See the Connect documentation](https://stripe.com/docs/connect/direct-charges#collecting-fees) for details.\n * `authorization_code` Authorization code on the charge.\n * `balance_transaction` ID of the balance transaction that describes the impact of this charge on your account balance (not including refunds or disputes).\n * `billing_details` \n * `calculated_statement_descriptor` The full statement descriptor that is passed to card networks, and that is displayed on your customers' credit card and bank statements. Allows you to see what the statement descriptor looks like after the static and dynamic portions are combined.\n * `captured` If the charge was created without capturing, this Boolean represents whether it is still uncaptured or has since been captured.\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `currency` Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).\n * `customer` ID of the customer this charge is for if one exists.\n * `description` An arbitrary string attached to the object. Often useful for displaying to users.\n * `destination` ID of an existing, connected Stripe account to transfer funds to if `transfer_data` was specified in the charge request.\n * `dispute` Details about the dispute if the charge has been disputed.\n * `disputed` Whether the charge has been disputed.\n * `failure_balance_transaction` ID of the balance transaction that describes the reversal of the balance on your account due to payment failure.\n * `failure_code` Error code explaining reason for charge failure if available (see [the errors section](https://stripe.com/docs/error-codes) for a list of codes).\n * `failure_message` Message to user further explaining reason for charge failure if available.\n * `fraud_details` Information on fraud assessments for the charge.\n * `id` Unique identifier for the object.\n * `invoice` ID of the invoice this charge is for if one exists.\n * `level3` \n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `metadata` Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `on_behalf_of` The account (if any) the charge was made on behalf of without triggering an automatic transfer. See the [Connect documentation](https://stripe.com/docs/connect/separate-charges-and-transfers) for details.\n * `outcome` Details about whether the payment was accepted, and why. See [understanding declines](https://stripe.com/docs/declines) for details.\n * `paid` `true` if the charge succeeded, or was successfully authorized for later capture.\n * `payment_intent` ID of the PaymentIntent associated with this charge, if one exists.\n * `payment_method` ID of the payment method used in this charge.\n * `payment_method_details` Details about the payment method at the time of the transaction.\n * `radar_options` \n * `receipt_email` This is the email address that the receipt for this charge was sent to.\n * `receipt_number` This is the transaction number that appears on email receipts sent for this charge. This attribute will be `null` until a receipt has been sent.\n * `receipt_url` This is the URL to view the receipt for this charge. The receipt is kept up-to-date to the latest state of the charge, including any refunds. If the charge is for an Invoice, the receipt will be stylized as an Invoice receipt.\n * `refunded` Whether the charge has been fully refunded. If the charge is only partially refunded, this attribute will still be false.\n * `refunds` A list of refunds that have been applied to the charge.\n * `review` ID of the review associated with this charge if one exists.\n * `shipping` Shipping information for the charge.\n * `source` This is a legacy field that will be removed in the future. It contains the Source, Card, or BankAccount object used for the charge. For details about the payment method used for this charge, refer to `payment_method` or `payment_method_details` instead.\n * `source_transfer` The transfer ID which created this charge. Only present if the charge came from another Stripe account. [See the Connect documentation](https://stripe.com/docs/connect/destination-charges) for details.\n * `statement_descriptor` For card charges, use `statement_descriptor_suffix` instead. Otherwise, you can use this value as the complete description of a charge on your customers’ statements. Must contain at least one letter, maximum 22 characters.\n * `statement_descriptor_suffix` Provides information about the charge that customers see on their statements. Concatenated with the prefix (shortened descriptor) or statement descriptor that’s set on the account to form the complete statement descriptor. Maximum 22 characters for the concatenated descriptor.\n * `status` The status of the payment is either `succeeded`, `pending`, or `failed`.\n * `transfer` ID of the transfer to the `destination` account (only applicable if the charge was created using the `destination` parameter).\n * `transfer_data` An optional dictionary including the account to automatically transfer to as part of a destination charge. [See the Connect documentation](https://stripe.com/docs/connect/destination-charges) for details.\n * `transfer_group` A string that identifies this transaction as part of a group. See the [Connect documentation](https://stripe.com/docs/connect/separate-charges-and-transfers#transfer-options) for details.\n" + @type t :: %__MODULE__{ + alternate_statement_descriptors: term, + amount: integer, + amount_captured: integer, + amount_refunded: integer, + application: (binary | term) | nil, + application_fee: (binary | Stripe.ApplicationFee.t()) | nil, + application_fee_amount: integer | nil, + authorization_code: binary, + balance_transaction: (binary | Stripe.BalanceTransaction.t()) | nil, + billing_details: term, + calculated_statement_descriptor: binary | nil, + captured: boolean, + created: integer, + currency: binary, + customer: (binary | Stripe.Customer.t() | Stripe.DeletedCustomer.t()) | nil, + description: binary | nil, + destination: (binary | Stripe.Account.t()) | nil, + dispute: (binary | Stripe.Dispute.t()) | nil, + disputed: boolean, + failure_balance_transaction: (binary | Stripe.BalanceTransaction.t()) | nil, + failure_code: binary | nil, + failure_message: binary | nil, + fraud_details: term | nil, + id: binary, + invoice: (binary | Stripe.Invoice.t()) | nil, + level3: term, + livemode: boolean, + metadata: term, + object: binary, + on_behalf_of: (binary | Stripe.Account.t()) | nil, + outcome: term | nil, + paid: boolean, + payment_intent: (binary | Stripe.PaymentIntent.t()) | nil, + payment_method: binary | nil, + payment_method_details: term | nil, + radar_options: term, + receipt_email: binary | nil, + receipt_number: binary | nil, + receipt_url: binary | nil, + refunded: boolean, + refunds: term | nil, + review: (binary | Stripe.Review.t()) | nil, + shipping: term | nil, + source: Stripe.PaymentSource.t() | nil, + source_transfer: (binary | Stripe.Transfer.t()) | nil, + statement_descriptor: binary | nil, + statement_descriptor_suffix: binary | nil, + status: binary, + transfer: binary | Stripe.Transfer.t(), + transfer_data: term | nil, + transfer_group: binary | nil + } + ) + + ( + @typedoc "Shipping address." + @type address :: %{ + optional(:city) => binary, + optional(:country) => binary, + optional(:line1) => binary, + optional(:line2) => binary, + optional(:postal_code) => binary, + optional(:state) => binary + } + ) + + ( + @typedoc nil + @type created :: %{ + optional(:gt) => integer, + optional(:gte) => integer, + optional(:lt) => integer, + optional(:lte) => integer + } + ) + + ( + @typedoc nil + @type destination :: %{optional(:account) => binary, optional(:amount) => integer} + ) + + ( + @typedoc "A set of key-value pairs you can attach to a charge giving information about its riskiness. If you believe a charge is fraudulent, include a `user_report` key with a value of `fraudulent`. If you believe a charge is safe, include a `user_report` key with a value of `safe`. Stripe will use the information you send to improve our fraud detection algorithms." + @type fraud_details :: %{optional(:user_report) => :fraudulent | :safe} + ) + + ( + @typedoc "Options to configure Radar. See [Radar Session](https://stripe.com/docs/radar/radar-session) for more information." + @type radar_options :: %{optional(:session) => binary} + ) + + ( + @typedoc "Shipping information for the charge. Helps prevent fraud on charges for physical goods." + @type shipping :: %{ + optional(:address) => address, + optional(:carrier) => binary, + optional(:name) => binary, + optional(:phone) => binary, + optional(:tracking_number) => binary + } + ) + + ( + @typedoc "An optional dictionary including the account to automatically transfer to as part of a destination charge. [See the Connect documentation](https://stripe.com/docs/connect/destination-charges) for details." + @type transfer_data :: %{optional(:amount) => integer, optional(:destination) => binary} + ) + + ( + nil + + @doc "

Search for charges you’ve previously created using Stripe’s Search Query Language.\nDon’t use search in read-after-write flows where strict consistency is necessary. Under normal operating\nconditions, data is searchable in less than a minute. Occasionally, propagation of new or updated data can be up\nto an hour behind during outages. Search functionality is not available to merchants in India.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/charges/search`\n" + ( + @spec search( + params :: %{ + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:page) => binary, + optional(:query) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.SearchResult.t(Stripe.Charge.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def search(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/charges/search", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Returns a list of charges you’ve previously created. The charges are returned in sorted order, with the most recent charges appearing first.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/charges`\n" + ( + @spec list( + params :: %{ + optional(:created) => created | integer, + optional(:customer) => binary, + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:payment_intent) => binary, + optional(:starting_after) => binary, + optional(:transfer_group) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.Charge.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/charges", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Use the Payment Intents API to initiate a new payment instead\nof using this method. Confirmation of the PaymentIntent creates the Charge\nobject used to request payment, so this method is limited to legacy integrations.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/charges`\n" + ( + @spec create( + params :: %{ + optional(:amount) => integer, + optional(:application_fee) => integer, + optional(:application_fee_amount) => integer, + optional(:capture) => boolean, + optional(:currency) => binary, + optional(:customer) => binary, + optional(:description) => binary, + optional(:destination) => destination, + optional(:expand) => list(binary), + optional(:metadata) => %{optional(binary) => binary} | binary, + optional(:on_behalf_of) => binary, + optional(:radar_options) => radar_options, + optional(:receipt_email) => binary, + optional(:shipping) => shipping, + optional(:source) => binary, + optional(:statement_descriptor) => binary, + optional(:statement_descriptor_suffix) => binary, + optional(:transfer_data) => transfer_data, + optional(:transfer_group) => binary + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.Charge.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/charges", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves the details of a charge that has previously been created. Supply the unique charge ID that was returned from your previous request, and Stripe will return the corresponding charge information. The same information is returned when creating or refunding the charge.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/charges/{charge}`\n" + ( + @spec retrieve( + charge :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: {:ok, Stripe.Charge.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def retrieve(charge, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/charges/{charge}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "charge", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "charge", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [charge] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Updates the specified charge by setting the values of the parameters passed. Any parameters not provided will be left unchanged.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/charges/{charge}`\n" + ( + @spec update( + charge :: binary(), + params :: %{ + optional(:customer) => binary, + optional(:description) => binary, + optional(:expand) => list(binary), + optional(:fraud_details) => fraud_details, + optional(:metadata) => %{optional(binary) => binary} | binary, + optional(:receipt_email) => binary, + optional(:shipping) => shipping, + optional(:transfer_group) => binary + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.Charge.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def update(charge, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/charges/{charge}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "charge", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "charge", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [charge] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Capture the payment of an existing, uncaptured charge that was created with the capture option set to false.

\n\n

Uncaptured payments expire a set number of days after they are created (7 by default), after which they are marked as refunded and capture attempts will fail.

\n\n

Don’t use this method to capture a PaymentIntent-initiated charge. Use Capture a PaymentIntent.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/charges/{charge}/capture`\n" + ( + @spec capture( + charge :: binary(), + params :: %{ + optional(:amount) => integer, + optional(:application_fee) => integer, + optional(:application_fee_amount) => integer, + optional(:expand) => list(binary), + optional(:receipt_email) => binary, + optional(:statement_descriptor) => binary, + optional(:statement_descriptor_suffix) => binary, + optional(:transfer_data) => transfer_data, + optional(:transfer_group) => binary + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.Charge.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def capture(charge, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/charges/{charge}/capture", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "charge", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "charge", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [charge] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/checkout__session.ex b/lib/generated/checkout__session.ex new file mode 100644 index 00000000..53ec8be7 --- /dev/null +++ b/lib/generated/checkout__session.ex @@ -0,0 +1,1272 @@ +defmodule Stripe.Checkout.Session do + use Stripe.Entity + + @moduledoc "A Checkout Session represents your customer's session as they pay for\none-time purchases or subscriptions through [Checkout](https://stripe.com/docs/payments/checkout)\nor [Payment Links](https://stripe.com/docs/payments/payment-links). We recommend creating a\nnew Session each time your customer attempts to pay.\n\nOnce payment is successful, the Checkout Session will contain a reference\nto the [Customer](https://stripe.com/docs/api/customers), and either the successful\n[PaymentIntent](https://stripe.com/docs/api/payment_intents) or an active\n[Subscription](https://stripe.com/docs/api/subscriptions).\n\nYou can create a Checkout Session on your server and redirect to its URL\nto begin Checkout.\n\nRelated guide: [Checkout quickstart](https://stripe.com/docs/checkout/quickstart)" + ( + defstruct [ + :shipping_options, + :id, + :consent, + :shipping_details, + :status, + :cancel_url, + :billing_address_collection, + :allow_promotion_codes, + :subscription, + :url, + :payment_method_collection, + :amount_total, + :amount_subtotal, + :currency_conversion, + :created, + :currency, + :tax_id_collection, + :after_expiration, + :client_reference_id, + :setup_intent, + :automatic_tax, + :expires_at, + :total_details, + :object, + :recovered_from, + :success_url, + :mode, + :custom_text, + :invoice, + :submit_type, + :shipping_cost, + :customer, + :invoice_creation, + :phone_number_collection, + :customer_details, + :customer_email, + :payment_intent, + :consent_collection, + :shipping_address_collection, + :locale, + :payment_method_types, + :metadata, + :payment_link, + :customer_creation, + :custom_fields, + :line_items, + :payment_method_options, + :livemode, + :payment_status + ] + + @typedoc "The `checkout.session` type.\n\n * `after_expiration` When set, provides configuration for actions to take if this Checkout Session expires.\n * `allow_promotion_codes` Enables user redeemable promotion codes.\n * `amount_subtotal` Total of all items before discounts or taxes are applied.\n * `amount_total` Total of all items after discounts and taxes are applied.\n * `automatic_tax` \n * `billing_address_collection` Describes whether Checkout should collect the customer's billing address.\n * `cancel_url` If set, Checkout displays a back button and customers will be directed to this URL if they decide to cancel payment and return to your website.\n * `client_reference_id` A unique string to reference the Checkout Session. This can be a\ncustomer ID, a cart ID, or similar, and can be used to reconcile the\nSession with your internal systems.\n * `consent` Results of `consent_collection` for this session.\n * `consent_collection` When set, provides configuration for the Checkout Session to gather active consent from customers.\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `currency` Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).\n * `currency_conversion` Currency conversion details for automatic currency conversion sessions\n * `custom_fields` Collect additional information from your customer using custom fields. Up to 2 fields are supported.\n * `custom_text` \n * `customer` The ID of the customer for this Session.\nFor Checkout Sessions in `payment` or `subscription` mode, Checkout\nwill create a new customer object based on information provided\nduring the payment flow unless an existing customer was provided when\nthe Session was created.\n * `customer_creation` Configure whether a Checkout Session creates a Customer when the Checkout Session completes.\n * `customer_details` The customer details including the customer's tax exempt status and the customer's tax IDs. Only the customer's email is present on Sessions in `setup` mode.\n * `customer_email` If provided, this value will be used when the Customer object is created.\nIf not provided, customers will be asked to enter their email address.\nUse this parameter to prefill customer data if you already have an email\non file. To access information about the customer once the payment flow is\ncomplete, use the `customer` attribute.\n * `expires_at` The timestamp at which the Checkout Session will expire.\n * `id` Unique identifier for the object.\n * `invoice` ID of the invoice created by the Checkout Session, if it exists.\n * `invoice_creation` Details on the state of invoice creation for the Checkout Session.\n * `line_items` The line items purchased by the customer.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `locale` The IETF language tag of the locale Checkout is displayed in. If blank or `auto`, the browser's locale is used.\n * `metadata` Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.\n * `mode` The mode of the Checkout Session.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `payment_intent` The ID of the PaymentIntent for Checkout Sessions in `payment` mode.\n * `payment_link` The ID of the Payment Link that created this Session.\n * `payment_method_collection` Configure whether a Checkout Session should collect a payment method.\n * `payment_method_options` Payment-method-specific configuration for the PaymentIntent or SetupIntent of this CheckoutSession.\n * `payment_method_types` A list of the types of payment methods (e.g. card) this Checkout\nSession is allowed to accept.\n * `payment_status` The payment status of the Checkout Session, one of `paid`, `unpaid`, or `no_payment_required`.\nYou can use this value to decide when to fulfill your customer's order.\n * `phone_number_collection` \n * `recovered_from` The ID of the original expired Checkout Session that triggered the recovery flow.\n * `setup_intent` The ID of the SetupIntent for Checkout Sessions in `setup` mode.\n * `shipping_address_collection` When set, provides configuration for Checkout to collect a shipping address from a customer.\n * `shipping_cost` The details of the customer cost of shipping, including the customer chosen ShippingRate.\n * `shipping_details` Shipping information for this Checkout Session.\n * `shipping_options` The shipping rate options applied to this Session.\n * `status` The status of the Checkout Session, one of `open`, `complete`, or `expired`.\n * `submit_type` Describes the type of transaction being performed by Checkout in order to customize\nrelevant text on the page, such as the submit button. `submit_type` can only be\nspecified on Checkout Sessions in `payment` mode, but not Checkout Sessions\nin `subscription` or `setup` mode.\n * `subscription` The ID of the subscription for Checkout Sessions in `subscription` mode.\n * `success_url` The URL the customer will be directed to after the payment or\nsubscription creation is successful.\n * `tax_id_collection` \n * `total_details` Tax and discount details for the computed total amount.\n * `url` The URL to the Checkout Session. Redirect customers to this URL to take them to Checkout. If you’re using [Custom Domains](https://stripe.com/docs/payments/checkout/custom-domains), the URL will use your subdomain. Otherwise, it’ll use `checkout.stripe.com.`\nThis value is only present when the session is active.\n" + @type t :: %__MODULE__{ + after_expiration: term | nil, + allow_promotion_codes: boolean | nil, + amount_subtotal: integer | nil, + amount_total: integer | nil, + automatic_tax: term, + billing_address_collection: binary | nil, + cancel_url: binary | nil, + client_reference_id: binary | nil, + consent: term | nil, + consent_collection: term | nil, + created: integer, + currency: binary | nil, + currency_conversion: term | nil, + custom_fields: term, + custom_text: term, + customer: (binary | Stripe.Customer.t() | Stripe.DeletedCustomer.t()) | nil, + customer_creation: binary | nil, + customer_details: term | nil, + customer_email: binary | nil, + expires_at: integer, + id: binary, + invoice: (binary | Stripe.Invoice.t()) | nil, + invoice_creation: term | nil, + line_items: term, + livemode: boolean, + locale: binary | nil, + metadata: term | nil, + mode: binary, + object: binary, + payment_intent: (binary | Stripe.PaymentIntent.t()) | nil, + payment_link: (binary | Stripe.PaymentLink.t()) | nil, + payment_method_collection: binary | nil, + payment_method_options: term | nil, + payment_method_types: term, + payment_status: binary, + phone_number_collection: term, + recovered_from: binary | nil, + setup_intent: (binary | Stripe.SetupIntent.t()) | nil, + shipping_address_collection: term | nil, + shipping_cost: term | nil, + shipping_details: term | nil, + shipping_options: term, + status: binary | nil, + submit_type: binary | nil, + subscription: (binary | Stripe.Subscription.t()) | nil, + success_url: binary | nil, + tax_id_collection: term, + total_details: term | nil, + url: binary | nil + } + ) + + ( + @typedoc "contains details about the ACSS Debit payment method options." + @type acss_debit :: %{ + optional(:currency) => :cad | :usd, + optional(:mandate_options) => mandate_options, + optional(:setup_future_usage) => :none | :off_session | :on_session, + optional(:verification_method) => :automatic | :instant | :microdeposits + } + ) + + ( + @typedoc "Shipping address." + @type address :: %{ + optional(:city) => binary, + optional(:country) => binary, + optional(:line1) => binary, + optional(:line2) => binary, + optional(:postal_code) => binary, + optional(:state) => binary + } + ) + + ( + @typedoc "When set, provides configuration for this item’s quantity to be adjusted by the customer during Checkout." + @type adjustable_quantity :: %{ + optional(:enabled) => boolean, + optional(:maximum) => integer, + optional(:minimum) => integer + } + ) + + ( + @typedoc "contains details about the Affirm payment method options." + @type affirm :: %{optional(:setup_future_usage) => :none} + ) + + ( + @typedoc "Configure actions after a Checkout Session has expired." + @type after_expiration :: %{optional(:recovery) => recovery} + ) + + ( + @typedoc "contains details about the Afterpay Clearpay payment method options." + @type afterpay_clearpay :: %{optional(:setup_future_usage) => :none} + ) + + ( + @typedoc "contains details about the Alipay payment method options." + @type alipay :: %{optional(:setup_future_usage) => :none} + ) + + ( + @typedoc "contains details about the AU Becs Debit payment method options." + @type au_becs_debit :: %{optional(:setup_future_usage) => :none} + ) + + ( + @typedoc "Settings for automatic tax lookup for this session and resulting payments, invoices, and subscriptions." + @type automatic_tax :: %{optional(:enabled) => boolean} + ) + + ( + @typedoc "contains details about the Bacs Debit payment method options." + @type bacs_debit :: %{optional(:setup_future_usage) => :none | :off_session | :on_session} + ) + + ( + @typedoc "contains details about the Bancontact payment method options." + @type bancontact :: %{optional(:setup_future_usage) => :none} + ) + + ( + @typedoc "Configuration for the bank transfer funding type, if the `funding_type` is set to `bank_transfer`." + @type bank_transfer :: %{ + optional(:eu_bank_transfer) => eu_bank_transfer, + optional(:requested_address_types) => + list(:aba | :iban | :sepa | :sort_code | :spei | :swift | :zengin), + optional(:type) => + :eu_bank_transfer + | :gb_bank_transfer + | :jp_bank_transfer + | :mx_bank_transfer + | :us_bank_transfer + } + ) + + ( + @typedoc "contains details about the Boleto payment method options." + @type boleto :: %{ + optional(:expires_after_days) => integer, + optional(:setup_future_usage) => :none | :off_session | :on_session + } + ) + + ( + @typedoc "contains details about the Card payment method options." + @type card :: %{ + optional(:installments) => installments, + optional(:setup_future_usage) => :off_session | :on_session, + optional(:statement_descriptor_suffix_kana) => binary, + optional(:statement_descriptor_suffix_kanji) => binary + } + ) + + ( + @typedoc "contains details about the Cashapp Pay payment method options." + @type cashapp :: %{optional(:setup_future_usage) => :none | :off_session | :on_session} + ) + + ( + @typedoc "Configure fields for the Checkout Session to gather active consent from customers." + @type consent_collection :: %{ + optional(:promotions) => :auto | :none, + optional(:terms_of_service) => :none | :required + } + ) + + ( + @typedoc nil + @type custom_fields :: %{ + optional(:dropdown) => dropdown, + optional(:key) => binary, + optional(:label) => label, + optional(:numeric) => numeric, + optional(:optional) => boolean, + optional(:text) => text, + optional(:type) => :dropdown | :numeric | :text + } + ) + + ( + @typedoc "Display additional text for your customers using custom text." + @type custom_text :: %{ + optional(:shipping_address) => shipping_address | binary, + optional(:submit) => submit | binary + } + ) + + ( + @typedoc "contains details about the Customer Balance payment method options." + @type customer_balance :: %{ + optional(:bank_transfer) => bank_transfer, + optional(:funding_type) => :bank_transfer, + optional(:setup_future_usage) => :none + } + ) + + ( + @typedoc nil + @type customer_details :: %{optional(:email) => binary} + ) + + ( + @typedoc "Controls what fields on Customer can be updated by the Checkout Session. Can only be provided when `customer` is provided." + @type customer_update :: %{ + optional(:address) => :auto | :never, + optional(:name) => :auto | :never, + optional(:shipping) => :auto | :never + } + ) + + ( + @typedoc "The estimated range for how long shipping will take, meant to be displayable to the customer. This will appear on CheckoutSessions." + @type delivery_estimate :: %{optional(:maximum) => maximum, optional(:minimum) => minimum} + ) + + ( + @typedoc nil + @type discounts :: %{optional(:coupon) => binary, optional(:promotion_code) => binary} + ) + + ( + @typedoc "Configuration for `type=dropdown` fields." + @type dropdown :: %{optional(:options) => list(options)} + ) + + ( + @typedoc "Defines how the subscription should behave when the user's free trial ends." + @type end_behavior :: %{ + optional(:missing_payment_method) => :cancel | :create_invoice | :pause + } + ) + + ( + @typedoc "contains details about the EPS payment method options." + @type eps :: %{optional(:setup_future_usage) => :none} + ) + + ( + @typedoc "Configuration for eu_bank_transfer funding type." + @type eu_bank_transfer :: %{optional(:country) => binary} + ) + + ( + @typedoc "Additional fields for Financial Connections Session creation" + @type financial_connections :: %{ + optional(:permissions) => + list(:balances | :ownership | :payment_method | :transactions) + } + ) + + ( + @typedoc "Describes a fixed amount to charge for shipping. Must be present if type is `fixed_amount`." + @type fixed_amount :: %{ + optional(:amount) => integer, + optional(:currency) => binary, + optional(:currency_options) => map() + } + ) + + ( + @typedoc "contains details about the FPX payment method options." + @type fpx :: %{optional(:setup_future_usage) => :none} + ) + + ( + @typedoc "contains details about the Giropay payment method options." + @type giropay :: %{optional(:setup_future_usage) => :none} + ) + + ( + @typedoc "contains details about the Grabpay payment method options." + @type grabpay :: %{optional(:setup_future_usage) => :none} + ) + + ( + @typedoc "contains details about the Ideal payment method options." + @type ideal :: %{optional(:setup_future_usage) => :none} + ) + + ( + @typedoc "Installment options for card payments" + @type installments :: %{optional(:enabled) => boolean} + ) + + ( + @typedoc "Generate a post-purchase Invoice for one-time payments." + @type invoice_creation :: %{ + optional(:enabled) => boolean, + optional(:invoice_data) => invoice_data + } + ) + + ( + @typedoc "Parameters passed when creating invoices for payment-mode Checkout Sessions." + @type invoice_data :: %{ + optional(:account_tax_ids) => list(binary) | binary, + optional(:custom_fields) => list(custom_fields) | binary, + optional(:description) => binary, + optional(:footer) => binary, + optional(:metadata) => %{optional(binary) => binary}, + optional(:rendering_options) => rendering_options | binary + } + ) + + ( + @typedoc "contains details about the Klarna payment method options." + @type klarna :: %{optional(:setup_future_usage) => :none} + ) + + ( + @typedoc "contains details about the Konbini payment method options." + @type konbini :: %{ + optional(:expires_after_days) => integer, + optional(:setup_future_usage) => :none + } + ) + + ( + @typedoc "The label for the field, displayed to the customer." + @type label :: %{optional(:custom) => binary, optional(:type) => :custom} + ) + + ( + @typedoc nil + @type line_items :: %{ + optional(:adjustable_quantity) => adjustable_quantity, + optional(:dynamic_tax_rates) => list(binary), + optional(:price) => binary, + optional(:price_data) => price_data, + optional(:quantity) => integer, + optional(:tax_rates) => list(binary) + } + ) + + ( + @typedoc "contains details about the Link payment method options." + @type link :: %{optional(:setup_future_usage) => :none | :off_session} + ) + + ( + @typedoc "Additional fields for Mandate creation" + @type mandate_options :: %{ + optional(:custom_mandate_url) => binary | binary, + optional(:default_for) => list(:invoice | :subscription), + optional(:interval_description) => binary, + optional(:payment_schedule) => :combined | :interval | :sporadic, + optional(:transaction_type) => :business | :personal + } + ) + + ( + @typedoc "The upper bound of the estimated range. If empty, represents no upper bound i.e., infinite." + @type maximum :: %{ + optional(:unit) => :business_day | :day | :hour | :month | :week, + optional(:value) => integer + } + ) + + ( + @typedoc "The lower bound of the estimated range. If empty, represents no lower bound." + @type minimum :: %{ + optional(:unit) => :business_day | :day | :hour | :month | :week, + optional(:value) => integer + } + ) + + ( + @typedoc "Configuration for `type=numeric` fields." + @type numeric :: %{optional(:maximum_length) => integer, optional(:minimum_length) => integer} + ) + + ( + @typedoc nil + @type options :: %{optional(:label) => binary, optional(:value) => binary} + ) + + ( + @typedoc "contains details about the OXXO payment method options." + @type oxxo :: %{ + optional(:expires_after_days) => integer, + optional(:setup_future_usage) => :none + } + ) + + ( + @typedoc "contains details about the P24 payment method options." + @type p24 :: %{ + optional(:setup_future_usage) => :none, + optional(:tos_shown_and_accepted) => boolean + } + ) + + ( + @typedoc "A subset of parameters to be passed to PaymentIntent creation for Checkout Sessions in `payment` mode." + @type payment_intent_data :: %{ + optional(:application_fee_amount) => integer, + optional(:capture_method) => :automatic | :automatic_async | :manual, + optional(:description) => binary, + optional(:metadata) => %{optional(binary) => binary}, + optional(:on_behalf_of) => binary, + optional(:receipt_email) => binary, + optional(:setup_future_usage) => :off_session | :on_session, + optional(:shipping) => shipping, + optional(:statement_descriptor) => binary, + optional(:statement_descriptor_suffix) => binary, + optional(:transfer_data) => transfer_data, + optional(:transfer_group) => binary + } + ) + + ( + @typedoc "Payment-method-specific configuration." + @type payment_method_options :: %{ + optional(:acss_debit) => acss_debit, + optional(:affirm) => affirm, + optional(:afterpay_clearpay) => afterpay_clearpay, + optional(:alipay) => alipay, + optional(:au_becs_debit) => au_becs_debit, + optional(:bacs_debit) => bacs_debit, + optional(:bancontact) => bancontact, + optional(:boleto) => boleto, + optional(:card) => card, + optional(:cashapp) => cashapp, + optional(:customer_balance) => customer_balance, + optional(:eps) => eps, + optional(:fpx) => fpx, + optional(:giropay) => giropay, + optional(:grabpay) => grabpay, + optional(:ideal) => ideal, + optional(:klarna) => klarna, + optional(:konbini) => konbini, + optional(:link) => link, + optional(:oxxo) => oxxo, + optional(:p24) => p24, + optional(:paynow) => paynow, + optional(:paypal) => paypal, + optional(:pix) => pix, + optional(:sepa_debit) => sepa_debit, + optional(:sofort) => sofort, + optional(:us_bank_account) => us_bank_account, + optional(:wechat_pay) => wechat_pay + } + ) + + ( + @typedoc "contains details about the PayNow payment method options." + @type paynow :: %{optional(:setup_future_usage) => :none} + ) + + ( + @typedoc "contains details about the PayPal payment method options." + @type paypal :: %{ + optional(:capture_method) => :manual, + optional(:preferred_locale) => + :"cs-CZ" + | :"da-DK" + | :"de-AT" + | :"de-DE" + | :"de-LU" + | :"el-GR" + | :"en-GB" + | :"en-US" + | :"es-ES" + | :"fi-FI" + | :"fr-BE" + | :"fr-FR" + | :"fr-LU" + | :"hu-HU" + | :"it-IT" + | :"nl-BE" + | :"nl-NL" + | :"pl-PL" + | :"pt-PT" + | :"sk-SK" + | :"sv-SE", + optional(:reference) => binary, + optional(:risk_correlation_id) => binary, + optional(:setup_future_usage) => :none | :off_session + } + ) + + ( + @typedoc "Controls phone number collection settings for the session.\n\nWe recommend that you review your privacy policy and check with your legal contacts\nbefore using this feature. Learn more about [collecting phone numbers with Checkout](https://stripe.com/docs/payments/checkout/phone-numbers)." + @type phone_number_collection :: %{optional(:enabled) => boolean} + ) + + ( + @typedoc "contains details about the Pix payment method options." + @type pix :: %{optional(:expires_after_seconds) => integer} + ) + + ( + @typedoc "Data used to generate a new [Price](https://stripe.com/docs/api/prices) object inline. One of `price` or `price_data` is required." + @type price_data :: %{ + optional(:currency) => binary, + optional(:product) => binary, + optional(:product_data) => product_data, + optional(:recurring) => recurring, + optional(:tax_behavior) => :exclusive | :inclusive | :unspecified, + optional(:unit_amount) => integer, + optional(:unit_amount_decimal) => binary + } + ) + + ( + @typedoc "Data used to generate a new product object inline. One of `product` or `product_data` is required." + @type product_data :: %{ + optional(:description) => binary, + optional(:images) => list(binary), + optional(:metadata) => %{optional(binary) => binary}, + optional(:name) => binary, + optional(:tax_code) => binary + } + ) + + ( + @typedoc "Configure a Checkout Session that can be used to recover an expired session." + @type recovery :: %{ + optional(:allow_promotion_codes) => boolean, + optional(:enabled) => boolean + } + ) + + ( + @typedoc "The recurring components of a price such as `interval` and `interval_count`." + @type recurring :: %{ + optional(:interval) => :day | :month | :week | :year, + optional(:interval_count) => integer + } + ) + + ( + @typedoc nil + @type rendering_options :: %{ + optional(:amount_tax_display) => :exclude_tax | :include_inclusive_tax + } + ) + + ( + @typedoc "contains details about the Sepa Debit payment method options." + @type sepa_debit :: %{optional(:setup_future_usage) => :none | :off_session | :on_session} + ) + + ( + @typedoc "A subset of parameters to be passed to SetupIntent creation for Checkout Sessions in `setup` mode." + @type setup_intent_data :: %{ + optional(:description) => binary, + optional(:metadata) => %{optional(binary) => binary}, + optional(:on_behalf_of) => binary + } + ) + + ( + @typedoc "Shipping information for this payment." + @type shipping :: %{ + optional(:address) => address, + optional(:carrier) => binary, + optional(:name) => binary, + optional(:phone) => binary, + optional(:tracking_number) => binary + } + ) + + ( + @typedoc nil + @type shipping_address :: %{optional(:message) => binary} + ) + + ( + @typedoc "When set, provides configuration for Checkout to collect a shipping address from a customer." + @type shipping_address_collection :: %{ + optional(:allowed_countries) => + list( + :AC + | :AD + | :AE + | :AF + | :AG + | :AI + | :AL + | :AM + | :AO + | :AQ + | :AR + | :AT + | :AU + | :AW + | :AX + | :AZ + | :BA + | :BB + | :BD + | :BE + | :BF + | :BG + | :BH + | :BI + | :BJ + | :BL + | :BM + | :BN + | :BO + | :BQ + | :BR + | :BS + | :BT + | :BV + | :BW + | :BY + | :BZ + | :CA + | :CD + | :CF + | :CG + | :CH + | :CI + | :CK + | :CL + | :CM + | :CN + | :CO + | :CR + | :CV + | :CW + | :CY + | :CZ + | :DE + | :DJ + | :DK + | :DM + | :DO + | :DZ + | :EC + | :EE + | :EG + | :EH + | :ER + | :ES + | :ET + | :FI + | :FJ + | :FK + | :FO + | :FR + | :GA + | :GB + | :GD + | :GE + | :GF + | :GG + | :GH + | :GI + | :GL + | :GM + | :GN + | :GP + | :GQ + | :GR + | :GS + | :GT + | :GU + | :GW + | :GY + | :HK + | :HN + | :HR + | :HT + | :HU + | :ID + | :IE + | :IL + | :IM + | :IN + | :IO + | :IQ + | :IS + | :IT + | :JE + | :JM + | :JO + | :JP + | :KE + | :KG + | :KH + | :KI + | :KM + | :KN + | :KR + | :KW + | :KY + | :KZ + | :LA + | :LB + | :LC + | :LI + | :LK + | :LR + | :LS + | :LT + | :LU + | :LV + | :LY + | :MA + | :MC + | :MD + | :ME + | :MF + | :MG + | :MK + | :ML + | :MM + | :MN + | :MO + | :MQ + | :MR + | :MS + | :MT + | :MU + | :MV + | :MW + | :MX + | :MY + | :MZ + | :NA + | :NC + | :NE + | :NG + | :NI + | :NL + | :NO + | :NP + | :NR + | :NU + | :NZ + | :OM + | :PA + | :PE + | :PF + | :PG + | :PH + | :PK + | :PL + | :PM + | :PN + | :PR + | :PS + | :PT + | :PY + | :QA + | :RE + | :RO + | :RS + | :RU + | :RW + | :SA + | :SB + | :SC + | :SE + | :SG + | :SH + | :SI + | :SJ + | :SK + | :SL + | :SM + | :SN + | :SO + | :SR + | :SS + | :ST + | :SV + | :SX + | :SZ + | :TA + | :TC + | :TD + | :TF + | :TG + | :TH + | :TJ + | :TK + | :TL + | :TM + | :TN + | :TO + | :TR + | :TT + | :TV + | :TW + | :TZ + | :UA + | :UG + | :US + | :UY + | :UZ + | :VA + | :VC + | :VE + | :VG + | :VN + | :VU + | :WF + | :WS + | :XK + | :YE + | :YT + | :ZA + | :ZM + | :ZW + | :ZZ + ) + } + ) + + ( + @typedoc nil + @type shipping_options :: %{ + optional(:shipping_rate) => binary, + optional(:shipping_rate_data) => shipping_rate_data + } + ) + + ( + @typedoc "Parameters to be passed to Shipping Rate creation for this shipping option" + @type shipping_rate_data :: %{ + optional(:delivery_estimate) => delivery_estimate, + optional(:display_name) => binary, + optional(:fixed_amount) => fixed_amount, + optional(:metadata) => %{optional(binary) => binary}, + optional(:tax_behavior) => :exclusive | :inclusive | :unspecified, + optional(:tax_code) => binary, + optional(:type) => :fixed_amount + } + ) + + ( + @typedoc "contains details about the Sofort payment method options." + @type sofort :: %{optional(:setup_future_usage) => :none} + ) + + ( + @typedoc nil + @type submit :: %{optional(:message) => binary} + ) + + ( + @typedoc "A subset of parameters to be passed to subscription creation for Checkout Sessions in `subscription` mode." + @type subscription_data :: %{ + optional(:application_fee_percent) => number, + optional(:billing_cycle_anchor) => integer, + optional(:coupon) => binary, + optional(:default_tax_rates) => list(binary), + optional(:description) => binary, + optional(:metadata) => %{optional(binary) => binary}, + optional(:on_behalf_of) => binary, + optional(:proration_behavior) => :create_prorations | :none, + optional(:transfer_data) => transfer_data, + optional(:trial_end) => integer, + optional(:trial_from_plan) => boolean, + optional(:trial_period_days) => integer, + optional(:trial_settings) => trial_settings + } + ) + + ( + @typedoc "Controls tax ID collection settings for the session." + @type tax_id_collection :: %{optional(:enabled) => boolean} + ) + + ( + @typedoc "Configuration for `type=text` fields." + @type text :: %{optional(:maximum_length) => integer, optional(:minimum_length) => integer} + ) + + ( + @typedoc "If specified, the funds from the subscription's invoices will be transferred to the destination and the ID of the resulting transfers will be found on the resulting charges." + @type transfer_data :: %{ + optional(:amount_percent) => number, + optional(:destination) => binary + } + ) + + ( + @typedoc "Settings related to subscription trials." + @type trial_settings :: %{optional(:end_behavior) => end_behavior} + ) + + ( + @typedoc "contains details about the Us Bank Account payment method options." + @type us_bank_account :: %{ + optional(:financial_connections) => financial_connections, + optional(:setup_future_usage) => :none | :off_session | :on_session, + optional(:verification_method) => :automatic | :instant + } + ) + + ( + @typedoc "contains details about the WeChat Pay payment method options." + @type wechat_pay :: %{ + optional(:app_id) => binary, + optional(:client) => :android | :ios | :web, + optional(:setup_future_usage) => :none + } + ) + + ( + nil + + @doc "

Returns a list of Checkout Sessions.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/checkout/sessions`\n" + ( + @spec list( + params :: %{ + optional(:customer) => binary, + optional(:customer_details) => customer_details, + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:payment_intent) => binary, + optional(:payment_link) => binary, + optional(:starting_after) => binary, + optional(:subscription) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.Checkout.Session.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/checkout/sessions", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves a Session object.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/checkout/sessions/{session}`\n" + ( + @spec retrieve( + session :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Checkout.Session.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def retrieve(session, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/checkout/sessions/{session}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "session", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "session", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [session] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Creates a Session object.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/checkout/sessions`\n" + ( + @spec create( + params :: %{ + optional(:payment_method_options) => payment_method_options, + optional(:line_items) => list(line_items), + optional(:custom_fields) => list(custom_fields), + optional(:customer_creation) => :always | :if_required, + optional(:expand) => list(binary), + optional(:metadata) => %{optional(binary) => binary}, + optional(:subscription_data) => subscription_data, + optional(:payment_method_types) => + list( + :acss_debit + | :affirm + | :afterpay_clearpay + | :alipay + | :au_becs_debit + | :bacs_debit + | :bancontact + | :blik + | :boleto + | :card + | :cashapp + | :customer_balance + | :eps + | :fpx + | :giropay + | :grabpay + | :ideal + | :klarna + | :konbini + | :link + | :oxxo + | :p24 + | :paynow + | :paypal + | :pix + | :promptpay + | :sepa_debit + | :sofort + | :us_bank_account + | :wechat_pay + | :zip + ), + optional(:locale) => + :auto + | :bg + | :cs + | :da + | :de + | :el + | :en + | :"en-GB" + | :es + | :"es-419" + | :et + | :fi + | :fil + | :fr + | :"fr-CA" + | :hr + | :hu + | :id + | :it + | :ja + | :ko + | :lt + | :lv + | :ms + | :mt + | :nb + | :nl + | :pl + | :pt + | :"pt-BR" + | :ro + | :ru + | :sk + | :sl + | :sv + | :th + | :tr + | :vi + | :zh + | :"zh-HK" + | :"zh-TW", + optional(:shipping_address_collection) => shipping_address_collection, + optional(:consent_collection) => consent_collection, + optional(:customer_email) => binary, + optional(:phone_number_collection) => phone_number_collection, + optional(:invoice_creation) => invoice_creation, + optional(:customer) => binary, + optional(:submit_type) => :auto | :book | :donate | :pay, + optional(:customer_update) => customer_update, + optional(:custom_text) => custom_text, + optional(:mode) => :payment | :setup | :subscription, + optional(:success_url) => binary, + optional(:expires_at) => integer, + optional(:automatic_tax) => automatic_tax, + optional(:client_reference_id) => binary, + optional(:after_expiration) => after_expiration, + optional(:tax_id_collection) => tax_id_collection, + optional(:currency) => binary, + optional(:discounts) => list(discounts), + optional(:payment_method_collection) => :always | :if_required, + optional(:allow_promotion_codes) => boolean, + optional(:billing_address_collection) => :auto | :required, + optional(:setup_intent_data) => setup_intent_data, + optional(:cancel_url) => binary, + optional(:payment_intent_data) => payment_intent_data, + optional(:shipping_options) => list(shipping_options), + optional(:shipping_rates) => list(binary) + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Checkout.Session.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/checkout/sessions", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

When retrieving a Checkout Session, there is an includable line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/checkout/sessions/{session}/line_items`\n" + ( + @spec list_line_items( + session :: binary(), + params :: %{ + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.Item.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list_line_items(session, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/checkout/sessions/{session}/line_items", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "session", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "session", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [session] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

A Session can be expired when it is in one of these statuses: open

\n\n

After it expires, a customer can’t complete a Session and customers loading the Session see a message saying the Session is expired.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/checkout/sessions/{session}/expire`\n" + ( + @spec expire( + session :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Checkout.Session.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def expire(session, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/checkout/sessions/{session}/expire", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "session", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "session", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [session] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/country_spec.ex b/lib/generated/country_spec.ex new file mode 100644 index 00000000..4381200b --- /dev/null +++ b/lib/generated/country_spec.ex @@ -0,0 +1,99 @@ +defmodule Stripe.CountrySpec do + use Stripe.Entity + + @moduledoc "Stripe needs to collect certain pieces of information about each account\ncreated. These requirements can differ depending on the account's country. The\nCountry Specs API makes these rules available to your integration.\n\nYou can also view the information from this API call as [an online\nguide](/docs/connect/required-verification-information)." + ( + defstruct [ + :default_currency, + :id, + :object, + :supported_bank_account_currencies, + :supported_payment_currencies, + :supported_payment_methods, + :supported_transfer_countries, + :verification_fields + ] + + @typedoc "The `country_spec` type.\n\n * `default_currency` The default currency for this country. This applies to both payment methods and bank accounts.\n * `id` Unique identifier for the object. Represented as the ISO country code for this country.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `supported_bank_account_currencies` Currencies that can be accepted in the specific country (for transfers).\n * `supported_payment_currencies` Currencies that can be accepted in the specified country (for payments).\n * `supported_payment_methods` Payment methods available in the specified country. You may need to enable some payment methods (e.g., [ACH](https://stripe.com/docs/ach)) on your account before they appear in this list. The `stripe` payment method refers to [charging through your platform](https://stripe.com/docs/connect/destination-charges).\n * `supported_transfer_countries` Countries that can accept transfers from the specified country.\n * `verification_fields` \n" + @type t :: %__MODULE__{ + default_currency: binary, + id: binary, + object: binary, + supported_bank_account_currencies: term, + supported_payment_currencies: term, + supported_payment_methods: term, + supported_transfer_countries: term, + verification_fields: term + } + ) + + ( + nil + + @doc "

Lists all Country Spec objects available in the API.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/country_specs`\n" + ( + @spec list( + params :: %{ + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.CountrySpec.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/country_specs", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Returns a Country Spec for a given Country code.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/country_specs/{country}`\n" + ( + @spec retrieve( + country :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: {:ok, Stripe.CountrySpec.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def retrieve(country, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/country_specs/{country}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "country", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "country", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [country] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/coupon.ex b/lib/generated/coupon.ex new file mode 100644 index 00000000..5099ed6b --- /dev/null +++ b/lib/generated/coupon.ex @@ -0,0 +1,251 @@ +defmodule Stripe.Coupon do + use Stripe.Entity + + @moduledoc "A coupon contains information about a percent-off or amount-off discount you\nmight want to apply to a customer. Coupons may be applied to [subscriptions](https://stripe.com/docs/api#subscriptions), [invoices](https://stripe.com/docs/api#invoices),\n[checkout sessions](https://stripe.com/docs/api/checkout/sessions), [quotes](https://stripe.com/docs/api#quotes), and more. Coupons do not work with conventional one-off [charges](https://stripe.com/docs/api#create_charge) or [payment intents](https://stripe.com/docs/api/payment_intents)." + ( + defstruct [ + :amount_off, + :applies_to, + :created, + :currency, + :currency_options, + :duration, + :duration_in_months, + :id, + :livemode, + :max_redemptions, + :metadata, + :name, + :object, + :percent_off, + :redeem_by, + :times_redeemed, + :valid + ] + + @typedoc "The `coupon` type.\n\n * `amount_off` Amount (in the `currency` specified) that will be taken off the subtotal of any invoices for this customer.\n * `applies_to` \n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `currency` If `amount_off` has been set, the three-letter [ISO code for the currency](https://stripe.com/docs/currencies) of the amount to take off.\n * `currency_options` Coupons defined in each available currency option. Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies).\n * `duration` One of `forever`, `once`, and `repeating`. Describes how long a customer who applies this coupon will get the discount.\n * `duration_in_months` If `duration` is `repeating`, the number of months the coupon applies. Null if coupon `duration` is `forever` or `once`.\n * `id` Unique identifier for the object.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `max_redemptions` Maximum number of times this coupon can be redeemed, in total, across all customers, before it is no longer valid.\n * `metadata` Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.\n * `name` Name of the coupon displayed to customers on for instance invoices or receipts.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `percent_off` Percent that will be taken off the subtotal of any invoices for this customer for the duration of the coupon. For example, a coupon with percent_off of 50 will make a %s100 invoice %s50 instead.\n * `redeem_by` Date after which the coupon can no longer be redeemed.\n * `times_redeemed` Number of times this coupon has been applied to a customer.\n * `valid` Taking account of the above properties, whether this coupon can still be applied to a customer.\n" + @type t :: %__MODULE__{ + amount_off: integer | nil, + applies_to: term, + created: integer, + currency: binary | nil, + currency_options: term, + duration: binary, + duration_in_months: integer | nil, + id: binary, + livemode: boolean, + max_redemptions: integer | nil, + metadata: term | nil, + name: binary | nil, + object: binary, + percent_off: term | nil, + redeem_by: integer | nil, + times_redeemed: integer, + valid: boolean + } + ) + + ( + @typedoc "A hash containing directions for what this Coupon will apply discounts to." + @type applies_to :: %{optional(:products) => list(binary)} + ) + + ( + @typedoc nil + @type created :: %{ + optional(:gt) => integer, + optional(:gte) => integer, + optional(:lt) => integer, + optional(:lte) => integer + } + ) + + ( + nil + + @doc "

Returns a list of your coupons.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/coupons`\n" + ( + @spec list( + params :: %{ + optional(:created) => created | integer, + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.Coupon.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/coupons", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

You can create coupons easily via the coupon management page of the Stripe dashboard. Coupon creation is also accessible via the API if you need to create coupons on the fly.

\n\n

A coupon has either a percent_off or an amount_off and currency. If you set an amount_off, that amount will be subtracted from any invoice’s subtotal. For example, an invoice with a subtotal of 100 will have a final total of 0 if a coupon with an amount_off of 200 is applied to it and an invoice with a subtotal of 300 will have a final total of 100 if a coupon with an amount_off of 200 is applied to it.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/coupons`\n" + ( + @spec create( + params :: %{ + optional(:amount_off) => integer, + optional(:applies_to) => applies_to, + optional(:currency) => binary, + optional(:currency_options) => map(), + optional(:duration) => :forever | :once | :repeating, + optional(:duration_in_months) => integer, + optional(:expand) => list(binary), + optional(:id) => binary, + optional(:max_redemptions) => integer, + optional(:metadata) => %{optional(binary) => binary} | binary, + optional(:name) => binary, + optional(:percent_off) => number, + optional(:redeem_by) => integer + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.Coupon.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/coupons", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves the coupon with the given ID.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/coupons/{coupon}`\n" + ( + @spec retrieve( + coupon :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: {:ok, Stripe.Coupon.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def retrieve(coupon, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/coupons/{coupon}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "coupon", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "coupon", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [coupon] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Updates the metadata of a coupon. Other coupon details (currency, duration, amount_off) are, by design, not editable.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/coupons/{coupon}`\n" + ( + @spec update( + coupon :: binary(), + params :: %{ + optional(:currency_options) => map(), + optional(:expand) => list(binary), + optional(:metadata) => %{optional(binary) => binary} | binary, + optional(:name) => binary + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.Coupon.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def update(coupon, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/coupons/{coupon}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "coupon", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "coupon", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [coupon] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

You can delete coupons via the coupon management page of the Stripe dashboard. However, deleting a coupon does not affect any customers who have already applied the coupon; it means that new customers can’t redeem the coupon. You can also delete coupons via the API.

\n\n#### Details\n\n * Method: `delete`\n * Path: `/v1/coupons/{coupon}`\n" + ( + @spec delete(coupon :: binary(), opts :: Keyword.t()) :: + {:ok, Stripe.DeletedCoupon.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def delete(coupon, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/coupons/{coupon}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "coupon", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "coupon", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [coupon] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_method(:delete) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/credit_note.ex b/lib/generated/credit_note.ex new file mode 100644 index 00000000..c114a402 --- /dev/null +++ b/lib/generated/credit_note.ex @@ -0,0 +1,364 @@ +defmodule Stripe.CreditNote do + use Stripe.Entity + + @moduledoc "Issue a credit note to adjust an invoice's amount after the invoice is finalized.\n\nRelated guide: [Credit notes](https://stripe.com/docs/billing/invoices/credit-notes)" + ( + defstruct [ + :amount, + :amount_shipping, + :created, + :currency, + :customer, + :customer_balance_transaction, + :discount_amount, + :discount_amounts, + :effective_at, + :id, + :invoice, + :lines, + :livemode, + :memo, + :metadata, + :number, + :object, + :out_of_band_amount, + :pdf, + :reason, + :refund, + :shipping_cost, + :status, + :subtotal, + :subtotal_excluding_tax, + :tax_amounts, + :total, + :total_excluding_tax, + :type, + :voided_at + ] + + @typedoc "The `credit_note` type.\n\n * `amount` The integer amount in %s representing the total amount of the credit note, including tax.\n * `amount_shipping` This is the sum of all the shipping amounts.\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `currency` Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).\n * `customer` ID of the customer.\n * `customer_balance_transaction` Customer balance transaction related to this credit note.\n * `discount_amount` The integer amount in %s representing the total amount of discount that was credited.\n * `discount_amounts` The aggregate amounts calculated per discount for all line items.\n * `effective_at` The date when this credit note is in effect. Same as `created` unless overwritten. When defined, this value replaces the system-generated 'Date of issue' printed on the credit note PDF.\n * `id` Unique identifier for the object.\n * `invoice` ID of the invoice.\n * `lines` Line items that make up the credit note\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `memo` Customer-facing text that appears on the credit note PDF.\n * `metadata` Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.\n * `number` A unique number that identifies this particular credit note and appears on the PDF of the credit note and its associated invoice.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `out_of_band_amount` Amount that was credited outside of Stripe.\n * `pdf` The link to download the PDF of the credit note.\n * `reason` Reason for issuing this credit note, one of `duplicate`, `fraudulent`, `order_change`, or `product_unsatisfactory`\n * `refund` Refund related to this credit note.\n * `shipping_cost` The details of the cost of shipping, including the ShippingRate applied to the invoice.\n * `status` Status of this credit note, one of `issued` or `void`. Learn more about [voiding credit notes](https://stripe.com/docs/billing/invoices/credit-notes#voiding).\n * `subtotal` The integer amount in %s representing the amount of the credit note, excluding exclusive tax and invoice level discounts.\n * `subtotal_excluding_tax` The integer amount in %s representing the amount of the credit note, excluding all tax and invoice level discounts.\n * `tax_amounts` The aggregate amounts calculated per tax rate for all line items.\n * `total` The integer amount in %s representing the total amount of the credit note, including tax and all discount.\n * `total_excluding_tax` The integer amount in %s representing the total amount of the credit note, excluding tax, but including discounts.\n * `type` Type of this credit note, one of `pre_payment` or `post_payment`. A `pre_payment` credit note means it was issued when the invoice was open. A `post_payment` credit note means it was issued when the invoice was paid.\n * `voided_at` The time that the credit note was voided.\n" + @type t :: %__MODULE__{ + amount: integer, + amount_shipping: integer, + created: integer, + currency: binary, + customer: binary | Stripe.Customer.t() | Stripe.DeletedCustomer.t(), + customer_balance_transaction: (binary | Stripe.CustomerBalanceTransaction.t()) | nil, + discount_amount: integer, + discount_amounts: term, + effective_at: integer | nil, + id: binary, + invoice: binary | Stripe.Invoice.t(), + lines: term, + livemode: boolean, + memo: binary | nil, + metadata: term | nil, + number: binary, + object: binary, + out_of_band_amount: integer | nil, + pdf: binary, + reason: binary | nil, + refund: (binary | Stripe.Refund.t()) | nil, + shipping_cost: term | nil, + status: binary, + subtotal: integer, + subtotal_excluding_tax: integer | nil, + tax_amounts: term, + total: integer, + total_excluding_tax: integer | nil, + type: binary, + voided_at: integer | nil + } + ) + + ( + @typedoc nil + @type lines :: %{ + optional(:amount) => integer, + optional(:description) => binary, + optional(:invoice_line_item) => binary, + optional(:quantity) => integer, + optional(:tax_rates) => list(binary) | binary, + optional(:type) => :custom_line_item | :invoice_line_item, + optional(:unit_amount) => integer, + optional(:unit_amount_decimal) => binary + } + ) + + ( + @typedoc "When shipping_cost contains the shipping_rate from the invoice, the shipping_cost is included in the credit note." + @type shipping_cost :: %{optional(:shipping_rate) => binary} + ) + + ( + nil + + @doc "

Issue a credit note to adjust the amount of a finalized invoice. For a status=open invoice, a credit note reduces\nits amount_due. For a status=paid invoice, a credit note does not affect its amount_due. Instead, it can result\nin any combination of the following:

\n\n\n\n

For post-payment credit notes the sum of the refund, credit and outside of Stripe amounts must equal the credit note total.

\n\n

You may issue multiple credit notes for an invoice. Each credit note will increment the invoice’s pre_payment_credit_notes_amount\nor post_payment_credit_notes_amount depending on its status at the time of credit note creation.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/credit_notes`\n" + ( + @spec create( + params :: %{ + optional(:amount) => integer, + optional(:credit_amount) => integer, + optional(:effective_at) => integer, + optional(:expand) => list(binary), + optional(:invoice) => binary, + optional(:lines) => list(lines), + optional(:memo) => binary, + optional(:metadata) => %{optional(binary) => binary}, + optional(:out_of_band_amount) => integer, + optional(:reason) => + :duplicate | :fraudulent | :order_change | :product_unsatisfactory, + optional(:refund) => binary, + optional(:refund_amount) => integer, + optional(:shipping_cost) => shipping_cost + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.CreditNote.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/credit_notes", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Get a preview of a credit note without creating it.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/credit_notes/preview`\n" + ( + @spec preview( + params :: %{ + optional(:amount) => integer, + optional(:credit_amount) => integer, + optional(:effective_at) => integer, + optional(:expand) => list(binary), + optional(:invoice) => binary, + optional(:lines) => list(lines), + optional(:memo) => binary, + optional(:metadata) => %{optional(binary) => binary}, + optional(:out_of_band_amount) => integer, + optional(:reason) => + :duplicate | :fraudulent | :order_change | :product_unsatisfactory, + optional(:refund) => binary, + optional(:refund_amount) => integer, + optional(:shipping_cost) => shipping_cost + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.CreditNote.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def preview(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/credit_notes/preview", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves the credit note object with the given identifier.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/credit_notes/{id}`\n" + ( + @spec retrieve( + id :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: {:ok, Stripe.CreditNote.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def retrieve(id, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/credit_notes/{id}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "id", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "id", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [id] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Returns a list of credit notes.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/credit_notes`\n" + ( + @spec list( + params :: %{ + optional(:customer) => binary, + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:invoice) => binary, + optional(:limit) => integer, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.CreditNote.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/credit_notes", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Updates an existing credit note.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/credit_notes/{id}`\n" + ( + @spec update( + id :: binary(), + params :: %{ + optional(:expand) => list(binary), + optional(:memo) => binary, + optional(:metadata) => %{optional(binary) => binary} + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.CreditNote.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def update(id, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/credit_notes/{id}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "id", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "id", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [id] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Marks a credit note as void. Learn more about voiding credit notes.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/credit_notes/{id}/void`\n" + ( + @spec void_credit_note( + id :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: {:ok, Stripe.CreditNote.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def void_credit_note(id, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/credit_notes/{id}/void", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "id", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "id", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [id] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

When retrieving a credit note preview, you’ll get a lines property containing the first handful of those items. This URL you can retrieve the full (paginated) list of line items.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/credit_notes/preview/lines`\n" + ( + @spec preview_lines( + params :: %{ + optional(:amount) => integer, + optional(:credit_amount) => integer, + optional(:effective_at) => integer, + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:invoice) => binary, + optional(:limit) => integer, + optional(:lines) => list(lines), + optional(:memo) => binary, + optional(:metadata) => %{optional(binary) => binary}, + optional(:out_of_band_amount) => integer, + optional(:reason) => + :duplicate | :fraudulent | :order_change | :product_unsatisfactory, + optional(:refund) => binary, + optional(:refund_amount) => integer, + optional(:shipping_cost) => shipping_cost, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.CreditNoteLineItem.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def preview_lines(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/credit_notes/preview/lines", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/credit_note_line_item.ex b/lib/generated/credit_note_line_item.ex new file mode 100644 index 00000000..1efb09be --- /dev/null +++ b/lib/generated/credit_note_line_item.ex @@ -0,0 +1,93 @@ +defmodule Stripe.CreditNoteLineItem do + use Stripe.Entity + @moduledoc "" + ( + defstruct [ + :amount, + :amount_excluding_tax, + :description, + :discount_amount, + :discount_amounts, + :id, + :invoice_line_item, + :livemode, + :object, + :quantity, + :tax_amounts, + :tax_rates, + :type, + :unit_amount, + :unit_amount_decimal, + :unit_amount_excluding_tax + ] + + @typedoc "The `credit_note_line_item` type.\n\n * `amount` The integer amount in %s representing the gross amount being credited for this line item, excluding (exclusive) tax and discounts.\n * `amount_excluding_tax` The integer amount in %s representing the amount being credited for this line item, excluding all tax and discounts.\n * `description` Description of the item being credited.\n * `discount_amount` The integer amount in %s representing the discount being credited for this line item.\n * `discount_amounts` The amount of discount calculated per discount for this line item\n * `id` Unique identifier for the object.\n * `invoice_line_item` ID of the invoice line item being credited\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `quantity` The number of units of product being credited.\n * `tax_amounts` The amount of tax calculated per tax rate for this line item\n * `tax_rates` The tax rates which apply to the line item.\n * `type` The type of the credit note line item, one of `invoice_line_item` or `custom_line_item`. When the type is `invoice_line_item` there is an additional `invoice_line_item` property on the resource the value of which is the id of the credited line item on the invoice.\n * `unit_amount` The cost of each unit of product being credited.\n * `unit_amount_decimal` Same as `unit_amount`, but contains a decimal value with at most 12 decimal places.\n * `unit_amount_excluding_tax` The amount in %s representing the unit amount being credited for this line item, excluding all tax and discounts.\n" + @type t :: %__MODULE__{ + amount: integer, + amount_excluding_tax: integer | nil, + description: binary | nil, + discount_amount: integer, + discount_amounts: term, + id: binary, + invoice_line_item: binary, + livemode: boolean, + object: binary, + quantity: integer | nil, + tax_amounts: term, + tax_rates: term, + type: binary, + unit_amount: integer | nil, + unit_amount_decimal: binary | nil, + unit_amount_excluding_tax: binary | nil + } + ) + + ( + nil + + @doc "

When retrieving a credit note, you’ll get a lines property containing the the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/credit_notes/{credit_note}/lines`\n" + ( + @spec list( + credit_note :: binary(), + params :: %{ + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.CreditNoteLineItem.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(credit_note, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/credit_notes/{credit_note}/lines", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "credit_note", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "credit_note", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [credit_note] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/customer.ex b/lib/generated/customer.ex new file mode 100644 index 00000000..7a054cdb --- /dev/null +++ b/lib/generated/customer.ex @@ -0,0 +1,808 @@ +defmodule Stripe.Customer do + use Stripe.Entity + + @moduledoc "This object represents a customer of your business. It lets you create recurring charges and track payments that belong to the same customer.\n\nRelated guide: [Save a card during payment](https://stripe.com/docs/payments/save-during-payment)" + ( + defstruct [ + :address, + :balance, + :cash_balance, + :created, + :currency, + :default_source, + :delinquent, + :description, + :discount, + :email, + :id, + :invoice_credit_balance, + :invoice_prefix, + :invoice_settings, + :livemode, + :metadata, + :name, + :next_invoice_sequence, + :object, + :phone, + :preferred_locales, + :shipping, + :sources, + :subscriptions, + :tax, + :tax_exempt, + :tax_ids, + :test_clock + ] + + @typedoc "The `customer` type.\n\n * `address` The customer's address.\n * `balance` Current balance, if any, being stored on the customer. If negative, the customer has credit to apply to their next invoice. If positive, the customer has an amount owed that will be added to their next invoice. The balance does not refer to any unpaid invoices; it solely takes into account amounts that have yet to be successfully applied to any invoice. This balance is only taken into account as invoices are finalized.\n * `cash_balance` The current funds being held by Stripe on behalf of the customer. These funds can be applied towards payment intents with source \"cash_balance\". The settings[reconciliation_mode] field describes whether these funds are applied to such payment intents manually or automatically.\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `currency` Three-letter [ISO code for the currency](https://stripe.com/docs/currencies) the customer can be charged in for recurring billing purposes.\n * `default_source` ID of the default payment source for the customer.\n\nIf you are using payment methods created via the PaymentMethods API, see the [invoice_settings.default_payment_method](https://stripe.com/docs/api/customers/object#customer_object-invoice_settings-default_payment_method) field instead.\n * `delinquent` When the customer's latest invoice is billed by charging automatically, `delinquent` is `true` if the invoice's latest charge failed. When the customer's latest invoice is billed by sending an invoice, `delinquent` is `true` if the invoice isn't paid by its due date.\n\nIf an invoice is marked uncollectible by [dunning](https://stripe.com/docs/billing/automatic-collection), `delinquent` doesn't get reset to `false`.\n * `description` An arbitrary string attached to the object. Often useful for displaying to users.\n * `discount` Describes the current discount active on the customer, if there is one.\n * `email` The customer's email address.\n * `id` Unique identifier for the object.\n * `invoice_credit_balance` The current multi-currency balances, if any, being stored on the customer. If positive in a currency, the customer has a credit to apply to their next invoice denominated in that currency. If negative, the customer has an amount owed that will be added to their next invoice denominated in that currency. These balances do not refer to any unpaid invoices. They solely track amounts that have yet to be successfully applied to any invoice. A balance in a particular currency is only applied to any invoice as an invoice in that currency is finalized.\n * `invoice_prefix` The prefix for the customer used to generate unique invoice numbers.\n * `invoice_settings` \n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `metadata` Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.\n * `name` The customer's full name or business name.\n * `next_invoice_sequence` The suffix of the customer's next invoice number, e.g., 0001.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `phone` The customer's phone number.\n * `preferred_locales` The customer's preferred locales (languages), ordered by preference.\n * `shipping` Mailing and shipping address for the customer. Appears on invoices emailed to this customer.\n * `sources` The customer's payment sources, if any.\n * `subscriptions` The customer's current subscriptions, if any.\n * `tax` \n * `tax_exempt` Describes the customer's tax exemption status. One of `none`, `exempt`, or `reverse`. When set to `reverse`, invoice and receipt PDFs include the text **\"Reverse charge\"**.\n * `tax_ids` The customer's tax IDs.\n * `test_clock` ID of the test clock this customer belongs to.\n" + @type t :: %__MODULE__{ + address: term | nil, + balance: integer, + cash_balance: Stripe.CashBalance.t() | nil, + created: integer, + currency: binary | nil, + default_source: (binary | Stripe.PaymentSource.t()) | nil, + delinquent: boolean | nil, + description: binary | nil, + discount: term | nil, + email: binary | nil, + id: binary, + invoice_credit_balance: term, + invoice_prefix: binary | nil, + invoice_settings: term, + livemode: boolean, + metadata: term, + name: binary | nil, + next_invoice_sequence: integer, + object: binary, + phone: binary | nil, + preferred_locales: term | nil, + shipping: term | nil, + sources: term, + subscriptions: term, + tax: term, + tax_exempt: binary | nil, + tax_ids: term, + test_clock: (binary | Stripe.TestHelpers.TestClock.t()) | nil + } + ) + + ( + @typedoc nil + @type address :: %{ + optional(:city) => binary, + optional(:country) => binary, + optional(:line1) => binary, + optional(:line2) => binary, + optional(:postal_code) => binary, + optional(:state) => binary + } + ) + + ( + @typedoc "Additional parameters for `bank_transfer` funding types" + @type bank_transfer :: %{ + optional(:eu_bank_transfer) => eu_bank_transfer, + optional(:requested_address_types) => list(:iban | :sort_code | :spei | :zengin), + optional(:type) => + :eu_bank_transfer + | :gb_bank_transfer + | :jp_bank_transfer + | :mx_bank_transfer + | :us_bank_transfer + } + ) + + ( + @typedoc "Balance information and default balance settings for this customer." + @type cash_balance :: %{optional(:settings) => settings} + ) + + ( + @typedoc nil + @type created :: %{ + optional(:gt) => integer, + optional(:gte) => integer, + optional(:lt) => integer, + optional(:lte) => integer + } + ) + + ( + @typedoc nil + @type custom_fields :: %{optional(:name) => binary, optional(:value) => binary} + ) + + ( + @typedoc "Configuration for eu_bank_transfer funding type." + @type eu_bank_transfer :: %{optional(:country) => binary} + ) + + ( + @typedoc "Default invoice settings for this customer." + @type invoice_settings :: %{ + optional(:custom_fields) => list(custom_fields) | binary, + optional(:default_payment_method) => binary, + optional(:footer) => binary, + optional(:rendering_options) => rendering_options | binary + } + ) + + ( + @typedoc nil + @type rendering_options :: %{ + optional(:amount_tax_display) => :exclude_tax | :include_inclusive_tax + } + ) + + ( + @typedoc "Settings controlling the behavior of the customer's cash balance,\nsuch as reconciliation of funds received." + @type settings :: %{ + optional(:reconciliation_mode) => :automatic | :manual | :merchant_default + } + ) + + ( + @typedoc nil + @type shipping :: %{ + optional(:address) => address, + optional(:name) => binary, + optional(:phone) => binary + } + ) + + ( + @typedoc "Tax details about the customer." + @type tax :: %{optional(:ip_address) => binary | binary} + ) + + ( + @typedoc nil + @type tax_id_data :: %{ + optional(:type) => + :ad_nrt + | :ae_trn + | :ar_cuit + | :au_abn + | :au_arn + | :bg_uic + | :bo_tin + | :br_cnpj + | :br_cpf + | :ca_bn + | :ca_gst_hst + | :ca_pst_bc + | :ca_pst_mb + | :ca_pst_sk + | :ca_qst + | :ch_vat + | :cl_tin + | :cn_tin + | :co_nit + | :cr_tin + | :do_rcn + | :ec_ruc + | :eg_tin + | :es_cif + | :eu_oss_vat + | :eu_vat + | :gb_vat + | :ge_vat + | :hk_br + | :hu_tin + | :id_npwp + | :il_vat + | :in_gst + | :is_vat + | :jp_cn + | :jp_rn + | :jp_trn + | :ke_pin + | :kr_brn + | :li_uid + | :mx_rfc + | :my_frp + | :my_itn + | :my_sst + | :no_vat + | :nz_gst + | :pe_ruc + | :ph_tin + | :ro_tin + | :rs_pib + | :ru_inn + | :ru_kpp + | :sa_vat + | :sg_gst + | :sg_uen + | :si_tin + | :sv_nit + | :th_vat + | :tr_tin + | :tw_vat + | :ua_vat + | :us_ein + | :uy_ruc + | :ve_rif + | :vn_tin + | :za_vat, + optional(:value) => binary + } + ) + + ( + nil + + @doc "

Search for customers you’ve previously created using Stripe’s Search Query Language.\nDon’t use search in read-after-write flows where strict consistency is necessary. Under normal operating\nconditions, data is searchable in less than a minute. Occasionally, propagation of new or updated data can be up\nto an hour behind during outages. Search functionality is not available to merchants in India.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/customers/search`\n" + ( + @spec search( + params :: %{ + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:page) => binary, + optional(:query) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.SearchResult.t(Stripe.Customer.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def search(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/customers/search", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Returns a list of your customers. The customers are returned sorted by creation date, with the most recent customers appearing first.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/customers`\n" + ( + @spec list( + params :: %{ + optional(:created) => created | integer, + optional(:email) => binary, + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:starting_after) => binary, + optional(:test_clock) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.Customer.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/customers", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Creates a new customer object.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/customers`\n" + ( + @spec create( + params :: %{ + optional(:address) => address | binary, + optional(:balance) => integer, + optional(:cash_balance) => cash_balance, + optional(:coupon) => binary, + optional(:description) => binary, + optional(:email) => binary, + optional(:expand) => list(binary), + optional(:invoice_prefix) => binary, + optional(:invoice_settings) => invoice_settings, + optional(:metadata) => %{optional(binary) => binary} | binary, + optional(:name) => binary, + optional(:next_invoice_sequence) => integer, + optional(:payment_method) => binary, + optional(:phone) => binary, + optional(:preferred_locales) => list(binary), + optional(:promotion_code) => binary, + optional(:shipping) => shipping | binary, + optional(:source) => binary, + optional(:tax) => tax, + optional(:tax_exempt) => :exempt | :none | :reverse, + optional(:tax_id_data) => list(tax_id_data), + optional(:test_clock) => binary, + optional(:validate) => boolean + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.Customer.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/customers", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves a Customer object.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/customers/{customer}`\n" + ( + @spec retrieve( + customer :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Customer.t() | Stripe.DeletedCustomer.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def retrieve(customer, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/customers/{customer}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "customer", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "customer", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [customer] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Updates the specified customer by setting the values of the parameters passed. Any parameters not provided will be left unchanged. For example, if you pass the source parameter, that becomes the customer’s active source (e.g., a card) to be used for all charges in the future. When you update a customer to a new valid card source by passing the source parameter: for each of the customer’s current subscriptions, if the subscription bills automatically and is in the past_due state, then the latest open invoice for the subscription with automatic collection enabled will be retried. This retry will not count as an automatic retry, and will not affect the next regularly scheduled payment for the invoice. Changing the default_source for a customer will not trigger this behavior.

\n\n

This request accepts mostly the same arguments as the customer creation call.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/customers/{customer}`\n" + ( + @spec update( + customer :: binary(), + params :: %{ + optional(:address) => address | binary, + optional(:balance) => integer, + optional(:cash_balance) => cash_balance, + optional(:coupon) => binary, + optional(:default_source) => binary, + optional(:description) => binary, + optional(:email) => binary, + optional(:expand) => list(binary), + optional(:invoice_prefix) => binary, + optional(:invoice_settings) => invoice_settings, + optional(:metadata) => %{optional(binary) => binary} | binary, + optional(:name) => binary, + optional(:next_invoice_sequence) => integer, + optional(:phone) => binary, + optional(:preferred_locales) => list(binary), + optional(:promotion_code) => binary, + optional(:shipping) => shipping | binary, + optional(:source) => binary, + optional(:tax) => tax, + optional(:tax_exempt) => :exempt | :none | :reverse, + optional(:validate) => boolean + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.Customer.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def update(customer, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/customers/{customer}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "customer", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "customer", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [customer] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Permanently deletes a customer. It cannot be undone. Also immediately cancels any active subscriptions on the customer.

\n\n#### Details\n\n * Method: `delete`\n * Path: `/v1/customers/{customer}`\n" + ( + @spec delete(customer :: binary(), opts :: Keyword.t()) :: + {:ok, Stripe.DeletedCustomer.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def delete(customer, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/customers/{customer}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "customer", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "customer", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [customer] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_method(:delete) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Returns a list of PaymentMethods for a given Customer

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/customers/{customer}/payment_methods`\n" + ( + @spec list_payment_methods( + customer :: binary(), + params :: %{ + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:starting_after) => binary, + optional(:type) => + :acss_debit + | :affirm + | :afterpay_clearpay + | :alipay + | :au_becs_debit + | :bacs_debit + | :bancontact + | :blik + | :boleto + | :card + | :card_present + | :cashapp + | :customer_balance + | :eps + | :fpx + | :giropay + | :grabpay + | :ideal + | :klarna + | :konbini + | :link + | :oxxo + | :p24 + | :paynow + | :paypal + | :pix + | :promptpay + | :sepa_debit + | :sofort + | :us_bank_account + | :wechat_pay + | :zip + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.PaymentMethod.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list_payment_methods(customer, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/customers/{customer}/payment_methods", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "customer", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "customer", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [customer] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves a PaymentMethod object for a given Customer.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/customers/{customer}/payment_methods/{payment_method}`\n" + ( + @spec retrieve_payment_method( + customer :: binary(), + payment_method :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.PaymentMethod.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def retrieve_payment_method(customer, payment_method, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/customers/{customer}/payment_methods/{payment_method}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "customer", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "customer", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + }, + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "payment_method", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "payment_method", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [customer, payment_method] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Returns a list of transactions that updated the customer’s balances.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/customers/{customer}/balance_transactions`\n" + ( + @spec balance_transactions( + customer :: binary(), + params :: %{ + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.CustomerBalanceTransaction.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def balance_transactions(customer, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/customers/{customer}/balance_transactions", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "customer", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "customer", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [customer] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Create an incoming testmode bank transfer

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/test_helpers/customers/{customer}/fund_cash_balance`\n" + ( + @spec fund_cash_balance( + customer :: binary(), + params :: %{ + optional(:amount) => integer, + optional(:currency) => binary, + optional(:expand) => list(binary), + optional(:reference) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.CustomerCashBalanceTransaction.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def fund_cash_balance(customer, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/test_helpers/customers/{customer}/fund_cash_balance", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "customer", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "customer", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [customer] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieve funding instructions for a customer cash balance. If funding instructions do not yet exist for the customer, new\nfunding instructions will be created. If funding instructions have already been created for a given customer, the same\nfunding instructions will be retrieved. In other words, we will return the same funding instructions each time.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/customers/{customer}/funding_instructions`\n" + ( + @spec create_funding_instructions( + customer :: binary(), + params :: %{ + optional(:bank_transfer) => bank_transfer, + optional(:currency) => binary, + optional(:expand) => list(binary), + optional(:funding_type) => :bank_transfer + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.FundingInstructions.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def create_funding_instructions(customer, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/customers/{customer}/funding_instructions", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "customer", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "customer", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [customer] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Removes the currently applied discount on a customer.

\n\n#### Details\n\n * Method: `delete`\n * Path: `/v1/customers/{customer}/discount`\n" + ( + @spec delete_discount(customer :: binary(), opts :: Keyword.t()) :: + {:ok, Stripe.DeletedDiscount.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def delete_discount(customer, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/customers/{customer}/discount", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "customer", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "customer", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [customer] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_method(:delete) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/customer_balance_transaction.ex b/lib/generated/customer_balance_transaction.ex new file mode 100644 index 00000000..a43a5a1e --- /dev/null +++ b/lib/generated/customer_balance_transaction.ex @@ -0,0 +1,258 @@ +defmodule Stripe.CustomerBalanceTransaction do + use Stripe.Entity + + @moduledoc "Each customer has a [Balance](https://stripe.com/docs/api/customers/object#customer_object-balance) value,\nwhich denotes a debit or credit that's automatically applied to their next invoice upon finalization.\nYou may modify the value directly by using the [update customer API](https://stripe.com/docs/api/customers/update),\nor by creating a Customer Balance Transaction, which increments or decrements the customer's `balance` by the specified `amount`.\n\nRelated guide: [Customer balance](https://stripe.com/docs/billing/customer/balance)" + ( + defstruct [ + :amount, + :created, + :credit_note, + :currency, + :customer, + :description, + :ending_balance, + :id, + :invoice, + :livemode, + :metadata, + :object, + :type + ] + + @typedoc "The `customer_balance_transaction` type.\n\n * `amount` The amount of the transaction. A negative value is a credit for the customer's balance, and a positive value is a debit to the customer's `balance`.\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `credit_note` The ID of the credit note (if any) related to the transaction.\n * `currency` Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).\n * `customer` The ID of the customer the transaction belongs to.\n * `description` An arbitrary string attached to the object. Often useful for displaying to users.\n * `ending_balance` The customer's `balance` after the transaction was applied. A negative value decreases the amount due on the customer's next invoice. A positive value increases the amount due on the customer's next invoice.\n * `id` Unique identifier for the object.\n * `invoice` The ID of the invoice (if any) related to the transaction.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `metadata` Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `type` Transaction type: `adjustment`, `applied_to_invoice`, `credit_note`, `initial`, `invoice_overpaid`, `invoice_too_large`, `invoice_too_small`, `unspent_receiver_credit`, or `unapplied_from_invoice`. See the [Customer Balance page](https://stripe.com/docs/billing/customer/balance#types) to learn more about transaction types.\n" + @type t :: %__MODULE__{ + amount: integer, + created: integer, + credit_note: (binary | Stripe.CreditNote.t()) | nil, + currency: binary, + customer: binary | Stripe.Customer.t(), + description: binary | nil, + ending_balance: integer, + id: binary, + invoice: (binary | Stripe.Invoice.t()) | nil, + livemode: boolean, + metadata: term | nil, + object: binary, + type: binary + } + ) + + ( + nil + + @doc "

Retrieves a specific customer balance transaction that updated the customer’s balances.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/customers/{customer}/balance_transactions/{transaction}`\n" + ( + @spec retrieve( + customer :: binary(), + transaction :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.CustomerBalanceTransaction.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def retrieve(customer, transaction, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/customers/{customer}/balance_transactions/{transaction}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "customer", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "customer", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + }, + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "transaction", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "transaction", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [customer, transaction] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Returns a list of transactions that updated the customer’s balances.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/customers/{customer}/balance_transactions`\n" + ( + @spec list( + customer :: binary(), + params :: %{ + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.CustomerBalanceTransaction.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(customer, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/customers/{customer}/balance_transactions", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "customer", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "customer", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [customer] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Creates an immutable transaction that updates the customer’s credit balance.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/customers/{customer}/balance_transactions`\n" + ( + @spec create( + customer :: binary(), + params :: %{ + optional(:amount) => integer, + optional(:currency) => binary, + optional(:description) => binary, + optional(:expand) => list(binary), + optional(:metadata) => %{optional(binary) => binary} | binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.CustomerBalanceTransaction.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def create(customer, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/customers/{customer}/balance_transactions", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "customer", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "customer", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [customer] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Most credit balance transaction fields are immutable, but you may update its description and metadata.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/customers/{customer}/balance_transactions/{transaction}`\n" + ( + @spec update( + customer :: binary(), + transaction :: binary(), + params :: %{ + optional(:description) => binary, + optional(:expand) => list(binary), + optional(:metadata) => %{optional(binary) => binary} | binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.CustomerBalanceTransaction.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def update(customer, transaction, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/customers/{customer}/balance_transactions/{transaction}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "customer", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "customer", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + }, + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "transaction", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "transaction", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [customer, transaction] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/customer_cash_balance_transaction.ex b/lib/generated/customer_cash_balance_transaction.ex new file mode 100644 index 00000000..b46d75af --- /dev/null +++ b/lib/generated/customer_cash_balance_transaction.ex @@ -0,0 +1,146 @@ +defmodule Stripe.CustomerCashBalanceTransaction do + use Stripe.Entity + + @moduledoc "Customers with certain payments enabled have a cash balance, representing funds that were paid\nby the customer to a merchant, but have not yet been allocated to a payment. Cash Balance Transactions\nrepresent when funds are moved into or out of this balance. This includes funding by the customer, allocation\nto payments, and refunds to the customer." + ( + defstruct [ + :applied_to_payment, + :created, + :currency, + :customer, + :ending_balance, + :funded, + :id, + :livemode, + :net_amount, + :object, + :refunded_from_payment, + :type, + :unapplied_from_payment + ] + + @typedoc "The `customer_cash_balance_transaction` type.\n\n * `applied_to_payment` \n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `currency` Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).\n * `customer` The customer whose available cash balance changed as a result of this transaction.\n * `ending_balance` The total available cash balance for the specified currency after this transaction was applied. Represented in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal).\n * `funded` \n * `id` Unique identifier for the object.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `net_amount` The amount by which the cash balance changed, represented in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). A positive value represents funds being added to the cash balance, a negative value represents funds being removed from the cash balance.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `refunded_from_payment` \n * `type` The type of the cash balance transaction. New types may be added in future. See [Customer Balance](https://stripe.com/docs/payments/customer-balance#types) to learn more about these types.\n * `unapplied_from_payment` \n" + @type t :: %__MODULE__{ + applied_to_payment: term, + created: integer, + currency: binary, + customer: binary | Stripe.Customer.t(), + ending_balance: integer, + funded: term, + id: binary, + livemode: boolean, + net_amount: integer, + object: binary, + refunded_from_payment: term, + type: binary, + unapplied_from_payment: term + } + ) + + ( + nil + + @doc "

Retrieves a specific cash balance transaction, which updated the customer’s cash balance.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/customers/{customer}/cash_balance_transactions/{transaction}`\n" + ( + @spec retrieve( + customer :: binary(), + transaction :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.CustomerCashBalanceTransaction.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def retrieve(customer, transaction, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/customers/{customer}/cash_balance_transactions/{transaction}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "customer", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "customer", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + }, + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "transaction", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "transaction", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [customer, transaction] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Returns a list of transactions that modified the customer’s cash balance.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/customers/{customer}/cash_balance_transactions`\n" + ( + @spec list( + customer :: binary(), + params :: %{ + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.CustomerCashBalanceTransaction.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(customer, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/customers/{customer}/cash_balance_transactions", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "customer", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "customer", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [customer] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/deleted_account.ex b/lib/generated/deleted_account.ex new file mode 100644 index 00000000..3095b26f --- /dev/null +++ b/lib/generated/deleted_account.ex @@ -0,0 +1,10 @@ +defmodule Stripe.DeletedAccount do + use Stripe.Entity + @moduledoc "" + ( + defstruct [:deleted, :id, :object] + + @typedoc "The `deleted_account` type.\n\n * `deleted` Always true for a deleted object\n * `id` Unique identifier for the object.\n * `object` String representing the object's type. Objects of the same type share the same value.\n" + @type t :: %__MODULE__{deleted: boolean, id: binary, object: binary} + ) +end \ No newline at end of file diff --git a/lib/generated/deleted_apple_pay_domain.ex b/lib/generated/deleted_apple_pay_domain.ex new file mode 100644 index 00000000..a2334ed6 --- /dev/null +++ b/lib/generated/deleted_apple_pay_domain.ex @@ -0,0 +1,10 @@ +defmodule Stripe.DeletedApplePayDomain do + use Stripe.Entity + @moduledoc "" + ( + defstruct [:deleted, :id, :object] + + @typedoc "The `deleted_apple_pay_domain` type.\n\n * `deleted` Always true for a deleted object\n * `id` Unique identifier for the object.\n * `object` String representing the object's type. Objects of the same type share the same value.\n" + @type t :: %__MODULE__{deleted: boolean, id: binary, object: binary} + ) +end \ No newline at end of file diff --git a/lib/generated/deleted_coupon.ex b/lib/generated/deleted_coupon.ex new file mode 100644 index 00000000..c454e5ac --- /dev/null +++ b/lib/generated/deleted_coupon.ex @@ -0,0 +1,10 @@ +defmodule Stripe.DeletedCoupon do + use Stripe.Entity + @moduledoc "" + ( + defstruct [:deleted, :id, :object] + + @typedoc "The `deleted_coupon` type.\n\n * `deleted` Always true for a deleted object\n * `id` Unique identifier for the object.\n * `object` String representing the object's type. Objects of the same type share the same value.\n" + @type t :: %__MODULE__{deleted: boolean, id: binary, object: binary} + ) +end \ No newline at end of file diff --git a/lib/generated/deleted_customer.ex b/lib/generated/deleted_customer.ex new file mode 100644 index 00000000..387393db --- /dev/null +++ b/lib/generated/deleted_customer.ex @@ -0,0 +1,10 @@ +defmodule Stripe.DeletedCustomer do + use Stripe.Entity + @moduledoc "" + ( + defstruct [:deleted, :id, :object] + + @typedoc "The `deleted_customer` type.\n\n * `deleted` Always true for a deleted object\n * `id` Unique identifier for the object.\n * `object` String representing the object's type. Objects of the same type share the same value.\n" + @type t :: %__MODULE__{deleted: boolean, id: binary, object: binary} + ) +end \ No newline at end of file diff --git a/lib/generated/deleted_discount.ex b/lib/generated/deleted_discount.ex new file mode 100644 index 00000000..6875ce82 --- /dev/null +++ b/lib/generated/deleted_discount.ex @@ -0,0 +1,34 @@ +defmodule Stripe.DeletedDiscount do + use Stripe.Entity + @moduledoc "" + ( + defstruct [ + :checkout_session, + :coupon, + :customer, + :deleted, + :id, + :invoice, + :invoice_item, + :object, + :promotion_code, + :start, + :subscription + ] + + @typedoc "The `deleted_discount` type.\n\n * `checkout_session` The Checkout session that this coupon is applied to, if it is applied to a particular session in payment mode. Will not be present for subscription mode.\n * `coupon` \n * `customer` The ID of the customer associated with this discount.\n * `deleted` Always true for a deleted object\n * `id` The ID of the discount object. Discounts cannot be fetched by ID. Use `expand[]=discounts` in API calls to expand discount IDs in an array.\n * `invoice` The invoice that the discount's coupon was applied to, if it was applied directly to a particular invoice.\n * `invoice_item` The invoice item `id` (or invoice line item `id` for invoice line items of type='subscription') that the discount's coupon was applied to, if it was applied directly to a particular invoice item or invoice line item.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `promotion_code` The promotion code applied to create this discount.\n * `start` Date that the coupon was applied.\n * `subscription` The subscription that this coupon is applied to, if it is applied to a particular subscription.\n" + @type t :: %__MODULE__{ + checkout_session: binary | nil, + coupon: Stripe.Coupon.t(), + customer: (binary | Stripe.Customer.t() | Stripe.DeletedCustomer.t()) | nil, + deleted: boolean, + id: binary, + invoice: binary | nil, + invoice_item: binary | nil, + object: binary, + promotion_code: (binary | Stripe.PromotionCode.t()) | nil, + start: integer, + subscription: binary | nil + } + ) +end \ No newline at end of file diff --git a/lib/generated/deleted_external_account.ex b/lib/generated/deleted_external_account.ex new file mode 100644 index 00000000..f49d78d2 --- /dev/null +++ b/lib/generated/deleted_external_account.ex @@ -0,0 +1,9 @@ +defmodule Stripe.DeletedExternalAccount do + use Stripe.Entity + @moduledoc nil + ( + defstruct [] + @typedoc "The `deleted_external_account` type.\n\n\n" + @type t :: %__MODULE__{} + ) +end \ No newline at end of file diff --git a/lib/generated/deleted_invoice.ex b/lib/generated/deleted_invoice.ex new file mode 100644 index 00000000..4eeefcd3 --- /dev/null +++ b/lib/generated/deleted_invoice.ex @@ -0,0 +1,10 @@ +defmodule Stripe.DeletedInvoice do + use Stripe.Entity + @moduledoc "" + ( + defstruct [:deleted, :id, :object] + + @typedoc "The `deleted_invoice` type.\n\n * `deleted` Always true for a deleted object\n * `id` Unique identifier for the object.\n * `object` String representing the object's type. Objects of the same type share the same value.\n" + @type t :: %__MODULE__{deleted: boolean, id: binary, object: binary} + ) +end \ No newline at end of file diff --git a/lib/generated/deleted_invoiceitem.ex b/lib/generated/deleted_invoiceitem.ex new file mode 100644 index 00000000..56eddc45 --- /dev/null +++ b/lib/generated/deleted_invoiceitem.ex @@ -0,0 +1,10 @@ +defmodule Stripe.DeletedInvoiceitem do + use Stripe.Entity + @moduledoc "" + ( + defstruct [:deleted, :id, :object] + + @typedoc "The `deleted_invoiceitem` type.\n\n * `deleted` Always true for a deleted object\n * `id` Unique identifier for the object.\n * `object` String representing the object's type. Objects of the same type share the same value.\n" + @type t :: %__MODULE__{deleted: boolean, id: binary, object: binary} + ) +end \ No newline at end of file diff --git a/lib/generated/deleted_payment_source.ex b/lib/generated/deleted_payment_source.ex new file mode 100644 index 00000000..e04d175d --- /dev/null +++ b/lib/generated/deleted_payment_source.ex @@ -0,0 +1,9 @@ +defmodule Stripe.DeletedPaymentSource do + use Stripe.Entity + @moduledoc nil + ( + defstruct [] + @typedoc "The `deleted_payment_source` type.\n\n\n" + @type t :: %__MODULE__{} + ) +end \ No newline at end of file diff --git a/lib/generated/deleted_person.ex b/lib/generated/deleted_person.ex new file mode 100644 index 00000000..25cebefb --- /dev/null +++ b/lib/generated/deleted_person.ex @@ -0,0 +1,10 @@ +defmodule Stripe.DeletedPerson do + use Stripe.Entity + @moduledoc "" + ( + defstruct [:deleted, :id, :object] + + @typedoc "The `deleted_person` type.\n\n * `deleted` Always true for a deleted object\n * `id` Unique identifier for the object.\n * `object` String representing the object's type. Objects of the same type share the same value.\n" + @type t :: %__MODULE__{deleted: boolean, id: binary, object: binary} + ) +end \ No newline at end of file diff --git a/lib/generated/deleted_plan.ex b/lib/generated/deleted_plan.ex new file mode 100644 index 00000000..d8560d61 --- /dev/null +++ b/lib/generated/deleted_plan.ex @@ -0,0 +1,10 @@ +defmodule Stripe.DeletedPlan do + use Stripe.Entity + @moduledoc "" + ( + defstruct [:deleted, :id, :object] + + @typedoc "The `deleted_plan` type.\n\n * `deleted` Always true for a deleted object\n * `id` Unique identifier for the object.\n * `object` String representing the object's type. Objects of the same type share the same value.\n" + @type t :: %__MODULE__{deleted: boolean, id: binary, object: binary} + ) +end \ No newline at end of file diff --git a/lib/generated/deleted_product.ex b/lib/generated/deleted_product.ex new file mode 100644 index 00000000..673533b6 --- /dev/null +++ b/lib/generated/deleted_product.ex @@ -0,0 +1,10 @@ +defmodule Stripe.DeletedProduct do + use Stripe.Entity + @moduledoc "" + ( + defstruct [:deleted, :id, :object] + + @typedoc "The `deleted_product` type.\n\n * `deleted` Always true for a deleted object\n * `id` Unique identifier for the object.\n * `object` String representing the object's type. Objects of the same type share the same value.\n" + @type t :: %__MODULE__{deleted: boolean, id: binary, object: binary} + ) +end \ No newline at end of file diff --git a/lib/generated/deleted_radar__value_list.ex b/lib/generated/deleted_radar__value_list.ex new file mode 100644 index 00000000..b457d48d --- /dev/null +++ b/lib/generated/deleted_radar__value_list.ex @@ -0,0 +1,10 @@ +defmodule Stripe.DeletedRadar.ValueList do + use Stripe.Entity + @moduledoc "" + ( + defstruct [:deleted, :id, :object] + + @typedoc "The `deleted_radar.value_list` type.\n\n * `deleted` Always true for a deleted object\n * `id` Unique identifier for the object.\n * `object` String representing the object's type. Objects of the same type share the same value.\n" + @type t :: %__MODULE__{deleted: boolean, id: binary, object: binary} + ) +end \ No newline at end of file diff --git a/lib/generated/deleted_radar__value_list_item.ex b/lib/generated/deleted_radar__value_list_item.ex new file mode 100644 index 00000000..69b1e2b4 --- /dev/null +++ b/lib/generated/deleted_radar__value_list_item.ex @@ -0,0 +1,10 @@ +defmodule Stripe.DeletedRadar.ValueListItem do + use Stripe.Entity + @moduledoc "" + ( + defstruct [:deleted, :id, :object] + + @typedoc "The `deleted_radar.value_list_item` type.\n\n * `deleted` Always true for a deleted object\n * `id` Unique identifier for the object.\n * `object` String representing the object's type. Objects of the same type share the same value.\n" + @type t :: %__MODULE__{deleted: boolean, id: binary, object: binary} + ) +end \ No newline at end of file diff --git a/lib/generated/deleted_subscription_item.ex b/lib/generated/deleted_subscription_item.ex new file mode 100644 index 00000000..1dacff7e --- /dev/null +++ b/lib/generated/deleted_subscription_item.ex @@ -0,0 +1,10 @@ +defmodule Stripe.DeletedSubscriptionItem do + use Stripe.Entity + @moduledoc "" + ( + defstruct [:deleted, :id, :object] + + @typedoc "The `deleted_subscription_item` type.\n\n * `deleted` Always true for a deleted object\n * `id` Unique identifier for the object.\n * `object` String representing the object's type. Objects of the same type share the same value.\n" + @type t :: %__MODULE__{deleted: boolean, id: binary, object: binary} + ) +end \ No newline at end of file diff --git a/lib/generated/deleted_tax_id.ex b/lib/generated/deleted_tax_id.ex new file mode 100644 index 00000000..2afc7bb7 --- /dev/null +++ b/lib/generated/deleted_tax_id.ex @@ -0,0 +1,10 @@ +defmodule Stripe.DeletedTaxId do + use Stripe.Entity + @moduledoc "" + ( + defstruct [:deleted, :id, :object] + + @typedoc "The `deleted_tax_id` type.\n\n * `deleted` Always true for a deleted object\n * `id` Unique identifier for the object.\n * `object` String representing the object's type. Objects of the same type share the same value.\n" + @type t :: %__MODULE__{deleted: boolean, id: binary, object: binary} + ) +end \ No newline at end of file diff --git a/lib/generated/deleted_terminal__configuration.ex b/lib/generated/deleted_terminal__configuration.ex new file mode 100644 index 00000000..f2266c3e --- /dev/null +++ b/lib/generated/deleted_terminal__configuration.ex @@ -0,0 +1,10 @@ +defmodule Stripe.DeletedTerminal.Configuration do + use Stripe.Entity + @moduledoc "" + ( + defstruct [:deleted, :id, :object] + + @typedoc "The `deleted_terminal.configuration` type.\n\n * `deleted` Always true for a deleted object\n * `id` Unique identifier for the object.\n * `object` String representing the object's type. Objects of the same type share the same value.\n" + @type t :: %__MODULE__{deleted: boolean, id: binary, object: binary} + ) +end \ No newline at end of file diff --git a/lib/generated/deleted_terminal__location.ex b/lib/generated/deleted_terminal__location.ex new file mode 100644 index 00000000..895658fa --- /dev/null +++ b/lib/generated/deleted_terminal__location.ex @@ -0,0 +1,10 @@ +defmodule Stripe.DeletedTerminal.Location do + use Stripe.Entity + @moduledoc "" + ( + defstruct [:deleted, :id, :object] + + @typedoc "The `deleted_terminal.location` type.\n\n * `deleted` Always true for a deleted object\n * `id` Unique identifier for the object.\n * `object` String representing the object's type. Objects of the same type share the same value.\n" + @type t :: %__MODULE__{deleted: boolean, id: binary, object: binary} + ) +end \ No newline at end of file diff --git a/lib/generated/deleted_terminal__reader.ex b/lib/generated/deleted_terminal__reader.ex new file mode 100644 index 00000000..139c390c --- /dev/null +++ b/lib/generated/deleted_terminal__reader.ex @@ -0,0 +1,10 @@ +defmodule Stripe.DeletedTerminal.Reader do + use Stripe.Entity + @moduledoc "" + ( + defstruct [:deleted, :id, :object] + + @typedoc "The `deleted_terminal.reader` type.\n\n * `deleted` Always true for a deleted object\n * `id` Unique identifier for the object.\n * `object` String representing the object's type. Objects of the same type share the same value.\n" + @type t :: %__MODULE__{deleted: boolean, id: binary, object: binary} + ) +end \ No newline at end of file diff --git a/lib/generated/deleted_test_helpers__test_clock.ex b/lib/generated/deleted_test_helpers__test_clock.ex new file mode 100644 index 00000000..f40dd012 --- /dev/null +++ b/lib/generated/deleted_test_helpers__test_clock.ex @@ -0,0 +1,10 @@ +defmodule Stripe.DeletedTestHelpers.TestClock do + use Stripe.Entity + @moduledoc "" + ( + defstruct [:deleted, :id, :object] + + @typedoc "The `deleted_test_helpers.test_clock` type.\n\n * `deleted` Always true for a deleted object\n * `id` Unique identifier for the object.\n * `object` String representing the object's type. Objects of the same type share the same value.\n" + @type t :: %__MODULE__{deleted: boolean, id: binary, object: binary} + ) +end \ No newline at end of file diff --git a/lib/generated/deleted_webhook_endpoint.ex b/lib/generated/deleted_webhook_endpoint.ex new file mode 100644 index 00000000..2cf79e01 --- /dev/null +++ b/lib/generated/deleted_webhook_endpoint.ex @@ -0,0 +1,10 @@ +defmodule Stripe.DeletedWebhookEndpoint do + use Stripe.Entity + @moduledoc "" + ( + defstruct [:deleted, :id, :object] + + @typedoc "The `deleted_webhook_endpoint` type.\n\n * `deleted` Always true for a deleted object\n * `id` Unique identifier for the object.\n * `object` String representing the object's type. Objects of the same type share the same value.\n" + @type t :: %__MODULE__{deleted: boolean, id: binary, object: binary} + ) +end \ No newline at end of file diff --git a/lib/generated/dispute.ex b/lib/generated/dispute.ex new file mode 100644 index 00000000..89d31fc1 --- /dev/null +++ b/lib/generated/dispute.ex @@ -0,0 +1,248 @@ +defmodule Stripe.Dispute do + use Stripe.Entity + + @moduledoc "A dispute occurs when a customer questions your charge with their card issuer.\nWhen this happens, you're given the opportunity to respond to the dispute with\nevidence that shows that the charge is legitimate. You can find more\ninformation about the dispute process in our [Disputes and\nFraud](/docs/disputes) documentation.\n\nRelated guide: [Disputes and fraud](https://stripe.com/docs/disputes)" + ( + defstruct [ + :amount, + :balance_transactions, + :charge, + :created, + :currency, + :evidence, + :evidence_details, + :id, + :is_charge_refundable, + :livemode, + :metadata, + :network_reason_code, + :object, + :payment_intent, + :reason, + :status + ] + + @typedoc "The `dispute` type.\n\n * `amount` Disputed amount. Usually the amount of the charge, but can differ (usually because of currency fluctuation or because only part of the order is disputed).\n * `balance_transactions` List of zero, one, or two balance transactions that show funds withdrawn and reinstated to your Stripe account as a result of this dispute.\n * `charge` ID of the charge that was disputed.\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `currency` Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).\n * `evidence` \n * `evidence_details` \n * `id` Unique identifier for the object.\n * `is_charge_refundable` If true, it is still possible to refund the disputed payment. Once the payment has been fully refunded, no further funds will be withdrawn from your Stripe account as a result of this dispute.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `metadata` Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.\n * `network_reason_code` Network-dependent reason code for the dispute.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `payment_intent` ID of the PaymentIntent that was disputed.\n * `reason` Reason given by cardholder for dispute. Possible values are `bank_cannot_process`, `check_returned`, `credit_not_processed`, `customer_initiated`, `debit_not_authorized`, `duplicate`, `fraudulent`, `general`, `incorrect_account_details`, `insufficient_funds`, `product_not_received`, `product_unacceptable`, `subscription_canceled`, or `unrecognized`. Read more about [dispute reasons](https://stripe.com/docs/disputes/categories).\n * `status` Current status of dispute. Possible values are `warning_needs_response`, `warning_under_review`, `warning_closed`, `needs_response`, `under_review`, `charge_refunded`, `won`, or `lost`.\n" + @type t :: %__MODULE__{ + amount: integer, + balance_transactions: term, + charge: binary | Stripe.Charge.t(), + created: integer, + currency: binary, + evidence: term, + evidence_details: term, + id: binary, + is_charge_refundable: boolean, + livemode: boolean, + metadata: term, + network_reason_code: binary | nil, + object: binary, + payment_intent: (binary | Stripe.PaymentIntent.t()) | nil, + reason: binary, + status: binary + } + ) + + ( + @typedoc nil + @type created :: %{ + optional(:gt) => integer, + optional(:gte) => integer, + optional(:lt) => integer, + optional(:lte) => integer + } + ) + + ( + @typedoc "Evidence to upload, to respond to a dispute. Updating any field in the hash will submit all fields in the hash for review. The combined character count of all fields is limited to 150,000." + @type evidence :: %{ + optional(:access_activity_log) => binary, + optional(:billing_address) => binary, + optional(:cancellation_policy) => binary, + optional(:cancellation_policy_disclosure) => binary, + optional(:cancellation_rebuttal) => binary, + optional(:customer_communication) => binary, + optional(:customer_email_address) => binary, + optional(:customer_name) => binary, + optional(:customer_purchase_ip) => binary, + optional(:customer_signature) => binary, + optional(:duplicate_charge_documentation) => binary, + optional(:duplicate_charge_explanation) => binary, + optional(:duplicate_charge_id) => binary, + optional(:product_description) => binary, + optional(:receipt) => binary, + optional(:refund_policy) => binary, + optional(:refund_policy_disclosure) => binary, + optional(:refund_refusal_explanation) => binary, + optional(:service_date) => binary, + optional(:service_documentation) => binary, + optional(:shipping_address) => binary, + optional(:shipping_carrier) => binary, + optional(:shipping_date) => binary, + optional(:shipping_documentation) => binary, + optional(:shipping_tracking_number) => binary, + optional(:uncategorized_file) => binary, + optional(:uncategorized_text) => binary + } + ) + + ( + nil + + @doc "

Returns a list of your disputes.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/disputes`\n" + ( + @spec list( + params :: %{ + optional(:charge) => binary, + optional(:created) => created | integer, + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:payment_intent) => binary, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.Dispute.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/disputes", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves the dispute with the given ID.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/disputes/{dispute}`\n" + ( + @spec retrieve( + dispute :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: {:ok, Stripe.Dispute.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def retrieve(dispute, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/disputes/{dispute}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "dispute", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "dispute", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [dispute] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

When you get a dispute, contacting your customer is always the best first step. If that doesn’t work, you can submit evidence to help us resolve the dispute in your favor. You can do this in your dashboard, but if you prefer, you can use the API to submit evidence programmatically.

\n\n

Depending on your dispute type, different evidence fields will give you a better chance of winning your dispute. To figure out which evidence fields to provide, see our guide to dispute types.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/disputes/{dispute}`\n" + ( + @spec update( + dispute :: binary(), + params :: %{ + optional(:evidence) => evidence, + optional(:expand) => list(binary), + optional(:metadata) => %{optional(binary) => binary} | binary, + optional(:submit) => boolean + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.Dispute.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def update(dispute, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/disputes/{dispute}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "dispute", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "dispute", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [dispute] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Closing the dispute for a charge indicates that you do not have any evidence to submit and are essentially dismissing the dispute, acknowledging it as lost.

\n\n

The status of the dispute will change from needs_response to lost. Closing a dispute is irreversible.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/disputes/{dispute}/close`\n" + ( + @spec close( + dispute :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: {:ok, Stripe.Dispute.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def close(dispute, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/disputes/{dispute}/close", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "dispute", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "dispute", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [dispute] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/ephemeral_key.ex b/lib/generated/ephemeral_key.ex new file mode 100644 index 00000000..83dc0aa6 --- /dev/null +++ b/lib/generated/ephemeral_key.ex @@ -0,0 +1,86 @@ +defmodule Stripe.EphemeralKey do + use Stripe.Entity + @moduledoc "" + ( + defstruct [:created, :expires, :id, :livemode, :object, :secret] + + @typedoc "The `ephemeral_key` type.\n\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `expires` Time at which the key will expire. Measured in seconds since the Unix epoch.\n * `id` Unique identifier for the object.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `secret` The key's secret. You can use this value to make authorized requests to the Stripe API.\n" + @type t :: %__MODULE__{ + created: integer, + expires: integer, + id: binary, + livemode: boolean, + object: binary, + secret: binary + } + ) + + ( + nil + + @doc "

Creates a short-lived API key for a given resource.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/ephemeral_keys`\n" + ( + @spec create( + params :: %{ + optional(:customer) => binary, + optional(:expand) => list(binary), + optional(:issuing_card) => binary, + optional(:verification_session) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.EphemeralKey.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/ephemeral_keys", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Invalidates a short-lived API key for a given resource.

\n\n#### Details\n\n * Method: `delete`\n * Path: `/v1/ephemeral_keys/{key}`\n" + ( + @spec delete( + key :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.EphemeralKey.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def delete(key, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/ephemeral_keys/{key}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "key", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "key", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [key] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:delete) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/event.ex b/lib/generated/event.ex new file mode 100644 index 00000000..a8fa411a --- /dev/null +++ b/lib/generated/event.ex @@ -0,0 +1,117 @@ +defmodule Stripe.Event do + use Stripe.Entity + + @moduledoc "Events are our way of letting you know when something interesting happens in\nyour account. When an interesting event occurs, we create a new `Event`\nobject. For example, when a charge succeeds, we create a `charge.succeeded`\nevent; and when an invoice payment attempt fails, we create an\n`invoice.payment_failed` event. Note that many API requests may cause multiple\nevents to be created. For example, if you create a new subscription for a\ncustomer, you will receive both a `customer.subscription.created` event and a\n`charge.succeeded` event.\n\nEvents occur when the state of another API resource changes. The state of that\nresource at the time of the change is embedded in the event's data field. For\nexample, a `charge.succeeded` event will contain a charge, and an\n`invoice.payment_failed` event will contain an invoice.\n\nAs with other API resources, you can use endpoints to retrieve an\n[individual event](https://stripe.com/docs/api#retrieve_event) or a [list of events](https://stripe.com/docs/api#list_events)\nfrom the API. We also have a separate\n[webhooks](http://en.wikipedia.org/wiki/Webhook) system for sending the\n`Event` objects directly to an endpoint on your server. Webhooks are managed\nin your\n[account settings](https://dashboard.stripe.com/account/webhooks),\nand our [Using Webhooks](https://stripe.com/docs/webhooks) guide will help you get set up.\n\nWhen using [Connect](https://stripe.com/docs/connect), you can also receive notifications of\nevents that occur in connected accounts. For these events, there will be an\nadditional `account` attribute in the received `Event` object.\n\n**NOTE:** Right now, access to events through the [Retrieve Event API](https://stripe.com/docs/api#retrieve_event) is\nguaranteed only for 30 days." + ( + defstruct [ + :account, + :api_version, + :created, + :data, + :id, + :livemode, + :object, + :pending_webhooks, + :request, + :type + ] + + @typedoc "The `event` type.\n\n * `account` The connected account that originated the event.\n * `api_version` The Stripe API version used to render `data`. *Note: This property is populated only for events on or after October 31, 2014*.\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `data` \n * `id` Unique identifier for the object.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `pending_webhooks` Number of webhooks that have yet to be successfully delivered (i.e., to return a 20x response) to the URLs you've specified.\n * `request` Information on the API request that instigated the event.\n * `type` Description of the event (e.g., `invoice.created` or `charge.refunded`).\n" + @type t :: %__MODULE__{ + account: binary, + api_version: binary | nil, + created: integer, + data: term, + id: binary, + livemode: boolean, + object: binary, + pending_webhooks: integer, + request: term | nil, + type: binary + } + ) + + ( + @typedoc nil + @type created :: %{ + optional(:gt) => integer, + optional(:gte) => integer, + optional(:lt) => integer, + optional(:lte) => integer + } + ) + + ( + nil + + @doc "

List events, going back up to 30 days. Each event data is rendered according to Stripe API version at its creation time, specified in event object api_version attribute (not according to your current Stripe API version or Stripe-Version header).

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/events`\n" + ( + @spec list( + params :: %{ + optional(:created) => created | integer, + optional(:delivery_success) => boolean, + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:starting_after) => binary, + optional(:type) => binary, + optional(:types) => list(binary) + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.Event.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/events", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves the details of an event. Supply the unique identifier of the event, which you might have received in a webhook.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/events/{id}`\n" + ( + @spec retrieve( + id :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: {:ok, Stripe.Event.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def retrieve(id, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/events/{id}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "id", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "id", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [id] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/exchange_rate.ex b/lib/generated/exchange_rate.ex new file mode 100644 index 00000000..a0c8e058 --- /dev/null +++ b/lib/generated/exchange_rate.ex @@ -0,0 +1,82 @@ +defmodule Stripe.ExchangeRate do + use Stripe.Entity + + @moduledoc "`Exchange Rate` objects allow you to determine the rates that Stripe is\ncurrently using to convert from one currency to another. Since this number is\nvariable throughout the day, there are various reasons why you might want to\nknow the current rate (for example, to dynamically price an item for a user\nwith a default payment in a foreign currency).\n\nIf you want a guarantee that the charge is made with a certain exchange rate\nyou expect is current, you can pass in `exchange_rate` to charges endpoints.\nIf the value is no longer up to date, the charge won't go through. Please\nrefer to our [Exchange Rates API](https://stripe.com/docs/exchange-rates) guide for more\ndetails." + ( + defstruct [:id, :object, :rates] + + @typedoc "The `exchange_rate` type.\n\n * `id` Unique identifier for the object. Represented as the three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) in lowercase.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `rates` Hash where the keys are supported currencies and the values are the exchange rate at which the base id currency converts to the key currency.\n" + @type t :: %__MODULE__{id: binary, object: binary, rates: term} + ) + + ( + nil + + @doc "

Returns a list of objects that contain the rates at which foreign currencies are converted to one another. Only shows the currencies for which Stripe supports.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/exchange_rates`\n" + ( + @spec list( + params :: %{ + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.ExchangeRate.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/exchange_rates", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves the exchange rates from the given currency to every supported currency.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/exchange_rates/{rate_id}`\n" + ( + @spec retrieve( + rate_id :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.ExchangeRate.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def retrieve(rate_id, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/exchange_rates/{rate_id}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "rate_id", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "rate_id", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [rate_id] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/external_account.ex b/lib/generated/external_account.ex new file mode 100644 index 00000000..b2421b99 --- /dev/null +++ b/lib/generated/external_account.ex @@ -0,0 +1,304 @@ +defmodule Stripe.ExternalAccount do + use Stripe.Entity + @moduledoc nil + ( + defstruct [] + @typedoc "The `external_account` type.\n\n\n" + @type t :: %__MODULE__{} + ) + + ( + @typedoc "One or more documents that support the [Bank account ownership verification](https://support.stripe.com/questions/bank-account-ownership-verification) requirement. Must be a document associated with the bank account that displays the last 4 digits of the account number, either a statement or a voided check." + @type bank_account_ownership_verification :: %{optional(:files) => list(binary)} + ) + + ( + @typedoc "Documents that may be submitted to satisfy various informational requests." + @type documents :: %{ + optional(:bank_account_ownership_verification) => bank_account_ownership_verification + } + ) + + ( + nil + + @doc "

List external accounts for an account.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/accounts/{account}/external_accounts`\n" + ( + @spec list( + account :: binary(), + params :: %{ + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.ExternalAccount.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(account, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/accounts/{account}/external_accounts", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "account", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "account", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [account] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieve a specified external account for a given account.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/accounts/{account}/external_accounts/{id}`\n" + ( + @spec retrieve( + account :: binary(), + id :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.ExternalAccount.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def retrieve(account, id, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/accounts/{account}/external_accounts/{id}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "account", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "account", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + }, + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "id", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "id", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [account, id] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Create an external account for a given account.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/accounts/{account}/external_accounts`\n" + ( + @spec create( + account :: binary(), + params :: %{ + optional(:default_for_currency) => boolean, + optional(:expand) => list(binary), + optional(:external_account) => binary, + optional(:metadata) => %{optional(binary) => binary} + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.ExternalAccount.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def create(account, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/accounts/{account}/external_accounts", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "account", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "account", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [account] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Updates the metadata, account holder name, account holder type of a bank account belonging to a Custom account, and optionally sets it as the default for its currency. Other bank account details are not editable by design.

\n\n

You can re-enable a disabled bank account by performing an update call without providing any arguments or changes.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/accounts/{account}/external_accounts/{id}`\n" + ( + @spec update( + account :: binary(), + id :: binary(), + params :: %{ + optional(:account_holder_name) => binary, + optional(:account_holder_type) => :company | :individual, + optional(:account_type) => :checking | :futsu | :savings | :toza, + optional(:address_city) => binary, + optional(:address_country) => binary, + optional(:address_line1) => binary, + optional(:address_line2) => binary, + optional(:address_state) => binary, + optional(:address_zip) => binary, + optional(:default_for_currency) => boolean, + optional(:documents) => documents, + optional(:exp_month) => binary, + optional(:exp_year) => binary, + optional(:expand) => list(binary), + optional(:metadata) => %{optional(binary) => binary} | binary, + optional(:name) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.ExternalAccount.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def update(account, id, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/accounts/{account}/external_accounts/{id}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "account", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "account", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + }, + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "id", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "id", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [account, id] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Delete a specified external account for a given account.

\n\n#### Details\n\n * Method: `delete`\n * Path: `/v1/accounts/{account}/external_accounts/{id}`\n" + ( + @spec delete(account :: binary(), id :: binary(), opts :: Keyword.t()) :: + {:ok, Stripe.DeletedExternalAccount.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def delete(account, id, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/accounts/{account}/external_accounts/{id}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "account", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "account", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + }, + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "id", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "id", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [account, id] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_method(:delete) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/fee_refund.ex b/lib/generated/fee_refund.ex new file mode 100644 index 00000000..7c69a42f --- /dev/null +++ b/lib/generated/fee_refund.ex @@ -0,0 +1,227 @@ +defmodule Stripe.FeeRefund do + use Stripe.Entity + + @moduledoc "`Application Fee Refund` objects allow you to refund an application fee that\nhas previously been created but not yet refunded. Funds will be refunded to\nthe Stripe account from which the fee was originally collected.\n\nRelated guide: [Refunding application fees](https://stripe.com/docs/connect/destination-charges#refunding-app-fee)" + ( + defstruct [:amount, :balance_transaction, :created, :currency, :fee, :id, :metadata, :object] + + @typedoc "The `fee_refund` type.\n\n * `amount` Amount, in %s.\n * `balance_transaction` Balance transaction that describes the impact on your account balance.\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `currency` Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).\n * `fee` ID of the application fee that was refunded.\n * `id` Unique identifier for the object.\n * `metadata` Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.\n * `object` String representing the object's type. Objects of the same type share the same value.\n" + @type t :: %__MODULE__{ + amount: integer, + balance_transaction: (binary | Stripe.BalanceTransaction.t()) | nil, + created: integer, + currency: binary, + fee: binary | Stripe.ApplicationFee.t(), + id: binary, + metadata: term | nil, + object: binary + } + ) + + ( + nil + + @doc "

Refunds an application fee that has previously been collected but not yet refunded.\nFunds will be refunded to the Stripe account from which the fee was originally collected.

\n\n

You can optionally refund only part of an application fee.\nYou can do so multiple times, until the entire fee has been refunded.

\n\n

Once entirely refunded, an application fee can’t be refunded again.\nThis method will raise an error when called on an already-refunded application fee,\nor when trying to refund more money than is left on an application fee.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/application_fees/{id}/refunds`\n" + ( + @spec create( + id :: binary(), + params :: %{ + optional(:amount) => integer, + optional(:expand) => list(binary), + optional(:metadata) => %{optional(binary) => binary} + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.FeeRefund.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def create(id, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/application_fees/{id}/refunds", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "id", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "id", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [id] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

You can see a list of the refunds belonging to a specific application fee. Note that the 10 most recent refunds are always available by default on the application fee object. If you need more than those 10, you can use this API method and the limit and starting_after parameters to page through additional refunds.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/application_fees/{id}/refunds`\n" + ( + @spec list( + id :: binary(), + params :: %{ + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.FeeRefund.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(id, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/application_fees/{id}/refunds", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "id", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "id", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [id] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

By default, you can see the 10 most recent refunds stored directly on the application fee object, but you can also retrieve details about a specific refund stored on the application fee.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/application_fees/{fee}/refunds/{id}`\n" + ( + @spec retrieve( + fee :: binary(), + id :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: {:ok, Stripe.FeeRefund.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def retrieve(fee, id, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/application_fees/{fee}/refunds/{id}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "fee", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "fee", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + }, + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "id", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "id", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [fee, id] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Updates the specified application fee refund by setting the values of the parameters passed. Any parameters not provided will be left unchanged.

\n\n

This request only accepts metadata as an argument.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/application_fees/{fee}/refunds/{id}`\n" + ( + @spec update( + fee :: binary(), + id :: binary(), + params :: %{ + optional(:expand) => list(binary), + optional(:metadata) => %{optional(binary) => binary} | binary + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.FeeRefund.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def update(fee, id, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/application_fees/{fee}/refunds/{id}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "fee", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "fee", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + }, + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "id", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "id", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [fee, id] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/file.ex b/lib/generated/file.ex new file mode 100644 index 00000000..9203c0bc --- /dev/null +++ b/lib/generated/file.ex @@ -0,0 +1,149 @@ +defmodule Stripe.File do + use Stripe.Entity + + @moduledoc "This is an object representing a file hosted on Stripe's servers. The\nfile may have been uploaded by yourself using the [create file](https://stripe.com/docs/api#create_file)\nrequest (for example, when uploading dispute evidence) or it may have\nbeen created by Stripe (for example, the results of a [Sigma scheduled\nquery](#scheduled_queries)).\n\nRelated guide: [File upload guide](https://stripe.com/docs/file-upload)" + ( + defstruct [ + :created, + :expires_at, + :filename, + :id, + :links, + :object, + :purpose, + :size, + :title, + :type, + :url + ] + + @typedoc "The `file` type.\n\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `expires_at` The time at which the file expires and is no longer available in epoch seconds.\n * `filename` A filename for the file, suitable for saving to a filesystem.\n * `id` Unique identifier for the object.\n * `links` A list of [file links](https://stripe.com/docs/api#file_links) that point at this file.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `purpose` The [purpose](https://stripe.com/docs/file-upload#uploading-a-file) of the uploaded file.\n * `size` The size in bytes of the file object.\n * `title` A user friendly title for the document.\n * `type` The type of the file returned (e.g., `csv`, `pdf`, `jpg`, or `png`).\n * `url` The URL from which the file can be downloaded using your live secret API key.\n" + @type t :: %__MODULE__{ + created: integer, + expires_at: integer | nil, + filename: binary | nil, + id: binary, + links: term | nil, + object: binary, + purpose: binary, + size: integer, + title: binary | nil, + type: binary | nil, + url: binary | nil + } + ) + + ( + @typedoc nil + @type created :: %{ + optional(:gt) => integer, + optional(:gte) => integer, + optional(:lt) => integer, + optional(:lte) => integer + } + ) + + ( + nil + + @doc "

Returns a list of the files that your account has access to. The files are returned sorted by creation date, with the most recently created files appearing first.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/files`\n" + ( + @spec list( + params :: %{ + optional(:created) => created | integer, + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:purpose) => + :account_requirement + | :additional_verification + | :business_icon + | :business_logo + | :customer_signature + | :dispute_evidence + | :document_provider_identity_document + | :finance_report_run + | :identity_document + | :identity_document_downloadable + | :pci_document + | :selfie + | :sigma_scheduled_query + | :tax_document_user_upload + | :terminal_reader_splashscreen, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.File.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/files", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves the details of an existing file object. Supply the unique file ID from a file, and Stripe will return the corresponding file object. To access file contents, see the File Upload Guide.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/files/{file}`\n" + ( + @spec retrieve( + file :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: {:ok, Stripe.File.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def retrieve(file, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/files/{file}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "file", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "file", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [file] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

To upload a file to Stripe, you’ll need to send a request of type multipart/form-data. The request should contain the file you would like to upload, as well as the parameters for creating a file.

\n\n

All of Stripe’s officially supported Client libraries should have support for sending multipart/form-data.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/files`\n" + ( + @spec create(opts :: Keyword.t()) :: + {:ok, Stripe.File.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def create(params \\ %{}, opts \\ []) do + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint("/v1/files") + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_file_upload_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/file_link.ex b/lib/generated/file_link.ex new file mode 100644 index 00000000..8ac6b9c0 --- /dev/null +++ b/lib/generated/file_link.ex @@ -0,0 +1,175 @@ +defmodule Stripe.FileLink do + use Stripe.Entity + + @moduledoc "To share the contents of a `File` object with non-Stripe users, you can\ncreate a `FileLink`. `FileLink`s contain a URL that can be used to\nretrieve the contents of the file without authentication." + ( + defstruct [:created, :expired, :expires_at, :file, :id, :livemode, :metadata, :object, :url] + + @typedoc "The `file_link` type.\n\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `expired` Whether this link is already expired.\n * `expires_at` Time at which the link expires.\n * `file` The file object this link points to.\n * `id` Unique identifier for the object.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `metadata` Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `url` The publicly accessible URL to download the file.\n" + @type t :: %__MODULE__{ + created: integer, + expired: boolean, + expires_at: integer | nil, + file: binary | Stripe.File.t(), + id: binary, + livemode: boolean, + metadata: term, + object: binary, + url: binary | nil + } + ) + + ( + @typedoc nil + @type created :: %{ + optional(:gt) => integer, + optional(:gte) => integer, + optional(:lt) => integer, + optional(:lte) => integer + } + ) + + ( + nil + + @doc "

Retrieves the file link with the given ID.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/file_links/{link}`\n" + ( + @spec retrieve( + link :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: {:ok, Stripe.FileLink.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def retrieve(link, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/file_links/{link}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "link", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "link", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [link] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Creates a new file link object.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/file_links`\n" + ( + @spec create( + params :: %{ + optional(:expand) => list(binary), + optional(:expires_at) => integer, + optional(:file) => binary, + optional(:metadata) => %{optional(binary) => binary} | binary + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.FileLink.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/file_links", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Updates an existing file link object. Expired links can no longer be updated.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/file_links/{link}`\n" + ( + @spec update( + link :: binary(), + params :: %{ + optional(:expand) => list(binary), + optional(:expires_at) => :now | integer | binary, + optional(:metadata) => %{optional(binary) => binary} | binary + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.FileLink.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def update(link, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/file_links/{link}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "link", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "link", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [link] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Returns a list of file links.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/file_links`\n" + ( + @spec list( + params :: %{ + optional(:created) => created | integer, + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:expired) => boolean, + optional(:file) => binary, + optional(:limit) => integer, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.FileLink.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/file_links", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/financial_connections__account.ex b/lib/generated/financial_connections__account.ex new file mode 100644 index 00000000..1e74acc4 --- /dev/null +++ b/lib/generated/financial_connections__account.ex @@ -0,0 +1,269 @@ +defmodule Stripe.FinancialConnections.Account do + use Stripe.Entity + + @moduledoc "A Financial Connections Account represents an account that exists outside of Stripe, to which you have been granted some degree of access." + ( + defstruct [ + :account_holder, + :balance, + :balance_refresh, + :category, + :created, + :display_name, + :id, + :institution_name, + :last4, + :livemode, + :object, + :ownership, + :ownership_refresh, + :permissions, + :status, + :subcategory, + :supported_payment_method_types + ] + + @typedoc "The `financial_connections.account` type.\n\n * `account_holder` The account holder that this account belongs to.\n * `balance` The most recent information about the account's balance.\n * `balance_refresh` The state of the most recent attempt to refresh the account balance.\n * `category` The type of the account. Account category is further divided in `subcategory`.\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `display_name` A human-readable name that has been assigned to this account, either by the account holder or by the institution.\n * `id` Unique identifier for the object.\n * `institution_name` The name of the institution that holds this account.\n * `last4` The last 4 digits of the account number. If present, this will be 4 numeric characters.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `ownership` The most recent information about the account's owners.\n * `ownership_refresh` The state of the most recent attempt to refresh the account owners.\n * `permissions` The list of permissions granted by this account.\n * `status` The status of the link to the account.\n * `subcategory` If `category` is `cash`, one of:\n\n - `checking`\n - `savings`\n - `other`\n\nIf `category` is `credit`, one of:\n\n - `mortgage`\n - `line_of_credit`\n - `credit_card`\n - `other`\n\nIf `category` is `investment` or `other`, this will be `other`.\n * `supported_payment_method_types` The [PaymentMethod type](https://stripe.com/docs/api/payment_methods/object#payment_method_object-type)(s) that can be created from this account.\n" + @type t :: %__MODULE__{ + account_holder: term | nil, + balance: term | nil, + balance_refresh: term | nil, + category: binary, + created: integer, + display_name: binary | nil, + id: binary, + institution_name: binary, + last4: binary | nil, + livemode: boolean, + object: binary, + ownership: (binary | term) | nil, + ownership_refresh: term | nil, + permissions: term | nil, + status: binary, + subcategory: binary, + supported_payment_method_types: term + } + ) + + ( + @typedoc nil + @type account_holder :: %{optional(:account) => binary, optional(:customer) => binary} + ) + + ( + nil + + @doc "

Returns a list of Financial Connections Account objects.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/financial_connections/accounts`\n" + ( + @spec list( + params :: %{ + optional(:account_holder) => account_holder, + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:session) => binary, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.FinancialConnections.Account.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params("/v1/financial_connections/accounts", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves the details of an Financial Connections Account.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/financial_connections/accounts/{account}`\n" + ( + @spec retrieve( + account :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.FinancialConnections.Account.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def retrieve(account, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/financial_connections/accounts/{account}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "account", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "account", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [account] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Lists all owners for a given Account

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/financial_connections/accounts/{account}/owners`\n" + ( + @spec list_owners( + account :: binary(), + params :: %{ + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:ownership) => binary, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.FinancialConnections.AccountOwner.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list_owners(account, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/financial_connections/accounts/{account}/owners", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "account", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "account", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [account] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Refreshes the data associated with a Financial Connections Account.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/financial_connections/accounts/{account}/refresh`\n" + ( + @spec refresh( + account :: binary(), + params :: %{ + optional(:expand) => list(binary), + optional(:features) => list(:balance | :ownership) + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.FinancialConnections.Account.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def refresh(account, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/financial_connections/accounts/{account}/refresh", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "account", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "account", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [account] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Disables your access to a Financial Connections Account. You will no longer be able to access data associated with the account (e.g. balances, transactions).

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/financial_connections/accounts/{account}/disconnect`\n" + ( + @spec disconnect( + account :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.FinancialConnections.Account.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def disconnect(account, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/financial_connections/accounts/{account}/disconnect", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "account", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "account", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [account] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/financial_connections__account_owner.ex b/lib/generated/financial_connections__account_owner.ex new file mode 100644 index 00000000..334696c8 --- /dev/null +++ b/lib/generated/financial_connections__account_owner.ex @@ -0,0 +1,19 @@ +defmodule Stripe.FinancialConnections.AccountOwner do + use Stripe.Entity + @moduledoc "Describes an owner of an account." + ( + defstruct [:email, :id, :name, :object, :ownership, :phone, :raw_address, :refreshed_at] + + @typedoc "The `financial_connections.account_owner` type.\n\n * `email` The email address of the owner.\n * `id` Unique identifier for the object.\n * `name` The full name of the owner.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `ownership` The ownership object that this owner belongs to.\n * `phone` The raw phone number of the owner.\n * `raw_address` The raw physical address of the owner.\n * `refreshed_at` The timestamp of the refresh that updated this owner.\n" + @type t :: %__MODULE__{ + email: binary | nil, + id: binary, + name: binary, + object: binary, + ownership: binary, + phone: binary | nil, + raw_address: binary | nil, + refreshed_at: integer | nil + } + ) +end \ No newline at end of file diff --git a/lib/generated/financial_connections__session.ex b/lib/generated/financial_connections__session.ex new file mode 100644 index 00000000..25574a19 --- /dev/null +++ b/lib/generated/financial_connections__session.ex @@ -0,0 +1,121 @@ +defmodule Stripe.FinancialConnections.Session do + use Stripe.Entity + + @moduledoc "A Financial Connections Session is the secure way to programmatically launch the client-side Stripe.js modal that lets your users link their accounts." + ( + defstruct [ + :account_holder, + :accounts, + :client_secret, + :filters, + :id, + :livemode, + :object, + :permissions, + :return_url + ] + + @typedoc "The `financial_connections.session` type.\n\n * `account_holder` The account holder for whom accounts are collected in this session.\n * `accounts` The accounts that were collected as part of this Session.\n * `client_secret` A value that will be passed to the client to launch the authentication flow.\n * `filters` \n * `id` Unique identifier for the object.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `permissions` Permissions requested for accounts collected during this session.\n * `return_url` For webview integrations only. Upon completing OAuth login in the native browser, the user will be redirected to this URL to return to your app.\n" + @type t :: %__MODULE__{ + account_holder: term | nil, + accounts: term, + client_secret: binary, + filters: term, + id: binary, + livemode: boolean, + object: binary, + permissions: term, + return_url: binary + } + ) + + ( + @typedoc "The account holder to link accounts for." + @type account_holder :: %{ + optional(:account) => binary, + optional(:customer) => binary, + optional(:type) => :account | :customer + } + ) + + ( + @typedoc "Filters to restrict the kinds of accounts to collect." + @type filters :: %{optional(:countries) => list(binary)} + ) + + ( + nil + + @doc "

To launch the Financial Connections authorization flow, create a Session. The session’s client_secret can be used to launch the flow using Stripe.js.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/financial_connections/sessions`\n" + ( + @spec create( + params :: %{ + optional(:account_holder) => account_holder, + optional(:expand) => list(binary), + optional(:filters) => filters, + optional(:permissions) => + list(:balances | :ownership | :payment_method | :transactions), + optional(:return_url) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.FinancialConnections.Session.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params("/v1/financial_connections/sessions", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves the details of a Financial Connections Session

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/financial_connections/sessions/{session}`\n" + ( + @spec retrieve( + session :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.FinancialConnections.Session.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def retrieve(session, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/financial_connections/sessions/{session}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "session", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "session", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [session] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/funding_instructions.ex b/lib/generated/funding_instructions.ex new file mode 100644 index 00000000..565f53c5 --- /dev/null +++ b/lib/generated/funding_instructions.ex @@ -0,0 +1,17 @@ +defmodule Stripe.FundingInstructions do + use Stripe.Entity + + @moduledoc "Each customer has a [`balance`](https://stripe.com/docs/api/customers/object#customer_object-balance) that is\nautomatically applied to future invoices and payments using the `customer_balance` payment method.\nCustomers can fund this balance by initiating a bank transfer to any account in the\n`financial_addresses` field.\nRelated guide: [Customer balance funding instructions](https://stripe.com/docs/payments/customer-balance/funding-instructions)" + ( + defstruct [:bank_transfer, :currency, :funding_type, :livemode, :object] + + @typedoc "The `funding_instructions` type.\n\n * `bank_transfer` \n * `currency` Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).\n * `funding_type` The `funding_type` of the returned instructions\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `object` String representing the object's type. Objects of the same type share the same value.\n" + @type t :: %__MODULE__{ + bank_transfer: term, + currency: binary, + funding_type: binary, + livemode: boolean, + object: binary + } + ) +end \ No newline at end of file diff --git a/lib/generated/identity__verification_report.ex b/lib/generated/identity__verification_report.ex new file mode 100644 index 00000000..e12bf289 --- /dev/null +++ b/lib/generated/identity__verification_report.ex @@ -0,0 +1,120 @@ +defmodule Stripe.Identity.VerificationReport do + use Stripe.Entity + + @moduledoc "A VerificationReport is the result of an attempt to collect and verify data from a user.\nThe collection of verification checks performed is determined from the `type` and `options`\nparameters used. You can find the result of each verification check performed in the\nappropriate sub-resource: `document`, `id_number`, `selfie`.\n\nEach VerificationReport contains a copy of any data collected by the user as well as\nreference IDs which can be used to access collected images through the [FileUpload](https://stripe.com/docs/api/files)\nAPI. To configure and create VerificationReports, use the\n[VerificationSession](https://stripe.com/docs/api/identity/verification_sessions) API.\n\nRelated guides: [Accessing verification results](https://stripe.com/docs/identity/verification-sessions#results)." + ( + defstruct [ + :created, + :document, + :id, + :id_number, + :livemode, + :object, + :options, + :selfie, + :type, + :verification_session + ] + + @typedoc "The `identity.verification_report` type.\n\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `document` \n * `id` Unique identifier for the object.\n * `id_number` \n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `options` \n * `selfie` \n * `type` Type of report.\n * `verification_session` ID of the VerificationSession that created this report.\n" + @type t :: %__MODULE__{ + created: integer, + document: term, + id: binary, + id_number: term, + livemode: boolean, + object: binary, + options: term, + selfie: term, + type: binary, + verification_session: binary | nil + } + ) + + ( + @typedoc nil + @type created :: %{ + optional(:gt) => integer, + optional(:gte) => integer, + optional(:lt) => integer, + optional(:lte) => integer + } + ) + + ( + nil + + @doc "

Retrieves an existing VerificationReport

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/identity/verification_reports/{report}`\n" + ( + @spec retrieve( + report :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Identity.VerificationReport.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def retrieve(report, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/identity/verification_reports/{report}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "report", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "report", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [report] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

List all verification reports.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/identity/verification_reports`\n" + ( + @spec list( + params :: %{ + optional(:created) => created | integer, + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:starting_after) => binary, + optional(:type) => :document | :id_number, + optional(:verification_session) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.Identity.VerificationReport.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params("/v1/identity/verification_reports", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/identity__verification_session.ex b/lib/generated/identity__verification_session.ex new file mode 100644 index 00000000..08027782 --- /dev/null +++ b/lib/generated/identity__verification_session.ex @@ -0,0 +1,310 @@ +defmodule Stripe.Identity.VerificationSession do + use Stripe.Entity + + @moduledoc "A VerificationSession guides you through the process of collecting and verifying the identities\nof your users. It contains details about the type of verification, such as what [verification\ncheck](/docs/identity/verification-checks) to perform. Only create one VerificationSession for\neach verification in your system.\n\nA VerificationSession transitions through [multiple\nstatuses](/docs/identity/how-sessions-work) throughout its lifetime as it progresses through\nthe verification flow. The VerificationSession contains the user's verified data after\nverification checks are complete.\n\nRelated guide: [The Verification Sessions API](https://stripe.com/docs/identity/verification-sessions)" + ( + defstruct [ + :client_secret, + :created, + :id, + :last_error, + :last_verification_report, + :livemode, + :metadata, + :object, + :options, + :redaction, + :status, + :type, + :url, + :verified_outputs + ] + + @typedoc "The `identity.verification_session` type.\n\n * `client_secret` The short-lived client secret used by Stripe.js to [show a verification modal](https://stripe.com/docs/js/identity/modal) inside your app. This client secret expires after 24 hours and can only be used once. Don’t store it, log it, embed it in a URL, or expose it to anyone other than the user. Make sure that you have TLS enabled on any page that includes the client secret. Refer to our docs on [passing the client secret to the frontend](https://stripe.com/docs/identity/verification-sessions#client-secret) to learn more.\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `id` Unique identifier for the object.\n * `last_error` If present, this property tells you the last error encountered when processing the verification.\n * `last_verification_report` ID of the most recent VerificationReport. [Learn more about accessing detailed verification results.](https://stripe.com/docs/identity/verification-sessions#results)\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `metadata` Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `options` A set of options for the session’s verification checks.\n * `redaction` Redaction status of this VerificationSession. If the VerificationSession is not redacted, this field will be null.\n * `status` Status of this VerificationSession. [Learn more about the lifecycle of sessions](https://stripe.com/docs/identity/how-sessions-work).\n * `type` The type of [verification check](https://stripe.com/docs/identity/verification-checks) to be performed.\n * `url` The short-lived URL that you use to redirect a user to Stripe to submit their identity information. This URL expires after 48 hours and can only be used once. Don’t store it, log it, send it in emails or expose it to anyone other than the user. Refer to our docs on [verifying identity documents](https://stripe.com/docs/identity/verify-identity-documents?platform=web&type=redirect) to learn how to redirect users to Stripe.\n * `verified_outputs` The user’s verified data.\n" + @type t :: %__MODULE__{ + client_secret: binary | nil, + created: integer, + id: binary, + last_error: term | nil, + last_verification_report: (binary | Stripe.Identity.VerificationReport.t()) | nil, + livemode: boolean, + metadata: term, + object: binary, + options: term | nil, + redaction: term | nil, + status: binary, + type: binary | nil, + url: binary | nil, + verified_outputs: term | nil + } + ) + + ( + @typedoc nil + @type created :: %{ + optional(:gt) => integer, + optional(:gte) => integer, + optional(:lt) => integer, + optional(:lte) => integer + } + ) + + ( + @typedoc nil + @type document :: %{ + optional(:allowed_types) => list(:driving_license | :id_card | :passport), + optional(:require_id_number) => boolean, + optional(:require_live_capture) => boolean, + optional(:require_matching_selfie) => boolean + } + ) + + ( + @typedoc "A set of options for the session’s verification checks." + @type options :: %{optional(:document) => document | binary} + ) + + ( + nil + + @doc "

Creates a VerificationSession object.

\n\n

After the VerificationSession is created, display a verification modal using the session client_secret or send your users to the session’s url.

\n\n

If your API key is in test mode, verification checks won’t actually process, though everything else will occur as if in live mode.

\n\n

Related guide: Verify your users’ identity documents

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/identity/verification_sessions`\n" + ( + @spec create( + params :: %{ + optional(:expand) => list(binary), + optional(:metadata) => %{optional(binary) => binary}, + optional(:options) => options, + optional(:return_url) => binary, + optional(:type) => :document | :id_number + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Identity.VerificationSession.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params("/v1/identity/verification_sessions", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves the details of a VerificationSession that was previously created.

\n\n

When the session status is requires_input, you can use this method to retrieve a valid\nclient_secret or url to allow re-submission.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/identity/verification_sessions/{session}`\n" + ( + @spec retrieve( + session :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Identity.VerificationSession.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def retrieve(session, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/identity/verification_sessions/{session}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "session", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "session", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [session] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Returns a list of VerificationSessions

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/identity/verification_sessions`\n" + ( + @spec list( + params :: %{ + optional(:created) => created | integer, + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:starting_after) => binary, + optional(:status) => :canceled | :processing | :requires_input | :verified + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.Identity.VerificationSession.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params("/v1/identity/verification_sessions", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

A VerificationSession object can be canceled when it is in requires_input status.

\n\n

Once canceled, future submission attempts are disabled. This cannot be undone. Learn more.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/identity/verification_sessions/{session}/cancel`\n" + ( + @spec cancel( + session :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Identity.VerificationSession.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def cancel(session, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/identity/verification_sessions/{session}/cancel", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "session", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "session", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [session] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Redact a VerificationSession to remove all collected information from Stripe. This will redact\nthe VerificationSession and all objects related to it, including VerificationReports, Events,\nrequest logs, etc.

\n\n

A VerificationSession object can be redacted when it is in requires_input or verified\nstatus. Redacting a VerificationSession in requires_action\nstate will automatically cancel it.

\n\n

The redaction process may take up to four days. When the redaction process is in progress, the\nVerificationSession’s redaction.status field will be set to processing; when the process is\nfinished, it will change to redacted and an identity.verification_session.redacted event\nwill be emitted.

\n\n

Redaction is irreversible. Redacted objects are still accessible in the Stripe API, but all the\nfields that contain personal data will be replaced by the string [redacted] or a similar\nplaceholder. The metadata field will also be erased. Redacted objects cannot be updated or\nused for any purpose.

\n\n

Learn more.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/identity/verification_sessions/{session}/redact`\n" + ( + @spec redact( + session :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Identity.VerificationSession.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def redact(session, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/identity/verification_sessions/{session}/redact", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "session", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "session", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [session] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Updates a VerificationSession object.

\n\n

When the session status is requires_input, you can use this method to update the\nverification check and options.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/identity/verification_sessions/{session}`\n" + ( + @spec update( + session :: binary(), + params :: %{ + optional(:expand) => list(binary), + optional(:metadata) => %{optional(binary) => binary}, + optional(:options) => options, + optional(:type) => :document | :id_number + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Identity.VerificationSession.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def update(session, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/identity/verification_sessions/{session}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "session", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "session", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [session] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/invoice.ex b/lib/generated/invoice.ex new file mode 100644 index 00000000..bb05c9d2 --- /dev/null +++ b/lib/generated/invoice.ex @@ -0,0 +1,1158 @@ +defmodule Stripe.Invoice do + use Stripe.Entity + + @moduledoc "Invoices are statements of amounts owed by a customer, and are either\ngenerated one-off, or generated periodically from a subscription.\n\nThey contain [invoice items](https://stripe.com/docs/api#invoiceitems), and proration adjustments\nthat may be caused by subscription upgrades/downgrades (if necessary).\n\nIf your invoice is configured to be billed through automatic charges,\nStripe automatically finalizes your invoice and attempts payment. Note\nthat finalizing the invoice,\n[when automatic](https://stripe.com/docs/invoicing/integration/automatic-advancement-collection), does\nnot happen immediately as the invoice is created. Stripe waits\nuntil one hour after the last webhook was successfully sent (or the last\nwebhook timed out after failing). If you (and the platforms you may have\nconnected to) have no webhooks configured, Stripe waits one hour after\ncreation to finalize the invoice.\n\nIf your invoice is configured to be billed by sending an email, then based on your\n[email settings](https://dashboard.stripe.com/account/billing/automatic),\nStripe will email the invoice to your customer and await payment. These\nemails can contain a link to a hosted page to pay the invoice.\n\nStripe applies any customer credit on the account before determining the\namount due for the invoice (i.e., the amount that will be actually\ncharged). If the amount due for the invoice is less than Stripe's [minimum allowed charge\nper currency](/docs/currencies#minimum-and-maximum-charge-amounts), the\ninvoice is automatically marked paid, and we add the amount due to the\ncustomer's credit balance which is applied to the next invoice.\n\nMore details on the customer's credit balance are\n[here](https://stripe.com/docs/billing/customer/balance).\n\nRelated guide: [Send invoices to customers](https://stripe.com/docs/billing/invoices/sending)" + ( + defstruct [ + :lines, + :default_tax_rates, + :id, + :attempted, + :transfer_data, + :period_start, + :tax, + :application_fee_amount, + :number, + :customer_address, + :shipping_details, + :ending_balance, + :status, + :from_invoice, + :total_tax_amounts, + :webhooks_delivered_at, + :subscription, + :next_payment_attempt, + :period_end, + :amount_remaining, + :quote, + :discounts, + :created, + :total_discount_amounts, + :currency, + :subtotal_excluding_tax, + :total_excluding_tax, + :automatic_tax, + :test_clock, + :post_payment_credit_notes_amount, + :status_transitions, + :latest_revision, + :object, + :billing_reason, + :receipt_number, + :default_source, + :rendering_options, + :due_date, + :application, + :payment_settings, + :statement_descriptor, + :hosted_invoice_url, + :account_tax_ids, + :amount_paid, + :shipping_cost, + :customer, + :account_name, + :charge, + :on_behalf_of, + :customer_email, + :discount, + :threshold_reason, + :paid_out_of_band, + :payment_intent, + :total, + :customer_shipping, + :footer, + :subscription_proration_date, + :pre_payment_credit_notes_amount, + :paid, + :description, + :metadata, + :account_country, + :subtotal, + :amount_shipping, + :custom_fields, + :customer_name, + :attempt_count, + :last_finalization_error, + :amount_due, + :default_payment_method, + :collection_method, + :effective_at, + :customer_tax_ids, + :livemode, + :starting_balance, + :invoice_pdf, + :customer_phone, + :auto_advance, + :customer_tax_exempt + ] + + @typedoc "The `invoice` type.\n\n * `account_country` The country of the business associated with this invoice, most often the business creating the invoice.\n * `account_name` The public name of the business associated with this invoice, most often the business creating the invoice.\n * `account_tax_ids` The account tax IDs associated with the invoice. Only editable when the invoice is a draft.\n * `amount_due` Final amount due at this time for this invoice. If the invoice's total is smaller than the minimum charge amount, for example, or if there is account credit that can be applied to the invoice, the `amount_due` may be 0. If there is a positive `starting_balance` for the invoice (the customer owes money), the `amount_due` will also take that into account. The charge that gets generated for the invoice will be for the amount specified in `amount_due`.\n * `amount_paid` The amount, in %s, that was paid.\n * `amount_remaining` The difference between amount_due and amount_paid, in %s.\n * `amount_shipping` This is the sum of all the shipping amounts.\n * `application` ID of the Connect Application that created the invoice.\n * `application_fee_amount` The fee in %s that will be applied to the invoice and transferred to the application owner's Stripe account when the invoice is paid.\n * `attempt_count` Number of payment attempts made for this invoice, from the perspective of the payment retry schedule. Any payment attempt counts as the first attempt, and subsequently only automatic retries increment the attempt count. In other words, manual payment attempts after the first attempt do not affect the retry schedule.\n * `attempted` Whether an attempt has been made to pay the invoice. An invoice is not attempted until 1 hour after the `invoice.created` webhook, for example, so you might not want to display that invoice as unpaid to your users.\n * `auto_advance` Controls whether Stripe performs [automatic collection](https://stripe.com/docs/invoicing/integration/automatic-advancement-collection) of the invoice. If `false`, the invoice's state doesn't automatically advance without an explicit action.\n * `automatic_tax` \n * `billing_reason` Indicates the reason why the invoice was created. `subscription_cycle` indicates an invoice created by a subscription advancing into a new period. `subscription_create` indicates an invoice created due to creating a subscription. `subscription_update` indicates an invoice created due to updating a subscription. `subscription` is set for all old invoices to indicate either a change to a subscription or a period advancement. `manual` is set for all invoices unrelated to a subscription (for example: created via the invoice editor). The `upcoming` value is reserved for simulated invoices per the upcoming invoice endpoint. `subscription_threshold` indicates an invoice created due to a billing threshold being reached.\n * `charge` ID of the latest charge generated for this invoice, if any.\n * `collection_method` Either `charge_automatically`, or `send_invoice`. When charging automatically, Stripe will attempt to pay this invoice using the default source attached to the customer. When sending an invoice, Stripe will email this invoice to the customer with payment instructions.\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `currency` Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).\n * `custom_fields` Custom fields displayed on the invoice.\n * `customer` The ID of the customer who will be billed.\n * `customer_address` The customer's address. Until the invoice is finalized, this field will equal `customer.address`. Once the invoice is finalized, this field will no longer be updated.\n * `customer_email` The customer's email. Until the invoice is finalized, this field will equal `customer.email`. Once the invoice is finalized, this field will no longer be updated.\n * `customer_name` The customer's name. Until the invoice is finalized, this field will equal `customer.name`. Once the invoice is finalized, this field will no longer be updated.\n * `customer_phone` The customer's phone number. Until the invoice is finalized, this field will equal `customer.phone`. Once the invoice is finalized, this field will no longer be updated.\n * `customer_shipping` The customer's shipping information. Until the invoice is finalized, this field will equal `customer.shipping`. Once the invoice is finalized, this field will no longer be updated.\n * `customer_tax_exempt` The customer's tax exempt status. Until the invoice is finalized, this field will equal `customer.tax_exempt`. Once the invoice is finalized, this field will no longer be updated.\n * `customer_tax_ids` The customer's tax IDs. Until the invoice is finalized, this field will contain the same tax IDs as `customer.tax_ids`. Once the invoice is finalized, this field will no longer be updated.\n * `default_payment_method` ID of the default payment method for the invoice. It must belong to the customer associated with the invoice. If not set, defaults to the subscription's default payment method, if any, or to the default payment method in the customer's invoice settings.\n * `default_source` ID of the default payment source for the invoice. It must belong to the customer associated with the invoice and be in a chargeable state. If not set, defaults to the subscription's default source, if any, or to the customer's default source.\n * `default_tax_rates` The tax rates applied to this invoice, if any.\n * `description` An arbitrary string attached to the object. Often useful for displaying to users. Referenced as 'memo' in the Dashboard.\n * `discount` Describes the current discount applied to this invoice, if there is one. Not populated if there are multiple discounts.\n * `discounts` The discounts applied to the invoice. Line item discounts are applied before invoice discounts. Use `expand[]=discounts` to expand each discount.\n * `due_date` The date on which payment for this invoice is due. This value will be `null` for invoices where `collection_method=charge_automatically`.\n * `effective_at` The date when this invoice is in effect. Same as `finalized_at` unless overwritten. When defined, this value replaces the system-generated 'Date of issue' printed on the invoice PDF and receipt.\n * `ending_balance` Ending customer balance after the invoice is finalized. Invoices are finalized approximately an hour after successful webhook delivery or when payment collection is attempted for the invoice. If the invoice has not been finalized yet, this will be null.\n * `footer` Footer displayed on the invoice.\n * `from_invoice` Details of the invoice that was cloned. See the [revision documentation](https://stripe.com/docs/invoicing/invoice-revisions) for more details.\n * `hosted_invoice_url` The URL for the hosted invoice page, which allows customers to view and pay an invoice. If the invoice has not been finalized yet, this will be null.\n * `id` Unique identifier for the object. This property is always present unless the invoice is an upcoming invoice. See [Retrieve an upcoming invoice](https://stripe.com/docs/api/invoices/upcoming) for more details.\n * `invoice_pdf` The link to download the PDF for the invoice. If the invoice has not been finalized yet, this will be null.\n * `last_finalization_error` The error encountered during the previous attempt to finalize the invoice. This field is cleared when the invoice is successfully finalized.\n * `latest_revision` The ID of the most recent non-draft revision of this invoice\n * `lines` The individual line items that make up the invoice. `lines` is sorted as follows: (1) pending invoice items (including prorations) in reverse chronological order, (2) subscription items in reverse chronological order, and (3) invoice items added after invoice creation in chronological order.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `metadata` Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.\n * `next_payment_attempt` The time at which payment will next be attempted. This value will be `null` for invoices where `collection_method=send_invoice`.\n * `number` A unique, identifying string that appears on emails sent to the customer for this invoice. This starts with the customer's unique invoice_prefix if it is specified.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `on_behalf_of` The account (if any) for which the funds of the invoice payment are intended. If set, the invoice will be presented with the branding and support information of the specified account. See the [Invoices with Connect](https://stripe.com/docs/billing/invoices/connect) documentation for details.\n * `paid` Whether payment was successfully collected for this invoice. An invoice can be paid (most commonly) with a charge or with credit from the customer's account balance.\n * `paid_out_of_band` Returns true if the invoice was manually marked paid, returns false if the invoice hasn't been paid yet or was paid on Stripe.\n * `payment_intent` The PaymentIntent associated with this invoice. The PaymentIntent is generated when the invoice is finalized, and can then be used to pay the invoice. Note that voiding an invoice will cancel the PaymentIntent.\n * `payment_settings` \n * `period_end` End of the usage period during which invoice items were added to this invoice.\n * `period_start` Start of the usage period during which invoice items were added to this invoice.\n * `post_payment_credit_notes_amount` Total amount of all post-payment credit notes issued for this invoice.\n * `pre_payment_credit_notes_amount` Total amount of all pre-payment credit notes issued for this invoice.\n * `quote` The quote this invoice was generated from.\n * `receipt_number` This is the transaction number that appears on email receipts sent for this invoice.\n * `rendering_options` Options for invoice PDF rendering.\n * `shipping_cost` The details of the cost of shipping, including the ShippingRate applied on the invoice.\n * `shipping_details` Shipping details for the invoice. The Invoice PDF will use the `shipping_details` value if it is set, otherwise the PDF will render the shipping address from the customer.\n * `starting_balance` Starting customer balance before the invoice is finalized. If the invoice has not been finalized yet, this will be the current customer balance. For revision invoices, this also includes any customer balance that was applied to the original invoice.\n * `statement_descriptor` Extra information about an invoice for the customer's credit card statement.\n * `status` The status of the invoice, one of `draft`, `open`, `paid`, `uncollectible`, or `void`. [Learn more](https://stripe.com/docs/billing/invoices/workflow#workflow-overview)\n * `status_transitions` \n * `subscription` The subscription that this invoice was prepared for, if any.\n * `subscription_proration_date` Only set for upcoming invoices that preview prorations. The time used to calculate prorations.\n * `subtotal` Total of all subscriptions, invoice items, and prorations on the invoice before any invoice level discount or exclusive tax is applied. Item discounts are already incorporated\n * `subtotal_excluding_tax` The integer amount in %s representing the subtotal of the invoice before any invoice level discount or tax is applied. Item discounts are already incorporated\n * `tax` The amount of tax on this invoice. This is the sum of all the tax amounts on this invoice.\n * `test_clock` ID of the test clock this invoice belongs to.\n * `threshold_reason` \n * `total` Total after discounts and taxes.\n * `total_discount_amounts` The aggregate amounts calculated per discount across all line items.\n * `total_excluding_tax` The integer amount in %s representing the total amount of the invoice including all discounts but excluding all tax.\n * `total_tax_amounts` The aggregate amounts calculated per tax rate for all line items.\n * `transfer_data` The account (if any) the payment will be attributed to for tax reporting, and where funds from the payment will be transferred to for the invoice.\n * `webhooks_delivered_at` Invoices are automatically paid or sent 1 hour after webhooks are delivered, or until all webhook delivery attempts have [been exhausted](https://stripe.com/docs/billing/webhooks#understand). This field tracks the time when webhooks for this invoice were successfully delivered. If the invoice had no webhooks to deliver, this will be set while the invoice is being created.\n" + @type t :: %__MODULE__{ + account_country: binary | nil, + account_name: binary | nil, + account_tax_ids: term | nil, + amount_due: integer, + amount_paid: integer, + amount_remaining: integer, + amount_shipping: integer, + application: (binary | term | term) | nil, + application_fee_amount: integer | nil, + attempt_count: integer, + attempted: boolean, + auto_advance: boolean, + automatic_tax: term, + billing_reason: binary | nil, + charge: (binary | Stripe.Charge.t()) | nil, + collection_method: binary, + created: integer, + currency: binary, + custom_fields: term | nil, + customer: (binary | Stripe.Customer.t() | Stripe.DeletedCustomer.t()) | nil, + customer_address: term | nil, + customer_email: binary | nil, + customer_name: binary | nil, + customer_phone: binary | nil, + customer_shipping: term | nil, + customer_tax_exempt: binary | nil, + customer_tax_ids: term | nil, + default_payment_method: (binary | Stripe.PaymentMethod.t()) | nil, + default_source: (binary | Stripe.PaymentSource.t()) | nil, + default_tax_rates: term, + description: binary | nil, + discount: term | nil, + discounts: term | nil, + due_date: integer | nil, + effective_at: integer | nil, + ending_balance: integer | nil, + footer: binary | nil, + from_invoice: term | nil, + hosted_invoice_url: binary | nil, + id: binary, + invoice_pdf: binary | nil, + last_finalization_error: Stripe.ApiErrors.t() | nil, + latest_revision: (binary | Stripe.Invoice.t()) | nil, + lines: term, + livemode: boolean, + metadata: term | nil, + next_payment_attempt: integer | nil, + number: binary | nil, + object: binary, + on_behalf_of: (binary | Stripe.Account.t()) | nil, + paid: boolean, + paid_out_of_band: boolean, + payment_intent: (binary | Stripe.PaymentIntent.t()) | nil, + payment_settings: term, + period_end: integer, + period_start: integer, + post_payment_credit_notes_amount: integer, + pre_payment_credit_notes_amount: integer, + quote: (binary | Stripe.Quote.t()) | nil, + receipt_number: binary | nil, + rendering_options: term | nil, + shipping_cost: term | nil, + shipping_details: term | nil, + starting_balance: integer, + statement_descriptor: binary | nil, + status: binary | nil, + status_transitions: term, + subscription: (binary | Stripe.Subscription.t()) | nil, + subscription_proration_date: integer, + subtotal: integer, + subtotal_excluding_tax: integer | nil, + tax: integer | nil, + test_clock: (binary | Stripe.TestHelpers.TestClock.t()) | nil, + threshold_reason: term, + total: integer, + total_discount_amounts: term | nil, + total_excluding_tax: integer | nil, + total_tax_amounts: term, + transfer_data: term | nil, + webhooks_delivered_at: integer | nil + } + ) + + ( + @typedoc nil + @type acss_debit :: %{ + optional(:mandate_options) => mandate_options, + optional(:verification_method) => :automatic | :instant | :microdeposits + } + ) + + ( + @typedoc nil + @type address :: %{ + optional(:city) => binary, + optional(:country) => binary, + optional(:line1) => binary, + optional(:line2) => binary, + optional(:postal_code) => binary, + optional(:state) => binary + } + ) + + ( + @typedoc nil + @type automatic_tax :: %{optional(:enabled) => boolean} + ) + + ( + @typedoc nil + @type bancontact :: %{optional(:preferred_language) => :de | :en | :fr | :nl} + ) + + ( + @typedoc "Configuration for the bank transfer funding type, if the `funding_type` is set to `bank_transfer`." + @type bank_transfer :: %{ + optional(:eu_bank_transfer) => eu_bank_transfer, + optional(:type) => binary + } + ) + + ( + @typedoc nil + @type billing_thresholds :: %{optional(:usage_gte) => integer} + ) + + ( + @typedoc nil + @type card :: %{ + optional(:installments) => installments, + optional(:request_three_d_secure) => :any | :automatic + } + ) + + ( + @typedoc nil + @type created :: %{ + optional(:gt) => integer, + optional(:gte) => integer, + optional(:lt) => integer, + optional(:lte) => integer + } + ) + + ( + @typedoc nil + @type custom_fields :: %{optional(:name) => binary, optional(:value) => binary} + ) + + ( + @typedoc nil + @type customer_balance :: %{ + optional(:bank_transfer) => bank_transfer, + optional(:funding_type) => binary + } + ) + + ( + @typedoc nil + @type customer_details :: %{ + optional(:address) => address | binary, + optional(:shipping) => shipping | binary, + optional(:tax) => tax, + optional(:tax_exempt) => :exempt | :none | :reverse, + optional(:tax_ids) => list(tax_ids) + } + ) + + ( + @typedoc "The estimated range for how long shipping will take, meant to be displayable to the customer. This will appear on CheckoutSessions." + @type delivery_estimate :: %{optional(:maximum) => maximum, optional(:minimum) => minimum} + ) + + ( + @typedoc nil + @type discounts :: %{optional(:coupon) => binary, optional(:discount) => binary} + ) + + ( + @typedoc nil + @type due_date :: %{ + optional(:gt) => integer, + optional(:gte) => integer, + optional(:lt) => integer, + optional(:lte) => integer + } + ) + + ( + @typedoc "Configuration for eu_bank_transfer funding type." + @type eu_bank_transfer :: %{optional(:country) => binary} + ) + + ( + @typedoc "Additional fields for Financial Connections Session creation" + @type financial_connections :: %{ + optional(:permissions) => + list(:balances | :ownership | :payment_method | :transactions) + } + ) + + ( + @typedoc "Describes a fixed amount to charge for shipping. Must be present if type is `fixed_amount`." + @type fixed_amount :: %{ + optional(:amount) => integer, + optional(:currency) => binary, + optional(:currency_options) => map() + } + ) + + ( + @typedoc "Revise an existing invoice. The new invoice will be created in `status=draft`. See the [revision documentation](https://stripe.com/docs/invoicing/invoice-revisions) for more details." + @type from_invoice :: %{optional(:action) => :revision, optional(:invoice) => binary} + ) + + ( + @typedoc "Installment configuration for payments attempted on this invoice (Mexico Only).\n\nFor more information, see the [installments integration guide](https://stripe.com/docs/payments/installments)." + @type installments :: %{optional(:enabled) => boolean, optional(:plan) => plan | binary} + ) + + ( + @typedoc nil + @type invoice_items :: %{ + optional(:amount) => integer, + optional(:currency) => binary, + optional(:description) => binary, + optional(:discountable) => boolean, + optional(:discounts) => list(discounts) | binary, + optional(:invoiceitem) => binary, + optional(:metadata) => %{optional(binary) => binary} | binary, + optional(:period) => period, + optional(:price) => binary, + optional(:price_data) => price_data, + optional(:quantity) => integer, + optional(:tax_behavior) => :exclusive | :inclusive | :unspecified, + optional(:tax_code) => binary | binary, + optional(:tax_rates) => list(binary) | binary, + optional(:unit_amount) => integer, + optional(:unit_amount_decimal) => binary + } + ) + + ( + @typedoc "Additional fields for Mandate creation" + @type mandate_options :: %{optional(:transaction_type) => :business | :personal} + ) + + ( + @typedoc "The upper bound of the estimated range. If empty, represents no upper bound i.e., infinite." + @type maximum :: %{ + optional(:unit) => :business_day | :day | :hour | :month | :week, + optional(:value) => integer + } + ) + + ( + @typedoc "The lower bound of the estimated range. If empty, represents no lower bound." + @type minimum :: %{ + optional(:unit) => :business_day | :day | :hour | :month | :week, + optional(:value) => integer + } + ) + + ( + @typedoc "Payment-method-specific configuration to provide to the invoice’s PaymentIntent." + @type payment_method_options :: %{ + optional(:acss_debit) => acss_debit | binary, + optional(:bancontact) => bancontact | binary, + optional(:card) => card | binary, + optional(:customer_balance) => customer_balance | binary, + optional(:konbini) => map() | binary, + optional(:us_bank_account) => us_bank_account | binary + } + ) + + ( + @typedoc "Configuration settings for the PaymentIntent that is generated when the invoice is finalized." + @type payment_settings :: %{ + optional(:default_mandate) => binary, + optional(:payment_method_options) => payment_method_options, + optional(:payment_method_types) => + list( + :ach_credit_transfer + | :ach_debit + | :acss_debit + | :au_becs_debit + | :bacs_debit + | :bancontact + | :boleto + | :card + | :cashapp + | :customer_balance + | :fpx + | :giropay + | :grabpay + | :ideal + | :konbini + | :link + | :paynow + | :paypal + | :promptpay + | :sepa_credit_transfer + | :sepa_debit + | :sofort + | :us_bank_account + | :wechat_pay + ) + | binary + } + ) + + ( + @typedoc "The period associated with this invoice item. When set to different values, the period will be rendered on the invoice. If you have [Stripe Revenue Recognition](https://stripe.com/docs/revenue-recognition) enabled, the period will be used to recognize and defer revenue. See the [Revenue Recognition documentation](https://stripe.com/docs/revenue-recognition/methodology/subscriptions-and-invoicing) for details." + @type period :: %{optional(:end) => integer, optional(:start) => integer} + ) + + ( + @typedoc nil + @type plan :: %{ + optional(:count) => integer, + optional(:interval) => :month, + optional(:type) => :fixed_count + } + ) + + ( + @typedoc "Data used to generate a new [Price](https://stripe.com/docs/api/prices) object inline." + @type price_data :: %{ + optional(:currency) => binary, + optional(:product) => binary, + optional(:recurring) => recurring, + optional(:tax_behavior) => :exclusive | :inclusive | :unspecified, + optional(:unit_amount) => integer, + optional(:unit_amount_decimal) => binary + } + ) + + ( + @typedoc "The recurring components of a price such as `interval` and `interval_count`." + @type recurring :: %{ + optional(:interval) => :day | :month | :week | :year, + optional(:interval_count) => integer + } + ) + + ( + @typedoc nil + @type rendering_options :: %{ + optional(:amount_tax_display) => :exclude_tax | :include_inclusive_tax + } + ) + + ( + @typedoc nil + @type shipping :: %{ + optional(:address) => address, + optional(:name) => binary, + optional(:phone) => binary + } + ) + + ( + @typedoc nil + @type shipping_cost :: %{ + optional(:shipping_rate) => binary, + optional(:shipping_rate_data) => shipping_rate_data + } + ) + + ( + @typedoc nil + @type shipping_details :: %{ + optional(:address) => address, + optional(:name) => binary, + optional(:phone) => binary + } + ) + + ( + @typedoc "Parameters to create a new ad-hoc shipping rate for this order." + @type shipping_rate_data :: %{ + optional(:delivery_estimate) => delivery_estimate, + optional(:display_name) => binary, + optional(:fixed_amount) => fixed_amount, + optional(:metadata) => %{optional(binary) => binary}, + optional(:tax_behavior) => :exclusive | :inclusive | :unspecified, + optional(:tax_code) => binary, + optional(:type) => :fixed_amount + } + ) + + ( + @typedoc nil + @type subscription_items :: %{ + optional(:billing_thresholds) => billing_thresholds | binary, + optional(:clear_usage) => boolean, + optional(:deleted) => boolean, + optional(:id) => binary, + optional(:metadata) => %{optional(binary) => binary} | binary, + optional(:plan) => binary, + optional(:price) => binary, + optional(:price_data) => price_data, + optional(:quantity) => integer, + optional(:tax_rates) => list(binary) | binary + } + ) + + ( + @typedoc "Tax details about the customer." + @type tax :: %{optional(:ip_address) => binary | binary} + ) + + ( + @typedoc nil + @type tax_ids :: %{ + optional(:type) => + :ad_nrt + | :ae_trn + | :ar_cuit + | :au_abn + | :au_arn + | :bg_uic + | :bo_tin + | :br_cnpj + | :br_cpf + | :ca_bn + | :ca_gst_hst + | :ca_pst_bc + | :ca_pst_mb + | :ca_pst_sk + | :ca_qst + | :ch_vat + | :cl_tin + | :cn_tin + | :co_nit + | :cr_tin + | :do_rcn + | :ec_ruc + | :eg_tin + | :es_cif + | :eu_oss_vat + | :eu_vat + | :gb_vat + | :ge_vat + | :hk_br + | :hu_tin + | :id_npwp + | :il_vat + | :in_gst + | :is_vat + | :jp_cn + | :jp_rn + | :jp_trn + | :ke_pin + | :kr_brn + | :li_uid + | :mx_rfc + | :my_frp + | :my_itn + | :my_sst + | :no_vat + | :nz_gst + | :pe_ruc + | :ph_tin + | :ro_tin + | :rs_pib + | :ru_inn + | :ru_kpp + | :sa_vat + | :sg_gst + | :sg_uen + | :si_tin + | :sv_nit + | :th_vat + | :tr_tin + | :tw_vat + | :ua_vat + | :us_ein + | :uy_ruc + | :ve_rif + | :vn_tin + | :za_vat, + optional(:value) => binary + } + ) + + ( + @typedoc nil + @type transfer_data :: %{optional(:amount) => integer, optional(:destination) => binary} + ) + + ( + @typedoc nil + @type us_bank_account :: %{ + optional(:financial_connections) => financial_connections, + optional(:verification_method) => :automatic | :instant | :microdeposits + } + ) + + ( + nil + + @doc "

Search for invoices you’ve previously created using Stripe’s Search Query Language.\nDon’t use search in read-after-write flows where strict consistency is necessary. Under normal operating\nconditions, data is searchable in less than a minute. Occasionally, propagation of new or updated data can be up\nto an hour behind during outages. Search functionality is not available to merchants in India.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/invoices/search`\n" + ( + @spec search( + params :: %{ + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:page) => binary, + optional(:query) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.SearchResult.t(Stripe.Invoice.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def search(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/invoices/search", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

At any time, you can preview the upcoming invoice for a customer. This will show you all the charges that are pending, including subscription renewal charges, invoice item charges, etc. It will also show you any discounts that are applicable to the invoice.

\n\n

Note that when you are viewing an upcoming invoice, you are simply viewing a preview – the invoice has not yet been created. As such, the upcoming invoice will not show up in invoice listing calls, and you cannot use the API to pay or edit the invoice. If you want to change the amount that your customer will be billed, you can add, remove, or update pending invoice items, or update the customer’s discount.

\n\n

You can preview the effects of updating a subscription, including a preview of what proration will take place. To ensure that the actual proration is calculated exactly the same as the previewed proration, you should pass a proration_date parameter when doing the actual subscription update. The value passed in should be the same as the subscription_proration_date returned on the upcoming invoice resource. The recommended way to get only the prorations being previewed is to consider only proration line items where period[start] is equal to the subscription_proration_date on the upcoming invoice resource.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/invoices/upcoming`\n" + ( + @spec upcoming( + params :: %{ + optional(:automatic_tax) => automatic_tax, + optional(:coupon) => binary, + optional(:currency) => binary, + optional(:customer) => binary, + optional(:customer_details) => customer_details, + optional(:discounts) => list(discounts) | binary, + optional(:expand) => list(binary), + optional(:invoice_items) => list(invoice_items), + optional(:schedule) => binary, + optional(:subscription) => binary, + optional(:subscription_billing_cycle_anchor) => (:now | :unchanged) | integer, + optional(:subscription_cancel_at) => integer | binary, + optional(:subscription_cancel_at_period_end) => boolean, + optional(:subscription_cancel_now) => boolean, + optional(:subscription_default_tax_rates) => list(binary) | binary, + optional(:subscription_items) => list(subscription_items), + optional(:subscription_proration_behavior) => + :always_invoice | :create_prorations | :none, + optional(:subscription_proration_date) => integer, + optional(:subscription_resume_at) => :now, + optional(:subscription_start_date) => integer, + optional(:subscription_trial_end) => :now | integer, + optional(:subscription_trial_from_plan) => boolean + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.Invoice.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def upcoming(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/invoices/upcoming", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Draft invoices are fully editable. Once an invoice is finalized,\nmonetary values, as well as collection_method, become uneditable.

\n\n

If you would like to stop the Stripe Billing engine from automatically finalizing, reattempting payments on,\nsending reminders for, or automatically reconciling invoices, pass\nauto_advance=false.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/invoices/{invoice}`\n" + ( + @spec update( + invoice :: binary(), + params :: %{ + optional(:account_tax_ids) => list(binary) | binary, + optional(:application_fee_amount) => integer, + optional(:auto_advance) => boolean, + optional(:automatic_tax) => automatic_tax, + optional(:collection_method) => :charge_automatically | :send_invoice, + optional(:custom_fields) => list(custom_fields) | binary, + optional(:days_until_due) => integer, + optional(:default_payment_method) => binary, + optional(:default_source) => binary, + optional(:default_tax_rates) => list(binary) | binary, + optional(:description) => binary, + optional(:discounts) => list(discounts) | binary, + optional(:due_date) => integer, + optional(:effective_at) => integer | binary, + optional(:expand) => list(binary), + optional(:footer) => binary, + optional(:metadata) => %{optional(binary) => binary} | binary, + optional(:on_behalf_of) => binary | binary, + optional(:payment_settings) => payment_settings, + optional(:rendering_options) => rendering_options | binary, + optional(:shipping_cost) => shipping_cost | binary, + optional(:shipping_details) => shipping_details | binary, + optional(:statement_descriptor) => binary, + optional(:transfer_data) => transfer_data | binary + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.Invoice.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def update(invoice, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/invoices/{invoice}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "invoice", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "invoice", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [invoice] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Stripe automatically creates and then attempts to collect payment on invoices for customers on subscriptions according to your subscriptions settings. However, if you’d like to attempt payment on an invoice out of the normal collection schedule or for some other reason, you can do so.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/invoices/{invoice}/pay`\n" + ( + @spec pay( + invoice :: binary(), + params :: %{ + optional(:expand) => list(binary), + optional(:forgive) => boolean, + optional(:mandate) => binary, + optional(:off_session) => boolean, + optional(:paid_out_of_band) => boolean, + optional(:payment_method) => binary, + optional(:source) => binary + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.Invoice.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def pay(invoice, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/invoices/{invoice}/pay", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "invoice", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "invoice", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [invoice] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

When retrieving an upcoming invoice, you’ll get a lines property containing the total count of line items and the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/invoices/upcoming/lines`\n" + ( + @spec upcoming_lines( + params :: %{ + optional(:automatic_tax) => automatic_tax, + optional(:coupon) => binary, + optional(:currency) => binary, + optional(:customer) => binary, + optional(:customer_details) => customer_details, + optional(:discounts) => list(discounts) | binary, + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:invoice_items) => list(invoice_items), + optional(:limit) => integer, + optional(:schedule) => binary, + optional(:starting_after) => binary, + optional(:subscription) => binary, + optional(:subscription_billing_cycle_anchor) => (:now | :unchanged) | integer, + optional(:subscription_cancel_at) => integer | binary, + optional(:subscription_cancel_at_period_end) => boolean, + optional(:subscription_cancel_now) => boolean, + optional(:subscription_default_tax_rates) => list(binary) | binary, + optional(:subscription_items) => list(subscription_items), + optional(:subscription_proration_behavior) => + :always_invoice | :create_prorations | :none, + optional(:subscription_proration_date) => integer, + optional(:subscription_resume_at) => :now, + optional(:subscription_start_date) => integer, + optional(:subscription_trial_end) => :now | integer, + optional(:subscription_trial_from_plan) => boolean + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.LineItem.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def upcoming_lines(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/invoices/upcoming/lines", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

This endpoint creates a draft invoice for a given customer. The invoice remains a draft until you finalize the invoice, which allows you to pay or send the invoice to your customers.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/invoices`\n" + ( + @spec create( + params :: %{ + optional(:account_tax_ids) => list(binary) | binary, + optional(:application_fee_amount) => integer, + optional(:auto_advance) => boolean, + optional(:automatic_tax) => automatic_tax, + optional(:collection_method) => :charge_automatically | :send_invoice, + optional(:currency) => binary, + optional(:custom_fields) => list(custom_fields) | binary, + optional(:customer) => binary, + optional(:days_until_due) => integer, + optional(:default_payment_method) => binary, + optional(:default_source) => binary, + optional(:default_tax_rates) => list(binary), + optional(:description) => binary, + optional(:discounts) => list(discounts) | binary, + optional(:due_date) => integer, + optional(:effective_at) => integer, + optional(:expand) => list(binary), + optional(:footer) => binary, + optional(:from_invoice) => from_invoice, + optional(:metadata) => %{optional(binary) => binary} | binary, + optional(:on_behalf_of) => binary, + optional(:payment_settings) => payment_settings, + optional(:pending_invoice_items_behavior) => + :exclude | :include | :include_and_require, + optional(:rendering_options) => rendering_options | binary, + optional(:shipping_cost) => shipping_cost, + optional(:shipping_details) => shipping_details, + optional(:statement_descriptor) => binary, + optional(:subscription) => binary, + optional(:transfer_data) => transfer_data + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.Invoice.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/invoices", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

You can list all invoices, or list the invoices for a specific customer. The invoices are returned sorted by creation date, with the most recently created invoices appearing first.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/invoices`\n" + ( + @spec list( + params :: %{ + optional(:collection_method) => :charge_automatically | :send_invoice, + optional(:created) => created | integer, + optional(:customer) => binary, + optional(:due_date) => due_date | integer, + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:starting_after) => binary, + optional(:status) => :draft | :open | :paid | :uncollectible | :void, + optional(:subscription) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.Invoice.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/invoices", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves the invoice with the given ID.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/invoices/{invoice}`\n" + ( + @spec retrieve( + invoice :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: {:ok, Stripe.Invoice.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def retrieve(invoice, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/invoices/{invoice}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "invoice", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "invoice", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [invoice] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Permanently deletes a one-off invoice draft. This cannot be undone. Attempts to delete invoices that are no longer in a draft state will fail; once an invoice has been finalized or if an invoice is for a subscription, it must be voided.

\n\n#### Details\n\n * Method: `delete`\n * Path: `/v1/invoices/{invoice}`\n" + ( + @spec delete(invoice :: binary(), opts :: Keyword.t()) :: + {:ok, Stripe.DeletedInvoice.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def delete(invoice, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/invoices/{invoice}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "invoice", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "invoice", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [invoice] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_method(:delete) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Stripe automatically finalizes drafts before sending and attempting payment on invoices. However, if you’d like to finalize a draft invoice manually, you can do so using this method.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/invoices/{invoice}/finalize`\n" + ( + @spec finalize_invoice( + invoice :: binary(), + params :: %{optional(:auto_advance) => boolean, optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: {:ok, Stripe.Invoice.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def finalize_invoice(invoice, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/invoices/{invoice}/finalize", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "invoice", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "invoice", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [invoice] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Stripe will automatically send invoices to customers according to your subscriptions settings. However, if you’d like to manually send an invoice to your customer out of the normal schedule, you can do so. When sending invoices that have already been paid, there will be no reference to the payment in the email.

\n\n

Requests made in test-mode result in no emails being sent, despite sending an invoice.sent event.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/invoices/{invoice}/send`\n" + ( + @spec send_invoice( + invoice :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: {:ok, Stripe.Invoice.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def send_invoice(invoice, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/invoices/{invoice}/send", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "invoice", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "invoice", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [invoice] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Marking an invoice as uncollectible is useful for keeping track of bad debts that can be written off for accounting purposes.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/invoices/{invoice}/mark_uncollectible`\n" + ( + @spec mark_uncollectible( + invoice :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: {:ok, Stripe.Invoice.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def mark_uncollectible(invoice, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/invoices/{invoice}/mark_uncollectible", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "invoice", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "invoice", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [invoice] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Mark a finalized invoice as void. This cannot be undone. Voiding an invoice is similar to deletion, however it only applies to finalized invoices and maintains a papertrail where the invoice can still be found.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/invoices/{invoice}/void`\n" + ( + @spec void_invoice( + invoice :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: {:ok, Stripe.Invoice.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def void_invoice(invoice, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/invoices/{invoice}/void", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "invoice", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "invoice", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [invoice] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/invoiceitem.ex b/lib/generated/invoiceitem.ex new file mode 100644 index 00000000..b858a4f7 --- /dev/null +++ b/lib/generated/invoiceitem.ex @@ -0,0 +1,301 @@ +defmodule Stripe.Invoiceitem do + use Stripe.Entity + + @moduledoc "Invoice Items represent the component lines of an [invoice](https://stripe.com/docs/api/invoices). An invoice item is added to an\ninvoice by creating or updating it with an `invoice` field, at which point it will be included as\n[an invoice line item](https://stripe.com/docs/api/invoices/line_item) within\n[invoice.lines](https://stripe.com/docs/api/invoices/object#invoice_object-lines).\n\nInvoice Items can be created before you are ready to actually send the invoice. This can be particularly useful when combined\nwith a [subscription](https://stripe.com/docs/api/subscriptions). Sometimes you want to add a charge or credit to a customer, but actually charge\nor credit the customer’s card only at the end of a regular billing cycle. This is useful for combining several charges\n(to minimize per-transaction fees), or for having Stripe tabulate your usage-based billing totals.\n\nRelated guides: [Integrate with the Invoicing API](https://stripe.com/docs/invoicing/integration), [Subscription Invoices](https://stripe.com/docs/billing/invoices/subscription#adding-upcoming-invoice-items)." + ( + defstruct [ + :amount, + :currency, + :customer, + :date, + :description, + :discountable, + :discounts, + :id, + :invoice, + :livemode, + :metadata, + :object, + :period, + :plan, + :price, + :proration, + :quantity, + :subscription, + :subscription_item, + :tax_rates, + :test_clock, + :unit_amount, + :unit_amount_decimal + ] + + @typedoc "The `invoiceitem` type.\n\n * `amount` Amount (in the `currency` specified) of the invoice item. This should always be equal to `unit_amount * quantity`.\n * `currency` Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).\n * `customer` The ID of the customer who will be billed when this invoice item is billed.\n * `date` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `description` An arbitrary string attached to the object. Often useful for displaying to users.\n * `discountable` If true, discounts will apply to this invoice item. Always false for prorations.\n * `discounts` The discounts which apply to the invoice item. Item discounts are applied before invoice discounts. Use `expand[]=discounts` to expand each discount.\n * `id` Unique identifier for the object.\n * `invoice` The ID of the invoice this invoice item belongs to.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `metadata` Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `period` \n * `plan` If the invoice item is a proration, the plan of the subscription that the proration was computed for.\n * `price` The price of the invoice item.\n * `proration` Whether the invoice item was created automatically as a proration adjustment when the customer switched plans.\n * `quantity` Quantity of units for the invoice item. If the invoice item is a proration, the quantity of the subscription that the proration was computed for.\n * `subscription` The subscription that this invoice item has been created for, if any.\n * `subscription_item` The subscription item that this invoice item has been created for, if any.\n * `tax_rates` The tax rates which apply to the invoice item. When set, the `default_tax_rates` on the invoice do not apply to this invoice item.\n * `test_clock` ID of the test clock this invoice item belongs to.\n * `unit_amount` Unit amount (in the `currency` specified) of the invoice item.\n * `unit_amount_decimal` Same as `unit_amount`, but contains a decimal value with at most 12 decimal places.\n" + @type t :: %__MODULE__{ + amount: integer, + currency: binary, + customer: binary | Stripe.Customer.t() | Stripe.DeletedCustomer.t(), + date: integer, + description: binary | nil, + discountable: boolean, + discounts: term | nil, + id: binary, + invoice: (binary | Stripe.Invoice.t()) | nil, + livemode: boolean, + metadata: term | nil, + object: binary, + period: term, + plan: Stripe.Plan.t() | nil, + price: Stripe.Price.t() | nil, + proration: boolean, + quantity: integer, + subscription: (binary | Stripe.Subscription.t()) | nil, + subscription_item: binary, + tax_rates: term | nil, + test_clock: (binary | Stripe.TestHelpers.TestClock.t()) | nil, + unit_amount: integer | nil, + unit_amount_decimal: binary | nil + } + ) + + ( + @typedoc nil + @type created :: %{ + optional(:gt) => integer, + optional(:gte) => integer, + optional(:lt) => integer, + optional(:lte) => integer + } + ) + + ( + @typedoc nil + @type discounts :: %{optional(:coupon) => binary, optional(:discount) => binary} + ) + + ( + @typedoc "The period associated with this invoice item. When set to different values, the period will be rendered on the invoice. If you have [Stripe Revenue Recognition](https://stripe.com/docs/revenue-recognition) enabled, the period will be used to recognize and defer revenue. See the [Revenue Recognition documentation](https://stripe.com/docs/revenue-recognition/methodology/subscriptions-and-invoicing) for details." + @type period :: %{optional(:end) => integer, optional(:start) => integer} + ) + + ( + @typedoc "Data used to generate a new [Price](https://stripe.com/docs/api/prices) object inline." + @type price_data :: %{ + optional(:currency) => binary, + optional(:product) => binary, + optional(:tax_behavior) => :exclusive | :inclusive | :unspecified, + optional(:unit_amount) => integer, + optional(:unit_amount_decimal) => binary + } + ) + + ( + nil + + @doc "

Returns a list of your invoice items. Invoice items are returned sorted by creation date, with the most recently created invoice items appearing first.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/invoiceitems`\n" + ( + @spec list( + params :: %{ + optional(:created) => created | integer, + optional(:customer) => binary, + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:invoice) => binary, + optional(:limit) => integer, + optional(:pending) => boolean, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.Invoiceitem.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/invoiceitems", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Creates an item to be added to a draft invoice (up to 250 items per invoice). If no invoice is specified, the item will be on the next invoice created for the customer specified.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/invoiceitems`\n" + ( + @spec create( + params :: %{ + optional(:amount) => integer, + optional(:currency) => binary, + optional(:customer) => binary, + optional(:description) => binary, + optional(:discountable) => boolean, + optional(:discounts) => list(discounts) | binary, + optional(:expand) => list(binary), + optional(:invoice) => binary, + optional(:metadata) => %{optional(binary) => binary} | binary, + optional(:period) => period, + optional(:price) => binary, + optional(:price_data) => price_data, + optional(:quantity) => integer, + optional(:subscription) => binary, + optional(:tax_behavior) => :exclusive | :inclusive | :unspecified, + optional(:tax_code) => binary | binary, + optional(:tax_rates) => list(binary), + optional(:unit_amount) => integer, + optional(:unit_amount_decimal) => binary + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.Invoiceitem.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/invoiceitems", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves the invoice item with the given ID.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/invoiceitems/{invoiceitem}`\n" + ( + @spec retrieve( + invoiceitem :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: {:ok, Stripe.Invoiceitem.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def retrieve(invoiceitem, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/invoiceitems/{invoiceitem}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "invoiceitem", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "invoiceitem", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [invoiceitem] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Updates the amount or description of an invoice item on an upcoming invoice. Updating an invoice item is only possible before the invoice it’s attached to is closed.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/invoiceitems/{invoiceitem}`\n" + ( + @spec update( + invoiceitem :: binary(), + params :: %{ + optional(:amount) => integer, + optional(:description) => binary, + optional(:discountable) => boolean, + optional(:discounts) => list(discounts) | binary, + optional(:expand) => list(binary), + optional(:metadata) => %{optional(binary) => binary} | binary, + optional(:period) => period, + optional(:price) => binary, + optional(:price_data) => price_data, + optional(:quantity) => integer, + optional(:tax_behavior) => :exclusive | :inclusive | :unspecified, + optional(:tax_code) => binary | binary, + optional(:tax_rates) => list(binary) | binary, + optional(:unit_amount) => integer, + optional(:unit_amount_decimal) => binary + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.Invoiceitem.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def update(invoiceitem, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/invoiceitems/{invoiceitem}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "invoiceitem", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "invoiceitem", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [invoiceitem] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Deletes an invoice item, removing it from an invoice. Deleting invoice items is only possible when they’re not attached to invoices, or if it’s attached to a draft invoice.

\n\n#### Details\n\n * Method: `delete`\n * Path: `/v1/invoiceitems/{invoiceitem}`\n" + ( + @spec delete(invoiceitem :: binary(), opts :: Keyword.t()) :: + {:ok, Stripe.DeletedInvoiceitem.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def delete(invoiceitem, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/invoiceitems/{invoiceitem}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "invoiceitem", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "invoiceitem", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [invoiceitem] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_method(:delete) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/issuing__authorization.ex b/lib/generated/issuing__authorization.ex new file mode 100644 index 00000000..1c8d5a4e --- /dev/null +++ b/lib/generated/issuing__authorization.ex @@ -0,0 +1,290 @@ +defmodule Stripe.Issuing.Authorization do + use Stripe.Entity + + @moduledoc "When an [issued card](https://stripe.com/docs/issuing) is used to make a purchase, an Issuing `Authorization`\nobject is created. [Authorizations](https://stripe.com/docs/issuing/purchases/authorizations) must be approved for the\npurchase to be completed successfully.\n\nRelated guide: [Issued card authorizations](https://stripe.com/docs/issuing/purchases/authorizations)" + ( + defstruct [ + :amount, + :amount_details, + :approved, + :authorization_method, + :balance_transactions, + :card, + :cardholder, + :created, + :currency, + :id, + :livemode, + :merchant_amount, + :merchant_currency, + :merchant_data, + :metadata, + :network_data, + :object, + :pending_request, + :request_history, + :status, + :transactions, + :treasury, + :verification_data, + :wallet + ] + + @typedoc "The `issuing.authorization` type.\n\n * `amount` The total amount that was authorized or rejected. This amount is in the card's currency and in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal).\n * `amount_details` Detailed breakdown of amount components. These amounts are denominated in `currency` and in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal).\n * `approved` Whether the authorization has been approved.\n * `authorization_method` How the card details were provided.\n * `balance_transactions` List of balance transactions associated with this authorization.\n * `card` \n * `cardholder` The cardholder to whom this authorization belongs.\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `currency` Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).\n * `id` Unique identifier for the object.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `merchant_amount` The total amount that was authorized or rejected. This amount is in the `merchant_currency` and in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal).\n * `merchant_currency` The currency that was presented to the cardholder for the authorization. Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).\n * `merchant_data` \n * `metadata` Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.\n * `network_data` Details about the authorization, such as identifiers, set by the card network.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `pending_request` The pending authorization request. This field will only be non-null during an `issuing_authorization.request` webhook.\n * `request_history` History of every time a `pending_request` authorization was approved/declined, either by you directly or by Stripe (e.g. based on your spending_controls). If the merchant changes the authorization by performing an incremental authorization, you can look at this field to see the previous requests for the authorization. This field can be helpful in determining why a given authorization was approved/declined.\n * `status` The current status of the authorization in its lifecycle.\n * `transactions` List of [transactions](https://stripe.com/docs/api/issuing/transactions) associated with this authorization.\n * `treasury` [Treasury](https://stripe.com/docs/api/treasury) details related to this authorization if it was created on a [FinancialAccount](https://stripe.com/docs/api/treasury/financial_accounts).\n * `verification_data` \n * `wallet` The digital wallet used for this transaction. One of `apple_pay`, `google_pay`, or `samsung_pay`. Will populate as `null` when no digital wallet was utilized.\n" + @type t :: %__MODULE__{ + amount: integer, + amount_details: term | nil, + approved: boolean, + authorization_method: binary, + balance_transactions: term, + card: Stripe.Issuing.Card.t(), + cardholder: (binary | Stripe.Issuing.Cardholder.t()) | nil, + created: integer, + currency: binary, + id: binary, + livemode: boolean, + merchant_amount: integer, + merchant_currency: binary, + merchant_data: term, + metadata: term, + network_data: term | nil, + object: binary, + pending_request: term | nil, + request_history: term, + status: binary, + transactions: term, + treasury: term | nil, + verification_data: term, + wallet: binary | nil + } + ) + + ( + @typedoc nil + @type created :: %{ + optional(:gt) => integer, + optional(:gte) => integer, + optional(:lt) => integer, + optional(:lte) => integer + } + ) + + ( + nil + + @doc "

Returns a list of Issuing Authorization objects. The objects are sorted in descending order by creation date, with the most recently created object appearing first.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/issuing/authorizations`\n" + ( + @spec list( + params :: %{ + optional(:card) => binary, + optional(:cardholder) => binary, + optional(:created) => created | integer, + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:starting_after) => binary, + optional(:status) => :closed | :pending | :reversed + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.Issuing.Authorization.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/issuing/authorizations", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves an Issuing Authorization object.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/issuing/authorizations/{authorization}`\n" + ( + @spec retrieve( + authorization :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Issuing.Authorization.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def retrieve(authorization, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/issuing/authorizations/{authorization}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "authorization", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "authorization", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [authorization] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Updates the specified Issuing Authorization object by setting the values of the parameters passed. Any parameters not provided will be left unchanged.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/issuing/authorizations/{authorization}`\n" + ( + @spec update( + authorization :: binary(), + params :: %{ + optional(:expand) => list(binary), + optional(:metadata) => %{optional(binary) => binary} | binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Issuing.Authorization.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def update(authorization, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/issuing/authorizations/{authorization}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "authorization", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "authorization", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [authorization] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Approves a pending Issuing Authorization object. This request should be made within the timeout window of the real-time authorization flow. \nYou can also respond directly to the webhook request to approve an authorization (preferred). More details can be found here.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/issuing/authorizations/{authorization}/approve`\n" + ( + @spec approve( + authorization :: binary(), + params :: %{ + optional(:amount) => integer, + optional(:expand) => list(binary), + optional(:metadata) => %{optional(binary) => binary} | binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Issuing.Authorization.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def approve(authorization, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/issuing/authorizations/{authorization}/approve", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "authorization", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "authorization", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [authorization] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Declines a pending Issuing Authorization object. This request should be made within the timeout window of the real time authorization flow.\nYou can also respond directly to the webhook request to decline an authorization (preferred). More details can be found here.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/issuing/authorizations/{authorization}/decline`\n" + ( + @spec decline( + authorization :: binary(), + params :: %{ + optional(:expand) => list(binary), + optional(:metadata) => %{optional(binary) => binary} | binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Issuing.Authorization.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def decline(authorization, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/issuing/authorizations/{authorization}/decline", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "authorization", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "authorization", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [authorization] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/issuing__card.ex b/lib/generated/issuing__card.ex new file mode 100644 index 00000000..8122945e --- /dev/null +++ b/lib/generated/issuing__card.ex @@ -0,0 +1,1343 @@ +defmodule Stripe.Issuing.Card do + use Stripe.Entity + + @moduledoc "You can [create physical or virtual cards](https://stripe.com/docs/issuing/cards) that are issued to cardholders." + ( + defstruct [ + :brand, + :cancellation_reason, + :cardholder, + :created, + :currency, + :cvc, + :exp_month, + :exp_year, + :financial_account, + :id, + :last4, + :livemode, + :metadata, + :number, + :object, + :replaced_by, + :replacement_for, + :replacement_reason, + :shipping, + :spending_controls, + :status, + :type, + :wallets + ] + + @typedoc "The `issuing.card` type.\n\n * `brand` The brand of the card.\n * `cancellation_reason` The reason why the card was canceled.\n * `cardholder` \n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `currency` Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Supported currencies are `usd` in the US, `eur` in the EU, and `gbp` in the UK.\n * `cvc` The card's CVC. For security reasons, this is only available for virtual cards, and will be omitted unless you explicitly request it with [the `expand` parameter](https://stripe.com/docs/api/expanding_objects). Additionally, it's only available via the [\"Retrieve a card\" endpoint](https://stripe.com/docs/api/issuing/cards/retrieve), not via \"List all cards\" or any other endpoint.\n * `exp_month` The expiration month of the card.\n * `exp_year` The expiration year of the card.\n * `financial_account` The financial account this card is attached to.\n * `id` Unique identifier for the object.\n * `last4` The last 4 digits of the card number.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `metadata` Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.\n * `number` The full unredacted card number. For security reasons, this is only available for virtual cards, and will be omitted unless you explicitly request it with [the `expand` parameter](https://stripe.com/docs/api/expanding_objects). Additionally, it's only available via the [\"Retrieve a card\" endpoint](https://stripe.com/docs/api/issuing/cards/retrieve), not via \"List all cards\" or any other endpoint.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `replaced_by` The latest card that replaces this card, if any.\n * `replacement_for` The card this card replaces, if any.\n * `replacement_reason` The reason why the previous card needed to be replaced.\n * `shipping` Where and how the card will be shipped.\n * `spending_controls` \n * `status` Whether authorizations can be approved on this card. May be blocked from activating cards depending on past-due Cardholder requirements. Defaults to `inactive`.\n * `type` The type of the card.\n * `wallets` Information relating to digital wallets (like Apple Pay and Google Pay).\n" + @type t :: %__MODULE__{ + brand: binary, + cancellation_reason: binary | nil, + cardholder: Stripe.Issuing.Cardholder.t(), + created: integer, + currency: binary, + cvc: binary, + exp_month: integer, + exp_year: integer, + financial_account: binary | nil, + id: binary, + last4: binary, + livemode: boolean, + metadata: term, + number: binary, + object: binary, + replaced_by: (binary | Stripe.Issuing.Card.t()) | nil, + replacement_for: (binary | Stripe.Issuing.Card.t()) | nil, + replacement_reason: binary | nil, + shipping: term | nil, + spending_controls: term, + status: binary, + type: binary, + wallets: term | nil + } + ) + + ( + @typedoc "The address that the card is shipped to." + @type address :: %{ + optional(:city) => binary, + optional(:country) => binary, + optional(:line1) => binary, + optional(:line2) => binary, + optional(:postal_code) => binary, + optional(:state) => binary + } + ) + + ( + @typedoc nil + @type created :: %{ + optional(:gt) => integer, + optional(:gte) => integer, + optional(:lt) => integer, + optional(:lte) => integer + } + ) + + ( + @typedoc "Customs information for the shipment." + @type customs :: %{optional(:eori_number) => binary} + ) + + ( + @typedoc "The desired new PIN for this card." + @type pin :: %{optional(:encrypted_number) => binary} + ) + + ( + @typedoc "The address where the card will be shipped." + @type shipping :: %{ + optional(:address) => address, + optional(:customs) => customs, + optional(:name) => binary, + optional(:phone_number) => binary, + optional(:require_signature) => boolean, + optional(:service) => :express | :priority | :standard, + optional(:type) => :bulk | :individual + } + ) + + ( + @typedoc "Rules that control spending for this card. Refer to our [documentation](https://stripe.com/docs/issuing/controls/spending-controls) for more details." + @type spending_controls :: %{ + optional(:allowed_categories) => + list( + :ac_refrigeration_repair + | :accounting_bookkeeping_services + | :advertising_services + | :agricultural_cooperative + | :airlines_air_carriers + | :airports_flying_fields + | :ambulance_services + | :amusement_parks_carnivals + | :antique_reproductions + | :antique_shops + | :aquariums + | :architectural_surveying_services + | :art_dealers_and_galleries + | :artists_supply_and_craft_shops + | :auto_and_home_supply_stores + | :auto_body_repair_shops + | :auto_paint_shops + | :auto_service_shops + | :automated_cash_disburse + | :automated_fuel_dispensers + | :automobile_associations + | :automotive_parts_and_accessories_stores + | :automotive_tire_stores + | :bail_and_bond_payments + | :bakeries + | :bands_orchestras + | :barber_and_beauty_shops + | :betting_casino_gambling + | :bicycle_shops + | :billiard_pool_establishments + | :boat_dealers + | :boat_rentals_and_leases + | :book_stores + | :books_periodicals_and_newspapers + | :bowling_alleys + | :bus_lines + | :business_secretarial_schools + | :buying_shopping_services + | :cable_satellite_and_other_pay_television_and_radio + | :camera_and_photographic_supply_stores + | :candy_nut_and_confectionery_stores + | :car_and_truck_dealers_new_used + | :car_and_truck_dealers_used_only + | :car_rental_agencies + | :car_washes + | :carpentry_services + | :carpet_upholstery_cleaning + | :caterers + | :charitable_and_social_service_organizations_fundraising + | :chemicals_and_allied_products + | :child_care_services + | :childrens_and_infants_wear_stores + | :chiropodists_podiatrists + | :chiropractors + | :cigar_stores_and_stands + | :civic_social_fraternal_associations + | :cleaning_and_maintenance + | :clothing_rental + | :colleges_universities + | :commercial_equipment + | :commercial_footwear + | :commercial_photography_art_and_graphics + | :commuter_transport_and_ferries + | :computer_network_services + | :computer_programming + | :computer_repair + | :computer_software_stores + | :computers_peripherals_and_software + | :concrete_work_services + | :construction_materials + | :consulting_public_relations + | :correspondence_schools + | :cosmetic_stores + | :counseling_services + | :country_clubs + | :courier_services + | :court_costs + | :credit_reporting_agencies + | :cruise_lines + | :dairy_products_stores + | :dance_hall_studios_schools + | :dating_escort_services + | :dentists_orthodontists + | :department_stores + | :detective_agencies + | :digital_goods_applications + | :digital_goods_games + | :digital_goods_large_volume + | :digital_goods_media + | :direct_marketing_catalog_merchant + | :direct_marketing_combination_catalog_and_retail_merchant + | :direct_marketing_inbound_telemarketing + | :direct_marketing_insurance_services + | :direct_marketing_other + | :direct_marketing_outbound_telemarketing + | :direct_marketing_subscription + | :direct_marketing_travel + | :discount_stores + | :doctors + | :door_to_door_sales + | :drapery_window_covering_and_upholstery_stores + | :drinking_places + | :drug_stores_and_pharmacies + | :drugs_drug_proprietaries_and_druggist_sundries + | :dry_cleaners + | :durable_goods + | :duty_free_stores + | :eating_places_restaurants + | :educational_services + | :electric_razor_stores + | :electric_vehicle_charging + | :electrical_parts_and_equipment + | :electrical_services + | :electronics_repair_shops + | :electronics_stores + | :elementary_secondary_schools + | :emergency_services_gcas_visa_use_only + | :employment_temp_agencies + | :equipment_rental + | :exterminating_services + | :family_clothing_stores + | :fast_food_restaurants + | :financial_institutions + | :fines_government_administrative_entities + | :fireplace_fireplace_screens_and_accessories_stores + | :floor_covering_stores + | :florists + | :florists_supplies_nursery_stock_and_flowers + | :freezer_and_locker_meat_provisioners + | :fuel_dealers_non_automotive + | :funeral_services_crematories + | :furniture_home_furnishings_and_equipment_stores_except_appliances + | :furniture_repair_refinishing + | :furriers_and_fur_shops + | :general_services + | :gift_card_novelty_and_souvenir_shops + | :glass_paint_and_wallpaper_stores + | :glassware_crystal_stores + | :golf_courses_public + | :government_licensed_horse_dog_racing_us_region_only + | :government_licensed_online_casions_online_gambling_us_region_only + | :government_owned_lotteries_non_us_region + | :government_owned_lotteries_us_region_only + | :government_services + | :grocery_stores_supermarkets + | :hardware_equipment_and_supplies + | :hardware_stores + | :health_and_beauty_spas + | :hearing_aids_sales_and_supplies + | :heating_plumbing_a_c + | :hobby_toy_and_game_shops + | :home_supply_warehouse_stores + | :hospitals + | :hotels_motels_and_resorts + | :household_appliance_stores + | :industrial_supplies + | :information_retrieval_services + | :insurance_default + | :insurance_underwriting_premiums + | :intra_company_purchases + | :jewelry_stores_watches_clocks_and_silverware_stores + | :landscaping_services + | :laundries + | :laundry_cleaning_services + | :legal_services_attorneys + | :luggage_and_leather_goods_stores + | :lumber_building_materials_stores + | :manual_cash_disburse + | :marinas_service_and_supplies + | :marketplaces + | :masonry_stonework_and_plaster + | :massage_parlors + | :medical_and_dental_labs + | :medical_dental_ophthalmic_and_hospital_equipment_and_supplies + | :medical_services + | :membership_organizations + | :mens_and_boys_clothing_and_accessories_stores + | :mens_womens_clothing_stores + | :metal_service_centers + | :miscellaneous + | :miscellaneous_apparel_and_accessory_shops + | :miscellaneous_auto_dealers + | :miscellaneous_business_services + | :miscellaneous_food_stores + | :miscellaneous_general_merchandise + | :miscellaneous_general_services + | :miscellaneous_home_furnishing_specialty_stores + | :miscellaneous_publishing_and_printing + | :miscellaneous_recreation_services + | :miscellaneous_repair_shops + | :miscellaneous_specialty_retail + | :mobile_home_dealers + | :motion_picture_theaters + | :motor_freight_carriers_and_trucking + | :motor_homes_dealers + | :motor_vehicle_supplies_and_new_parts + | :motorcycle_shops_and_dealers + | :motorcycle_shops_dealers + | :music_stores_musical_instruments_pianos_and_sheet_music + | :news_dealers_and_newsstands + | :non_fi_money_orders + | :non_fi_stored_value_card_purchase_load + | :nondurable_goods + | :nurseries_lawn_and_garden_supply_stores + | :nursing_personal_care + | :office_and_commercial_furniture + | :opticians_eyeglasses + | :optometrists_ophthalmologist + | :orthopedic_goods_prosthetic_devices + | :osteopaths + | :package_stores_beer_wine_and_liquor + | :paints_varnishes_and_supplies + | :parking_lots_garages + | :passenger_railways + | :pawn_shops + | :pet_shops_pet_food_and_supplies + | :petroleum_and_petroleum_products + | :photo_developing + | :photographic_photocopy_microfilm_equipment_and_supplies + | :photographic_studios + | :picture_video_production + | :piece_goods_notions_and_other_dry_goods + | :plumbing_heating_equipment_and_supplies + | :political_organizations + | :postal_services_government_only + | :precious_stones_and_metals_watches_and_jewelry + | :professional_services + | :public_warehousing_and_storage + | :quick_copy_repro_and_blueprint + | :railroads + | :real_estate_agents_and_managers_rentals + | :record_stores + | :recreational_vehicle_rentals + | :religious_goods_stores + | :religious_organizations + | :roofing_siding_sheet_metal + | :secretarial_support_services + | :security_brokers_dealers + | :service_stations + | :sewing_needlework_fabric_and_piece_goods_stores + | :shoe_repair_hat_cleaning + | :shoe_stores + | :small_appliance_repair + | :snowmobile_dealers + | :special_trade_services + | :specialty_cleaning + | :sporting_goods_stores + | :sporting_recreation_camps + | :sports_and_riding_apparel_stores + | :sports_clubs_fields + | :stamp_and_coin_stores + | :stationary_office_supplies_printing_and_writing_paper + | :stationery_stores_office_and_school_supply_stores + | :swimming_pools_sales + | :t_ui_travel_germany + | :tailors_alterations + | :tax_payments_government_agencies + | :tax_preparation_services + | :taxicabs_limousines + | :telecommunication_equipment_and_telephone_sales + | :telecommunication_services + | :telegraph_services + | :tent_and_awning_shops + | :testing_laboratories + | :theatrical_ticket_agencies + | :timeshares + | :tire_retreading_and_repair + | :tolls_bridge_fees + | :tourist_attractions_and_exhibits + | :towing_services + | :trailer_parks_campgrounds + | :transportation_services + | :travel_agencies_tour_operators + | :truck_stop_iteration + | :truck_utility_trailer_rentals + | :typesetting_plate_making_and_related_services + | :typewriter_stores + | :u_s_federal_government_agencies_or_departments + | :uniforms_commercial_clothing + | :used_merchandise_and_secondhand_stores + | :utilities + | :variety_stores + | :veterinary_services + | :video_amusement_game_supplies + | :video_game_arcades + | :video_tape_rental_stores + | :vocational_trade_schools + | :watch_jewelry_repair + | :welding_repair + | :wholesale_clubs + | :wig_and_toupee_stores + | :wires_money_orders + | :womens_accessory_and_specialty_shops + | :womens_ready_to_wear_stores + | :wrecking_and_salvage_yards + ), + optional(:blocked_categories) => + list( + :ac_refrigeration_repair + | :accounting_bookkeeping_services + | :advertising_services + | :agricultural_cooperative + | :airlines_air_carriers + | :airports_flying_fields + | :ambulance_services + | :amusement_parks_carnivals + | :antique_reproductions + | :antique_shops + | :aquariums + | :architectural_surveying_services + | :art_dealers_and_galleries + | :artists_supply_and_craft_shops + | :auto_and_home_supply_stores + | :auto_body_repair_shops + | :auto_paint_shops + | :auto_service_shops + | :automated_cash_disburse + | :automated_fuel_dispensers + | :automobile_associations + | :automotive_parts_and_accessories_stores + | :automotive_tire_stores + | :bail_and_bond_payments + | :bakeries + | :bands_orchestras + | :barber_and_beauty_shops + | :betting_casino_gambling + | :bicycle_shops + | :billiard_pool_establishments + | :boat_dealers + | :boat_rentals_and_leases + | :book_stores + | :books_periodicals_and_newspapers + | :bowling_alleys + | :bus_lines + | :business_secretarial_schools + | :buying_shopping_services + | :cable_satellite_and_other_pay_television_and_radio + | :camera_and_photographic_supply_stores + | :candy_nut_and_confectionery_stores + | :car_and_truck_dealers_new_used + | :car_and_truck_dealers_used_only + | :car_rental_agencies + | :car_washes + | :carpentry_services + | :carpet_upholstery_cleaning + | :caterers + | :charitable_and_social_service_organizations_fundraising + | :chemicals_and_allied_products + | :child_care_services + | :childrens_and_infants_wear_stores + | :chiropodists_podiatrists + | :chiropractors + | :cigar_stores_and_stands + | :civic_social_fraternal_associations + | :cleaning_and_maintenance + | :clothing_rental + | :colleges_universities + | :commercial_equipment + | :commercial_footwear + | :commercial_photography_art_and_graphics + | :commuter_transport_and_ferries + | :computer_network_services + | :computer_programming + | :computer_repair + | :computer_software_stores + | :computers_peripherals_and_software + | :concrete_work_services + | :construction_materials + | :consulting_public_relations + | :correspondence_schools + | :cosmetic_stores + | :counseling_services + | :country_clubs + | :courier_services + | :court_costs + | :credit_reporting_agencies + | :cruise_lines + | :dairy_products_stores + | :dance_hall_studios_schools + | :dating_escort_services + | :dentists_orthodontists + | :department_stores + | :detective_agencies + | :digital_goods_applications + | :digital_goods_games + | :digital_goods_large_volume + | :digital_goods_media + | :direct_marketing_catalog_merchant + | :direct_marketing_combination_catalog_and_retail_merchant + | :direct_marketing_inbound_telemarketing + | :direct_marketing_insurance_services + | :direct_marketing_other + | :direct_marketing_outbound_telemarketing + | :direct_marketing_subscription + | :direct_marketing_travel + | :discount_stores + | :doctors + | :door_to_door_sales + | :drapery_window_covering_and_upholstery_stores + | :drinking_places + | :drug_stores_and_pharmacies + | :drugs_drug_proprietaries_and_druggist_sundries + | :dry_cleaners + | :durable_goods + | :duty_free_stores + | :eating_places_restaurants + | :educational_services + | :electric_razor_stores + | :electric_vehicle_charging + | :electrical_parts_and_equipment + | :electrical_services + | :electronics_repair_shops + | :electronics_stores + | :elementary_secondary_schools + | :emergency_services_gcas_visa_use_only + | :employment_temp_agencies + | :equipment_rental + | :exterminating_services + | :family_clothing_stores + | :fast_food_restaurants + | :financial_institutions + | :fines_government_administrative_entities + | :fireplace_fireplace_screens_and_accessories_stores + | :floor_covering_stores + | :florists + | :florists_supplies_nursery_stock_and_flowers + | :freezer_and_locker_meat_provisioners + | :fuel_dealers_non_automotive + | :funeral_services_crematories + | :furniture_home_furnishings_and_equipment_stores_except_appliances + | :furniture_repair_refinishing + | :furriers_and_fur_shops + | :general_services + | :gift_card_novelty_and_souvenir_shops + | :glass_paint_and_wallpaper_stores + | :glassware_crystal_stores + | :golf_courses_public + | :government_licensed_horse_dog_racing_us_region_only + | :government_licensed_online_casions_online_gambling_us_region_only + | :government_owned_lotteries_non_us_region + | :government_owned_lotteries_us_region_only + | :government_services + | :grocery_stores_supermarkets + | :hardware_equipment_and_supplies + | :hardware_stores + | :health_and_beauty_spas + | :hearing_aids_sales_and_supplies + | :heating_plumbing_a_c + | :hobby_toy_and_game_shops + | :home_supply_warehouse_stores + | :hospitals + | :hotels_motels_and_resorts + | :household_appliance_stores + | :industrial_supplies + | :information_retrieval_services + | :insurance_default + | :insurance_underwriting_premiums + | :intra_company_purchases + | :jewelry_stores_watches_clocks_and_silverware_stores + | :landscaping_services + | :laundries + | :laundry_cleaning_services + | :legal_services_attorneys + | :luggage_and_leather_goods_stores + | :lumber_building_materials_stores + | :manual_cash_disburse + | :marinas_service_and_supplies + | :marketplaces + | :masonry_stonework_and_plaster + | :massage_parlors + | :medical_and_dental_labs + | :medical_dental_ophthalmic_and_hospital_equipment_and_supplies + | :medical_services + | :membership_organizations + | :mens_and_boys_clothing_and_accessories_stores + | :mens_womens_clothing_stores + | :metal_service_centers + | :miscellaneous + | :miscellaneous_apparel_and_accessory_shops + | :miscellaneous_auto_dealers + | :miscellaneous_business_services + | :miscellaneous_food_stores + | :miscellaneous_general_merchandise + | :miscellaneous_general_services + | :miscellaneous_home_furnishing_specialty_stores + | :miscellaneous_publishing_and_printing + | :miscellaneous_recreation_services + | :miscellaneous_repair_shops + | :miscellaneous_specialty_retail + | :mobile_home_dealers + | :motion_picture_theaters + | :motor_freight_carriers_and_trucking + | :motor_homes_dealers + | :motor_vehicle_supplies_and_new_parts + | :motorcycle_shops_and_dealers + | :motorcycle_shops_dealers + | :music_stores_musical_instruments_pianos_and_sheet_music + | :news_dealers_and_newsstands + | :non_fi_money_orders + | :non_fi_stored_value_card_purchase_load + | :nondurable_goods + | :nurseries_lawn_and_garden_supply_stores + | :nursing_personal_care + | :office_and_commercial_furniture + | :opticians_eyeglasses + | :optometrists_ophthalmologist + | :orthopedic_goods_prosthetic_devices + | :osteopaths + | :package_stores_beer_wine_and_liquor + | :paints_varnishes_and_supplies + | :parking_lots_garages + | :passenger_railways + | :pawn_shops + | :pet_shops_pet_food_and_supplies + | :petroleum_and_petroleum_products + | :photo_developing + | :photographic_photocopy_microfilm_equipment_and_supplies + | :photographic_studios + | :picture_video_production + | :piece_goods_notions_and_other_dry_goods + | :plumbing_heating_equipment_and_supplies + | :political_organizations + | :postal_services_government_only + | :precious_stones_and_metals_watches_and_jewelry + | :professional_services + | :public_warehousing_and_storage + | :quick_copy_repro_and_blueprint + | :railroads + | :real_estate_agents_and_managers_rentals + | :record_stores + | :recreational_vehicle_rentals + | :religious_goods_stores + | :religious_organizations + | :roofing_siding_sheet_metal + | :secretarial_support_services + | :security_brokers_dealers + | :service_stations + | :sewing_needlework_fabric_and_piece_goods_stores + | :shoe_repair_hat_cleaning + | :shoe_stores + | :small_appliance_repair + | :snowmobile_dealers + | :special_trade_services + | :specialty_cleaning + | :sporting_goods_stores + | :sporting_recreation_camps + | :sports_and_riding_apparel_stores + | :sports_clubs_fields + | :stamp_and_coin_stores + | :stationary_office_supplies_printing_and_writing_paper + | :stationery_stores_office_and_school_supply_stores + | :swimming_pools_sales + | :t_ui_travel_germany + | :tailors_alterations + | :tax_payments_government_agencies + | :tax_preparation_services + | :taxicabs_limousines + | :telecommunication_equipment_and_telephone_sales + | :telecommunication_services + | :telegraph_services + | :tent_and_awning_shops + | :testing_laboratories + | :theatrical_ticket_agencies + | :timeshares + | :tire_retreading_and_repair + | :tolls_bridge_fees + | :tourist_attractions_and_exhibits + | :towing_services + | :trailer_parks_campgrounds + | :transportation_services + | :travel_agencies_tour_operators + | :truck_stop_iteration + | :truck_utility_trailer_rentals + | :typesetting_plate_making_and_related_services + | :typewriter_stores + | :u_s_federal_government_agencies_or_departments + | :uniforms_commercial_clothing + | :used_merchandise_and_secondhand_stores + | :utilities + | :variety_stores + | :veterinary_services + | :video_amusement_game_supplies + | :video_game_arcades + | :video_tape_rental_stores + | :vocational_trade_schools + | :watch_jewelry_repair + | :welding_repair + | :wholesale_clubs + | :wig_and_toupee_stores + | :wires_money_orders + | :womens_accessory_and_specialty_shops + | :womens_ready_to_wear_stores + | :wrecking_and_salvage_yards + ), + optional(:spending_limits) => list(spending_limits) + } + ) + + ( + @typedoc nil + @type spending_limits :: %{ + optional(:amount) => integer, + optional(:categories) => + list( + :ac_refrigeration_repair + | :accounting_bookkeeping_services + | :advertising_services + | :agricultural_cooperative + | :airlines_air_carriers + | :airports_flying_fields + | :ambulance_services + | :amusement_parks_carnivals + | :antique_reproductions + | :antique_shops + | :aquariums + | :architectural_surveying_services + | :art_dealers_and_galleries + | :artists_supply_and_craft_shops + | :auto_and_home_supply_stores + | :auto_body_repair_shops + | :auto_paint_shops + | :auto_service_shops + | :automated_cash_disburse + | :automated_fuel_dispensers + | :automobile_associations + | :automotive_parts_and_accessories_stores + | :automotive_tire_stores + | :bail_and_bond_payments + | :bakeries + | :bands_orchestras + | :barber_and_beauty_shops + | :betting_casino_gambling + | :bicycle_shops + | :billiard_pool_establishments + | :boat_dealers + | :boat_rentals_and_leases + | :book_stores + | :books_periodicals_and_newspapers + | :bowling_alleys + | :bus_lines + | :business_secretarial_schools + | :buying_shopping_services + | :cable_satellite_and_other_pay_television_and_radio + | :camera_and_photographic_supply_stores + | :candy_nut_and_confectionery_stores + | :car_and_truck_dealers_new_used + | :car_and_truck_dealers_used_only + | :car_rental_agencies + | :car_washes + | :carpentry_services + | :carpet_upholstery_cleaning + | :caterers + | :charitable_and_social_service_organizations_fundraising + | :chemicals_and_allied_products + | :child_care_services + | :childrens_and_infants_wear_stores + | :chiropodists_podiatrists + | :chiropractors + | :cigar_stores_and_stands + | :civic_social_fraternal_associations + | :cleaning_and_maintenance + | :clothing_rental + | :colleges_universities + | :commercial_equipment + | :commercial_footwear + | :commercial_photography_art_and_graphics + | :commuter_transport_and_ferries + | :computer_network_services + | :computer_programming + | :computer_repair + | :computer_software_stores + | :computers_peripherals_and_software + | :concrete_work_services + | :construction_materials + | :consulting_public_relations + | :correspondence_schools + | :cosmetic_stores + | :counseling_services + | :country_clubs + | :courier_services + | :court_costs + | :credit_reporting_agencies + | :cruise_lines + | :dairy_products_stores + | :dance_hall_studios_schools + | :dating_escort_services + | :dentists_orthodontists + | :department_stores + | :detective_agencies + | :digital_goods_applications + | :digital_goods_games + | :digital_goods_large_volume + | :digital_goods_media + | :direct_marketing_catalog_merchant + | :direct_marketing_combination_catalog_and_retail_merchant + | :direct_marketing_inbound_telemarketing + | :direct_marketing_insurance_services + | :direct_marketing_other + | :direct_marketing_outbound_telemarketing + | :direct_marketing_subscription + | :direct_marketing_travel + | :discount_stores + | :doctors + | :door_to_door_sales + | :drapery_window_covering_and_upholstery_stores + | :drinking_places + | :drug_stores_and_pharmacies + | :drugs_drug_proprietaries_and_druggist_sundries + | :dry_cleaners + | :durable_goods + | :duty_free_stores + | :eating_places_restaurants + | :educational_services + | :electric_razor_stores + | :electric_vehicle_charging + | :electrical_parts_and_equipment + | :electrical_services + | :electronics_repair_shops + | :electronics_stores + | :elementary_secondary_schools + | :emergency_services_gcas_visa_use_only + | :employment_temp_agencies + | :equipment_rental + | :exterminating_services + | :family_clothing_stores + | :fast_food_restaurants + | :financial_institutions + | :fines_government_administrative_entities + | :fireplace_fireplace_screens_and_accessories_stores + | :floor_covering_stores + | :florists + | :florists_supplies_nursery_stock_and_flowers + | :freezer_and_locker_meat_provisioners + | :fuel_dealers_non_automotive + | :funeral_services_crematories + | :furniture_home_furnishings_and_equipment_stores_except_appliances + | :furniture_repair_refinishing + | :furriers_and_fur_shops + | :general_services + | :gift_card_novelty_and_souvenir_shops + | :glass_paint_and_wallpaper_stores + | :glassware_crystal_stores + | :golf_courses_public + | :government_licensed_horse_dog_racing_us_region_only + | :government_licensed_online_casions_online_gambling_us_region_only + | :government_owned_lotteries_non_us_region + | :government_owned_lotteries_us_region_only + | :government_services + | :grocery_stores_supermarkets + | :hardware_equipment_and_supplies + | :hardware_stores + | :health_and_beauty_spas + | :hearing_aids_sales_and_supplies + | :heating_plumbing_a_c + | :hobby_toy_and_game_shops + | :home_supply_warehouse_stores + | :hospitals + | :hotels_motels_and_resorts + | :household_appliance_stores + | :industrial_supplies + | :information_retrieval_services + | :insurance_default + | :insurance_underwriting_premiums + | :intra_company_purchases + | :jewelry_stores_watches_clocks_and_silverware_stores + | :landscaping_services + | :laundries + | :laundry_cleaning_services + | :legal_services_attorneys + | :luggage_and_leather_goods_stores + | :lumber_building_materials_stores + | :manual_cash_disburse + | :marinas_service_and_supplies + | :marketplaces + | :masonry_stonework_and_plaster + | :massage_parlors + | :medical_and_dental_labs + | :medical_dental_ophthalmic_and_hospital_equipment_and_supplies + | :medical_services + | :membership_organizations + | :mens_and_boys_clothing_and_accessories_stores + | :mens_womens_clothing_stores + | :metal_service_centers + | :miscellaneous + | :miscellaneous_apparel_and_accessory_shops + | :miscellaneous_auto_dealers + | :miscellaneous_business_services + | :miscellaneous_food_stores + | :miscellaneous_general_merchandise + | :miscellaneous_general_services + | :miscellaneous_home_furnishing_specialty_stores + | :miscellaneous_publishing_and_printing + | :miscellaneous_recreation_services + | :miscellaneous_repair_shops + | :miscellaneous_specialty_retail + | :mobile_home_dealers + | :motion_picture_theaters + | :motor_freight_carriers_and_trucking + | :motor_homes_dealers + | :motor_vehicle_supplies_and_new_parts + | :motorcycle_shops_and_dealers + | :motorcycle_shops_dealers + | :music_stores_musical_instruments_pianos_and_sheet_music + | :news_dealers_and_newsstands + | :non_fi_money_orders + | :non_fi_stored_value_card_purchase_load + | :nondurable_goods + | :nurseries_lawn_and_garden_supply_stores + | :nursing_personal_care + | :office_and_commercial_furniture + | :opticians_eyeglasses + | :optometrists_ophthalmologist + | :orthopedic_goods_prosthetic_devices + | :osteopaths + | :package_stores_beer_wine_and_liquor + | :paints_varnishes_and_supplies + | :parking_lots_garages + | :passenger_railways + | :pawn_shops + | :pet_shops_pet_food_and_supplies + | :petroleum_and_petroleum_products + | :photo_developing + | :photographic_photocopy_microfilm_equipment_and_supplies + | :photographic_studios + | :picture_video_production + | :piece_goods_notions_and_other_dry_goods + | :plumbing_heating_equipment_and_supplies + | :political_organizations + | :postal_services_government_only + | :precious_stones_and_metals_watches_and_jewelry + | :professional_services + | :public_warehousing_and_storage + | :quick_copy_repro_and_blueprint + | :railroads + | :real_estate_agents_and_managers_rentals + | :record_stores + | :recreational_vehicle_rentals + | :religious_goods_stores + | :religious_organizations + | :roofing_siding_sheet_metal + | :secretarial_support_services + | :security_brokers_dealers + | :service_stations + | :sewing_needlework_fabric_and_piece_goods_stores + | :shoe_repair_hat_cleaning + | :shoe_stores + | :small_appliance_repair + | :snowmobile_dealers + | :special_trade_services + | :specialty_cleaning + | :sporting_goods_stores + | :sporting_recreation_camps + | :sports_and_riding_apparel_stores + | :sports_clubs_fields + | :stamp_and_coin_stores + | :stationary_office_supplies_printing_and_writing_paper + | :stationery_stores_office_and_school_supply_stores + | :swimming_pools_sales + | :t_ui_travel_germany + | :tailors_alterations + | :tax_payments_government_agencies + | :tax_preparation_services + | :taxicabs_limousines + | :telecommunication_equipment_and_telephone_sales + | :telecommunication_services + | :telegraph_services + | :tent_and_awning_shops + | :testing_laboratories + | :theatrical_ticket_agencies + | :timeshares + | :tire_retreading_and_repair + | :tolls_bridge_fees + | :tourist_attractions_and_exhibits + | :towing_services + | :trailer_parks_campgrounds + | :transportation_services + | :travel_agencies_tour_operators + | :truck_stop_iteration + | :truck_utility_trailer_rentals + | :typesetting_plate_making_and_related_services + | :typewriter_stores + | :u_s_federal_government_agencies_or_departments + | :uniforms_commercial_clothing + | :used_merchandise_and_secondhand_stores + | :utilities + | :variety_stores + | :veterinary_services + | :video_amusement_game_supplies + | :video_game_arcades + | :video_tape_rental_stores + | :vocational_trade_schools + | :watch_jewelry_repair + | :welding_repair + | :wholesale_clubs + | :wig_and_toupee_stores + | :wires_money_orders + | :womens_accessory_and_specialty_shops + | :womens_ready_to_wear_stores + | :wrecking_and_salvage_yards + ), + optional(:interval) => + :all_time | :daily | :monthly | :per_authorization | :weekly | :yearly + } + ) + + ( + nil + + @doc "

Returns a list of Issuing Card objects. The objects are sorted in descending order by creation date, with the most recently created object appearing first.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/issuing/cards`\n" + ( + @spec list( + params :: %{ + optional(:cardholder) => binary, + optional(:created) => created | integer, + optional(:ending_before) => binary, + optional(:exp_month) => integer, + optional(:exp_year) => integer, + optional(:expand) => list(binary), + optional(:last4) => binary, + optional(:limit) => integer, + optional(:starting_after) => binary, + optional(:status) => :active | :canceled | :inactive, + optional(:type) => :physical | :virtual + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.Issuing.Card.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/issuing/cards", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Creates an Issuing Card object.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/issuing/cards`\n" + ( + @spec create( + params :: %{ + optional(:cardholder) => binary, + optional(:currency) => binary, + optional(:expand) => list(binary), + optional(:financial_account) => binary, + optional(:metadata) => %{optional(binary) => binary}, + optional(:replacement_for) => binary, + optional(:replacement_reason) => :damaged | :expired | :lost | :stolen, + optional(:shipping) => shipping, + optional(:spending_controls) => spending_controls, + optional(:status) => :active | :inactive, + optional(:type) => :physical | :virtual + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Issuing.Card.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/issuing/cards", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves an Issuing Card object.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/issuing/cards/{card}`\n" + ( + @spec retrieve( + card :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Issuing.Card.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def retrieve(card, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/issuing/cards/{card}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "card", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "card", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [card] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Updates the specified Issuing Card object by setting the values of the parameters passed. Any parameters not provided will be left unchanged.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/issuing/cards/{card}`\n" + ( + @spec update( + card :: binary(), + params :: %{ + optional(:cancellation_reason) => :lost | :stolen, + optional(:expand) => list(binary), + optional(:metadata) => %{optional(binary) => binary} | binary, + optional(:pin) => pin, + optional(:spending_controls) => spending_controls, + optional(:status) => :active | :canceled | :inactive + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Issuing.Card.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def update(card, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/issuing/cards/{card}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "card", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "card", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [card] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Updates the shipping status of the specified Issuing Card object to delivered.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/test_helpers/issuing/cards/{card}/shipping/deliver`\n" + ( + @spec deliver_card( + card :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Issuing.Card.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def deliver_card(card, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/test_helpers/issuing/cards/{card}/shipping/deliver", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "card", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "card", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [card] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Updates the shipping status of the specified Issuing Card object to shipped.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/test_helpers/issuing/cards/{card}/shipping/ship`\n" + ( + @spec ship_card( + card :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Issuing.Card.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def ship_card(card, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/test_helpers/issuing/cards/{card}/shipping/ship", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "card", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "card", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [card] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Updates the shipping status of the specified Issuing Card object to returned.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/test_helpers/issuing/cards/{card}/shipping/return`\n" + ( + @spec return_card( + card :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Issuing.Card.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def return_card(card, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/test_helpers/issuing/cards/{card}/shipping/return", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "card", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "card", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [card] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Updates the shipping status of the specified Issuing Card object to failure.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/test_helpers/issuing/cards/{card}/shipping/fail`\n" + ( + @spec fail_card( + card :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Issuing.Card.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def fail_card(card, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/test_helpers/issuing/cards/{card}/shipping/fail", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "card", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "card", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [card] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/issuing__cardholder.ex b/lib/generated/issuing__cardholder.ex new file mode 100644 index 00000000..19b149bf --- /dev/null +++ b/lib/generated/issuing__cardholder.ex @@ -0,0 +1,1202 @@ +defmodule Stripe.Issuing.Cardholder do + use Stripe.Entity + + @moduledoc "An Issuing `Cardholder` object represents an individual or business entity who is [issued](https://stripe.com/docs/issuing) cards.\n\nRelated guide: [How to create a cardholder](https://stripe.com/docs/issuing/cards#create-cardholder)" + ( + defstruct [ + :billing, + :company, + :created, + :email, + :id, + :individual, + :livemode, + :metadata, + :name, + :object, + :phone_number, + :preferred_locales, + :requirements, + :spending_controls, + :status, + :type + ] + + @typedoc "The `issuing.cardholder` type.\n\n * `billing` \n * `company` Additional information about a `company` cardholder.\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `email` The cardholder's email address.\n * `id` Unique identifier for the object.\n * `individual` Additional information about an `individual` cardholder.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `metadata` Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.\n * `name` The cardholder's name. This will be printed on cards issued to them.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `phone_number` The cardholder's phone number. This is required for all cardholders who will be creating EU cards. See the [3D Secure documentation](https://stripe.com/docs/issuing/3d-secure#when-is-3d-secure-applied) for more details.\n * `preferred_locales` The cardholder’s preferred locales (languages), ordered by preference. Locales can be `de`, `en`, `es`, `fr`, or `it`.\n This changes the language of the [3D Secure flow](https://stripe.com/docs/issuing/3d-secure) and one-time password messages sent to the cardholder.\n * `requirements` \n * `spending_controls` Rules that control spending across this cardholder's cards. Refer to our [documentation](https://stripe.com/docs/issuing/controls/spending-controls) for more details.\n * `status` Specifies whether to permit authorizations on this cardholder's cards.\n * `type` One of `individual` or `company`. See [Choose a cardholder type](https://stripe.com/docs/issuing/other/choose-cardholder) for more details.\n" + @type t :: %__MODULE__{ + billing: term, + company: term | nil, + created: integer, + email: binary | nil, + id: binary, + individual: term | nil, + livemode: boolean, + metadata: term, + name: binary, + object: binary, + phone_number: binary | nil, + preferred_locales: term | nil, + requirements: term, + spending_controls: term | nil, + status: binary, + type: binary + } + ) + + ( + @typedoc "The cardholder’s billing address." + @type address :: %{ + optional(:city) => binary, + optional(:country) => binary, + optional(:line1) => binary, + optional(:line2) => binary, + optional(:postal_code) => binary, + optional(:state) => binary + } + ) + + ( + @typedoc "The cardholder's billing address." + @type billing :: %{optional(:address) => address} + ) + + ( + @typedoc "Information related to the card_issuing program for this cardholder." + @type card_issuing :: %{optional(:user_terms_acceptance) => user_terms_acceptance} + ) + + ( + @typedoc "Additional information about a `company` cardholder." + @type company :: %{optional(:tax_id) => binary} + ) + + ( + @typedoc nil + @type created :: %{ + optional(:gt) => integer, + optional(:gte) => integer, + optional(:lt) => integer, + optional(:lte) => integer + } + ) + + ( + @typedoc "The date of birth of this cardholder." + @type dob :: %{ + optional(:day) => integer, + optional(:month) => integer, + optional(:year) => integer + } + ) + + ( + @typedoc "An identifying document, either a passport or local ID card." + @type document :: %{optional(:back) => binary, optional(:front) => binary} + ) + + ( + @typedoc "Additional information about an `individual` cardholder." + @type individual :: %{ + optional(:card_issuing) => card_issuing, + optional(:dob) => dob, + optional(:first_name) => binary, + optional(:last_name) => binary, + optional(:verification) => verification + } + ) + + ( + @typedoc "Rules that control spending across this cardholder's cards. Refer to our [documentation](https://stripe.com/docs/issuing/controls/spending-controls) for more details." + @type spending_controls :: %{ + optional(:allowed_categories) => + list( + :ac_refrigeration_repair + | :accounting_bookkeeping_services + | :advertising_services + | :agricultural_cooperative + | :airlines_air_carriers + | :airports_flying_fields + | :ambulance_services + | :amusement_parks_carnivals + | :antique_reproductions + | :antique_shops + | :aquariums + | :architectural_surveying_services + | :art_dealers_and_galleries + | :artists_supply_and_craft_shops + | :auto_and_home_supply_stores + | :auto_body_repair_shops + | :auto_paint_shops + | :auto_service_shops + | :automated_cash_disburse + | :automated_fuel_dispensers + | :automobile_associations + | :automotive_parts_and_accessories_stores + | :automotive_tire_stores + | :bail_and_bond_payments + | :bakeries + | :bands_orchestras + | :barber_and_beauty_shops + | :betting_casino_gambling + | :bicycle_shops + | :billiard_pool_establishments + | :boat_dealers + | :boat_rentals_and_leases + | :book_stores + | :books_periodicals_and_newspapers + | :bowling_alleys + | :bus_lines + | :business_secretarial_schools + | :buying_shopping_services + | :cable_satellite_and_other_pay_television_and_radio + | :camera_and_photographic_supply_stores + | :candy_nut_and_confectionery_stores + | :car_and_truck_dealers_new_used + | :car_and_truck_dealers_used_only + | :car_rental_agencies + | :car_washes + | :carpentry_services + | :carpet_upholstery_cleaning + | :caterers + | :charitable_and_social_service_organizations_fundraising + | :chemicals_and_allied_products + | :child_care_services + | :childrens_and_infants_wear_stores + | :chiropodists_podiatrists + | :chiropractors + | :cigar_stores_and_stands + | :civic_social_fraternal_associations + | :cleaning_and_maintenance + | :clothing_rental + | :colleges_universities + | :commercial_equipment + | :commercial_footwear + | :commercial_photography_art_and_graphics + | :commuter_transport_and_ferries + | :computer_network_services + | :computer_programming + | :computer_repair + | :computer_software_stores + | :computers_peripherals_and_software + | :concrete_work_services + | :construction_materials + | :consulting_public_relations + | :correspondence_schools + | :cosmetic_stores + | :counseling_services + | :country_clubs + | :courier_services + | :court_costs + | :credit_reporting_agencies + | :cruise_lines + | :dairy_products_stores + | :dance_hall_studios_schools + | :dating_escort_services + | :dentists_orthodontists + | :department_stores + | :detective_agencies + | :digital_goods_applications + | :digital_goods_games + | :digital_goods_large_volume + | :digital_goods_media + | :direct_marketing_catalog_merchant + | :direct_marketing_combination_catalog_and_retail_merchant + | :direct_marketing_inbound_telemarketing + | :direct_marketing_insurance_services + | :direct_marketing_other + | :direct_marketing_outbound_telemarketing + | :direct_marketing_subscription + | :direct_marketing_travel + | :discount_stores + | :doctors + | :door_to_door_sales + | :drapery_window_covering_and_upholstery_stores + | :drinking_places + | :drug_stores_and_pharmacies + | :drugs_drug_proprietaries_and_druggist_sundries + | :dry_cleaners + | :durable_goods + | :duty_free_stores + | :eating_places_restaurants + | :educational_services + | :electric_razor_stores + | :electric_vehicle_charging + | :electrical_parts_and_equipment + | :electrical_services + | :electronics_repair_shops + | :electronics_stores + | :elementary_secondary_schools + | :emergency_services_gcas_visa_use_only + | :employment_temp_agencies + | :equipment_rental + | :exterminating_services + | :family_clothing_stores + | :fast_food_restaurants + | :financial_institutions + | :fines_government_administrative_entities + | :fireplace_fireplace_screens_and_accessories_stores + | :floor_covering_stores + | :florists + | :florists_supplies_nursery_stock_and_flowers + | :freezer_and_locker_meat_provisioners + | :fuel_dealers_non_automotive + | :funeral_services_crematories + | :furniture_home_furnishings_and_equipment_stores_except_appliances + | :furniture_repair_refinishing + | :furriers_and_fur_shops + | :general_services + | :gift_card_novelty_and_souvenir_shops + | :glass_paint_and_wallpaper_stores + | :glassware_crystal_stores + | :golf_courses_public + | :government_licensed_horse_dog_racing_us_region_only + | :government_licensed_online_casions_online_gambling_us_region_only + | :government_owned_lotteries_non_us_region + | :government_owned_lotteries_us_region_only + | :government_services + | :grocery_stores_supermarkets + | :hardware_equipment_and_supplies + | :hardware_stores + | :health_and_beauty_spas + | :hearing_aids_sales_and_supplies + | :heating_plumbing_a_c + | :hobby_toy_and_game_shops + | :home_supply_warehouse_stores + | :hospitals + | :hotels_motels_and_resorts + | :household_appliance_stores + | :industrial_supplies + | :information_retrieval_services + | :insurance_default + | :insurance_underwriting_premiums + | :intra_company_purchases + | :jewelry_stores_watches_clocks_and_silverware_stores + | :landscaping_services + | :laundries + | :laundry_cleaning_services + | :legal_services_attorneys + | :luggage_and_leather_goods_stores + | :lumber_building_materials_stores + | :manual_cash_disburse + | :marinas_service_and_supplies + | :marketplaces + | :masonry_stonework_and_plaster + | :massage_parlors + | :medical_and_dental_labs + | :medical_dental_ophthalmic_and_hospital_equipment_and_supplies + | :medical_services + | :membership_organizations + | :mens_and_boys_clothing_and_accessories_stores + | :mens_womens_clothing_stores + | :metal_service_centers + | :miscellaneous + | :miscellaneous_apparel_and_accessory_shops + | :miscellaneous_auto_dealers + | :miscellaneous_business_services + | :miscellaneous_food_stores + | :miscellaneous_general_merchandise + | :miscellaneous_general_services + | :miscellaneous_home_furnishing_specialty_stores + | :miscellaneous_publishing_and_printing + | :miscellaneous_recreation_services + | :miscellaneous_repair_shops + | :miscellaneous_specialty_retail + | :mobile_home_dealers + | :motion_picture_theaters + | :motor_freight_carriers_and_trucking + | :motor_homes_dealers + | :motor_vehicle_supplies_and_new_parts + | :motorcycle_shops_and_dealers + | :motorcycle_shops_dealers + | :music_stores_musical_instruments_pianos_and_sheet_music + | :news_dealers_and_newsstands + | :non_fi_money_orders + | :non_fi_stored_value_card_purchase_load + | :nondurable_goods + | :nurseries_lawn_and_garden_supply_stores + | :nursing_personal_care + | :office_and_commercial_furniture + | :opticians_eyeglasses + | :optometrists_ophthalmologist + | :orthopedic_goods_prosthetic_devices + | :osteopaths + | :package_stores_beer_wine_and_liquor + | :paints_varnishes_and_supplies + | :parking_lots_garages + | :passenger_railways + | :pawn_shops + | :pet_shops_pet_food_and_supplies + | :petroleum_and_petroleum_products + | :photo_developing + | :photographic_photocopy_microfilm_equipment_and_supplies + | :photographic_studios + | :picture_video_production + | :piece_goods_notions_and_other_dry_goods + | :plumbing_heating_equipment_and_supplies + | :political_organizations + | :postal_services_government_only + | :precious_stones_and_metals_watches_and_jewelry + | :professional_services + | :public_warehousing_and_storage + | :quick_copy_repro_and_blueprint + | :railroads + | :real_estate_agents_and_managers_rentals + | :record_stores + | :recreational_vehicle_rentals + | :religious_goods_stores + | :religious_organizations + | :roofing_siding_sheet_metal + | :secretarial_support_services + | :security_brokers_dealers + | :service_stations + | :sewing_needlework_fabric_and_piece_goods_stores + | :shoe_repair_hat_cleaning + | :shoe_stores + | :small_appliance_repair + | :snowmobile_dealers + | :special_trade_services + | :specialty_cleaning + | :sporting_goods_stores + | :sporting_recreation_camps + | :sports_and_riding_apparel_stores + | :sports_clubs_fields + | :stamp_and_coin_stores + | :stationary_office_supplies_printing_and_writing_paper + | :stationery_stores_office_and_school_supply_stores + | :swimming_pools_sales + | :t_ui_travel_germany + | :tailors_alterations + | :tax_payments_government_agencies + | :tax_preparation_services + | :taxicabs_limousines + | :telecommunication_equipment_and_telephone_sales + | :telecommunication_services + | :telegraph_services + | :tent_and_awning_shops + | :testing_laboratories + | :theatrical_ticket_agencies + | :timeshares + | :tire_retreading_and_repair + | :tolls_bridge_fees + | :tourist_attractions_and_exhibits + | :towing_services + | :trailer_parks_campgrounds + | :transportation_services + | :travel_agencies_tour_operators + | :truck_stop_iteration + | :truck_utility_trailer_rentals + | :typesetting_plate_making_and_related_services + | :typewriter_stores + | :u_s_federal_government_agencies_or_departments + | :uniforms_commercial_clothing + | :used_merchandise_and_secondhand_stores + | :utilities + | :variety_stores + | :veterinary_services + | :video_amusement_game_supplies + | :video_game_arcades + | :video_tape_rental_stores + | :vocational_trade_schools + | :watch_jewelry_repair + | :welding_repair + | :wholesale_clubs + | :wig_and_toupee_stores + | :wires_money_orders + | :womens_accessory_and_specialty_shops + | :womens_ready_to_wear_stores + | :wrecking_and_salvage_yards + ), + optional(:blocked_categories) => + list( + :ac_refrigeration_repair + | :accounting_bookkeeping_services + | :advertising_services + | :agricultural_cooperative + | :airlines_air_carriers + | :airports_flying_fields + | :ambulance_services + | :amusement_parks_carnivals + | :antique_reproductions + | :antique_shops + | :aquariums + | :architectural_surveying_services + | :art_dealers_and_galleries + | :artists_supply_and_craft_shops + | :auto_and_home_supply_stores + | :auto_body_repair_shops + | :auto_paint_shops + | :auto_service_shops + | :automated_cash_disburse + | :automated_fuel_dispensers + | :automobile_associations + | :automotive_parts_and_accessories_stores + | :automotive_tire_stores + | :bail_and_bond_payments + | :bakeries + | :bands_orchestras + | :barber_and_beauty_shops + | :betting_casino_gambling + | :bicycle_shops + | :billiard_pool_establishments + | :boat_dealers + | :boat_rentals_and_leases + | :book_stores + | :books_periodicals_and_newspapers + | :bowling_alleys + | :bus_lines + | :business_secretarial_schools + | :buying_shopping_services + | :cable_satellite_and_other_pay_television_and_radio + | :camera_and_photographic_supply_stores + | :candy_nut_and_confectionery_stores + | :car_and_truck_dealers_new_used + | :car_and_truck_dealers_used_only + | :car_rental_agencies + | :car_washes + | :carpentry_services + | :carpet_upholstery_cleaning + | :caterers + | :charitable_and_social_service_organizations_fundraising + | :chemicals_and_allied_products + | :child_care_services + | :childrens_and_infants_wear_stores + | :chiropodists_podiatrists + | :chiropractors + | :cigar_stores_and_stands + | :civic_social_fraternal_associations + | :cleaning_and_maintenance + | :clothing_rental + | :colleges_universities + | :commercial_equipment + | :commercial_footwear + | :commercial_photography_art_and_graphics + | :commuter_transport_and_ferries + | :computer_network_services + | :computer_programming + | :computer_repair + | :computer_software_stores + | :computers_peripherals_and_software + | :concrete_work_services + | :construction_materials + | :consulting_public_relations + | :correspondence_schools + | :cosmetic_stores + | :counseling_services + | :country_clubs + | :courier_services + | :court_costs + | :credit_reporting_agencies + | :cruise_lines + | :dairy_products_stores + | :dance_hall_studios_schools + | :dating_escort_services + | :dentists_orthodontists + | :department_stores + | :detective_agencies + | :digital_goods_applications + | :digital_goods_games + | :digital_goods_large_volume + | :digital_goods_media + | :direct_marketing_catalog_merchant + | :direct_marketing_combination_catalog_and_retail_merchant + | :direct_marketing_inbound_telemarketing + | :direct_marketing_insurance_services + | :direct_marketing_other + | :direct_marketing_outbound_telemarketing + | :direct_marketing_subscription + | :direct_marketing_travel + | :discount_stores + | :doctors + | :door_to_door_sales + | :drapery_window_covering_and_upholstery_stores + | :drinking_places + | :drug_stores_and_pharmacies + | :drugs_drug_proprietaries_and_druggist_sundries + | :dry_cleaners + | :durable_goods + | :duty_free_stores + | :eating_places_restaurants + | :educational_services + | :electric_razor_stores + | :electric_vehicle_charging + | :electrical_parts_and_equipment + | :electrical_services + | :electronics_repair_shops + | :electronics_stores + | :elementary_secondary_schools + | :emergency_services_gcas_visa_use_only + | :employment_temp_agencies + | :equipment_rental + | :exterminating_services + | :family_clothing_stores + | :fast_food_restaurants + | :financial_institutions + | :fines_government_administrative_entities + | :fireplace_fireplace_screens_and_accessories_stores + | :floor_covering_stores + | :florists + | :florists_supplies_nursery_stock_and_flowers + | :freezer_and_locker_meat_provisioners + | :fuel_dealers_non_automotive + | :funeral_services_crematories + | :furniture_home_furnishings_and_equipment_stores_except_appliances + | :furniture_repair_refinishing + | :furriers_and_fur_shops + | :general_services + | :gift_card_novelty_and_souvenir_shops + | :glass_paint_and_wallpaper_stores + | :glassware_crystal_stores + | :golf_courses_public + | :government_licensed_horse_dog_racing_us_region_only + | :government_licensed_online_casions_online_gambling_us_region_only + | :government_owned_lotteries_non_us_region + | :government_owned_lotteries_us_region_only + | :government_services + | :grocery_stores_supermarkets + | :hardware_equipment_and_supplies + | :hardware_stores + | :health_and_beauty_spas + | :hearing_aids_sales_and_supplies + | :heating_plumbing_a_c + | :hobby_toy_and_game_shops + | :home_supply_warehouse_stores + | :hospitals + | :hotels_motels_and_resorts + | :household_appliance_stores + | :industrial_supplies + | :information_retrieval_services + | :insurance_default + | :insurance_underwriting_premiums + | :intra_company_purchases + | :jewelry_stores_watches_clocks_and_silverware_stores + | :landscaping_services + | :laundries + | :laundry_cleaning_services + | :legal_services_attorneys + | :luggage_and_leather_goods_stores + | :lumber_building_materials_stores + | :manual_cash_disburse + | :marinas_service_and_supplies + | :marketplaces + | :masonry_stonework_and_plaster + | :massage_parlors + | :medical_and_dental_labs + | :medical_dental_ophthalmic_and_hospital_equipment_and_supplies + | :medical_services + | :membership_organizations + | :mens_and_boys_clothing_and_accessories_stores + | :mens_womens_clothing_stores + | :metal_service_centers + | :miscellaneous + | :miscellaneous_apparel_and_accessory_shops + | :miscellaneous_auto_dealers + | :miscellaneous_business_services + | :miscellaneous_food_stores + | :miscellaneous_general_merchandise + | :miscellaneous_general_services + | :miscellaneous_home_furnishing_specialty_stores + | :miscellaneous_publishing_and_printing + | :miscellaneous_recreation_services + | :miscellaneous_repair_shops + | :miscellaneous_specialty_retail + | :mobile_home_dealers + | :motion_picture_theaters + | :motor_freight_carriers_and_trucking + | :motor_homes_dealers + | :motor_vehicle_supplies_and_new_parts + | :motorcycle_shops_and_dealers + | :motorcycle_shops_dealers + | :music_stores_musical_instruments_pianos_and_sheet_music + | :news_dealers_and_newsstands + | :non_fi_money_orders + | :non_fi_stored_value_card_purchase_load + | :nondurable_goods + | :nurseries_lawn_and_garden_supply_stores + | :nursing_personal_care + | :office_and_commercial_furniture + | :opticians_eyeglasses + | :optometrists_ophthalmologist + | :orthopedic_goods_prosthetic_devices + | :osteopaths + | :package_stores_beer_wine_and_liquor + | :paints_varnishes_and_supplies + | :parking_lots_garages + | :passenger_railways + | :pawn_shops + | :pet_shops_pet_food_and_supplies + | :petroleum_and_petroleum_products + | :photo_developing + | :photographic_photocopy_microfilm_equipment_and_supplies + | :photographic_studios + | :picture_video_production + | :piece_goods_notions_and_other_dry_goods + | :plumbing_heating_equipment_and_supplies + | :political_organizations + | :postal_services_government_only + | :precious_stones_and_metals_watches_and_jewelry + | :professional_services + | :public_warehousing_and_storage + | :quick_copy_repro_and_blueprint + | :railroads + | :real_estate_agents_and_managers_rentals + | :record_stores + | :recreational_vehicle_rentals + | :religious_goods_stores + | :religious_organizations + | :roofing_siding_sheet_metal + | :secretarial_support_services + | :security_brokers_dealers + | :service_stations + | :sewing_needlework_fabric_and_piece_goods_stores + | :shoe_repair_hat_cleaning + | :shoe_stores + | :small_appliance_repair + | :snowmobile_dealers + | :special_trade_services + | :specialty_cleaning + | :sporting_goods_stores + | :sporting_recreation_camps + | :sports_and_riding_apparel_stores + | :sports_clubs_fields + | :stamp_and_coin_stores + | :stationary_office_supplies_printing_and_writing_paper + | :stationery_stores_office_and_school_supply_stores + | :swimming_pools_sales + | :t_ui_travel_germany + | :tailors_alterations + | :tax_payments_government_agencies + | :tax_preparation_services + | :taxicabs_limousines + | :telecommunication_equipment_and_telephone_sales + | :telecommunication_services + | :telegraph_services + | :tent_and_awning_shops + | :testing_laboratories + | :theatrical_ticket_agencies + | :timeshares + | :tire_retreading_and_repair + | :tolls_bridge_fees + | :tourist_attractions_and_exhibits + | :towing_services + | :trailer_parks_campgrounds + | :transportation_services + | :travel_agencies_tour_operators + | :truck_stop_iteration + | :truck_utility_trailer_rentals + | :typesetting_plate_making_and_related_services + | :typewriter_stores + | :u_s_federal_government_agencies_or_departments + | :uniforms_commercial_clothing + | :used_merchandise_and_secondhand_stores + | :utilities + | :variety_stores + | :veterinary_services + | :video_amusement_game_supplies + | :video_game_arcades + | :video_tape_rental_stores + | :vocational_trade_schools + | :watch_jewelry_repair + | :welding_repair + | :wholesale_clubs + | :wig_and_toupee_stores + | :wires_money_orders + | :womens_accessory_and_specialty_shops + | :womens_ready_to_wear_stores + | :wrecking_and_salvage_yards + ), + optional(:spending_limits) => list(spending_limits), + optional(:spending_limits_currency) => binary + } + ) + + ( + @typedoc nil + @type spending_limits :: %{ + optional(:amount) => integer, + optional(:categories) => + list( + :ac_refrigeration_repair + | :accounting_bookkeeping_services + | :advertising_services + | :agricultural_cooperative + | :airlines_air_carriers + | :airports_flying_fields + | :ambulance_services + | :amusement_parks_carnivals + | :antique_reproductions + | :antique_shops + | :aquariums + | :architectural_surveying_services + | :art_dealers_and_galleries + | :artists_supply_and_craft_shops + | :auto_and_home_supply_stores + | :auto_body_repair_shops + | :auto_paint_shops + | :auto_service_shops + | :automated_cash_disburse + | :automated_fuel_dispensers + | :automobile_associations + | :automotive_parts_and_accessories_stores + | :automotive_tire_stores + | :bail_and_bond_payments + | :bakeries + | :bands_orchestras + | :barber_and_beauty_shops + | :betting_casino_gambling + | :bicycle_shops + | :billiard_pool_establishments + | :boat_dealers + | :boat_rentals_and_leases + | :book_stores + | :books_periodicals_and_newspapers + | :bowling_alleys + | :bus_lines + | :business_secretarial_schools + | :buying_shopping_services + | :cable_satellite_and_other_pay_television_and_radio + | :camera_and_photographic_supply_stores + | :candy_nut_and_confectionery_stores + | :car_and_truck_dealers_new_used + | :car_and_truck_dealers_used_only + | :car_rental_agencies + | :car_washes + | :carpentry_services + | :carpet_upholstery_cleaning + | :caterers + | :charitable_and_social_service_organizations_fundraising + | :chemicals_and_allied_products + | :child_care_services + | :childrens_and_infants_wear_stores + | :chiropodists_podiatrists + | :chiropractors + | :cigar_stores_and_stands + | :civic_social_fraternal_associations + | :cleaning_and_maintenance + | :clothing_rental + | :colleges_universities + | :commercial_equipment + | :commercial_footwear + | :commercial_photography_art_and_graphics + | :commuter_transport_and_ferries + | :computer_network_services + | :computer_programming + | :computer_repair + | :computer_software_stores + | :computers_peripherals_and_software + | :concrete_work_services + | :construction_materials + | :consulting_public_relations + | :correspondence_schools + | :cosmetic_stores + | :counseling_services + | :country_clubs + | :courier_services + | :court_costs + | :credit_reporting_agencies + | :cruise_lines + | :dairy_products_stores + | :dance_hall_studios_schools + | :dating_escort_services + | :dentists_orthodontists + | :department_stores + | :detective_agencies + | :digital_goods_applications + | :digital_goods_games + | :digital_goods_large_volume + | :digital_goods_media + | :direct_marketing_catalog_merchant + | :direct_marketing_combination_catalog_and_retail_merchant + | :direct_marketing_inbound_telemarketing + | :direct_marketing_insurance_services + | :direct_marketing_other + | :direct_marketing_outbound_telemarketing + | :direct_marketing_subscription + | :direct_marketing_travel + | :discount_stores + | :doctors + | :door_to_door_sales + | :drapery_window_covering_and_upholstery_stores + | :drinking_places + | :drug_stores_and_pharmacies + | :drugs_drug_proprietaries_and_druggist_sundries + | :dry_cleaners + | :durable_goods + | :duty_free_stores + | :eating_places_restaurants + | :educational_services + | :electric_razor_stores + | :electric_vehicle_charging + | :electrical_parts_and_equipment + | :electrical_services + | :electronics_repair_shops + | :electronics_stores + | :elementary_secondary_schools + | :emergency_services_gcas_visa_use_only + | :employment_temp_agencies + | :equipment_rental + | :exterminating_services + | :family_clothing_stores + | :fast_food_restaurants + | :financial_institutions + | :fines_government_administrative_entities + | :fireplace_fireplace_screens_and_accessories_stores + | :floor_covering_stores + | :florists + | :florists_supplies_nursery_stock_and_flowers + | :freezer_and_locker_meat_provisioners + | :fuel_dealers_non_automotive + | :funeral_services_crematories + | :furniture_home_furnishings_and_equipment_stores_except_appliances + | :furniture_repair_refinishing + | :furriers_and_fur_shops + | :general_services + | :gift_card_novelty_and_souvenir_shops + | :glass_paint_and_wallpaper_stores + | :glassware_crystal_stores + | :golf_courses_public + | :government_licensed_horse_dog_racing_us_region_only + | :government_licensed_online_casions_online_gambling_us_region_only + | :government_owned_lotteries_non_us_region + | :government_owned_lotteries_us_region_only + | :government_services + | :grocery_stores_supermarkets + | :hardware_equipment_and_supplies + | :hardware_stores + | :health_and_beauty_spas + | :hearing_aids_sales_and_supplies + | :heating_plumbing_a_c + | :hobby_toy_and_game_shops + | :home_supply_warehouse_stores + | :hospitals + | :hotels_motels_and_resorts + | :household_appliance_stores + | :industrial_supplies + | :information_retrieval_services + | :insurance_default + | :insurance_underwriting_premiums + | :intra_company_purchases + | :jewelry_stores_watches_clocks_and_silverware_stores + | :landscaping_services + | :laundries + | :laundry_cleaning_services + | :legal_services_attorneys + | :luggage_and_leather_goods_stores + | :lumber_building_materials_stores + | :manual_cash_disburse + | :marinas_service_and_supplies + | :marketplaces + | :masonry_stonework_and_plaster + | :massage_parlors + | :medical_and_dental_labs + | :medical_dental_ophthalmic_and_hospital_equipment_and_supplies + | :medical_services + | :membership_organizations + | :mens_and_boys_clothing_and_accessories_stores + | :mens_womens_clothing_stores + | :metal_service_centers + | :miscellaneous + | :miscellaneous_apparel_and_accessory_shops + | :miscellaneous_auto_dealers + | :miscellaneous_business_services + | :miscellaneous_food_stores + | :miscellaneous_general_merchandise + | :miscellaneous_general_services + | :miscellaneous_home_furnishing_specialty_stores + | :miscellaneous_publishing_and_printing + | :miscellaneous_recreation_services + | :miscellaneous_repair_shops + | :miscellaneous_specialty_retail + | :mobile_home_dealers + | :motion_picture_theaters + | :motor_freight_carriers_and_trucking + | :motor_homes_dealers + | :motor_vehicle_supplies_and_new_parts + | :motorcycle_shops_and_dealers + | :motorcycle_shops_dealers + | :music_stores_musical_instruments_pianos_and_sheet_music + | :news_dealers_and_newsstands + | :non_fi_money_orders + | :non_fi_stored_value_card_purchase_load + | :nondurable_goods + | :nurseries_lawn_and_garden_supply_stores + | :nursing_personal_care + | :office_and_commercial_furniture + | :opticians_eyeglasses + | :optometrists_ophthalmologist + | :orthopedic_goods_prosthetic_devices + | :osteopaths + | :package_stores_beer_wine_and_liquor + | :paints_varnishes_and_supplies + | :parking_lots_garages + | :passenger_railways + | :pawn_shops + | :pet_shops_pet_food_and_supplies + | :petroleum_and_petroleum_products + | :photo_developing + | :photographic_photocopy_microfilm_equipment_and_supplies + | :photographic_studios + | :picture_video_production + | :piece_goods_notions_and_other_dry_goods + | :plumbing_heating_equipment_and_supplies + | :political_organizations + | :postal_services_government_only + | :precious_stones_and_metals_watches_and_jewelry + | :professional_services + | :public_warehousing_and_storage + | :quick_copy_repro_and_blueprint + | :railroads + | :real_estate_agents_and_managers_rentals + | :record_stores + | :recreational_vehicle_rentals + | :religious_goods_stores + | :religious_organizations + | :roofing_siding_sheet_metal + | :secretarial_support_services + | :security_brokers_dealers + | :service_stations + | :sewing_needlework_fabric_and_piece_goods_stores + | :shoe_repair_hat_cleaning + | :shoe_stores + | :small_appliance_repair + | :snowmobile_dealers + | :special_trade_services + | :specialty_cleaning + | :sporting_goods_stores + | :sporting_recreation_camps + | :sports_and_riding_apparel_stores + | :sports_clubs_fields + | :stamp_and_coin_stores + | :stationary_office_supplies_printing_and_writing_paper + | :stationery_stores_office_and_school_supply_stores + | :swimming_pools_sales + | :t_ui_travel_germany + | :tailors_alterations + | :tax_payments_government_agencies + | :tax_preparation_services + | :taxicabs_limousines + | :telecommunication_equipment_and_telephone_sales + | :telecommunication_services + | :telegraph_services + | :tent_and_awning_shops + | :testing_laboratories + | :theatrical_ticket_agencies + | :timeshares + | :tire_retreading_and_repair + | :tolls_bridge_fees + | :tourist_attractions_and_exhibits + | :towing_services + | :trailer_parks_campgrounds + | :transportation_services + | :travel_agencies_tour_operators + | :truck_stop_iteration + | :truck_utility_trailer_rentals + | :typesetting_plate_making_and_related_services + | :typewriter_stores + | :u_s_federal_government_agencies_or_departments + | :uniforms_commercial_clothing + | :used_merchandise_and_secondhand_stores + | :utilities + | :variety_stores + | :veterinary_services + | :video_amusement_game_supplies + | :video_game_arcades + | :video_tape_rental_stores + | :vocational_trade_schools + | :watch_jewelry_repair + | :welding_repair + | :wholesale_clubs + | :wig_and_toupee_stores + | :wires_money_orders + | :womens_accessory_and_specialty_shops + | :womens_ready_to_wear_stores + | :wrecking_and_salvage_yards + ), + optional(:interval) => + :all_time | :daily | :monthly | :per_authorization | :weekly | :yearly + } + ) + + ( + @typedoc "Information about cardholder acceptance of [Authorized User Terms](https://stripe.com/docs/issuing/cards)." + @type user_terms_acceptance :: %{ + optional(:date) => integer, + optional(:ip) => binary, + optional(:user_agent) => binary + } + ) + + ( + @typedoc "Government-issued ID document for this cardholder." + @type verification :: %{optional(:document) => document} + ) + + ( + nil + + @doc "

Returns a list of Issuing Cardholder objects. The objects are sorted in descending order by creation date, with the most recently created object appearing first.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/issuing/cardholders`\n" + ( + @spec list( + params :: %{ + optional(:created) => created | integer, + optional(:email) => binary, + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:phone_number) => binary, + optional(:starting_after) => binary, + optional(:status) => :active | :blocked | :inactive, + optional(:type) => :company | :individual + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.Issuing.Cardholder.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/issuing/cardholders", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Creates a new Issuing Cardholder object that can be issued cards.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/issuing/cardholders`\n" + ( + @spec create( + params :: %{ + optional(:billing) => billing, + optional(:company) => company, + optional(:email) => binary, + optional(:expand) => list(binary), + optional(:individual) => individual, + optional(:metadata) => %{optional(binary) => binary}, + optional(:name) => binary, + optional(:phone_number) => binary, + optional(:preferred_locales) => list(:de | :en | :es | :fr | :it), + optional(:spending_controls) => spending_controls, + optional(:status) => :active | :inactive, + optional(:type) => :company | :individual + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Issuing.Cardholder.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/issuing/cardholders", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves an Issuing Cardholder object.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/issuing/cardholders/{cardholder}`\n" + ( + @spec retrieve( + cardholder :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Issuing.Cardholder.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def retrieve(cardholder, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/issuing/cardholders/{cardholder}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "cardholder", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "cardholder", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [cardholder] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Updates the specified Issuing Cardholder object by setting the values of the parameters passed. Any parameters not provided will be left unchanged.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/issuing/cardholders/{cardholder}`\n" + ( + @spec update( + cardholder :: binary(), + params :: %{ + optional(:billing) => billing, + optional(:company) => company, + optional(:email) => binary, + optional(:expand) => list(binary), + optional(:individual) => individual, + optional(:metadata) => %{optional(binary) => binary}, + optional(:phone_number) => binary, + optional(:preferred_locales) => list(:de | :en | :es | :fr | :it), + optional(:spending_controls) => spending_controls, + optional(:status) => :active | :inactive + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Issuing.Cardholder.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def update(cardholder, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/issuing/cardholders/{cardholder}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "cardholder", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "cardholder", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [cardholder] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/issuing__dispute.ex b/lib/generated/issuing__dispute.ex new file mode 100644 index 00000000..fd917227 --- /dev/null +++ b/lib/generated/issuing__dispute.ex @@ -0,0 +1,356 @@ +defmodule Stripe.Issuing.Dispute do + use Stripe.Entity + + @moduledoc "As a [card issuer](https://stripe.com/docs/issuing), you can dispute transactions that the cardholder does not recognize, suspects to be fraudulent, or has other issues with.\n\nRelated guide: [Issuing disputes](https://stripe.com/docs/issuing/purchases/disputes)" + ( + defstruct [ + :amount, + :balance_transactions, + :created, + :currency, + :evidence, + :id, + :livemode, + :metadata, + :object, + :status, + :transaction, + :treasury + ] + + @typedoc "The `issuing.dispute` type.\n\n * `amount` Disputed amount in the card's currency and in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). Usually the amount of the `transaction`, but can differ (usually because of currency fluctuation).\n * `balance_transactions` List of balance transactions associated with the dispute.\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `currency` The currency the `transaction` was made in.\n * `evidence` \n * `id` Unique identifier for the object.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `metadata` Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `status` Current status of the dispute.\n * `transaction` The transaction being disputed.\n * `treasury` [Treasury](https://stripe.com/docs/api/treasury) details related to this dispute if it was created on a [FinancialAccount](/docs/api/treasury/financial_accounts\n" + @type t :: %__MODULE__{ + amount: integer, + balance_transactions: term | nil, + created: integer, + currency: binary, + evidence: term, + id: binary, + livemode: boolean, + metadata: term, + object: binary, + status: binary, + transaction: binary | Stripe.Issuing.Transaction.t(), + treasury: term | nil + } + ) + + ( + @typedoc nil + @type canceled :: %{ + optional(:additional_documentation) => binary | binary, + optional(:canceled_at) => integer | binary, + optional(:cancellation_policy_provided) => boolean | binary, + optional(:cancellation_reason) => binary, + optional(:expected_at) => integer | binary, + optional(:explanation) => binary, + optional(:product_description) => binary, + optional(:product_type) => :merchandise | :service, + optional(:return_status) => :merchant_rejected | :successful, + optional(:returned_at) => integer | binary + } + ) + + ( + @typedoc nil + @type created :: %{ + optional(:gt) => integer, + optional(:gte) => integer, + optional(:lt) => integer, + optional(:lte) => integer + } + ) + + ( + @typedoc nil + @type duplicate :: %{ + optional(:additional_documentation) => binary | binary, + optional(:card_statement) => binary | binary, + optional(:cash_receipt) => binary | binary, + optional(:check_image) => binary | binary, + optional(:explanation) => binary, + optional(:original_transaction) => binary + } + ) + + ( + @typedoc "Evidence provided for the dispute." + @type evidence :: %{ + optional(:canceled) => canceled | binary, + optional(:duplicate) => duplicate | binary, + optional(:fraudulent) => fraudulent | binary, + optional(:merchandise_not_as_described) => merchandise_not_as_described | binary, + optional(:not_received) => not_received | binary, + optional(:other) => other | binary, + optional(:reason) => + :canceled + | :duplicate + | :fraudulent + | :merchandise_not_as_described + | :not_received + | :other + | :service_not_as_described, + optional(:service_not_as_described) => service_not_as_described | binary + } + ) + + ( + @typedoc nil + @type fraudulent :: %{ + optional(:additional_documentation) => binary | binary, + optional(:explanation) => binary + } + ) + + ( + @typedoc nil + @type merchandise_not_as_described :: %{ + optional(:additional_documentation) => binary | binary, + optional(:explanation) => binary, + optional(:received_at) => integer | binary, + optional(:return_description) => binary, + optional(:return_status) => :merchant_rejected | :successful, + optional(:returned_at) => integer | binary + } + ) + + ( + @typedoc nil + @type not_received :: %{ + optional(:additional_documentation) => binary | binary, + optional(:expected_at) => integer | binary, + optional(:explanation) => binary, + optional(:product_description) => binary, + optional(:product_type) => :merchandise | :service + } + ) + + ( + @typedoc nil + @type other :: %{ + optional(:additional_documentation) => binary | binary, + optional(:explanation) => binary, + optional(:product_description) => binary, + optional(:product_type) => :merchandise | :service + } + ) + + ( + @typedoc nil + @type service_not_as_described :: %{ + optional(:additional_documentation) => binary | binary, + optional(:canceled_at) => integer | binary, + optional(:cancellation_reason) => binary, + optional(:explanation) => binary, + optional(:received_at) => integer | binary + } + ) + + ( + @typedoc "Params for disputes related to Treasury FinancialAccounts" + @type treasury :: %{optional(:received_debit) => binary} + ) + + ( + nil + + @doc "

Returns a list of Issuing Dispute objects. The objects are sorted in descending order by creation date, with the most recently created object appearing first.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/issuing/disputes`\n" + ( + @spec list( + params :: %{ + optional(:created) => created | integer, + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:starting_after) => binary, + optional(:status) => :expired | :lost | :submitted | :unsubmitted | :won, + optional(:transaction) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.Issuing.Dispute.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/issuing/disputes", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Creates an Issuing Dispute object. Individual pieces of evidence within the evidence object are optional at this point. Stripe only validates that required evidence is present during submission. Refer to Dispute reasons and evidence for more details about evidence requirements.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/issuing/disputes`\n" + ( + @spec create( + params :: %{ + optional(:amount) => integer, + optional(:evidence) => evidence, + optional(:expand) => list(binary), + optional(:metadata) => %{optional(binary) => binary}, + optional(:transaction) => binary, + optional(:treasury) => treasury + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Issuing.Dispute.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/issuing/disputes", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Updates the specified Issuing Dispute object by setting the values of the parameters passed. Any parameters not provided will be left unchanged. Properties on the evidence object can be unset by passing in an empty string.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/issuing/disputes/{dispute}`\n" + ( + @spec update( + dispute :: binary(), + params :: %{ + optional(:amount) => integer, + optional(:evidence) => evidence, + optional(:expand) => list(binary), + optional(:metadata) => %{optional(binary) => binary} | binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Issuing.Dispute.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def update(dispute, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/issuing/disputes/{dispute}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "dispute", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "dispute", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [dispute] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves an Issuing Dispute object.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/issuing/disputes/{dispute}`\n" + ( + @spec retrieve( + dispute :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Issuing.Dispute.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def retrieve(dispute, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/issuing/disputes/{dispute}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "dispute", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "dispute", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [dispute] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Submits an Issuing Dispute to the card network. Stripe validates that all evidence fields required for the dispute’s reason are present. For more details, see Dispute reasons and evidence.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/issuing/disputes/{dispute}/submit`\n" + ( + @spec submit( + dispute :: binary(), + params :: %{ + optional(:expand) => list(binary), + optional(:metadata) => %{optional(binary) => binary} | binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Issuing.Dispute.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def submit(dispute, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/issuing/disputes/{dispute}/submit", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "dispute", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "dispute", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [dispute] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/issuing__transaction.ex b/lib/generated/issuing__transaction.ex new file mode 100644 index 00000000..61bde91b --- /dev/null +++ b/lib/generated/issuing__transaction.ex @@ -0,0 +1,187 @@ +defmodule Stripe.Issuing.Transaction do + use Stripe.Entity + + @moduledoc "Any use of an [issued card](https://stripe.com/docs/issuing) that results in funds entering or leaving\nyour Stripe account, such as a completed purchase or refund, is represented by an Issuing\n`Transaction` object.\n\nRelated guide: [Issued card transactions](https://stripe.com/docs/issuing/purchases/transactions)" + ( + defstruct [ + :amount, + :amount_details, + :authorization, + :balance_transaction, + :card, + :cardholder, + :created, + :currency, + :dispute, + :id, + :livemode, + :merchant_amount, + :merchant_currency, + :merchant_data, + :metadata, + :object, + :purchase_details, + :treasury, + :type, + :wallet + ] + + @typedoc "The `issuing.transaction` type.\n\n * `amount` The transaction amount, which will be reflected in your balance. This amount is in your currency and in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal).\n * `amount_details` Detailed breakdown of amount components. These amounts are denominated in `currency` and in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal).\n * `authorization` The `Authorization` object that led to this transaction.\n * `balance_transaction` ID of the [balance transaction](https://stripe.com/docs/api/balance_transactions) associated with this transaction.\n * `card` The card used to make this transaction.\n * `cardholder` The cardholder to whom this transaction belongs.\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `currency` Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).\n * `dispute` If you've disputed the transaction, the ID of the dispute.\n * `id` Unique identifier for the object.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `merchant_amount` The amount that the merchant will receive, denominated in `merchant_currency` and in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). It will be different from `amount` if the merchant is taking payment in a different currency.\n * `merchant_currency` The currency with which the merchant is taking payment.\n * `merchant_data` \n * `metadata` Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `purchase_details` Additional purchase information that is optionally provided by the merchant.\n * `treasury` [Treasury](https://stripe.com/docs/api/treasury) details related to this transaction if it was created on a [FinancialAccount](/docs/api/treasury/financial_accounts\n * `type` The nature of the transaction.\n * `wallet` The digital wallet used for this transaction. One of `apple_pay`, `google_pay`, or `samsung_pay`.\n" + @type t :: %__MODULE__{ + amount: integer, + amount_details: term | nil, + authorization: (binary | Stripe.Issuing.Authorization.t()) | nil, + balance_transaction: (binary | Stripe.BalanceTransaction.t()) | nil, + card: binary | Stripe.Issuing.Card.t(), + cardholder: (binary | Stripe.Issuing.Cardholder.t()) | nil, + created: integer, + currency: binary, + dispute: (binary | Stripe.Issuing.Dispute.t()) | nil, + id: binary, + livemode: boolean, + merchant_amount: integer, + merchant_currency: binary, + merchant_data: term, + metadata: term, + object: binary, + purchase_details: term | nil, + treasury: term | nil, + type: binary, + wallet: binary | nil + } + ) + + ( + @typedoc nil + @type created :: %{ + optional(:gt) => integer, + optional(:gte) => integer, + optional(:lt) => integer, + optional(:lte) => integer + } + ) + + ( + nil + + @doc "

Returns a list of Issuing Transaction objects. The objects are sorted in descending order by creation date, with the most recently created object appearing first.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/issuing/transactions`\n" + ( + @spec list( + params :: %{ + optional(:card) => binary, + optional(:cardholder) => binary, + optional(:created) => created | integer, + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:starting_after) => binary, + optional(:type) => :capture | :refund + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.Issuing.Transaction.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/issuing/transactions", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves an Issuing Transaction object.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/issuing/transactions/{transaction}`\n" + ( + @spec retrieve( + transaction :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Issuing.Transaction.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def retrieve(transaction, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/issuing/transactions/{transaction}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "transaction", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "transaction", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [transaction] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Updates the specified Issuing Transaction object by setting the values of the parameters passed. Any parameters not provided will be left unchanged.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/issuing/transactions/{transaction}`\n" + ( + @spec update( + transaction :: binary(), + params :: %{ + optional(:expand) => list(binary), + optional(:metadata) => %{optional(binary) => binary} | binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Issuing.Transaction.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def update(transaction, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/issuing/transactions/{transaction}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "transaction", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "transaction", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [transaction] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/item.ex b/lib/generated/item.ex new file mode 100644 index 00000000..2d473e44 --- /dev/null +++ b/lib/generated/item.ex @@ -0,0 +1,36 @@ +defmodule Stripe.Item do + use Stripe.Entity + @moduledoc "A line item." + ( + defstruct [ + :amount_discount, + :amount_subtotal, + :amount_tax, + :amount_total, + :currency, + :description, + :discounts, + :id, + :object, + :price, + :quantity, + :taxes + ] + + @typedoc "The `item` type.\n\n * `amount_discount` Total discount amount applied. If no discounts were applied, defaults to 0.\n * `amount_subtotal` Total before any discounts or taxes are applied.\n * `amount_tax` Total tax amount applied. If no tax was applied, defaults to 0.\n * `amount_total` Total after discounts and taxes.\n * `currency` Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).\n * `description` An arbitrary string attached to the object. Often useful for displaying to users. Defaults to product name.\n * `discounts` The discounts applied to the line item.\n * `id` Unique identifier for the object.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `price` The price used to generate the line item.\n * `quantity` The quantity of products being purchased.\n * `taxes` The taxes applied to the line item.\n" + @type t :: %__MODULE__{ + amount_discount: integer, + amount_subtotal: integer, + amount_tax: integer, + amount_total: integer, + currency: binary, + description: binary, + discounts: term, + id: binary, + object: binary, + price: Stripe.Price.t() | nil, + quantity: integer | nil, + taxes: term + } + ) +end \ No newline at end of file diff --git a/lib/generated/line_item.ex b/lib/generated/line_item.ex new file mode 100644 index 00000000..b9c7a8bc --- /dev/null +++ b/lib/generated/line_item.ex @@ -0,0 +1,109 @@ +defmodule Stripe.LineItem do + use Stripe.Entity + @moduledoc "" + ( + defstruct [ + :amount, + :amount_excluding_tax, + :currency, + :description, + :discount_amounts, + :discountable, + :discounts, + :id, + :invoice_item, + :livemode, + :metadata, + :object, + :period, + :plan, + :price, + :proration, + :proration_details, + :quantity, + :subscription, + :subscription_item, + :tax_amounts, + :tax_rates, + :type, + :unit_amount_excluding_tax + ] + + @typedoc "The `line_item` type.\n\n * `amount` The amount, in %s.\n * `amount_excluding_tax` The integer amount in %s representing the amount for this line item, excluding all tax and discounts.\n * `currency` Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).\n * `description` An arbitrary string attached to the object. Often useful for displaying to users.\n * `discount_amounts` The amount of discount calculated per discount for this line item.\n * `discountable` If true, discounts will apply to this line item. Always false for prorations.\n * `discounts` The discounts applied to the invoice line item. Line item discounts are applied before invoice discounts. Use `expand[]=discounts` to expand each discount.\n * `id` Unique identifier for the object.\n * `invoice_item` The ID of the [invoice item](https://stripe.com/docs/api/invoiceitems) associated with this line item if any.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `metadata` Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Note that for line items with `type=subscription` this will reflect the metadata of the subscription that caused the line item to be created.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `period` \n * `plan` The plan of the subscription, if the line item is a subscription or a proration.\n * `price` The price of the line item.\n * `proration` Whether this is a proration.\n * `proration_details` Additional details for proration line items\n * `quantity` The quantity of the subscription, if the line item is a subscription or a proration.\n * `subscription` The subscription that the invoice item pertains to, if any.\n * `subscription_item` The subscription item that generated this line item. Left empty if the line item is not an explicit result of a subscription.\n * `tax_amounts` The amount of tax calculated per tax rate for this line item\n * `tax_rates` The tax rates which apply to the line item.\n * `type` A string identifying the type of the source of this line item, either an `invoiceitem` or a `subscription`.\n * `unit_amount_excluding_tax` The amount in %s representing the unit amount for this line item, excluding all tax and discounts.\n" + @type t :: %__MODULE__{ + amount: integer, + amount_excluding_tax: integer | nil, + currency: binary, + description: binary | nil, + discount_amounts: term | nil, + discountable: boolean, + discounts: term | nil, + id: binary, + invoice_item: binary | Stripe.Invoiceitem.t(), + livemode: boolean, + metadata: term, + object: binary, + period: term, + plan: Stripe.Plan.t() | nil, + price: Stripe.Price.t() | nil, + proration: boolean, + proration_details: term | nil, + quantity: integer | nil, + subscription: (binary | Stripe.Subscription.t()) | nil, + subscription_item: binary | Stripe.SubscriptionItem.t(), + tax_amounts: term, + tax_rates: term, + type: binary, + unit_amount_excluding_tax: binary | nil + } + ) + + ( + nil + + @doc "

When retrieving an invoice, you’ll get a lines property containing the total count of line items and the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/invoices/{invoice}/lines`\n" + ( + @spec list( + invoice :: binary(), + params :: %{ + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.LineItem.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(invoice, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/invoices/{invoice}/lines", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "invoice", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "invoice", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [invoice] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/login_link.ex b/lib/generated/login_link.ex new file mode 100644 index 00000000..25a02112 --- /dev/null +++ b/lib/generated/login_link.ex @@ -0,0 +1,52 @@ +defmodule Stripe.LoginLink do + use Stripe.Entity + + @moduledoc "Login Links are single-use login link for an Express account to access their Stripe dashboard." + ( + defstruct [:created, :object, :url] + + @typedoc "The `login_link` type.\n\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `url` The URL for the login link.\n" + @type t :: %__MODULE__{created: integer, object: binary, url: binary} + ) + + ( + nil + + @doc "

Creates a single-use login link for an Express account to access their Stripe dashboard.

\n\n

You may only create login links for Express accounts connected to your platform.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/accounts/{account}/login_links`\n" + ( + @spec create( + account :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: {:ok, Stripe.LoginLink.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def create(account, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/accounts/{account}/login_links", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "account", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "account", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [account] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/mandate.ex b/lib/generated/mandate.ex new file mode 100644 index 00000000..eb23d66a --- /dev/null +++ b/lib/generated/mandate.ex @@ -0,0 +1,76 @@ +defmodule Stripe.Mandate do + use Stripe.Entity + + @moduledoc "A Mandate is a record of the permission a customer has given you to debit their payment method." + ( + defstruct [ + :customer_acceptance, + :id, + :livemode, + :multi_use, + :object, + :on_behalf_of, + :payment_method, + :payment_method_details, + :single_use, + :status, + :type + ] + + @typedoc "The `mandate` type.\n\n * `customer_acceptance` \n * `id` Unique identifier for the object.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `multi_use` \n * `object` String representing the object's type. Objects of the same type share the same value.\n * `on_behalf_of` The account (if any) for which the mandate is intended.\n * `payment_method` ID of the payment method associated with this mandate.\n * `payment_method_details` \n * `single_use` \n * `status` The status of the mandate, which indicates whether it can be used to initiate a payment.\n * `type` The type of the mandate.\n" + @type t :: %__MODULE__{ + customer_acceptance: term, + id: binary, + livemode: boolean, + multi_use: term, + object: binary, + on_behalf_of: binary, + payment_method: binary | Stripe.PaymentMethod.t(), + payment_method_details: term, + single_use: term, + status: binary, + type: binary + } + ) + + ( + nil + + @doc "

Retrieves a Mandate object.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/mandates/{mandate}`\n" + ( + @spec retrieve( + mandate :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: {:ok, Stripe.Mandate.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def retrieve(mandate, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/mandates/{mandate}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "mandate", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "mandate", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [mandate] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/payment_intent.ex b/lib/generated/payment_intent.ex new file mode 100644 index 00000000..5d2440c6 --- /dev/null +++ b/lib/generated/payment_intent.ex @@ -0,0 +1,1204 @@ +defmodule Stripe.PaymentIntent do + use Stripe.Entity + + @moduledoc "A PaymentIntent guides you through the process of collecting a payment from your customer.\nWe recommend that you create exactly one PaymentIntent for each order or\ncustomer session in your system. You can reference the PaymentIntent later to\nsee the history of payment attempts for a particular session.\n\nA PaymentIntent transitions through\n[multiple statuses](https://stripe.com/docs/payments/intents#intent-statuses)\nthroughout its lifetime as it interfaces with Stripe.js to perform\nauthentication flows and ultimately creates at most one successful charge.\n\nRelated guide: [Payment Intents API](https://stripe.com/docs/payments/payment-intents)" + ( + defstruct [ + :shipping, + :id, + :transfer_data, + :statement_descriptor_suffix, + :application_fee_amount, + :amount_details, + :transfer_group, + :status, + :cancellation_reason, + :created, + :currency, + :canceled_at, + :last_payment_error, + :source, + :object, + :receipt_email, + :client_secret, + :application, + :latest_charge, + :statement_descriptor, + :automatic_payment_methods, + :invoice, + :amount, + :customer, + :on_behalf_of, + :next_action, + :confirmation_method, + :review, + :amount_capturable, + :payment_method_types, + :description, + :metadata, + :amount_received, + :payment_method_options, + :capture_method, + :processing, + :livemode, + :payment_method, + :setup_future_usage + ] + + @typedoc "The `payment_intent` type.\n\n * `amount` Amount intended to be collected by this PaymentIntent. A positive integer representing how much to charge in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). The minimum amount is $0.50 US or [equivalent in charge currency](https://stripe.com/docs/currencies#minimum-and-maximum-charge-amounts). The amount value supports up to eight digits (e.g., a value of 99999999 for a USD charge of $999,999.99).\n * `amount_capturable` Amount that can be captured from this PaymentIntent.\n * `amount_details` \n * `amount_received` Amount that was collected by this PaymentIntent.\n * `application` ID of the Connect application that created the PaymentIntent.\n * `application_fee_amount` The amount of the application fee (if any) that will be requested to be applied to the payment and transferred to the application owner's Stripe account. The amount of the application fee collected will be capped at the total payment amount. For more information, see the PaymentIntents [use case for connected accounts](https://stripe.com/docs/payments/connected-accounts).\n * `automatic_payment_methods` Settings to configure compatible payment methods from the [Stripe Dashboard](https://dashboard.stripe.com/settings/payment_methods)\n * `canceled_at` Populated when `status` is `canceled`, this is the time at which the PaymentIntent was canceled. Measured in seconds since the Unix epoch.\n * `cancellation_reason` Reason for cancellation of this PaymentIntent, either user-provided (`duplicate`, `fraudulent`, `requested_by_customer`, or `abandoned`) or generated by Stripe internally (`failed_invoice`, `void_invoice`, or `automatic`).\n * `capture_method` Controls when the funds will be captured from the customer's account.\n * `client_secret` The client secret of this PaymentIntent. Used for client-side retrieval using a publishable key. \n\nThe client secret can be used to complete a payment from your frontend. It should not be stored, logged, or exposed to anyone other than the customer. Make sure that you have TLS enabled on any page that includes the client secret.\n\nRefer to our docs to [accept a payment](https://stripe.com/docs/payments/accept-a-payment?ui=elements) and learn about how `client_secret` should be handled.\n * `confirmation_method` \n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `currency` Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).\n * `customer` ID of the Customer this PaymentIntent belongs to, if one exists.\n\nPayment methods attached to other Customers cannot be used with this PaymentIntent.\n\nIf present in combination with [setup_future_usage](https://stripe.com/docs/api#payment_intent_object-setup_future_usage), this PaymentIntent's payment method will be attached to the Customer after the PaymentIntent has been confirmed and any required actions from the user are complete.\n * `description` An arbitrary string attached to the object. Often useful for displaying to users.\n * `id` Unique identifier for the object.\n * `invoice` ID of the invoice that created this PaymentIntent, if it exists.\n * `last_payment_error` The payment error encountered in the previous PaymentIntent confirmation. It will be cleared if the PaymentIntent is later updated for any reason.\n * `latest_charge` The latest charge created by this payment intent.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `metadata` Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format. For more information, see the [documentation](https://stripe.com/docs/payments/payment-intents/creating-payment-intents#storing-information-in-metadata).\n * `next_action` If present, this property tells you what actions you need to take in order for your customer to fulfill a payment using the provided source.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `on_behalf_of` The account (if any) for which the funds of the PaymentIntent are intended. See the PaymentIntents [use case for connected accounts](https://stripe.com/docs/payments/connected-accounts) for details.\n * `payment_method` ID of the payment method used in this PaymentIntent.\n * `payment_method_options` Payment-method-specific configuration for this PaymentIntent.\n * `payment_method_types` The list of payment method types (e.g. card) that this PaymentIntent is allowed to use.\n * `processing` If present, this property tells you about the processing state of the payment.\n * `receipt_email` Email address that the receipt for the resulting payment will be sent to. If `receipt_email` is specified for a payment in live mode, a receipt will be sent regardless of your [email settings](https://dashboard.stripe.com/account/emails).\n * `review` ID of the review associated with this PaymentIntent, if any.\n * `setup_future_usage` Indicates that you intend to make future payments with this PaymentIntent's payment method.\n\nProviding this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes.\n\nWhen processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication).\n * `shipping` Shipping information for this PaymentIntent.\n * `source` This is a legacy field that will be removed in the future. It is the ID of the Source object that is associated with this PaymentIntent, if one was supplied.\n * `statement_descriptor` For non-card charges, you can use this value as the complete description that appears on your customers’ statements. Must contain at least one letter, maximum 22 characters.\n * `statement_descriptor_suffix` Provides information about a card payment that customers see on their statements. Concatenated with the prefix (shortened descriptor) or statement descriptor that’s set on the account to form the complete statement descriptor. Maximum 22 characters for the concatenated descriptor.\n * `status` Status of this PaymentIntent, one of `requires_payment_method`, `requires_confirmation`, `requires_action`, `processing`, `requires_capture`, `canceled`, or `succeeded`. Read more about each PaymentIntent [status](https://stripe.com/docs/payments/intents#intent-statuses).\n * `transfer_data` The data with which to automatically create a Transfer when the payment is finalized. See the PaymentIntents [use case for connected accounts](https://stripe.com/docs/payments/connected-accounts) for details.\n * `transfer_group` A string that identifies the resulting payment as part of a group. See the PaymentIntents [use case for connected accounts](https://stripe.com/docs/payments/connected-accounts) for details.\n" + @type t :: %__MODULE__{ + amount: integer, + amount_capturable: integer, + amount_details: term, + amount_received: integer, + application: (binary | term) | nil, + application_fee_amount: integer | nil, + automatic_payment_methods: term | nil, + canceled_at: integer | nil, + cancellation_reason: binary | nil, + capture_method: binary, + client_secret: binary | nil, + confirmation_method: binary, + created: integer, + currency: binary, + customer: (binary | Stripe.Customer.t() | Stripe.DeletedCustomer.t()) | nil, + description: binary | nil, + id: binary, + invoice: (binary | Stripe.Invoice.t()) | nil, + last_payment_error: Stripe.ApiErrors.t() | nil, + latest_charge: (binary | Stripe.Charge.t()) | nil, + livemode: boolean, + metadata: term, + next_action: term | nil, + object: binary, + on_behalf_of: (binary | Stripe.Account.t()) | nil, + payment_method: (binary | Stripe.PaymentMethod.t()) | nil, + payment_method_options: term | nil, + payment_method_types: term, + processing: term | nil, + receipt_email: binary | nil, + review: (binary | Stripe.Review.t()) | nil, + setup_future_usage: binary | nil, + shipping: term | nil, + source: (binary | Stripe.PaymentSource.t() | Stripe.DeletedPaymentSource.t()) | nil, + statement_descriptor: binary | nil, + statement_descriptor_suffix: binary | nil, + status: binary, + transfer_data: term | nil, + transfer_group: binary | nil + } + ) + + ( + @typedoc nil + @type acss_debit :: %{ + optional(:mandate_options) => mandate_options, + optional(:setup_future_usage) => :none | :off_session | :on_session, + optional(:verification_method) => :automatic | :instant | :microdeposits + } + ) + + ( + @typedoc "Shipping address." + @type address :: %{ + optional(:city) => binary, + optional(:country) => binary, + optional(:line1) => binary, + optional(:line2) => binary, + optional(:postal_code) => binary, + optional(:state) => binary + } + ) + + ( + @typedoc nil + @type affirm :: %{ + optional(:capture_method) => :manual, + optional(:preferred_locale) => binary, + optional(:setup_future_usage) => :none + } + ) + + ( + @typedoc nil + @type afterpay_clearpay :: %{ + optional(:capture_method) => :manual, + optional(:reference) => binary, + optional(:setup_future_usage) => :none + } + ) + + ( + @typedoc nil + @type alipay :: %{optional(:setup_future_usage) => :none | :off_session} + ) + + ( + @typedoc nil + @type au_becs_debit :: %{optional(:setup_future_usage) => :none | :off_session | :on_session} + ) + + ( + @typedoc "When enabled, this PaymentIntent will accept payment methods that you have enabled in the Dashboard and are compatible with this PaymentIntent's other parameters." + @type automatic_payment_methods :: %{ + optional(:allow_redirects) => :always | :never, + optional(:enabled) => boolean + } + ) + + ( + @typedoc "If this is a `bacs_debit` PaymentMethod, this hash contains details about the Bacs Direct Debit bank account." + @type bacs_debit :: %{optional(:account_number) => binary, optional(:sort_code) => binary} + ) + + ( + @typedoc nil + @type bancontact :: %{ + optional(:preferred_language) => :de | :en | :fr | :nl, + optional(:setup_future_usage) => :none | :off_session + } + ) + + ( + @typedoc "Configuration for the bank transfer funding type, if the `funding_type` is set to `bank_transfer`." + @type bank_transfer :: %{ + optional(:eu_bank_transfer) => eu_bank_transfer, + optional(:requested_address_types) => + list(:aba | :iban | :sepa | :sort_code | :spei | :swift | :zengin), + optional(:type) => + :eu_bank_transfer + | :gb_bank_transfer + | :jp_bank_transfer + | :mx_bank_transfer + | :us_bank_transfer + } + ) + + ( + @typedoc "Billing information associated with the PaymentMethod that may be used or required by particular types of payment methods." + @type billing_details :: %{ + optional(:address) => address | binary, + optional(:email) => binary | binary, + optional(:name) => binary, + optional(:phone) => binary + } + ) + + ( + @typedoc nil + @type blik :: %{optional(:code) => binary} + ) + + ( + @typedoc "If this is a `boleto` PaymentMethod, this hash contains details about the Boleto payment method." + @type boleto :: %{optional(:tax_id) => binary} + ) + + ( + @typedoc nil + @type card :: %{ + optional(:capture_method) => :manual, + optional(:cvc_token) => binary, + optional(:installments) => installments, + optional(:mandate_options) => mandate_options, + optional(:moto) => boolean, + optional(:network) => + :amex + | :cartes_bancaires + | :diners + | :discover + | :eftpos_au + | :interac + | :jcb + | :mastercard + | :unionpay + | :unknown + | :visa, + optional(:request_three_d_secure) => :any | :automatic, + optional(:setup_future_usage) => :none | :off_session | :on_session, + optional(:statement_descriptor_suffix_kana) => binary | binary, + optional(:statement_descriptor_suffix_kanji) => binary | binary + } + ) + + ( + @typedoc nil + @type card_present :: %{ + optional(:request_extended_authorization) => boolean, + optional(:request_incremental_authorization_support) => boolean + } + ) + + ( + @typedoc nil + @type cashapp :: %{ + optional(:capture_method) => :manual, + optional(:setup_future_usage) => :none | :off_session | :on_session + } + ) + + ( + @typedoc nil + @type created :: %{ + optional(:gt) => integer, + optional(:gte) => integer, + optional(:lt) => integer, + optional(:lte) => integer + } + ) + + ( + @typedoc "This hash contains details about the customer acceptance of the Mandate." + @type customer_acceptance :: %{ + optional(:accepted_at) => integer, + optional(:offline) => map(), + optional(:online) => online, + optional(:type) => :offline | :online + } + ) + + ( + @typedoc nil + @type customer_balance :: %{ + optional(:bank_transfer) => bank_transfer, + optional(:funding_type) => :bank_transfer, + optional(:setup_future_usage) => :none + } + ) + + ( + @typedoc "Customer's date of birth" + @type dob :: %{ + optional(:day) => integer, + optional(:month) => integer, + optional(:year) => integer + } + ) + + ( + @typedoc "If this is an `eps` PaymentMethod, this hash contains details about the EPS payment method." + @type eps :: %{ + optional(:bank) => + :arzte_und_apotheker_bank + | :austrian_anadi_bank_ag + | :bank_austria + | :bankhaus_carl_spangler + | :bankhaus_schelhammer_und_schattera_ag + | :bawag_psk_ag + | :bks_bank_ag + | :brull_kallmus_bank_ag + | :btv_vier_lander_bank + | :capital_bank_grawe_gruppe_ag + | :deutsche_bank_ag + | :dolomitenbank + | :easybank_ag + | :erste_bank_und_sparkassen + | :hypo_alpeadriabank_international_ag + | :hypo_bank_burgenland_aktiengesellschaft + | :hypo_noe_lb_fur_niederosterreich_u_wien + | :hypo_oberosterreich_salzburg_steiermark + | :hypo_tirol_bank_ag + | :hypo_vorarlberg_bank_ag + | :marchfelder_bank + | :oberbank_ag + | :raiffeisen_bankengruppe_osterreich + | :schoellerbank_ag + | :sparda_bank_wien + | :volksbank_gruppe + | :volkskreditbank_ag + | :vr_bank_braunau + } + ) + + ( + @typedoc "Configuration for the eu_bank_transfer funding type." + @type eu_bank_transfer :: %{optional(:country) => binary} + ) + + ( + @typedoc "Additional fields for Financial Connections Session creation" + @type financial_connections :: %{ + optional(:permissions) => + list(:balances | :ownership | :payment_method | :transactions), + optional(:return_url) => binary + } + ) + + ( + @typedoc "If this is an `fpx` PaymentMethod, this hash contains details about the FPX payment method." + @type fpx :: %{ + optional(:account_holder_type) => :company | :individual, + optional(:bank) => + :affin_bank + | :agrobank + | :alliance_bank + | :ambank + | :bank_islam + | :bank_muamalat + | :bank_of_china + | :bank_rakyat + | :bsn + | :cimb + | :deutsche_bank + | :hong_leong_bank + | :hsbc + | :kfh + | :maybank2e + | :maybank2u + | :ocbc + | :pb_enterprise + | :public_bank + | :rhb + | :standard_chartered + | :uob + } + ) + + ( + @typedoc nil + @type giropay :: %{optional(:setup_future_usage) => :none} + ) + + ( + @typedoc nil + @type grabpay :: %{optional(:setup_future_usage) => :none} + ) + + ( + @typedoc nil + @type ideal :: %{optional(:setup_future_usage) => :none | :off_session} + ) + + ( + @typedoc "Installment configuration for payments attempted on this PaymentIntent (Mexico Only).\n\nFor more information, see the [installments integration guide](https://stripe.com/docs/payments/installments)." + @type installments :: %{optional(:enabled) => boolean, optional(:plan) => plan | binary} + ) + + ( + @typedoc "If this is a `klarna` PaymentMethod, this hash contains details about the Klarna payment method." + @type klarna :: %{optional(:dob) => dob} + ) + + ( + @typedoc nil + @type konbini :: %{ + optional(:confirmation_number) => binary, + optional(:expires_after_days) => integer | binary, + optional(:expires_at) => integer | binary, + optional(:product_description) => binary, + optional(:setup_future_usage) => :none + } + ) + + ( + @typedoc nil + @type link :: %{ + optional(:capture_method) => :manual, + optional(:persistent_token) => binary, + optional(:setup_future_usage) => :none | :off_session + } + ) + + ( + @typedoc "This hash contains details about the Mandate to create. This parameter can only be used with [`confirm=true`](https://stripe.com/docs/api/payment_intents/create#create_payment_intent-confirm)." + @type mandate_data :: %{optional(:customer_acceptance) => customer_acceptance} + ) + + ( + @typedoc "Additional fields for Mandate creation" + @type mandate_options :: %{ + optional(:custom_mandate_url) => binary | binary, + optional(:interval_description) => binary, + optional(:payment_schedule) => :combined | :interval | :sporadic, + optional(:transaction_type) => :business | :personal + } + ) + + ( + @typedoc "Additional fields for network related functions" + @type networks :: %{optional(:requested) => list(:ach | :us_domestic_wire)} + ) + + ( + @typedoc "If this is a Mandate accepted online, this hash contains details about the online acceptance." + @type online :: %{optional(:ip_address) => binary, optional(:user_agent) => binary} + ) + + ( + @typedoc nil + @type oxxo :: %{ + optional(:expires_after_days) => integer, + optional(:setup_future_usage) => :none + } + ) + + ( + @typedoc "If this is a `p24` PaymentMethod, this hash contains details about the P24 payment method." + @type p24 :: %{ + optional(:bank) => + :alior_bank + | :bank_millennium + | :bank_nowy_bfg_sa + | :bank_pekao_sa + | :banki_spbdzielcze + | :blik + | :bnp_paribas + | :boz + | :citi_handlowy + | :credit_agricole + | :envelobank + | :etransfer_pocztowy24 + | :getin_bank + | :ideabank + | :ing + | :inteligo + | :mbank_mtransfer + | :nest_przelew + | :noble_pay + | :pbac_z_ipko + | :plus_bank + | :santander_przelew24 + | :tmobile_usbugi_bankowe + | :toyota_bank + | :volkswagen_bank + } + ) + + ( + @typedoc "If provided, this hash will be used to create a PaymentMethod. The new PaymentMethod will appear\nin the [payment_method](https://stripe.com/docs/api/payment_intents/object#payment_intent_object-payment_method)\nproperty on the PaymentIntent." + @type payment_method_data :: %{ + optional(:pix) => map(), + optional(:fpx) => fpx, + optional(:affirm) => map(), + optional(:acss_debit) => acss_debit, + optional(:bacs_debit) => bacs_debit, + optional(:alipay) => map(), + optional(:giropay) => map(), + optional(:ideal) => ideal, + optional(:radar_options) => radar_options, + optional(:metadata) => %{optional(binary) => binary}, + optional(:link) => map(), + optional(:promptpay) => map(), + optional(:cashapp) => map(), + optional(:oxxo) => map(), + optional(:interac_present) => map(), + optional(:us_bank_account) => us_bank_account, + optional(:zip) => map(), + optional(:paypal) => map(), + optional(:boleto) => boleto, + optional(:konbini) => map(), + optional(:billing_details) => billing_details, + optional(:blik) => map(), + optional(:wechat_pay) => map(), + optional(:sofort) => sofort, + optional(:p24) => p24, + optional(:afterpay_clearpay) => map(), + optional(:type) => + :acss_debit + | :affirm + | :afterpay_clearpay + | :alipay + | :au_becs_debit + | :bacs_debit + | :bancontact + | :blik + | :boleto + | :cashapp + | :customer_balance + | :eps + | :fpx + | :giropay + | :grabpay + | :ideal + | :klarna + | :konbini + | :link + | :oxxo + | :p24 + | :paynow + | :paypal + | :pix + | :promptpay + | :sepa_debit + | :sofort + | :us_bank_account + | :wechat_pay + | :zip, + optional(:grabpay) => map(), + optional(:bancontact) => map(), + optional(:au_becs_debit) => au_becs_debit, + optional(:customer_balance) => map(), + optional(:sepa_debit) => sepa_debit, + optional(:klarna) => klarna, + optional(:paynow) => map(), + optional(:eps) => eps + } + ) + + ( + @typedoc "Payment-method-specific configuration for this PaymentIntent." + @type payment_method_options :: %{ + optional(:pix) => pix | binary, + optional(:fpx) => fpx | binary, + optional(:affirm) => affirm | binary, + optional(:acss_debit) => acss_debit | binary, + optional(:bacs_debit) => bacs_debit | binary, + optional(:alipay) => alipay | binary, + optional(:giropay) => giropay | binary, + optional(:ideal) => ideal | binary, + optional(:card) => card | binary, + optional(:link) => link | binary, + optional(:promptpay) => promptpay | binary, + optional(:cashapp) => cashapp | binary, + optional(:oxxo) => oxxo | binary, + optional(:interac_present) => map() | binary, + optional(:us_bank_account) => us_bank_account | binary, + optional(:zip) => zip | binary, + optional(:paypal) => paypal | binary, + optional(:boleto) => boleto | binary, + optional(:konbini) => konbini | binary, + optional(:blik) => blik | binary, + optional(:wechat_pay) => wechat_pay | binary, + optional(:sofort) => sofort | binary, + optional(:p24) => p24 | binary, + optional(:afterpay_clearpay) => afterpay_clearpay | binary, + optional(:grabpay) => grabpay | binary, + optional(:bancontact) => bancontact | binary, + optional(:au_becs_debit) => au_becs_debit | binary, + optional(:customer_balance) => customer_balance | binary, + optional(:card_present) => card_present | binary, + optional(:sepa_debit) => sepa_debit | binary, + optional(:klarna) => klarna | binary, + optional(:paynow) => paynow | binary, + optional(:eps) => eps | binary + } + ) + + ( + @typedoc nil + @type paynow :: %{optional(:setup_future_usage) => :none} + ) + + ( + @typedoc nil + @type paypal :: %{ + optional(:capture_method) => :manual, + optional(:preferred_locale) => + :"cs-CZ" + | :"da-DK" + | :"de-AT" + | :"de-DE" + | :"de-LU" + | :"el-GR" + | :"en-GB" + | :"en-US" + | :"es-ES" + | :"fi-FI" + | :"fr-BE" + | :"fr-FR" + | :"fr-LU" + | :"hu-HU" + | :"it-IT" + | :"nl-BE" + | :"nl-NL" + | :"pl-PL" + | :"pt-PT" + | :"sk-SK" + | :"sv-SE", + optional(:reference) => binary, + optional(:risk_correlation_id) => binary, + optional(:setup_future_usage) => :none | :off_session + } + ) + + ( + @typedoc nil + @type pix :: %{ + optional(:expires_after_seconds) => integer, + optional(:expires_at) => integer, + optional(:setup_future_usage) => :none + } + ) + + ( + @typedoc nil + @type plan :: %{ + optional(:count) => integer, + optional(:interval) => :month, + optional(:type) => :fixed_count + } + ) + + ( + @typedoc nil + @type promptpay :: %{optional(:setup_future_usage) => :none} + ) + + ( + @typedoc "Options to configure Radar. See [Radar Session](https://stripe.com/docs/radar/radar-session) for more information." + @type radar_options :: %{optional(:session) => binary} + ) + + ( + @typedoc "If this is a `sepa_debit` PaymentMethod, this hash contains details about the SEPA debit bank account." + @type sepa_debit :: %{optional(:iban) => binary} + ) + + ( + @typedoc "Shipping information for this PaymentIntent." + @type shipping :: %{ + optional(:address) => address, + optional(:carrier) => binary, + optional(:name) => binary, + optional(:phone) => binary, + optional(:tracking_number) => binary + } + ) + + ( + @typedoc "If this is a `sofort` PaymentMethod, this hash contains details about the SOFORT payment method." + @type sofort :: %{optional(:country) => :AT | :BE | :DE | :ES | :IT | :NL} + ) + + ( + @typedoc "The parameters used to automatically create a Transfer when the payment succeeds.\nFor more information, see the PaymentIntents [use case for connected accounts](https://stripe.com/docs/payments/connected-accounts)." + @type transfer_data :: %{optional(:amount) => integer, optional(:destination) => binary} + ) + + ( + @typedoc nil + @type us_bank_account :: %{ + optional(:financial_connections) => financial_connections, + optional(:networks) => networks, + optional(:setup_future_usage) => :none | :off_session | :on_session, + optional(:verification_method) => :automatic | :instant | :microdeposits + } + ) + + ( + @typedoc nil + @type wechat_pay :: %{ + optional(:app_id) => binary, + optional(:client) => :android | :ios | :web, + optional(:setup_future_usage) => :none + } + ) + + ( + @typedoc nil + @type zip :: %{optional(:setup_future_usage) => :none} + ) + + ( + nil + + @doc "

Search for PaymentIntents you’ve previously created using Stripe’s Search Query Language.\nDon’t use search in read-after-write flows where strict consistency is necessary. Under normal operating\nconditions, data is searchable in less than a minute. Occasionally, propagation of new or updated data can be up\nto an hour behind during outages. Search functionality is not available to merchants in India.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/payment_intents/search`\n" + ( + @spec search( + params :: %{ + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:page) => binary, + optional(:query) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.SearchResult.t(Stripe.PaymentIntent.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def search(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/payment_intents/search", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Creates a PaymentIntent object.

\n\n

After the PaymentIntent is created, attach a payment method and confirm\nto continue the payment. You can read more about the different payment flows\navailable via the Payment Intents API here.

\n\n

When confirm=true is used during creation, it is equivalent to creating\nand confirming the PaymentIntent in the same call. You may use any parameters\navailable in the confirm API when confirm=true\nis supplied.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/payment_intents`\n" + ( + @spec create( + params :: %{ + optional(:amount) => integer, + optional(:application_fee_amount) => integer, + optional(:automatic_payment_methods) => automatic_payment_methods, + optional(:capture_method) => :automatic | :automatic_async | :manual, + optional(:confirm) => boolean, + optional(:confirmation_method) => :automatic | :manual, + optional(:currency) => binary, + optional(:customer) => binary, + optional(:description) => binary, + optional(:error_on_requires_action) => boolean, + optional(:expand) => list(binary), + optional(:mandate) => binary, + optional(:mandate_data) => mandate_data, + optional(:metadata) => %{optional(binary) => binary}, + optional(:off_session) => boolean | :one_off | :recurring, + optional(:on_behalf_of) => binary, + optional(:payment_method) => binary, + optional(:payment_method_data) => payment_method_data, + optional(:payment_method_options) => payment_method_options, + optional(:payment_method_types) => list(binary), + optional(:radar_options) => radar_options, + optional(:receipt_email) => binary, + optional(:return_url) => binary, + optional(:setup_future_usage) => :off_session | :on_session, + optional(:shipping) => shipping, + optional(:statement_descriptor) => binary, + optional(:statement_descriptor_suffix) => binary, + optional(:transfer_data) => transfer_data, + optional(:transfer_group) => binary, + optional(:use_stripe_sdk) => boolean + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.PaymentIntent.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/payment_intents", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Returns a list of PaymentIntents.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/payment_intents`\n" + ( + @spec list( + params :: %{ + optional(:created) => created | integer, + optional(:customer) => binary, + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.PaymentIntent.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/payment_intents", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves the details of a PaymentIntent that has previously been created.

\n\n

Client-side retrieval using a publishable key is allowed when the client_secret is provided in the query string.

\n\n

When retrieved with a publishable key, only a subset of properties will be returned. Please refer to the payment intent object reference for more details.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/payment_intents/{intent}`\n" + ( + @spec retrieve( + intent :: binary(), + params :: %{optional(:client_secret) => binary, optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.PaymentIntent.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def retrieve(intent, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/payment_intents/{intent}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "intent", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "intent", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [intent] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Updates properties on a PaymentIntent object without confirming.

\n\n

Depending on which properties you update, you may need to confirm the\nPaymentIntent again. For example, updating the payment_method will\nalways require you to confirm the PaymentIntent again. If you prefer to\nupdate and confirm at the same time, we recommend updating properties via\nthe confirm API instead.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/payment_intents/{intent}`\n" + ( + @spec update( + intent :: binary(), + params :: %{ + optional(:amount) => integer, + optional(:application_fee_amount) => integer | binary, + optional(:capture_method) => :automatic | :automatic_async | :manual, + optional(:currency) => binary, + optional(:customer) => binary, + optional(:description) => binary, + optional(:expand) => list(binary), + optional(:metadata) => %{optional(binary) => binary} | binary, + optional(:payment_method) => binary, + optional(:payment_method_data) => payment_method_data, + optional(:payment_method_options) => payment_method_options, + optional(:payment_method_types) => list(binary), + optional(:receipt_email) => binary | binary, + optional(:setup_future_usage) => :off_session | :on_session, + optional(:shipping) => shipping | binary, + optional(:statement_descriptor) => binary, + optional(:statement_descriptor_suffix) => binary, + optional(:transfer_data) => transfer_data, + optional(:transfer_group) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.PaymentIntent.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def update(intent, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/payment_intents/{intent}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "intent", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "intent", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [intent] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Confirm that your customer intends to pay with current or provided\npayment method. Upon confirmation, the PaymentIntent will attempt to initiate\na payment.\nIf the selected payment method requires additional authentication steps, the\nPaymentIntent will transition to the requires_action status and\nsuggest additional actions via next_action. If payment fails,\nthe PaymentIntent transitions to the requires_payment_method status or the\ncanceled status if the confirmation limit is reached. If\npayment succeeds, the PaymentIntent will transition to the succeeded\nstatus (or requires_capture, if capture_method is set to manual).\nIf the confirmation_method is automatic, payment may be attempted\nusing our client SDKs\nand the PaymentIntent’s client_secret.\nAfter next_actions are handled by the client, no additional\nconfirmation is required to complete the payment.\nIf the confirmation_method is manual, all payment attempts must be\ninitiated using a secret key.\nIf any actions are required for the payment, the PaymentIntent will\nreturn to the requires_confirmation state\nafter those actions are completed. Your server needs to then\nexplicitly re-confirm the PaymentIntent to initiate the next payment\nattempt. Read the expanded documentation\nto learn more about manual confirmation.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/payment_intents/{intent}/confirm`\n" + ( + @spec confirm( + intent :: binary(), + params :: %{ + optional(:capture_method) => :automatic | :automatic_async | :manual, + optional(:error_on_requires_action) => boolean, + optional(:expand) => list(binary), + optional(:mandate) => binary, + optional(:mandate_data) => mandate_data | mandate_data, + optional(:off_session) => boolean | :one_off | :recurring, + optional(:payment_method) => binary, + optional(:payment_method_data) => payment_method_data, + optional(:payment_method_options) => payment_method_options, + optional(:radar_options) => radar_options, + optional(:receipt_email) => binary | binary, + optional(:return_url) => binary, + optional(:setup_future_usage) => :off_session | :on_session, + optional(:shipping) => shipping | binary, + optional(:use_stripe_sdk) => boolean + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.PaymentIntent.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def confirm(intent, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/payment_intents/{intent}/confirm", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "intent", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "intent", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [intent] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

A PaymentIntent object can be canceled when it is in one of these statuses: requires_payment_method, requires_capture, requires_confirmation, requires_action or, in rare cases, processing.

\n\n

Once canceled, no additional charges will be made by the PaymentIntent and any operations on the PaymentIntent will fail with an error. For PaymentIntents with a status of requires_capture, the remaining amount_capturable will automatically be refunded.

\n\n

You cannot cancel the PaymentIntent for a Checkout Session. Expire the Checkout Session instead.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/payment_intents/{intent}/cancel`\n" + ( + @spec cancel( + intent :: binary(), + params :: %{ + optional(:cancellation_reason) => + :abandoned | :duplicate | :fraudulent | :requested_by_customer, + optional(:expand) => list(binary) + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.PaymentIntent.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def cancel(intent, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/payment_intents/{intent}/cancel", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "intent", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "intent", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [intent] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Capture the funds of an existing uncaptured PaymentIntent when its status is requires_capture.

\n\n

Uncaptured PaymentIntents will be canceled a set number of days after they are created (7 by default).

\n\n

Learn more about separate authorization and capture.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/payment_intents/{intent}/capture`\n" + ( + @spec capture( + intent :: binary(), + params :: %{ + optional(:amount_to_capture) => integer, + optional(:application_fee_amount) => integer, + optional(:expand) => list(binary), + optional(:metadata) => %{optional(binary) => binary} | binary, + optional(:statement_descriptor) => binary, + optional(:statement_descriptor_suffix) => binary, + optional(:transfer_data) => transfer_data + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.PaymentIntent.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def capture(intent, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/payment_intents/{intent}/capture", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "intent", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "intent", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [intent] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Perform an incremental authorization on an eligible\nPaymentIntent. To be eligible, the\nPaymentIntent’s status must be requires_capture and\nincremental_authorization_supported\nmust be true.

\n\n

Incremental authorizations attempt to increase the authorized amount on\nyour customer’s card to the new, higher amount provided. As with the\ninitial authorization, incremental authorizations may be declined. A\nsingle PaymentIntent can call this endpoint multiple times to further\nincrease the authorized amount.

\n\n

If the incremental authorization succeeds, the PaymentIntent object is\nreturned with the updated\namount.\nIf the incremental authorization fails, a\ncard_declined error is returned, and no\nfields on the PaymentIntent or Charge are updated. The PaymentIntent\nobject remains capturable for the previously authorized amount.

\n\n

Each PaymentIntent can have a maximum of 10 incremental authorization attempts, including declines.\nOnce captured, a PaymentIntent can no longer be incremented.

\n\n

Learn more about incremental authorizations.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/payment_intents/{intent}/increment_authorization`\n" + ( + @spec increment_authorization( + intent :: binary(), + params :: %{ + optional(:amount) => integer, + optional(:application_fee_amount) => integer, + optional(:description) => binary, + optional(:expand) => list(binary), + optional(:metadata) => %{optional(binary) => binary}, + optional(:statement_descriptor) => binary, + optional(:transfer_data) => transfer_data + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.PaymentIntent.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def increment_authorization(intent, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/payment_intents/{intent}/increment_authorization", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "intent", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "intent", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [intent] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Verifies microdeposits on a PaymentIntent object.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/payment_intents/{intent}/verify_microdeposits`\n" + ( + @spec verify_microdeposits( + intent :: binary(), + params :: %{ + optional(:amounts) => list(integer), + optional(:descriptor_code) => binary, + optional(:expand) => list(binary) + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.PaymentIntent.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def verify_microdeposits(intent, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/payment_intents/{intent}/verify_microdeposits", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "intent", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "intent", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [intent] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Manually reconcile the remaining amount for a customer_balance PaymentIntent.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/payment_intents/{intent}/apply_customer_balance`\n" + ( + @spec apply_customer_balance( + intent :: binary(), + params :: %{ + optional(:amount) => integer, + optional(:currency) => binary, + optional(:expand) => list(binary) + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.PaymentIntent.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def apply_customer_balance(intent, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/payment_intents/{intent}/apply_customer_balance", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "intent", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "intent", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [intent] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/payment_link.ex b/lib/generated/payment_link.ex new file mode 100644 index 00000000..2c06cfdf --- /dev/null +++ b/lib/generated/payment_link.ex @@ -0,0 +1,774 @@ +defmodule Stripe.PaymentLink do + use Stripe.Entity + + @moduledoc "A payment link is a shareable URL that will take your customers to a hosted payment page. A payment link can be shared and used multiple times.\n\nWhen a customer opens a payment link it will open a new [checkout session](https://stripe.com/docs/api/checkout/sessions) to render the payment page. You can use [checkout session events](https://stripe.com/docs/api/events/types#event_types-checkout.session.completed) to track payments through payment links.\n\nRelated guide: [Payment Links API](https://stripe.com/docs/payment-links)" + ( + defstruct [ + :active, + :after_completion, + :allow_promotion_codes, + :application_fee_amount, + :application_fee_percent, + :automatic_tax, + :billing_address_collection, + :consent_collection, + :currency, + :custom_fields, + :custom_text, + :customer_creation, + :id, + :invoice_creation, + :line_items, + :livemode, + :metadata, + :object, + :on_behalf_of, + :payment_intent_data, + :payment_method_collection, + :payment_method_types, + :phone_number_collection, + :shipping_address_collection, + :shipping_options, + :submit_type, + :subscription_data, + :tax_id_collection, + :transfer_data, + :url + ] + + @typedoc "The `payment_link` type.\n\n * `active` Whether the payment link's `url` is active. If `false`, customers visiting the URL will be shown a page saying that the link has been deactivated.\n * `after_completion` \n * `allow_promotion_codes` Whether user redeemable promotion codes are enabled.\n * `application_fee_amount` The amount of the application fee (if any) that will be requested to be applied to the payment and transferred to the application owner's Stripe account.\n * `application_fee_percent` This represents the percentage of the subscription invoice subtotal that will be transferred to the application owner's Stripe account.\n * `automatic_tax` \n * `billing_address_collection` Configuration for collecting the customer's billing address.\n * `consent_collection` When set, provides configuration to gather active consent from customers.\n * `currency` Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).\n * `custom_fields` Collect additional information from your customer using custom fields. Up to 2 fields are supported.\n * `custom_text` \n * `customer_creation` Configuration for Customer creation during checkout.\n * `id` Unique identifier for the object.\n * `invoice_creation` Configuration for creating invoice for payment mode payment links.\n * `line_items` The line items representing what is being sold.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `metadata` Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `on_behalf_of` The account on behalf of which to charge. See the [Connect documentation](https://support.stripe.com/questions/sending-invoices-on-behalf-of-connected-accounts) for details.\n * `payment_intent_data` Indicates the parameters to be passed to PaymentIntent creation during checkout.\n * `payment_method_collection` Configuration for collecting a payment method during checkout.\n * `payment_method_types` The list of payment method types that customers can use. When `null`, Stripe will dynamically show relevant payment methods you've enabled in your [payment method settings](https://dashboard.stripe.com/settings/payment_methods).\n * `phone_number_collection` \n * `shipping_address_collection` Configuration for collecting the customer's shipping address.\n * `shipping_options` The shipping rate options applied to the session.\n * `submit_type` Indicates the type of transaction being performed which customizes relevant text on the page, such as the submit button.\n * `subscription_data` When creating a subscription, the specified configuration data will be used. There must be at least one line item with a recurring price to use `subscription_data`.\n * `tax_id_collection` \n * `transfer_data` The account (if any) the payments will be attributed to for tax reporting, and where funds from each payment will be transferred to.\n * `url` The public URL that can be shared with customers.\n" + @type t :: %__MODULE__{ + active: boolean, + after_completion: term, + allow_promotion_codes: boolean, + application_fee_amount: integer | nil, + application_fee_percent: term | nil, + automatic_tax: term, + billing_address_collection: binary, + consent_collection: term | nil, + currency: binary, + custom_fields: term, + custom_text: term, + customer_creation: binary, + id: binary, + invoice_creation: term | nil, + line_items: term, + livemode: boolean, + metadata: term, + object: binary, + on_behalf_of: (binary | Stripe.Account.t()) | nil, + payment_intent_data: term | nil, + payment_method_collection: binary, + payment_method_types: term | nil, + phone_number_collection: term, + shipping_address_collection: term | nil, + shipping_options: term, + submit_type: binary, + subscription_data: term | nil, + tax_id_collection: term, + transfer_data: term | nil, + url: binary + } + ) + + ( + @typedoc "When set, provides configuration for this item’s quantity to be adjusted by the customer during checkout." + @type adjustable_quantity :: %{ + optional(:enabled) => boolean, + optional(:maximum) => integer, + optional(:minimum) => integer + } + ) + + ( + @typedoc "Behavior after the purchase is complete." + @type after_completion :: %{ + optional(:hosted_confirmation) => hosted_confirmation, + optional(:redirect) => redirect, + optional(:type) => :hosted_confirmation | :redirect + } + ) + + ( + @typedoc "Configuration for automatic tax collection." + @type automatic_tax :: %{optional(:enabled) => boolean} + ) + + ( + @typedoc "Configure fields to gather active consent from customers." + @type consent_collection :: %{ + optional(:promotions) => :auto | :none, + optional(:terms_of_service) => :none | :required + } + ) + + ( + @typedoc nil + @type custom_fields :: %{ + optional(:dropdown) => dropdown, + optional(:key) => binary, + optional(:label) => label, + optional(:numeric) => numeric, + optional(:optional) => boolean, + optional(:text) => text, + optional(:type) => :dropdown | :numeric | :text + } + ) + + ( + @typedoc "Display additional text for your customers using custom text." + @type custom_text :: %{ + optional(:shipping_address) => shipping_address | binary, + optional(:submit) => submit | binary + } + ) + + ( + @typedoc "Configuration for `type=dropdown` fields." + @type dropdown :: %{optional(:options) => list(options)} + ) + + ( + @typedoc "Configuration when `type=hosted_confirmation`." + @type hosted_confirmation :: %{optional(:custom_message) => binary} + ) + + ( + @typedoc "Generate a post-purchase Invoice for one-time payments." + @type invoice_creation :: %{ + optional(:enabled) => boolean, + optional(:invoice_data) => invoice_data + } + ) + + ( + @typedoc "Invoice PDF configuration." + @type invoice_data :: %{ + optional(:account_tax_ids) => list(binary) | binary, + optional(:custom_fields) => list(custom_fields) | binary, + optional(:description) => binary, + optional(:footer) => binary, + optional(:metadata) => %{optional(binary) => binary} | binary, + optional(:rendering_options) => rendering_options | binary + } + ) + + ( + @typedoc "The label for the field, displayed to the customer." + @type label :: %{optional(:custom) => binary, optional(:type) => :custom} + ) + + ( + @typedoc nil + @type line_items :: %{ + optional(:adjustable_quantity) => adjustable_quantity, + optional(:price) => binary, + optional(:quantity) => integer + } + ) + + ( + @typedoc "Configuration for `type=numeric` fields." + @type numeric :: %{optional(:maximum_length) => integer, optional(:minimum_length) => integer} + ) + + ( + @typedoc nil + @type options :: %{optional(:label) => binary, optional(:value) => binary} + ) + + ( + @typedoc "A subset of parameters to be passed to PaymentIntent creation for Checkout Sessions in `payment` mode." + @type payment_intent_data :: %{ + optional(:capture_method) => :automatic | :automatic_async | :manual, + optional(:setup_future_usage) => :off_session | :on_session + } + ) + + ( + @typedoc "Controls phone number collection settings during checkout.\n\nWe recommend that you review your privacy policy and check with your legal contacts." + @type phone_number_collection :: %{optional(:enabled) => boolean} + ) + + ( + @typedoc "Configuration when `type=redirect`." + @type redirect :: %{optional(:url) => binary} + ) + + ( + @typedoc nil + @type rendering_options :: %{ + optional(:amount_tax_display) => :exclude_tax | :include_inclusive_tax + } + ) + + ( + @typedoc nil + @type shipping_address :: %{optional(:message) => binary} + ) + + ( + @typedoc "Configuration for collecting the customer's shipping address." + @type shipping_address_collection :: %{ + optional(:allowed_countries) => + list( + :AC + | :AD + | :AE + | :AF + | :AG + | :AI + | :AL + | :AM + | :AO + | :AQ + | :AR + | :AT + | :AU + | :AW + | :AX + | :AZ + | :BA + | :BB + | :BD + | :BE + | :BF + | :BG + | :BH + | :BI + | :BJ + | :BL + | :BM + | :BN + | :BO + | :BQ + | :BR + | :BS + | :BT + | :BV + | :BW + | :BY + | :BZ + | :CA + | :CD + | :CF + | :CG + | :CH + | :CI + | :CK + | :CL + | :CM + | :CN + | :CO + | :CR + | :CV + | :CW + | :CY + | :CZ + | :DE + | :DJ + | :DK + | :DM + | :DO + | :DZ + | :EC + | :EE + | :EG + | :EH + | :ER + | :ES + | :ET + | :FI + | :FJ + | :FK + | :FO + | :FR + | :GA + | :GB + | :GD + | :GE + | :GF + | :GG + | :GH + | :GI + | :GL + | :GM + | :GN + | :GP + | :GQ + | :GR + | :GS + | :GT + | :GU + | :GW + | :GY + | :HK + | :HN + | :HR + | :HT + | :HU + | :ID + | :IE + | :IL + | :IM + | :IN + | :IO + | :IQ + | :IS + | :IT + | :JE + | :JM + | :JO + | :JP + | :KE + | :KG + | :KH + | :KI + | :KM + | :KN + | :KR + | :KW + | :KY + | :KZ + | :LA + | :LB + | :LC + | :LI + | :LK + | :LR + | :LS + | :LT + | :LU + | :LV + | :LY + | :MA + | :MC + | :MD + | :ME + | :MF + | :MG + | :MK + | :ML + | :MM + | :MN + | :MO + | :MQ + | :MR + | :MS + | :MT + | :MU + | :MV + | :MW + | :MX + | :MY + | :MZ + | :NA + | :NC + | :NE + | :NG + | :NI + | :NL + | :NO + | :NP + | :NR + | :NU + | :NZ + | :OM + | :PA + | :PE + | :PF + | :PG + | :PH + | :PK + | :PL + | :PM + | :PN + | :PR + | :PS + | :PT + | :PY + | :QA + | :RE + | :RO + | :RS + | :RU + | :RW + | :SA + | :SB + | :SC + | :SE + | :SG + | :SH + | :SI + | :SJ + | :SK + | :SL + | :SM + | :SN + | :SO + | :SR + | :SS + | :ST + | :SV + | :SX + | :SZ + | :TA + | :TC + | :TD + | :TF + | :TG + | :TH + | :TJ + | :TK + | :TL + | :TM + | :TN + | :TO + | :TR + | :TT + | :TV + | :TW + | :TZ + | :UA + | :UG + | :US + | :UY + | :UZ + | :VA + | :VC + | :VE + | :VG + | :VN + | :VU + | :WF + | :WS + | :XK + | :YE + | :YT + | :ZA + | :ZM + | :ZW + | :ZZ + ) + } + ) + + ( + @typedoc nil + @type shipping_options :: %{optional(:shipping_rate) => binary} + ) + + ( + @typedoc nil + @type submit :: %{optional(:message) => binary} + ) + + ( + @typedoc "When creating a subscription, the specified configuration data will be used. There must be at least one line item with a recurring price to use `subscription_data`." + @type subscription_data :: %{ + optional(:description) => binary, + optional(:trial_period_days) => integer + } + ) + + ( + @typedoc "Controls tax ID collection during checkout." + @type tax_id_collection :: %{optional(:enabled) => boolean} + ) + + ( + @typedoc "Configuration for `type=text` fields." + @type text :: %{optional(:maximum_length) => integer, optional(:minimum_length) => integer} + ) + + ( + @typedoc "The account (if any) the payments will be attributed to for tax reporting, and where funds from each payment will be transferred to." + @type transfer_data :: %{optional(:amount) => integer, optional(:destination) => binary} + ) + + ( + nil + + @doc "

Returns a list of your payment links.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/payment_links`\n" + ( + @spec list( + params :: %{ + optional(:active) => boolean, + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.PaymentLink.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/payment_links", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieve a payment link.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/payment_links/{payment_link}`\n" + ( + @spec retrieve( + payment_link :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: {:ok, Stripe.PaymentLink.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def retrieve(payment_link, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/payment_links/{payment_link}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "payment_link", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "payment_link", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [payment_link] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

When retrieving a payment link, there is an includable line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/payment_links/{payment_link}/line_items`\n" + ( + @spec list_line_items( + payment_link :: binary(), + params :: %{ + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.Item.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list_line_items(payment_link, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/payment_links/{payment_link}/line_items", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "payment_link", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "payment_link", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [payment_link] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Creates a payment link.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/payment_links`\n" + ( + @spec create( + params :: %{ + optional(:after_completion) => after_completion, + optional(:allow_promotion_codes) => boolean, + optional(:application_fee_amount) => integer, + optional(:application_fee_percent) => number, + optional(:automatic_tax) => automatic_tax, + optional(:billing_address_collection) => :auto | :required, + optional(:consent_collection) => consent_collection, + optional(:currency) => binary, + optional(:custom_fields) => list(custom_fields), + optional(:custom_text) => custom_text, + optional(:customer_creation) => :always | :if_required, + optional(:expand) => list(binary), + optional(:invoice_creation) => invoice_creation, + optional(:line_items) => list(line_items), + optional(:metadata) => %{optional(binary) => binary}, + optional(:on_behalf_of) => binary, + optional(:payment_intent_data) => payment_intent_data, + optional(:payment_method_collection) => :always | :if_required, + optional(:payment_method_types) => + list( + :affirm + | :afterpay_clearpay + | :alipay + | :au_becs_debit + | :bacs_debit + | :bancontact + | :blik + | :boleto + | :card + | :cashapp + | :eps + | :fpx + | :giropay + | :grabpay + | :ideal + | :klarna + | :konbini + | :link + | :oxxo + | :p24 + | :paynow + | :paypal + | :pix + | :promptpay + | :sepa_debit + | :sofort + | :us_bank_account + | :wechat_pay + ), + optional(:phone_number_collection) => phone_number_collection, + optional(:shipping_address_collection) => shipping_address_collection, + optional(:shipping_options) => list(shipping_options), + optional(:submit_type) => :auto | :book | :donate | :pay, + optional(:subscription_data) => subscription_data, + optional(:tax_id_collection) => tax_id_collection, + optional(:transfer_data) => transfer_data + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.PaymentLink.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/payment_links", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Updates a payment link.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/payment_links/{payment_link}`\n" + ( + @spec update( + payment_link :: binary(), + params :: %{ + optional(:active) => boolean, + optional(:after_completion) => after_completion, + optional(:allow_promotion_codes) => boolean, + optional(:automatic_tax) => automatic_tax, + optional(:billing_address_collection) => :auto | :required, + optional(:custom_fields) => list(custom_fields) | binary, + optional(:custom_text) => custom_text, + optional(:customer_creation) => :always | :if_required, + optional(:expand) => list(binary), + optional(:invoice_creation) => invoice_creation, + optional(:line_items) => list(line_items), + optional(:metadata) => %{optional(binary) => binary}, + optional(:payment_method_collection) => :always | :if_required, + optional(:payment_method_types) => + list( + :affirm + | :afterpay_clearpay + | :alipay + | :au_becs_debit + | :bacs_debit + | :bancontact + | :blik + | :boleto + | :card + | :cashapp + | :eps + | :fpx + | :giropay + | :grabpay + | :ideal + | :klarna + | :konbini + | :link + | :oxxo + | :p24 + | :paynow + | :paypal + | :pix + | :promptpay + | :sepa_debit + | :sofort + | :us_bank_account + | :wechat_pay + ) + | binary, + optional(:shipping_address_collection) => shipping_address_collection | binary + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.PaymentLink.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def update(payment_link, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/payment_links/{payment_link}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "payment_link", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "payment_link", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [payment_link] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/payment_method.ex b/lib/generated/payment_method.ex new file mode 100644 index 00000000..79c1cd4b --- /dev/null +++ b/lib/generated/payment_method.ex @@ -0,0 +1,650 @@ +defmodule Stripe.PaymentMethod do + use Stripe.Entity + + @moduledoc "PaymentMethod objects represent your customer's payment instruments.\nYou can use them with [PaymentIntents](https://stripe.com/docs/payments/payment-intents) to collect payments or save them to\nCustomer objects to store instrument details for future payments.\n\nRelated guides: [Payment Methods](https://stripe.com/docs/payments/payment-methods) and [More Payment Scenarios](https://stripe.com/docs/payments/more-payment-scenarios)." + ( + defstruct [ + :eps, + :id, + :paynow, + :klarna, + :sepa_debit, + :card_present, + :customer_balance, + :au_becs_debit, + :bancontact, + :grabpay, + :type, + :afterpay_clearpay, + :created, + :p24, + :sofort, + :wechat_pay, + :blik, + :billing_details, + :konbini, + :object, + :boleto, + :paypal, + :zip, + :us_bank_account, + :customer, + :interac_present, + :oxxo, + :cashapp, + :promptpay, + :link, + :metadata, + :radar_options, + :card, + :ideal, + :giropay, + :alipay, + :bacs_debit, + :acss_debit, + :livemode, + :affirm, + :fpx, + :pix + ] + + @typedoc "The `payment_method` type.\n\n * `acss_debit` \n * `affirm` \n * `afterpay_clearpay` \n * `alipay` \n * `au_becs_debit` \n * `bacs_debit` \n * `bancontact` \n * `billing_details` \n * `blik` \n * `boleto` \n * `card` \n * `card_present` \n * `cashapp` \n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `customer` The ID of the Customer to which this PaymentMethod is saved. This will not be set when the PaymentMethod has not been saved to a Customer.\n * `customer_balance` \n * `eps` \n * `fpx` \n * `giropay` \n * `grabpay` \n * `id` Unique identifier for the object.\n * `ideal` \n * `interac_present` \n * `klarna` \n * `konbini` \n * `link` \n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `metadata` Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `oxxo` \n * `p24` \n * `paynow` \n * `paypal` \n * `pix` \n * `promptpay` \n * `radar_options` \n * `sepa_debit` \n * `sofort` \n * `type` The type of the PaymentMethod. An additional hash is included on the PaymentMethod with a name matching this value. It contains additional information specific to the PaymentMethod type.\n * `us_bank_account` \n * `wechat_pay` \n * `zip` \n" + @type t :: %__MODULE__{ + acss_debit: term, + affirm: term, + afterpay_clearpay: term, + alipay: term, + au_becs_debit: term, + bacs_debit: term, + bancontact: term, + billing_details: term, + blik: term, + boleto: term, + card: term, + card_present: term, + cashapp: term, + created: integer, + customer: (binary | Stripe.Customer.t()) | nil, + customer_balance: term, + eps: term, + fpx: term, + giropay: term, + grabpay: term, + id: binary, + ideal: term, + interac_present: term, + klarna: term, + konbini: term, + link: term, + livemode: boolean, + metadata: term | nil, + object: binary, + oxxo: term, + p24: term, + paynow: term, + paypal: term, + pix: term, + promptpay: term, + radar_options: term, + sepa_debit: term, + sofort: term, + type: binary, + us_bank_account: term, + wechat_pay: term, + zip: term + } + ) + + ( + @typedoc "If this is an `acss_debit` PaymentMethod, this hash contains details about the ACSS Debit payment method." + @type acss_debit :: %{ + optional(:account_number) => binary, + optional(:institution_number) => binary, + optional(:transit_number) => binary + } + ) + + ( + @typedoc nil + @type address :: %{ + optional(:city) => binary, + optional(:country) => binary, + optional(:line1) => binary, + optional(:line2) => binary, + optional(:postal_code) => binary, + optional(:state) => binary + } + ) + + ( + @typedoc "If this is an `au_becs_debit` PaymentMethod, this hash contains details about the bank account." + @type au_becs_debit :: %{optional(:account_number) => binary, optional(:bsb_number) => binary} + ) + + ( + @typedoc "If this is a `bacs_debit` PaymentMethod, this hash contains details about the Bacs Direct Debit bank account." + @type bacs_debit :: %{optional(:account_number) => binary, optional(:sort_code) => binary} + ) + + ( + @typedoc "Billing information associated with the PaymentMethod that may be used or required by particular types of payment methods." + @type billing_details :: %{ + optional(:address) => address | binary, + optional(:email) => binary | binary, + optional(:name) => binary, + optional(:phone) => binary + } + ) + + ( + @typedoc "If this is a `boleto` PaymentMethod, this hash contains details about the Boleto payment method." + @type boleto :: %{optional(:tax_id) => binary} + ) + + ( + @typedoc nil + @type card :: %{ + optional(:cvc) => binary, + optional(:exp_month) => integer, + optional(:exp_year) => integer, + optional(:number) => binary + } + ) + + ( + @typedoc "Customer's date of birth" + @type dob :: %{ + optional(:day) => integer, + optional(:month) => integer, + optional(:year) => integer + } + ) + + ( + @typedoc "If this is an `eps` PaymentMethod, this hash contains details about the EPS payment method." + @type eps :: %{ + optional(:bank) => + :arzte_und_apotheker_bank + | :austrian_anadi_bank_ag + | :bank_austria + | :bankhaus_carl_spangler + | :bankhaus_schelhammer_und_schattera_ag + | :bawag_psk_ag + | :bks_bank_ag + | :brull_kallmus_bank_ag + | :btv_vier_lander_bank + | :capital_bank_grawe_gruppe_ag + | :deutsche_bank_ag + | :dolomitenbank + | :easybank_ag + | :erste_bank_und_sparkassen + | :hypo_alpeadriabank_international_ag + | :hypo_bank_burgenland_aktiengesellschaft + | :hypo_noe_lb_fur_niederosterreich_u_wien + | :hypo_oberosterreich_salzburg_steiermark + | :hypo_tirol_bank_ag + | :hypo_vorarlberg_bank_ag + | :marchfelder_bank + | :oberbank_ag + | :raiffeisen_bankengruppe_osterreich + | :schoellerbank_ag + | :sparda_bank_wien + | :volksbank_gruppe + | :volkskreditbank_ag + | :vr_bank_braunau + } + ) + + ( + @typedoc "If this is an `fpx` PaymentMethod, this hash contains details about the FPX payment method." + @type fpx :: %{ + optional(:account_holder_type) => :company | :individual, + optional(:bank) => + :affin_bank + | :agrobank + | :alliance_bank + | :ambank + | :bank_islam + | :bank_muamalat + | :bank_of_china + | :bank_rakyat + | :bsn + | :cimb + | :deutsche_bank + | :hong_leong_bank + | :hsbc + | :kfh + | :maybank2e + | :maybank2u + | :ocbc + | :pb_enterprise + | :public_bank + | :rhb + | :standard_chartered + | :uob + } + ) + + ( + @typedoc "If this is an `ideal` PaymentMethod, this hash contains details about the iDEAL payment method." + @type ideal :: %{ + optional(:bank) => + :abn_amro + | :asn_bank + | :bunq + | :handelsbanken + | :ing + | :knab + | :moneyou + | :rabobank + | :regiobank + | :revolut + | :sns_bank + | :triodos_bank + | :van_lanschot + | :yoursafe + } + ) + + ( + @typedoc "If this is a `klarna` PaymentMethod, this hash contains details about the Klarna payment method." + @type klarna :: %{optional(:dob) => dob} + ) + + ( + @typedoc "If this is a `p24` PaymentMethod, this hash contains details about the P24 payment method." + @type p24 :: %{ + optional(:bank) => + :alior_bank + | :bank_millennium + | :bank_nowy_bfg_sa + | :bank_pekao_sa + | :banki_spbdzielcze + | :blik + | :bnp_paribas + | :boz + | :citi_handlowy + | :credit_agricole + | :envelobank + | :etransfer_pocztowy24 + | :getin_bank + | :ideabank + | :ing + | :inteligo + | :mbank_mtransfer + | :nest_przelew + | :noble_pay + | :pbac_z_ipko + | :plus_bank + | :santander_przelew24 + | :tmobile_usbugi_bankowe + | :toyota_bank + | :volkswagen_bank + } + ) + + ( + @typedoc "Options to configure Radar. See [Radar Session](https://stripe.com/docs/radar/radar-session) for more information." + @type radar_options :: %{optional(:session) => binary} + ) + + ( + @typedoc "If this is a `sepa_debit` PaymentMethod, this hash contains details about the SEPA debit bank account." + @type sepa_debit :: %{optional(:iban) => binary} + ) + + ( + @typedoc "If this is a `sofort` PaymentMethod, this hash contains details about the SOFORT payment method." + @type sofort :: %{optional(:country) => :AT | :BE | :DE | :ES | :IT | :NL} + ) + + ( + @typedoc "If this is an `us_bank_account` PaymentMethod, this hash contains details about the US bank account payment method." + @type us_bank_account :: %{ + optional(:account_holder_type) => :company | :individual, + optional(:account_number) => binary, + optional(:account_type) => :checking | :savings, + optional(:financial_connections_account) => binary, + optional(:routing_number) => binary + } + ) + + ( + nil + + @doc "

Creates a PaymentMethod object. Read the Stripe.js reference to learn how to create PaymentMethods via Stripe.js.

\n\n

Instead of creating a PaymentMethod directly, we recommend using the PaymentIntents API to accept a payment immediately or the SetupIntent API to collect payment method details ahead of a future payment.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/payment_methods`\n" + ( + @spec create( + params :: %{ + optional(:pix) => map(), + optional(:payment_method) => binary, + optional(:fpx) => fpx, + optional(:affirm) => map(), + optional(:acss_debit) => acss_debit, + optional(:bacs_debit) => bacs_debit, + optional(:alipay) => map(), + optional(:giropay) => map(), + optional(:ideal) => ideal, + optional(:expand) => list(binary), + optional(:card) => card | card, + optional(:radar_options) => radar_options, + optional(:metadata) => %{optional(binary) => binary}, + optional(:link) => map(), + optional(:promptpay) => map(), + optional(:cashapp) => map(), + optional(:oxxo) => map(), + optional(:interac_present) => map(), + optional(:customer) => binary, + optional(:us_bank_account) => us_bank_account, + optional(:zip) => map(), + optional(:paypal) => map(), + optional(:boleto) => boleto, + optional(:konbini) => map(), + optional(:billing_details) => billing_details, + optional(:blik) => map(), + optional(:wechat_pay) => map(), + optional(:sofort) => sofort, + optional(:p24) => p24, + optional(:afterpay_clearpay) => map(), + optional(:type) => + :acss_debit + | :affirm + | :afterpay_clearpay + | :alipay + | :au_becs_debit + | :bacs_debit + | :bancontact + | :blik + | :boleto + | :card + | :cashapp + | :customer_balance + | :eps + | :fpx + | :giropay + | :grabpay + | :ideal + | :klarna + | :konbini + | :link + | :oxxo + | :p24 + | :paynow + | :paypal + | :pix + | :promptpay + | :sepa_debit + | :sofort + | :us_bank_account + | :wechat_pay + | :zip, + optional(:grabpay) => map(), + optional(:bancontact) => map(), + optional(:au_becs_debit) => au_becs_debit, + optional(:customer_balance) => map(), + optional(:sepa_debit) => sepa_debit, + optional(:klarna) => klarna, + optional(:paynow) => map(), + optional(:eps) => eps + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.PaymentMethod.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/payment_methods", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves a PaymentMethod object attached to the StripeAccount. To retrieve a payment method attached to a Customer, you should use Retrieve a Customer’s PaymentMethods

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/payment_methods/{payment_method}`\n" + ( + @spec retrieve( + payment_method :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.PaymentMethod.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def retrieve(payment_method, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/payment_methods/{payment_method}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "payment_method", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "payment_method", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [payment_method] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Updates a PaymentMethod object. A PaymentMethod must be attached a customer to be updated.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/payment_methods/{payment_method}`\n" + ( + @spec update( + payment_method :: binary(), + params :: %{ + optional(:acss_debit) => map(), + optional(:affirm) => map(), + optional(:au_becs_debit) => map(), + optional(:bacs_debit) => map(), + optional(:billing_details) => billing_details, + optional(:blik) => map(), + optional(:card) => card, + optional(:cashapp) => map(), + optional(:expand) => list(binary), + optional(:link) => map(), + optional(:metadata) => %{optional(binary) => binary} | binary, + optional(:sepa_debit) => map(), + optional(:us_bank_account) => us_bank_account, + optional(:zip) => map() + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.PaymentMethod.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def update(payment_method, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/payment_methods/{payment_method}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "payment_method", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "payment_method", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [payment_method] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Returns a list of PaymentMethods for Treasury flows. If you want to list the PaymentMethods attached to a Customer for payments, you should use the List a Customer’s PaymentMethods API instead.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/payment_methods`\n" + ( + @spec list( + params :: %{ + optional(:customer) => binary, + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:starting_after) => binary, + optional(:type) => + :acss_debit + | :affirm + | :afterpay_clearpay + | :alipay + | :au_becs_debit + | :bacs_debit + | :bancontact + | :blik + | :boleto + | :card + | :card_present + | :cashapp + | :customer_balance + | :eps + | :fpx + | :giropay + | :grabpay + | :ideal + | :klarna + | :konbini + | :link + | :oxxo + | :p24 + | :paynow + | :paypal + | :pix + | :promptpay + | :sepa_debit + | :sofort + | :us_bank_account + | :wechat_pay + | :zip + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.PaymentMethod.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/payment_methods", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Attaches a PaymentMethod object to a Customer.

\n\n

To attach a new PaymentMethod to a customer for future payments, we recommend you use a SetupIntent\nor a PaymentIntent with setup_future_usage.\nThese approaches will perform any necessary steps to set up the PaymentMethod for future payments. Using the /v1/payment_methods/:id/attach\nendpoint without first using a SetupIntent or PaymentIntent with setup_future_usage does not optimize the PaymentMethod for\nfuture use, which makes later declines and payment friction more likely.\nSee Optimizing cards for future payments for more information about setting up\nfuture payments.

\n\n

To use this PaymentMethod as the default for invoice or subscription payments,\nset invoice_settings.default_payment_method,\non the Customer to the PaymentMethod’s ID.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/payment_methods/{payment_method}/attach`\n" + ( + @spec attach( + payment_method :: binary(), + params :: %{optional(:customer) => binary, optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.PaymentMethod.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def attach(payment_method, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/payment_methods/{payment_method}/attach", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "payment_method", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "payment_method", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [payment_method] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Detaches a PaymentMethod object from a Customer. After a PaymentMethod is detached, it can no longer be used for a payment or re-attached to a Customer.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/payment_methods/{payment_method}/detach`\n" + ( + @spec detach( + payment_method :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.PaymentMethod.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def detach(payment_method, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/payment_methods/{payment_method}/detach", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "payment_method", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "payment_method", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [payment_method] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/payment_source.ex b/lib/generated/payment_source.ex new file mode 100644 index 00000000..b5111788 --- /dev/null +++ b/lib/generated/payment_source.ex @@ -0,0 +1,162 @@ +defmodule Stripe.PaymentSource do + use Stripe.Entity + @moduledoc nil + ( + defstruct [] + @typedoc "The `payment_source` type.\n\n\n" + @type t :: %__MODULE__{} + ) + + ( + nil + + @doc "

List sources for a specified customer.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/customers/{customer}/sources`\n" + ( + @spec list( + customer :: binary(), + params :: %{ + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:object) => binary, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.PaymentSource.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(customer, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/customers/{customer}/sources", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "customer", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "customer", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [customer] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieve a specified source for a given customer.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/customers/{customer}/sources/{id}`\n" + ( + @spec retrieve( + customer :: binary(), + id :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.PaymentSource.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def retrieve(customer, id, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/customers/{customer}/sources/{id}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "customer", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "customer", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + }, + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "id", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "id", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [customer, id] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

When you create a new credit card, you must specify a customer or recipient on which to create it.

\n\n

If the card’s owner has no default card, then the new card will become the default.\nHowever, if the owner already has a default, then it will not change.\nTo change the default, you should update the customer to have a new default_source.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/customers/{customer}/sources`\n" + ( + @spec create( + customer :: binary(), + params :: %{ + optional(:expand) => list(binary), + optional(:metadata) => %{optional(binary) => binary}, + optional(:source) => binary, + optional(:validate) => boolean + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.PaymentSource.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def create(customer, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/customers/{customer}/sources", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "customer", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "customer", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [customer] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/payout.ex b/lib/generated/payout.ex new file mode 100644 index 00000000..7e3986ce --- /dev/null +++ b/lib/generated/payout.ex @@ -0,0 +1,314 @@ +defmodule Stripe.Payout do + use Stripe.Entity + + @moduledoc "A `Payout` object is created when you receive funds from Stripe, or when you\ninitiate a payout to either a bank account or debit card of a [connected\nStripe account](/docs/connect/bank-debit-card-payouts). You can retrieve individual payouts,\nas well as list all payouts. Payouts are made on [varying\nschedules](/docs/connect/manage-payout-schedule), depending on your country and\nindustry.\n\nRelated guide: [Receiving payouts](https://stripe.com/docs/payouts)" + ( + defstruct [ + :amount, + :arrival_date, + :automatic, + :balance_transaction, + :created, + :currency, + :description, + :destination, + :failure_balance_transaction, + :failure_code, + :failure_message, + :id, + :livemode, + :metadata, + :method, + :object, + :original_payout, + :reconciliation_status, + :reversed_by, + :source_type, + :statement_descriptor, + :status, + :type + ] + + @typedoc "The `payout` type.\n\n * `amount` Amount (in %s) to be transferred to your bank account or debit card.\n * `arrival_date` Date the payout is expected to arrive in the bank. This factors in delays like weekends or bank holidays.\n * `automatic` Returns `true` if the payout was created by an [automated payout schedule](https://stripe.com/docs/payouts#payout-schedule), and `false` if it was [requested manually](https://stripe.com/docs/payouts#manual-payouts).\n * `balance_transaction` ID of the balance transaction that describes the impact of this payout on your account balance.\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `currency` Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).\n * `description` An arbitrary string attached to the object. Often useful for displaying to users.\n * `destination` ID of the bank account or card the payout was sent to.\n * `failure_balance_transaction` If the payout failed or was canceled, this will be the ID of the balance transaction that reversed the initial balance transaction, and puts the funds from the failed payout back in your balance.\n * `failure_code` Error code explaining reason for payout failure if available. See [Types of payout failures](https://stripe.com/docs/api#payout_failures) for a list of failure codes.\n * `failure_message` Message to user further explaining reason for payout failure if available.\n * `id` Unique identifier for the object.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `metadata` Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.\n * `method` The method used to send this payout, which can be `standard` or `instant`. `instant` is only supported for payouts to debit cards. (See [Instant payouts for marketplaces](https://stripe.com/blog/instant-payouts-for-marketplaces) for more information.)\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `original_payout` If the payout reverses another, this is the ID of the original payout.\n * `reconciliation_status` If `completed`, the [Balance Transactions API](https://stripe.com/docs/api/balance_transactions/list#balance_transaction_list-payout) may be used to list all Balance Transactions that were paid out in this payout.\n * `reversed_by` If the payout was reversed, this is the ID of the payout that reverses this payout.\n * `source_type` The source balance this payout came from. One of `card`, `fpx`, or `bank_account`.\n * `statement_descriptor` Extra information about a payout to be displayed on the user's bank statement.\n * `status` Current status of the payout: `paid`, `pending`, `in_transit`, `canceled` or `failed`. A payout is `pending` until it is submitted to the bank, when it becomes `in_transit`. The status then changes to `paid` if the transaction goes through, or to `failed` or `canceled` (within 5 business days). Some failed payouts may initially show as `paid` but then change to `failed`.\n * `type` Can be `bank_account` or `card`.\n" + @type t :: %__MODULE__{ + amount: integer, + arrival_date: integer, + automatic: boolean, + balance_transaction: (binary | Stripe.BalanceTransaction.t()) | nil, + created: integer, + currency: binary, + description: binary | nil, + destination: + (binary | Stripe.ExternalAccount.t() | Stripe.DeletedExternalAccount.t()) | nil, + failure_balance_transaction: (binary | Stripe.BalanceTransaction.t()) | nil, + failure_code: binary | nil, + failure_message: binary | nil, + id: binary, + livemode: boolean, + metadata: term | nil, + method: binary, + object: binary, + original_payout: (binary | Stripe.Payout.t()) | nil, + reconciliation_status: binary, + reversed_by: (binary | Stripe.Payout.t()) | nil, + source_type: binary, + statement_descriptor: binary | nil, + status: binary, + type: binary + } + ) + + ( + @typedoc nil + @type arrival_date :: %{ + optional(:gt) => integer, + optional(:gte) => integer, + optional(:lt) => integer, + optional(:lte) => integer + } + ) + + ( + @typedoc nil + @type created :: %{ + optional(:gt) => integer, + optional(:gte) => integer, + optional(:lt) => integer, + optional(:lte) => integer + } + ) + + ( + nil + + @doc "

Retrieves the details of an existing payout. Supply the unique payout ID from either a payout creation request or the payout list, and Stripe will return the corresponding payout information.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/payouts/{payout}`\n" + ( + @spec retrieve( + payout :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: {:ok, Stripe.Payout.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def retrieve(payout, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/payouts/{payout}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "payout", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "payout", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [payout] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Returns a list of existing payouts sent to third-party bank accounts or that Stripe has sent you. The payouts are returned in sorted order, with the most recently created payouts appearing first.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/payouts`\n" + ( + @spec list( + params :: %{ + optional(:arrival_date) => arrival_date | integer, + optional(:created) => created | integer, + optional(:destination) => binary, + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:starting_after) => binary, + optional(:status) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.Payout.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/payouts", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

To send funds to your own bank account, you create a new payout object. Your Stripe balance must be able to cover the payout amount, or you’ll receive an “Insufficient Funds” error.

\n\n

If your API key is in test mode, money won’t actually be sent, though everything else will occur as if in live mode.

\n\n

If you are creating a manual payout on a Stripe account that uses multiple payment source types, you’ll need to specify the source type balance that the payout should draw from. The balance object details available and pending amounts by source type.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/payouts`\n" + ( + @spec create( + params :: %{ + optional(:amount) => integer, + optional(:currency) => binary, + optional(:description) => binary, + optional(:destination) => binary, + optional(:expand) => list(binary), + optional(:metadata) => %{optional(binary) => binary}, + optional(:method) => :instant | :standard, + optional(:source_type) => :bank_account | :card | :fpx, + optional(:statement_descriptor) => binary + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.Payout.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/payouts", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Updates the specified payout by setting the values of the parameters passed. Any parameters not provided will be left unchanged. This request accepts only the metadata as arguments.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/payouts/{payout}`\n" + ( + @spec update( + payout :: binary(), + params :: %{ + optional(:expand) => list(binary), + optional(:metadata) => %{optional(binary) => binary} | binary + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.Payout.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def update(payout, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/payouts/{payout}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "payout", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "payout", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [payout] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

A previously created payout can be canceled if it has not yet been paid out. Funds will be refunded to your available balance. You may not cancel automatic Stripe payouts.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/payouts/{payout}/cancel`\n" + ( + @spec cancel( + payout :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: {:ok, Stripe.Payout.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def cancel(payout, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/payouts/{payout}/cancel", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "payout", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "payout", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [payout] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Reverses a payout by debiting the destination bank account. Only payouts for connected accounts to US bank accounts may be reversed at this time. If the payout is in the pending status, /v1/payouts/:id/cancel should be used instead.

\n\n

By requesting a reversal via /v1/payouts/:id/reverse, you confirm that the authorized signatory of the selected bank account has authorized the debit on the bank account and that no other authorization is required.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/payouts/{payout}/reverse`\n" + ( + @spec reverse( + payout :: binary(), + params :: %{ + optional(:expand) => list(binary), + optional(:metadata) => %{optional(binary) => binary} + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.Payout.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def reverse(payout, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/payouts/{payout}/reverse", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "payout", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "payout", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [payout] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/person.ex b/lib/generated/person.ex new file mode 100644 index 00000000..ec488b0b --- /dev/null +++ b/lib/generated/person.ex @@ -0,0 +1,491 @@ +defmodule Stripe.Person do + use Stripe.Entity + + @moduledoc "This is an object representing a person associated with a Stripe account.\n\nA platform cannot access a Standard or Express account's persons after the account starts onboarding, such as after generating an account link for the account.\nSee the [Standard onboarding](https://stripe.com/docs/connect/standard-accounts) or [Express onboarding documentation](https://stripe.com/docs/connect/express-accounts) for information about platform prefilling and account onboarding steps.\n\nRelated guide: [Handling identity verification with the API](https://stripe.com/docs/connect/identity-verification-api#person-information)" + ( + defstruct [ + :account, + :address, + :address_kana, + :address_kanji, + :created, + :dob, + :email, + :first_name, + :first_name_kana, + :first_name_kanji, + :full_name_aliases, + :future_requirements, + :gender, + :id, + :id_number_provided, + :id_number_secondary_provided, + :last_name, + :last_name_kana, + :last_name_kanji, + :maiden_name, + :metadata, + :nationality, + :object, + :phone, + :political_exposure, + :registered_address, + :relationship, + :requirements, + :ssn_last_4_provided, + :verification + ] + + @typedoc "The `person` type.\n\n * `account` The account the person is associated with.\n * `address` \n * `address_kana` The Kana variation of the person's address (Japan only).\n * `address_kanji` The Kanji variation of the person's address (Japan only).\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `dob` \n * `email` The person's email address.\n * `first_name` The person's first name.\n * `first_name_kana` The Kana variation of the person's first name (Japan only).\n * `first_name_kanji` The Kanji variation of the person's first name (Japan only).\n * `full_name_aliases` A list of alternate names or aliases that the person is known by.\n * `future_requirements` Information about the upcoming new requirements for this person, including what information needs to be collected, and by when.\n * `gender` The person's gender (International regulations require either \"male\" or \"female\").\n * `id` Unique identifier for the object.\n * `id_number_provided` Whether the person's `id_number` was provided.\n * `id_number_secondary_provided` Whether the person's `id_number_secondary` was provided.\n * `last_name` The person's last name.\n * `last_name_kana` The Kana variation of the person's last name (Japan only).\n * `last_name_kanji` The Kanji variation of the person's last name (Japan only).\n * `maiden_name` The person's maiden name.\n * `metadata` Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.\n * `nationality` The country where the person is a national.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `phone` The person's phone number.\n * `political_exposure` Indicates if the person or any of their representatives, family members, or other closely related persons, declares that they hold or have held an important public job or function, in any jurisdiction.\n * `registered_address` \n * `relationship` \n * `requirements` Information about the requirements for this person, including what information needs to be collected, and by when.\n * `ssn_last_4_provided` Whether the last four digits of the person's Social Security number have been provided (U.S. only).\n * `verification` \n" + @type t :: %__MODULE__{ + account: binary, + address: term, + address_kana: term | nil, + address_kanji: term | nil, + created: integer, + dob: term, + email: binary | nil, + first_name: binary | nil, + first_name_kana: binary | nil, + first_name_kanji: binary | nil, + full_name_aliases: term, + future_requirements: term | nil, + gender: binary | nil, + id: binary, + id_number_provided: boolean, + id_number_secondary_provided: boolean, + last_name: binary | nil, + last_name_kana: binary | nil, + last_name_kanji: binary | nil, + maiden_name: binary | nil, + metadata: term, + nationality: binary | nil, + object: binary, + phone: binary | nil, + political_exposure: binary, + registered_address: term, + relationship: term, + requirements: term | nil, + ssn_last_4_provided: boolean, + verification: term + } + ) + + ( + @typedoc "A document showing address, either a passport, local ID card, or utility bill from a well-known utility company." + @type additional_document :: %{optional(:back) => binary, optional(:front) => binary} + ) + + ( + @typedoc "The person's address." + @type address :: %{ + optional(:city) => binary, + optional(:country) => binary, + optional(:line1) => binary, + optional(:line2) => binary, + optional(:postal_code) => binary, + optional(:state) => binary + } + ) + + ( + @typedoc "The Kana variation of the person's address (Japan only)." + @type address_kana :: %{ + optional(:city) => binary, + optional(:country) => binary, + optional(:line1) => binary, + optional(:line2) => binary, + optional(:postal_code) => binary, + optional(:state) => binary, + optional(:town) => binary + } + ) + + ( + @typedoc "The Kanji variation of the person's address (Japan only)." + @type address_kanji :: %{ + optional(:city) => binary, + optional(:country) => binary, + optional(:line1) => binary, + optional(:line2) => binary, + optional(:postal_code) => binary, + optional(:state) => binary, + optional(:town) => binary + } + ) + + ( + @typedoc "One or more documents that demonstrate proof that this person is authorized to represent the company." + @type company_authorization :: %{optional(:files) => list(binary)} + ) + + ( + @typedoc nil + @type dob :: %{ + optional(:day) => integer, + optional(:month) => integer, + optional(:year) => integer + } + ) + + ( + @typedoc "An identifying document, either a passport or local ID card." + @type document :: %{optional(:back) => binary, optional(:front) => binary} + ) + + ( + @typedoc "Documents that may be submitted to satisfy various informational requests." + @type documents :: %{ + optional(:company_authorization) => company_authorization, + optional(:passport) => passport, + optional(:visa) => visa + } + ) + + ( + @typedoc "One or more documents showing the person's passport page with photo and personal data." + @type passport :: %{optional(:files) => list(binary)} + ) + + ( + @typedoc "The person's registered address." + @type registered_address :: %{ + optional(:city) => binary, + optional(:country) => binary, + optional(:line1) => binary, + optional(:line2) => binary, + optional(:postal_code) => binary, + optional(:state) => binary + } + ) + + ( + @typedoc nil + @type relationship :: %{ + optional(:director) => boolean, + optional(:executive) => boolean, + optional(:owner) => boolean, + optional(:representative) => boolean + } + ) + + ( + @typedoc "The person's verification status." + @type verification :: %{ + optional(:additional_document) => additional_document, + optional(:document) => document + } + ) + + ( + @typedoc "One or more documents showing the person's visa required for living in the country where they are residing." + @type visa :: %{optional(:files) => list(binary)} + ) + + ( + nil + + @doc "

Returns a list of people associated with the account’s legal entity. The people are returned sorted by creation date, with the most recent people appearing first.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/accounts/{account}/persons`\n" + ( + @spec list( + account :: binary(), + params :: %{ + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:relationship) => relationship, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.Person.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(account, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/accounts/{account}/persons", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "account", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "account", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [account] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves an existing person.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/accounts/{account}/persons/{person}`\n" + ( + @spec retrieve( + account :: binary(), + person :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: {:ok, Stripe.Person.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def retrieve(account, person, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/accounts/{account}/persons/{person}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "account", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "account", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + }, + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "person", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "person", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [account, person] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Creates a new person.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/accounts/{account}/persons`\n" + ( + @spec create( + account :: binary(), + params :: %{ + optional(:address) => address, + optional(:address_kana) => address_kana, + optional(:address_kanji) => address_kanji, + optional(:dob) => dob | binary, + optional(:documents) => documents, + optional(:email) => binary, + optional(:expand) => list(binary), + optional(:first_name) => binary, + optional(:first_name_kana) => binary, + optional(:first_name_kanji) => binary, + optional(:full_name_aliases) => list(binary) | binary, + optional(:gender) => binary, + optional(:id_number) => binary, + optional(:id_number_secondary) => binary, + optional(:last_name) => binary, + optional(:last_name_kana) => binary, + optional(:last_name_kanji) => binary, + optional(:maiden_name) => binary, + optional(:metadata) => %{optional(binary) => binary} | binary, + optional(:nationality) => binary, + optional(:person_token) => binary, + optional(:phone) => binary, + optional(:political_exposure) => binary, + optional(:registered_address) => registered_address, + optional(:relationship) => relationship, + optional(:ssn_last_4) => binary, + optional(:verification) => verification + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.Person.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def create(account, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/accounts/{account}/persons", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "account", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "account", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [account] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Updates an existing person.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/accounts/{account}/persons/{person}`\n" + ( + @spec update( + account :: binary(), + person :: binary(), + params :: %{ + optional(:address) => address, + optional(:address_kana) => address_kana, + optional(:address_kanji) => address_kanji, + optional(:dob) => dob | binary, + optional(:documents) => documents, + optional(:email) => binary, + optional(:expand) => list(binary), + optional(:first_name) => binary, + optional(:first_name_kana) => binary, + optional(:first_name_kanji) => binary, + optional(:full_name_aliases) => list(binary) | binary, + optional(:gender) => binary, + optional(:id_number) => binary, + optional(:id_number_secondary) => binary, + optional(:last_name) => binary, + optional(:last_name_kana) => binary, + optional(:last_name_kanji) => binary, + optional(:maiden_name) => binary, + optional(:metadata) => %{optional(binary) => binary} | binary, + optional(:nationality) => binary, + optional(:person_token) => binary, + optional(:phone) => binary, + optional(:political_exposure) => binary, + optional(:registered_address) => registered_address, + optional(:relationship) => relationship, + optional(:ssn_last_4) => binary, + optional(:verification) => verification + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.Person.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def update(account, person, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/accounts/{account}/persons/{person}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "account", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "account", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + }, + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "person", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "person", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [account, person] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Deletes an existing person’s relationship to the account’s legal entity. Any person with a relationship for an account can be deleted through the API, except if the person is the account_opener. If your integration is using the executive parameter, you cannot delete the only verified executive on file.

\n\n#### Details\n\n * Method: `delete`\n * Path: `/v1/accounts/{account}/persons/{person}`\n" + ( + @spec delete(account :: binary(), person :: binary(), opts :: Keyword.t()) :: + {:ok, Stripe.DeletedPerson.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def delete(account, person, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/accounts/{account}/persons/{person}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "account", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "account", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + }, + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "person", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "person", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [account, person] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_method(:delete) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/plan.ex b/lib/generated/plan.ex new file mode 100644 index 00000000..8e108356 --- /dev/null +++ b/lib/generated/plan.ex @@ -0,0 +1,290 @@ +defmodule Stripe.Plan do + use Stripe.Entity + + @moduledoc "You can now model subscriptions more flexibly using the [Prices API](https://stripe.com/docs/api#prices). It replaces the Plans API and is backwards compatible to simplify your migration.\n\nPlans define the base price, currency, and billing cycle for recurring purchases of products.\n[Products](https://stripe.com/docs/api#products) help you track inventory or provisioning, and plans help you track pricing. Different physical goods or levels of service should be represented by products, and pricing options should be represented by plans. This approach lets you change prices without having to change your provisioning scheme.\n\nFor example, you might have a single \"gold\" product that has plans for $10/month, $100/year, €9/month, and €90/year.\n\nRelated guides: [Set up a subscription](https://stripe.com/docs/billing/subscriptions/set-up-subscription) and more about [products and prices](https://stripe.com/docs/products-prices/overview)." + ( + defstruct [ + :active, + :aggregate_usage, + :amount, + :amount_decimal, + :billing_scheme, + :created, + :currency, + :id, + :interval, + :interval_count, + :livemode, + :metadata, + :nickname, + :object, + :product, + :tiers, + :tiers_mode, + :transform_usage, + :trial_period_days, + :usage_type + ] + + @typedoc "The `plan` type.\n\n * `active` Whether the plan can be used for new purchases.\n * `aggregate_usage` Specifies a usage aggregation strategy for plans of `usage_type=metered`. Allowed values are `sum` for summing up all usage during a period, `last_during_period` for using the last usage record reported within a period, `last_ever` for using the last usage record ever (across period bounds) or `max` which uses the usage record with the maximum reported usage during a period. Defaults to `sum`.\n * `amount` The unit amount in %s to be charged, represented as a whole integer if possible. Only set if `billing_scheme=per_unit`.\n * `amount_decimal` The unit amount in %s to be charged, represented as a decimal string with at most 12 decimal places. Only set if `billing_scheme=per_unit`.\n * `billing_scheme` Describes how to compute the price per period. Either `per_unit` or `tiered`. `per_unit` indicates that the fixed amount (specified in `amount`) will be charged per unit in `quantity` (for plans with `usage_type=licensed`), or per unit of total usage (for plans with `usage_type=metered`). `tiered` indicates that the unit pricing will be computed using a tiering strategy as defined using the `tiers` and `tiers_mode` attributes.\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `currency` Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).\n * `id` Unique identifier for the object.\n * `interval` The frequency at which a subscription is billed. One of `day`, `week`, `month` or `year`.\n * `interval_count` The number of intervals (specified in the `interval` attribute) between subscription billings. For example, `interval=month` and `interval_count=3` bills every 3 months.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `metadata` Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.\n * `nickname` A brief description of the plan, hidden from customers.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `product` The product whose pricing this plan determines.\n * `tiers` Each element represents a pricing tier. This parameter requires `billing_scheme` to be set to `tiered`. See also the documentation for `billing_scheme`.\n * `tiers_mode` Defines if the tiering price should be `graduated` or `volume` based. In `volume`-based tiering, the maximum quantity within a period determines the per unit price. In `graduated` tiering, pricing can change as the quantity grows.\n * `transform_usage` Apply a transformation to the reported usage or set quantity before computing the amount billed. Cannot be combined with `tiers`.\n * `trial_period_days` Default number of trial days when subscribing a customer to this plan using [`trial_from_plan=true`](https://stripe.com/docs/api#create_subscription-trial_from_plan).\n * `usage_type` Configures how the quantity per period should be determined. Can be either `metered` or `licensed`. `licensed` automatically bills the `quantity` set when adding it to a subscription. `metered` aggregates the total usage based on usage records. Defaults to `licensed`.\n" + @type t :: %__MODULE__{ + active: boolean, + aggregate_usage: binary | nil, + amount: integer | nil, + amount_decimal: binary | nil, + billing_scheme: binary, + created: integer, + currency: binary, + id: binary, + interval: binary, + interval_count: integer, + livemode: boolean, + metadata: term | nil, + nickname: binary | nil, + object: binary, + product: (binary | Stripe.Product.t() | Stripe.DeletedProduct.t()) | nil, + tiers: term, + tiers_mode: binary | nil, + transform_usage: term | nil, + trial_period_days: integer | nil, + usage_type: binary + } + ) + + ( + @typedoc nil + @type created :: %{ + optional(:gt) => integer, + optional(:gte) => integer, + optional(:lt) => integer, + optional(:lte) => integer + } + ) + + ( + @typedoc "The product whose pricing the created plan will represent. This can either be the ID of an existing product, or a dictionary containing fields used to create a [service product](https://stripe.com/docs/api#product_object-type)." + @type product :: %{ + optional(:active) => boolean, + optional(:id) => binary, + optional(:metadata) => %{optional(binary) => binary}, + optional(:name) => binary, + optional(:statement_descriptor) => binary, + optional(:tax_code) => binary, + optional(:unit_label) => binary + } + ) + + ( + @typedoc nil + @type tiers :: %{ + optional(:flat_amount) => integer, + optional(:flat_amount_decimal) => binary, + optional(:unit_amount) => integer, + optional(:unit_amount_decimal) => binary, + optional(:up_to) => :inf | integer + } + ) + + ( + @typedoc "Apply a transformation to the reported usage or set quantity before computing the billed price. Cannot be combined with `tiers`." + @type transform_usage :: %{optional(:divide_by) => integer, optional(:round) => :down | :up} + ) + + ( + nil + + @doc "

Returns a list of your plans.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/plans`\n" + ( + @spec list( + params :: %{ + optional(:active) => boolean, + optional(:created) => created | integer, + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:product) => binary, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.Plan.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/plans", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

You can now model subscriptions more flexibly using the Prices API. It replaces the Plans API and is backwards compatible to simplify your migration.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/plans`\n" + ( + @spec create( + params :: %{ + optional(:active) => boolean, + optional(:aggregate_usage) => :last_during_period | :last_ever | :max | :sum, + optional(:amount) => integer, + optional(:amount_decimal) => binary, + optional(:billing_scheme) => :per_unit | :tiered, + optional(:currency) => binary, + optional(:expand) => list(binary), + optional(:id) => binary, + optional(:interval) => :day | :month | :week | :year, + optional(:interval_count) => integer, + optional(:metadata) => %{optional(binary) => binary} | binary, + optional(:nickname) => binary, + optional(:product) => product | binary, + optional(:tiers) => list(tiers), + optional(:tiers_mode) => :graduated | :volume, + optional(:transform_usage) => transform_usage, + optional(:trial_period_days) => integer, + optional(:usage_type) => :licensed | :metered + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.Plan.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/plans", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves the plan with the given ID.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/plans/{plan}`\n" + ( + @spec retrieve( + plan :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: {:ok, Stripe.Plan.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def retrieve(plan, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/plans/{plan}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "plan", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "plan", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [plan] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Updates the specified plan by setting the values of the parameters passed. Any parameters not provided are left unchanged. By design, you cannot change a plan’s ID, amount, currency, or billing cycle.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/plans/{plan}`\n" + ( + @spec update( + plan :: binary(), + params :: %{ + optional(:active) => boolean, + optional(:expand) => list(binary), + optional(:metadata) => %{optional(binary) => binary} | binary, + optional(:nickname) => binary, + optional(:product) => binary, + optional(:trial_period_days) => integer + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.Plan.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def update(plan, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/plans/{plan}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "plan", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "plan", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [plan] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Deleting plans means new subscribers can’t be added. Existing subscribers aren’t affected.

\n\n#### Details\n\n * Method: `delete`\n * Path: `/v1/plans/{plan}`\n" + ( + @spec delete(plan :: binary(), opts :: Keyword.t()) :: + {:ok, Stripe.DeletedPlan.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def delete(plan, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/plans/{plan}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "plan", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "plan", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [plan] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_method(:delete) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/price.ex b/lib/generated/price.ex new file mode 100644 index 00000000..6f7ec7de --- /dev/null +++ b/lib/generated/price.ex @@ -0,0 +1,313 @@ +defmodule Stripe.Price do + use Stripe.Entity + + @moduledoc "Prices define the unit cost, currency, and (optional) billing cycle for both recurring and one-time purchases of products.\n[Products](https://stripe.com/docs/api#products) help you track inventory or provisioning, and prices help you track payment terms. Different physical goods or levels of service should be represented by products, and pricing options should be represented by prices. This approach lets you change prices without having to change your provisioning scheme.\n\nFor example, you might have a single \"gold\" product that has prices for $10/month, $100/year, and €9 once.\n\nRelated guides: [Set up a subscription](https://stripe.com/docs/billing/subscriptions/set-up-subscription), [create an invoice](https://stripe.com/docs/billing/invoices/create), and more about [products and prices](https://stripe.com/docs/products-prices/overview)." + ( + defstruct [ + :active, + :billing_scheme, + :created, + :currency, + :currency_options, + :custom_unit_amount, + :id, + :livemode, + :lookup_key, + :metadata, + :nickname, + :object, + :product, + :recurring, + :tax_behavior, + :tiers, + :tiers_mode, + :transform_quantity, + :type, + :unit_amount, + :unit_amount_decimal + ] + + @typedoc "The `price` type.\n\n * `active` Whether the price can be used for new purchases.\n * `billing_scheme` Describes how to compute the price per period. Either `per_unit` or `tiered`. `per_unit` indicates that the fixed amount (specified in `unit_amount` or `unit_amount_decimal`) will be charged per unit in `quantity` (for prices with `usage_type=licensed`), or per unit of total usage (for prices with `usage_type=metered`). `tiered` indicates that the unit pricing will be computed using a tiering strategy as defined using the `tiers` and `tiers_mode` attributes.\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `currency` Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).\n * `currency_options` Prices defined in each available currency option. Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies).\n * `custom_unit_amount` When set, provides configuration for the amount to be adjusted by the customer during Checkout Sessions and Payment Links.\n * `id` Unique identifier for the object.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `lookup_key` A lookup key used to retrieve prices dynamically from a static string. This may be up to 200 characters.\n * `metadata` Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.\n * `nickname` A brief description of the price, hidden from customers.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `product` The ID of the product this price is associated with.\n * `recurring` The recurring components of a price such as `interval` and `usage_type`.\n * `tax_behavior` Only required if a [default tax behavior](https://stripe.com/docs/tax/products-prices-tax-categories-tax-behavior#setting-a-default-tax-behavior-(recommended)) was not provided in the Stripe Tax settings. Specifies whether the price is considered inclusive of taxes or exclusive of taxes. One of `inclusive`, `exclusive`, or `unspecified`. Once specified as either `inclusive` or `exclusive`, it cannot be changed.\n * `tiers` Each element represents a pricing tier. This parameter requires `billing_scheme` to be set to `tiered`. See also the documentation for `billing_scheme`.\n * `tiers_mode` Defines if the tiering price should be `graduated` or `volume` based. In `volume`-based tiering, the maximum quantity within a period determines the per unit price. In `graduated` tiering, pricing can change as the quantity grows.\n * `transform_quantity` Apply a transformation to the reported usage or set quantity before computing the amount billed. Cannot be combined with `tiers`.\n * `type` One of `one_time` or `recurring` depending on whether the price is for a one-time purchase or a recurring (subscription) purchase.\n * `unit_amount` The unit amount in %s to be charged, represented as a whole integer if possible. Only set if `billing_scheme=per_unit`.\n * `unit_amount_decimal` The unit amount in %s to be charged, represented as a decimal string with at most 12 decimal places. Only set if `billing_scheme=per_unit`.\n" + @type t :: %__MODULE__{ + active: boolean, + billing_scheme: binary, + created: integer, + currency: binary, + currency_options: term, + custom_unit_amount: term | nil, + id: binary, + livemode: boolean, + lookup_key: binary | nil, + metadata: term, + nickname: binary | nil, + object: binary, + product: binary | Stripe.Product.t() | Stripe.DeletedProduct.t(), + recurring: term | nil, + tax_behavior: binary | nil, + tiers: term, + tiers_mode: binary | nil, + transform_quantity: term | nil, + type: binary, + unit_amount: integer | nil, + unit_amount_decimal: binary | nil + } + ) + + ( + @typedoc nil + @type created :: %{ + optional(:gt) => integer, + optional(:gte) => integer, + optional(:lt) => integer, + optional(:lte) => integer + } + ) + + ( + @typedoc "When set, provides configuration for the amount to be adjusted by the customer during Checkout Sessions and Payment Links." + @type custom_unit_amount :: %{ + optional(:enabled) => boolean, + optional(:maximum) => integer, + optional(:minimum) => integer, + optional(:preset) => integer + } + ) + + ( + @typedoc "These fields can be used to create a new product that this price will belong to." + @type product_data :: %{ + optional(:active) => boolean, + optional(:id) => binary, + optional(:metadata) => %{optional(binary) => binary}, + optional(:name) => binary, + optional(:statement_descriptor) => binary, + optional(:tax_code) => binary, + optional(:unit_label) => binary + } + ) + + ( + @typedoc nil + @type recurring :: %{ + optional(:interval) => :day | :month | :week | :year, + optional(:usage_type) => :licensed | :metered + } + ) + + ( + @typedoc nil + @type tiers :: %{ + optional(:flat_amount) => integer, + optional(:flat_amount_decimal) => binary, + optional(:unit_amount) => integer, + optional(:unit_amount_decimal) => binary, + optional(:up_to) => :inf | integer + } + ) + + ( + @typedoc "Apply a transformation to the reported usage or set quantity before computing the billed price. Cannot be combined with `tiers`." + @type transform_quantity :: %{ + optional(:divide_by) => integer, + optional(:round) => :down | :up + } + ) + + ( + nil + + @doc "

Search for prices you’ve previously created using Stripe’s Search Query Language.\nDon’t use search in read-after-write flows where strict consistency is necessary. Under normal operating\nconditions, data is searchable in less than a minute. Occasionally, propagation of new or updated data can be up\nto an hour behind during outages. Search functionality is not available to merchants in India.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/prices/search`\n" + ( + @spec search( + params :: %{ + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:page) => binary, + optional(:query) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.SearchResult.t(Stripe.Price.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def search(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/prices/search", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Returns a list of your prices.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/prices`\n" + ( + @spec list( + params :: %{ + optional(:active) => boolean, + optional(:created) => created | integer, + optional(:currency) => binary, + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:lookup_keys) => list(binary), + optional(:product) => binary, + optional(:recurring) => recurring, + optional(:starting_after) => binary, + optional(:type) => :one_time | :recurring + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.Price.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/prices", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Creates a new price for an existing product. The price can be recurring or one-time.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/prices`\n" + ( + @spec create( + params :: %{ + optional(:active) => boolean, + optional(:billing_scheme) => :per_unit | :tiered, + optional(:currency) => binary, + optional(:currency_options) => map(), + optional(:custom_unit_amount) => custom_unit_amount, + optional(:expand) => list(binary), + optional(:lookup_key) => binary, + optional(:metadata) => %{optional(binary) => binary}, + optional(:nickname) => binary, + optional(:product) => binary, + optional(:product_data) => product_data, + optional(:recurring) => recurring, + optional(:tax_behavior) => :exclusive | :inclusive | :unspecified, + optional(:tiers) => list(tiers), + optional(:tiers_mode) => :graduated | :volume, + optional(:transfer_lookup_key) => boolean, + optional(:transform_quantity) => transform_quantity, + optional(:unit_amount) => integer, + optional(:unit_amount_decimal) => binary + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.Price.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/prices", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves the price with the given ID.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/prices/{price}`\n" + ( + @spec retrieve( + price :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: {:ok, Stripe.Price.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def retrieve(price, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/prices/{price}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "price", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "price", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [price] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Updates the specified price by setting the values of the parameters passed. Any parameters not provided are left unchanged.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/prices/{price}`\n" + ( + @spec update( + price :: binary(), + params :: %{ + optional(:active) => boolean, + optional(:currency_options) => map() | binary, + optional(:expand) => list(binary), + optional(:lookup_key) => binary, + optional(:metadata) => %{optional(binary) => binary} | binary, + optional(:nickname) => binary, + optional(:recurring) => recurring | binary, + optional(:tax_behavior) => :exclusive | :inclusive | :unspecified, + optional(:transfer_lookup_key) => boolean + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.Price.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def update(price, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/prices/{price}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "price", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "price", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [price] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/product.ex b/lib/generated/product.ex new file mode 100644 index 00000000..2a4c57ef --- /dev/null +++ b/lib/generated/product.ex @@ -0,0 +1,335 @@ +defmodule Stripe.Product do + use Stripe.Entity + + @moduledoc "Products describe the specific goods or services you offer to your customers.\nFor example, you might offer a Standard and Premium version of your goods or service; each version would be a separate Product.\nThey can be used in conjunction with [Prices](https://stripe.com/docs/api#prices) to configure pricing in Payment Links, Checkout, and Subscriptions.\n\nRelated guides: [Set up a subscription](https://stripe.com/docs/billing/subscriptions/set-up-subscription),\n[share a Payment Link](https://stripe.com/docs/payment-links),\n[accept payments with Checkout](https://stripe.com/docs/payments/accept-a-payment#create-product-prices-upfront),\nand more about [Products and Prices](https://stripe.com/docs/products-prices/overview)" + ( + defstruct [ + :active, + :attributes, + :caption, + :created, + :deactivate_on, + :default_price, + :description, + :id, + :images, + :livemode, + :metadata, + :name, + :object, + :package_dimensions, + :shippable, + :statement_descriptor, + :tax_code, + :type, + :unit_label, + :updated, + :url + ] + + @typedoc "The `product` type.\n\n * `active` Whether the product is currently available for purchase.\n * `attributes` A list of up to 5 attributes that each SKU can provide values for (e.g., `[\"color\", \"size\"]`).\n * `caption` A short one-line description of the product, meant to be displayable to the customer. Only applicable to products of `type=good`.\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `deactivate_on` An array of connect application identifiers that cannot purchase this product. Only applicable to products of `type=good`.\n * `default_price` The ID of the [Price](https://stripe.com/docs/api/prices) object that is the default price for this product.\n * `description` The product's description, meant to be displayable to the customer. Use this field to optionally store a long form explanation of the product being sold for your own rendering purposes.\n * `id` Unique identifier for the object.\n * `images` A list of up to 8 URLs of images for this product, meant to be displayable to the customer.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `metadata` Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.\n * `name` The product's name, meant to be displayable to the customer.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `package_dimensions` The dimensions of this product for shipping purposes.\n * `shippable` Whether this product is shipped (i.e., physical goods).\n * `statement_descriptor` Extra information about a product which will appear on your customer's credit card statement. In the case that multiple products are billed at once, the first statement descriptor will be used.\n * `tax_code` A [tax code](https://stripe.com/docs/tax/tax-categories) ID.\n * `type` The type of the product. The product is either of type `good`, which is eligible for use with Orders and SKUs, or `service`, which is eligible for use with Subscriptions and Plans.\n * `unit_label` A label that represents units of this product. When set, this will be included in customers' receipts, invoices, Checkout, and the customer portal.\n * `updated` Time at which the object was last updated. Measured in seconds since the Unix epoch.\n * `url` A URL of a publicly-accessible webpage for this product.\n" + @type t :: %__MODULE__{ + active: boolean, + attributes: term | nil, + caption: binary | nil, + created: integer, + deactivate_on: term, + default_price: (binary | Stripe.Price.t()) | nil, + description: binary | nil, + id: binary, + images: term, + livemode: boolean, + metadata: term, + name: binary, + object: binary, + package_dimensions: term | nil, + shippable: boolean | nil, + statement_descriptor: binary | nil, + tax_code: (binary | Stripe.TaxCode.t()) | nil, + type: binary, + unit_label: binary | nil, + updated: integer, + url: binary | nil + } + ) + + ( + @typedoc nil + @type created :: %{ + optional(:gt) => integer, + optional(:gte) => integer, + optional(:lt) => integer, + optional(:lte) => integer + } + ) + + ( + @typedoc "Data used to generate a new [Price](https://stripe.com/docs/api/prices) object. This Price will be set as the default price for this product." + @type default_price_data :: %{ + optional(:currency) => binary, + optional(:currency_options) => map(), + optional(:recurring) => recurring, + optional(:tax_behavior) => :exclusive | :inclusive | :unspecified, + optional(:unit_amount) => integer, + optional(:unit_amount_decimal) => binary + } + ) + + ( + @typedoc "The dimensions of this product for shipping purposes." + @type package_dimensions :: %{ + optional(:height) => number, + optional(:length) => number, + optional(:weight) => number, + optional(:width) => number + } + ) + + ( + @typedoc "The recurring components of a price such as `interval` and `interval_count`." + @type recurring :: %{ + optional(:interval) => :day | :month | :week | :year, + optional(:interval_count) => integer + } + ) + + ( + nil + + @doc "

Search for products you’ve previously created using Stripe’s Search Query Language.\nDon’t use search in read-after-write flows where strict consistency is necessary. Under normal operating\nconditions, data is searchable in less than a minute. Occasionally, propagation of new or updated data can be up\nto an hour behind during outages. Search functionality is not available to merchants in India.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/products/search`\n" + ( + @spec search( + params :: %{ + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:page) => binary, + optional(:query) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.SearchResult.t(Stripe.Product.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def search(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/products/search", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Creates a new product object.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/products`\n" + ( + @spec create( + params :: %{ + optional(:active) => boolean, + optional(:attributes) => list(binary), + optional(:caption) => binary, + optional(:deactivate_on) => list(binary), + optional(:default_price_data) => default_price_data, + optional(:description) => binary, + optional(:expand) => list(binary), + optional(:id) => binary, + optional(:images) => list(binary), + optional(:metadata) => %{optional(binary) => binary}, + optional(:name) => binary, + optional(:package_dimensions) => package_dimensions, + optional(:shippable) => boolean, + optional(:statement_descriptor) => binary, + optional(:tax_code) => binary, + optional(:type) => :good | :service, + optional(:unit_label) => binary, + optional(:url) => binary + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.Product.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/products", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves the details of an existing product. Supply the unique product ID from either a product creation request or the product list, and Stripe will return the corresponding product information.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/products/{id}`\n" + ( + @spec retrieve( + id :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: {:ok, Stripe.Product.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def retrieve(id, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/products/{id}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "id", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "id", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [id] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Updates the specific product by setting the values of the parameters passed. Any parameters not provided will be left unchanged.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/products/{id}`\n" + ( + @spec update( + id :: binary(), + params :: %{ + optional(:active) => boolean, + optional(:attributes) => list(binary) | binary, + optional(:caption) => binary, + optional(:deactivate_on) => list(binary), + optional(:default_price) => binary, + optional(:description) => binary, + optional(:expand) => list(binary), + optional(:images) => list(binary) | binary, + optional(:metadata) => %{optional(binary) => binary} | binary, + optional(:name) => binary, + optional(:package_dimensions) => package_dimensions | binary, + optional(:shippable) => boolean, + optional(:statement_descriptor) => binary, + optional(:tax_code) => binary | binary, + optional(:unit_label) => binary, + optional(:url) => binary | binary + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.Product.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def update(id, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/products/{id}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "id", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "id", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [id] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Returns a list of your products. The products are returned sorted by creation date, with the most recently created products appearing first.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/products`\n" + ( + @spec list( + params :: %{ + optional(:active) => boolean, + optional(:created) => created | integer, + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:ids) => list(binary), + optional(:limit) => integer, + optional(:shippable) => boolean, + optional(:starting_after) => binary, + optional(:type) => :good | :service, + optional(:url) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.Product.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/products", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Delete a product. Deleting a product is only possible if it has no prices associated with it. Additionally, deleting a product with type=good is only possible if it has no SKUs associated with it.

\n\n#### Details\n\n * Method: `delete`\n * Path: `/v1/products/{id}`\n" + ( + @spec delete(id :: binary(), opts :: Keyword.t()) :: + {:ok, Stripe.DeletedProduct.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def delete(id, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/products/{id}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "id", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "id", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [id] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_method(:delete) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/promotion_code.ex b/lib/generated/promotion_code.ex new file mode 100644 index 00000000..4eb6e7f3 --- /dev/null +++ b/lib/generated/promotion_code.ex @@ -0,0 +1,214 @@ +defmodule Stripe.PromotionCode do + use Stripe.Entity + + @moduledoc "A Promotion Code represents a customer-redeemable code for a [coupon](https://stripe.com/docs/api#coupons). It can be used to\ncreate multiple codes for a single coupon." + ( + defstruct [ + :active, + :code, + :coupon, + :created, + :customer, + :expires_at, + :id, + :livemode, + :max_redemptions, + :metadata, + :object, + :restrictions, + :times_redeemed + ] + + @typedoc "The `promotion_code` type.\n\n * `active` Whether the promotion code is currently active. A promotion code is only active if the coupon is also valid.\n * `code` The customer-facing code. Regardless of case, this code must be unique across all active promotion codes for each customer.\n * `coupon` \n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `customer` The customer that this promotion code can be used by.\n * `expires_at` Date at which the promotion code can no longer be redeemed.\n * `id` Unique identifier for the object.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `max_redemptions` Maximum number of times this promotion code can be redeemed.\n * `metadata` Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `restrictions` \n * `times_redeemed` Number of times this promotion code has been used.\n" + @type t :: %__MODULE__{ + active: boolean, + code: binary, + coupon: Stripe.Coupon.t(), + created: integer, + customer: (binary | Stripe.Customer.t() | Stripe.DeletedCustomer.t()) | nil, + expires_at: integer | nil, + id: binary, + livemode: boolean, + max_redemptions: integer | nil, + metadata: term | nil, + object: binary, + restrictions: term, + times_redeemed: integer + } + ) + + ( + @typedoc nil + @type created :: %{ + optional(:gt) => integer, + optional(:gte) => integer, + optional(:lt) => integer, + optional(:lte) => integer + } + ) + + ( + @typedoc "Settings that restrict the redemption of the promotion code." + @type restrictions :: %{ + optional(:currency_options) => map(), + optional(:first_time_transaction) => boolean, + optional(:minimum_amount) => integer, + optional(:minimum_amount_currency) => binary + } + ) + + ( + nil + + @doc "

Retrieves the promotion code with the given ID. In order to retrieve a promotion code by the customer-facing code use list with the desired code.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/promotion_codes/{promotion_code}`\n" + ( + @spec retrieve( + promotion_code :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.PromotionCode.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def retrieve(promotion_code, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/promotion_codes/{promotion_code}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "promotion_code", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "promotion_code", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [promotion_code] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

A promotion code points to a coupon. You can optionally restrict the code to a specific customer, redemption limit, and expiration date.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/promotion_codes`\n" + ( + @spec create( + params :: %{ + optional(:active) => boolean, + optional(:code) => binary, + optional(:coupon) => binary, + optional(:customer) => binary, + optional(:expand) => list(binary), + optional(:expires_at) => integer, + optional(:max_redemptions) => integer, + optional(:metadata) => %{optional(binary) => binary}, + optional(:restrictions) => restrictions + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.PromotionCode.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/promotion_codes", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Updates the specified promotion code by setting the values of the parameters passed. Most fields are, by design, not editable.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/promotion_codes/{promotion_code}`\n" + ( + @spec update( + promotion_code :: binary(), + params :: %{ + optional(:active) => boolean, + optional(:expand) => list(binary), + optional(:metadata) => %{optional(binary) => binary} | binary, + optional(:restrictions) => restrictions + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.PromotionCode.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def update(promotion_code, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/promotion_codes/{promotion_code}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "promotion_code", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "promotion_code", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [promotion_code] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Returns a list of your promotion codes.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/promotion_codes`\n" + ( + @spec list( + params :: %{ + optional(:active) => boolean, + optional(:code) => binary, + optional(:coupon) => binary, + optional(:created) => created | integer, + optional(:customer) => binary, + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.PromotionCode.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/promotion_codes", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/quote.ex b/lib/generated/quote.ex new file mode 100644 index 00000000..292129c6 --- /dev/null +++ b/lib/generated/quote.ex @@ -0,0 +1,588 @@ +defmodule Stripe.Quote do + use Stripe.Entity + + @moduledoc "A Quote is a way to model prices that you'd like to provide to a customer.\nOnce accepted, it will automatically create an invoice, subscription or subscription schedule." + ( + defstruct [ + :default_tax_rates, + :id, + :transfer_data, + :application_fee_amount, + :number, + :from_quote, + :status, + :subscription, + :amount_total, + :amount_subtotal, + :discounts, + :created, + :currency, + :automatic_tax, + :test_clock, + :status_transitions, + :expires_at, + :total_details, + :invoice_settings, + :object, + :application, + :invoice, + :customer, + :on_behalf_of, + :subscription_schedule, + :header, + :footer, + :description, + :subscription_data, + :metadata, + :line_items, + :collection_method, + :livemode, + :computed, + :application_fee_percent + ] + + @typedoc "The `quote` type.\n\n * `amount_subtotal` Total before any discounts or taxes are applied.\n * `amount_total` Total after discounts and taxes are applied.\n * `application` ID of the Connect Application that created the quote.\n * `application_fee_amount` The amount of the application fee (if any) that will be requested to be applied to the payment and transferred to the application owner's Stripe account. Only applicable if there are no line items with recurring prices on the quote.\n * `application_fee_percent` A non-negative decimal between 0 and 100, with at most two decimal places. This represents the percentage of the subscription invoice subtotal that will be transferred to the application owner's Stripe account. Only applicable if there are line items with recurring prices on the quote.\n * `automatic_tax` \n * `collection_method` Either `charge_automatically`, or `send_invoice`. When charging automatically, Stripe will attempt to pay invoices at the end of the subscription cycle or on finalization using the default payment method attached to the subscription or customer. When sending an invoice, Stripe will email your customer an invoice with payment instructions and mark the subscription as `active`. Defaults to `charge_automatically`.\n * `computed` \n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `currency` Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).\n * `customer` The customer which this quote belongs to. A customer is required before finalizing the quote. Once specified, it cannot be changed.\n * `default_tax_rates` The tax rates applied to this quote.\n * `description` A description that will be displayed on the quote PDF.\n * `discounts` The discounts applied to this quote.\n * `expires_at` The date on which the quote will be canceled if in `open` or `draft` status. Measured in seconds since the Unix epoch.\n * `footer` A footer that will be displayed on the quote PDF.\n * `from_quote` Details of the quote that was cloned. See the [cloning documentation](https://stripe.com/docs/quotes/clone) for more details.\n * `header` A header that will be displayed on the quote PDF.\n * `id` Unique identifier for the object.\n * `invoice` The invoice that was created from this quote.\n * `invoice_settings` All invoices will be billed using the specified settings.\n * `line_items` A list of items the customer is being quoted for.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `metadata` Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.\n * `number` A unique number that identifies this particular quote. This number is assigned once the quote is [finalized](https://stripe.com/docs/quotes/overview#finalize).\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `on_behalf_of` The account on behalf of which to charge. See the [Connect documentation](https://support.stripe.com/questions/sending-invoices-on-behalf-of-connected-accounts) for details.\n * `status` The status of the quote.\n * `status_transitions` \n * `subscription` The subscription that was created or updated from this quote.\n * `subscription_data` \n * `subscription_schedule` The subscription schedule that was created or updated from this quote.\n * `test_clock` ID of the test clock this quote belongs to.\n * `total_details` \n * `transfer_data` The account (if any) the payments will be attributed to for tax reporting, and where funds from each payment will be transferred to for each of the invoices.\n" + @type t :: %__MODULE__{ + amount_subtotal: integer, + amount_total: integer, + application: (binary | term | term) | nil, + application_fee_amount: integer | nil, + application_fee_percent: term | nil, + automatic_tax: term, + collection_method: binary, + computed: term, + created: integer, + currency: binary | nil, + customer: (binary | Stripe.Customer.t() | Stripe.DeletedCustomer.t()) | nil, + default_tax_rates: term, + description: binary | nil, + discounts: term, + expires_at: integer, + footer: binary | nil, + from_quote: term | nil, + header: binary | nil, + id: binary, + invoice: (binary | Stripe.Invoice.t() | Stripe.DeletedInvoice.t()) | nil, + invoice_settings: term | nil, + line_items: term, + livemode: boolean, + metadata: term, + number: binary | nil, + object: binary, + on_behalf_of: (binary | Stripe.Account.t()) | nil, + status: binary, + status_transitions: term, + subscription: (binary | Stripe.Subscription.t()) | nil, + subscription_data: term, + subscription_schedule: (binary | Stripe.SubscriptionSchedule.t()) | nil, + test_clock: (binary | Stripe.TestHelpers.TestClock.t()) | nil, + total_details: term, + transfer_data: term | nil + } + ) + + ( + @typedoc "Settings for automatic tax lookup for this quote and resulting invoices and subscriptions." + @type automatic_tax :: %{optional(:enabled) => boolean} + ) + + ( + @typedoc nil + @type discounts :: %{optional(:coupon) => binary, optional(:discount) => binary} + ) + + ( + @typedoc "Clone an existing quote. The new quote will be created in `status=draft`. When using this parameter, you cannot specify any other parameters except for `expires_at`." + @type from_quote :: %{optional(:is_revision) => boolean, optional(:quote) => binary} + ) + + ( + @typedoc "All invoices will be billed using the specified settings." + @type invoice_settings :: %{optional(:days_until_due) => integer} + ) + + ( + @typedoc nil + @type line_items :: %{ + optional(:price) => binary, + optional(:price_data) => price_data, + optional(:quantity) => integer, + optional(:tax_rates) => list(binary) | binary + } + ) + + ( + @typedoc "Data used to generate a new [Price](https://stripe.com/docs/api/prices) object inline. One of `price` or `price_data` is required." + @type price_data :: %{ + optional(:currency) => binary, + optional(:product) => binary, + optional(:recurring) => recurring, + optional(:tax_behavior) => :exclusive | :inclusive | :unspecified, + optional(:unit_amount) => integer, + optional(:unit_amount_decimal) => binary + } + ) + + ( + @typedoc "The recurring components of a price such as `interval` and `interval_count`." + @type recurring :: %{ + optional(:interval) => :day | :month | :week | :year, + optional(:interval_count) => integer + } + ) + + ( + @typedoc "When creating a subscription or subscription schedule, the specified configuration data will be used. There must be at least one line item with a recurring price for a subscription or subscription schedule to be created. A subscription schedule is created if `subscription_data[effective_date]` is present and in the future, otherwise a subscription is created." + @type subscription_data :: %{ + optional(:description) => binary, + optional(:effective_date) => :current_period_end | integer | binary, + optional(:trial_period_days) => integer | binary + } + ) + + ( + @typedoc nil + @type transfer_data :: %{ + optional(:amount) => integer, + optional(:amount_percent) => number, + optional(:destination) => binary + } + ) + + ( + nil + + @doc "

Retrieves the quote with the given ID.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/quotes/{quote}`\n" + ( + @spec retrieve( + quote :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: {:ok, Stripe.Quote.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def retrieve(quote, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/quotes/{quote}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "quote", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "quote", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [quote] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

A quote models prices and services for a customer. Default options for header, description, footer, and expires_at can be set in the dashboard via the quote template.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/quotes`\n" + ( + @spec create( + params :: %{ + optional(:application_fee_amount) => integer | binary, + optional(:application_fee_percent) => number | binary, + optional(:automatic_tax) => automatic_tax, + optional(:collection_method) => :charge_automatically | :send_invoice, + optional(:customer) => binary, + optional(:default_tax_rates) => list(binary) | binary, + optional(:description) => binary, + optional(:discounts) => list(discounts) | binary, + optional(:expand) => list(binary), + optional(:expires_at) => integer, + optional(:footer) => binary, + optional(:from_quote) => from_quote, + optional(:header) => binary, + optional(:invoice_settings) => invoice_settings, + optional(:line_items) => list(line_items), + optional(:metadata) => %{optional(binary) => binary}, + optional(:on_behalf_of) => binary | binary, + optional(:subscription_data) => subscription_data, + optional(:test_clock) => binary, + optional(:transfer_data) => transfer_data | binary + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.Quote.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/quotes", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

A quote models prices and services for a customer.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/quotes/{quote}`\n" + ( + @spec update( + quote :: binary(), + params :: %{ + optional(:application_fee_amount) => integer | binary, + optional(:application_fee_percent) => number | binary, + optional(:automatic_tax) => automatic_tax, + optional(:collection_method) => :charge_automatically | :send_invoice, + optional(:customer) => binary, + optional(:default_tax_rates) => list(binary) | binary, + optional(:description) => binary, + optional(:discounts) => list(discounts) | binary, + optional(:expand) => list(binary), + optional(:expires_at) => integer, + optional(:footer) => binary, + optional(:header) => binary, + optional(:invoice_settings) => invoice_settings, + optional(:line_items) => list(line_items), + optional(:metadata) => %{optional(binary) => binary}, + optional(:on_behalf_of) => binary | binary, + optional(:subscription_data) => subscription_data, + optional(:transfer_data) => transfer_data | binary + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.Quote.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def update(quote, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/quotes/{quote}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "quote", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "quote", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [quote] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Cancels the quote.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/quotes/{quote}/cancel`\n" + ( + @spec cancel( + quote :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: {:ok, Stripe.Quote.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def cancel(quote, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/quotes/{quote}/cancel", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "quote", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "quote", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [quote] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Finalizes the quote.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/quotes/{quote}/finalize`\n" + ( + @spec finalize_quote( + quote :: binary(), + params :: %{optional(:expand) => list(binary), optional(:expires_at) => integer}, + opts :: Keyword.t() + ) :: {:ok, Stripe.Quote.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def finalize_quote(quote, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/quotes/{quote}/finalize", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "quote", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "quote", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [quote] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Accepts the specified quote.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/quotes/{quote}/accept`\n" + ( + @spec accept( + quote :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: {:ok, Stripe.Quote.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def accept(quote, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/quotes/{quote}/accept", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "quote", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "quote", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [quote] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Returns a list of your quotes.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/quotes`\n" + ( + @spec list( + params :: %{ + optional(:customer) => binary, + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:starting_after) => binary, + optional(:status) => :accepted | :canceled | :draft | :open, + optional(:test_clock) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.Quote.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/quotes", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

When retrieving a quote, there is an includable line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/quotes/{quote}/line_items`\n" + ( + @spec list_line_items( + quote :: binary(), + params :: %{ + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.Item.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list_line_items(quote, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/quotes/{quote}/line_items", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "quote", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "quote", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [quote] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

When retrieving a quote, there is an includable computed.upfront.line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of upfront line items.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/quotes/{quote}/computed_upfront_line_items`\n" + ( + @spec list_computed_upfront_line_items( + quote :: binary(), + params :: %{ + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.Item.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list_computed_upfront_line_items(quote, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/quotes/{quote}/computed_upfront_line_items", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "quote", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "quote", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [quote] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Download the PDF for a finalized quote

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/quotes/{quote}/pdf`\n" + ( + @spec pdf( + quote :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: {:ok, []} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def pdf(quote, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/quotes/{quote}/pdf", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "quote", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "quote", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [quote] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/radar__early_fraud_warning.ex b/lib/generated/radar__early_fraud_warning.ex new file mode 100644 index 00000000..c6df372a --- /dev/null +++ b/lib/generated/radar__early_fraud_warning.ex @@ -0,0 +1,104 @@ +defmodule Stripe.Radar.EarlyFraudWarning do + use Stripe.Entity + + @moduledoc "An early fraud warning indicates that the card issuer has notified us that a\ncharge may be fraudulent.\n\nRelated guide: [Early fraud warnings](https://stripe.com/docs/disputes/measuring#early-fraud-warnings)" + ( + defstruct [ + :actionable, + :charge, + :created, + :fraud_type, + :id, + :livemode, + :object, + :payment_intent + ] + + @typedoc "The `radar.early_fraud_warning` type.\n\n * `actionable` An EFW is actionable if it has not received a dispute and has not been fully refunded. You may wish to proactively refund a charge that receives an EFW, in order to avoid receiving a dispute later.\n * `charge` ID of the charge this early fraud warning is for, optionally expanded.\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `fraud_type` The type of fraud labelled by the issuer. One of `card_never_received`, `fraudulent_card_application`, `made_with_counterfeit_card`, `made_with_lost_card`, `made_with_stolen_card`, `misc`, `unauthorized_use_of_card`.\n * `id` Unique identifier for the object.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `payment_intent` ID of the Payment Intent this early fraud warning is for, optionally expanded.\n" + @type t :: %__MODULE__{ + actionable: boolean, + charge: binary | Stripe.Charge.t(), + created: integer, + fraud_type: binary, + id: binary, + livemode: boolean, + object: binary, + payment_intent: binary | Stripe.PaymentIntent.t() + } + ) + + ( + nil + + @doc "

Returns a list of early fraud warnings.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/radar/early_fraud_warnings`\n" + ( + @spec list( + params :: %{ + optional(:charge) => binary, + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:payment_intent) => binary, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.Radar.EarlyFraudWarning.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/radar/early_fraud_warnings", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves the details of an early fraud warning that has previously been created.

\n\n

Please refer to the early fraud warning object reference for more details.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/radar/early_fraud_warnings/{early_fraud_warning}`\n" + ( + @spec retrieve( + early_fraud_warning :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Radar.EarlyFraudWarning.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def retrieve(early_fraud_warning, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/radar/early_fraud_warnings/{early_fraud_warning}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "early_fraud_warning", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "early_fraud_warning", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [early_fraud_warning] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/radar__value_list.ex b/lib/generated/radar__value_list.ex new file mode 100644 index 00000000..baf68fd1 --- /dev/null +++ b/lib/generated/radar__value_list.ex @@ -0,0 +1,245 @@ +defmodule Stripe.Radar.ValueList do + use Stripe.Entity + + @moduledoc "Value lists allow you to group values together which can then be referenced in rules.\n\nRelated guide: [Default Stripe lists](https://stripe.com/docs/radar/lists#managing-list-items)" + ( + defstruct [ + :alias, + :created, + :created_by, + :id, + :item_type, + :list_items, + :livemode, + :metadata, + :name, + :object + ] + + @typedoc "The `radar.value_list` type.\n\n * `alias` The name of the value list for use in rules.\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `created_by` The name or email address of the user who created this value list.\n * `id` Unique identifier for the object.\n * `item_type` The type of items in the value list. One of `card_fingerprint`, `card_bin`, `email`, `ip_address`, `country`, `string`, `case_sensitive_string`, or `customer_id`.\n * `list_items` List of items contained within this value list.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `metadata` Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.\n * `name` The name of the value list.\n * `object` String representing the object's type. Objects of the same type share the same value.\n" + @type t :: %__MODULE__{ + alias: binary, + created: integer, + created_by: binary, + id: binary, + item_type: binary, + list_items: term, + livemode: boolean, + metadata: term, + name: binary, + object: binary + } + ) + + ( + @typedoc nil + @type created :: %{ + optional(:gt) => integer, + optional(:gte) => integer, + optional(:lt) => integer, + optional(:lte) => integer + } + ) + + ( + nil + + @doc "

Returns a list of ValueList objects. The objects are sorted in descending order by creation date, with the most recently created object appearing first.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/radar/value_lists`\n" + ( + @spec list( + params :: %{ + optional(:alias) => binary, + optional(:contains) => binary, + optional(:created) => created | integer, + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.Radar.ValueList.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/radar/value_lists", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves a ValueList object.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/radar/value_lists/{value_list}`\n" + ( + @spec retrieve( + value_list :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Radar.ValueList.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def retrieve(value_list, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/radar/value_lists/{value_list}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "value_list", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "value_list", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [value_list] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Creates a new ValueList object, which can then be referenced in rules.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/radar/value_lists`\n" + ( + @spec create( + params :: %{ + optional(:alias) => binary, + optional(:expand) => list(binary), + optional(:item_type) => + :card_bin + | :card_fingerprint + | :case_sensitive_string + | :country + | :customer_id + | :email + | :ip_address + | binary, + optional(:metadata) => %{optional(binary) => binary}, + optional(:name) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Radar.ValueList.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/radar/value_lists", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Updates a ValueList object by setting the values of the parameters passed. Any parameters not provided will be left unchanged. Note that item_type is immutable.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/radar/value_lists/{value_list}`\n" + ( + @spec update( + value_list :: binary(), + params :: %{ + optional(:alias) => binary, + optional(:expand) => list(binary), + optional(:metadata) => %{optional(binary) => binary}, + optional(:name) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Radar.ValueList.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def update(value_list, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/radar/value_lists/{value_list}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "value_list", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "value_list", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [value_list] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Deletes a ValueList object, also deleting any items contained within the value list. To be deleted, a value list must not be referenced in any rules.

\n\n#### Details\n\n * Method: `delete`\n * Path: `/v1/radar/value_lists/{value_list}`\n" + ( + @spec delete(value_list :: binary(), opts :: Keyword.t()) :: + {:ok, Stripe.DeletedRadar.ValueList.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def delete(value_list, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/radar/value_lists/{value_list}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "value_list", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "value_list", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [value_list] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_method(:delete) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/radar__value_list_item.ex b/lib/generated/radar__value_list_item.ex new file mode 100644 index 00000000..8ad3f3a2 --- /dev/null +++ b/lib/generated/radar__value_list_item.ex @@ -0,0 +1,172 @@ +defmodule Stripe.Radar.ValueListItem do + use Stripe.Entity + + @moduledoc "Value list items allow you to add specific values to a given Radar value list, which can then be used in rules.\n\nRelated guide: [Managing list items](https://stripe.com/docs/radar/lists#managing-list-items)" + ( + defstruct [:created, :created_by, :id, :livemode, :object, :value, :value_list] + + @typedoc "The `radar.value_list_item` type.\n\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `created_by` The name or email address of the user who added this item to the value list.\n * `id` Unique identifier for the object.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `value` The value of the item.\n * `value_list` The identifier of the value list this item belongs to.\n" + @type t :: %__MODULE__{ + created: integer, + created_by: binary, + id: binary, + livemode: boolean, + object: binary, + value: binary, + value_list: binary + } + ) + + ( + @typedoc nil + @type created :: %{ + optional(:gt) => integer, + optional(:gte) => integer, + optional(:lt) => integer, + optional(:lte) => integer + } + ) + + ( + nil + + @doc "

Returns a list of ValueListItem objects. The objects are sorted in descending order by creation date, with the most recently created object appearing first.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/radar/value_list_items`\n" + ( + @spec list( + params :: %{ + optional(:created) => created | integer, + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:starting_after) => binary, + optional(:value) => binary, + optional(:value_list) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.Radar.ValueListItem.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/radar/value_list_items", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves a ValueListItem object.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/radar/value_list_items/{item}`\n" + ( + @spec retrieve( + item :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Radar.ValueListItem.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def retrieve(item, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/radar/value_list_items/{item}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "item", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "item", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [item] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Creates a new ValueListItem object, which is added to the specified parent value list.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/radar/value_list_items`\n" + ( + @spec create( + params :: %{ + optional(:expand) => list(binary), + optional(:value) => binary, + optional(:value_list) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Radar.ValueListItem.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/radar/value_list_items", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Deletes a ValueListItem object, removing it from its parent value list.

\n\n#### Details\n\n * Method: `delete`\n * Path: `/v1/radar/value_list_items/{item}`\n" + ( + @spec delete(item :: binary(), opts :: Keyword.t()) :: + {:ok, Stripe.DeletedRadar.ValueListItem.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def delete(item, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/radar/value_list_items/{item}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "item", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "item", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [item] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_method(:delete) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/refund.ex b/lib/generated/refund.ex new file mode 100644 index 00000000..9deb81f8 --- /dev/null +++ b/lib/generated/refund.ex @@ -0,0 +1,314 @@ +defmodule Stripe.Refund do + use Stripe.Entity + + @moduledoc "`Refund` objects allow you to refund a charge that has previously been created\nbut not yet refunded. Funds will be refunded to the credit or debit card that\nwas originally charged.\n\nRelated guide: [Refunds](https://stripe.com/docs/refunds)" + ( + defstruct [ + :amount, + :balance_transaction, + :charge, + :created, + :currency, + :description, + :failure_balance_transaction, + :failure_reason, + :id, + :instructions_email, + :metadata, + :next_action, + :object, + :payment_intent, + :reason, + :receipt_number, + :source_transfer_reversal, + :status, + :transfer_reversal + ] + + @typedoc "The `refund` type.\n\n * `amount` Amount, in %s.\n * `balance_transaction` Balance transaction that describes the impact on your account balance.\n * `charge` ID of the charge that was refunded.\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `currency` Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).\n * `description` An arbitrary string attached to the object. Often useful for displaying to users. (Available on non-card refunds only)\n * `failure_balance_transaction` If the refund failed, this balance transaction describes the adjustment made on your account balance that reverses the initial balance transaction.\n * `failure_reason` If the refund failed, the reason for refund failure if known. Possible values are `lost_or_stolen_card`, `expired_or_canceled_card`, `charge_for_pending_refund_disputed`, `insufficient_funds`, `declined`, `merchant_request` or `unknown`.\n * `id` Unique identifier for the object.\n * `instructions_email` For payment methods without native refund support (e.g., Konbini, PromptPay), email for the customer to receive refund instructions.\n * `metadata` Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.\n * `next_action` \n * `object` String representing the object's type. Objects of the same type share the same value.\n * `payment_intent` ID of the PaymentIntent that was refunded.\n * `reason` Reason for the refund, either user-provided (`duplicate`, `fraudulent`, or `requested_by_customer`) or generated by Stripe internally (`expired_uncaptured_charge`).\n * `receipt_number` This is the transaction number that appears on email receipts sent for this refund.\n * `source_transfer_reversal` The transfer reversal that is associated with the refund. Only present if the charge came from another Stripe account. See the Connect documentation for details.\n * `status` Status of the refund. For credit card refunds, this can be `pending`, `succeeded`, or `failed`. For other types of refunds, it can be `pending`, `requires_action`, `succeeded`, `failed`, or `canceled`. Refer to our [refunds](https://stripe.com/docs/refunds#failed-refunds) documentation for more details.\n * `transfer_reversal` If the accompanying transfer was reversed, the transfer reversal object. Only applicable if the charge was created using the destination parameter.\n" + @type t :: %__MODULE__{ + amount: integer, + balance_transaction: (binary | Stripe.BalanceTransaction.t()) | nil, + charge: (binary | Stripe.Charge.t()) | nil, + created: integer, + currency: binary, + description: binary, + failure_balance_transaction: binary | Stripe.BalanceTransaction.t(), + failure_reason: binary, + id: binary, + instructions_email: binary, + metadata: term | nil, + next_action: term, + object: binary, + payment_intent: (binary | Stripe.PaymentIntent.t()) | nil, + reason: binary | nil, + receipt_number: binary | nil, + source_transfer_reversal: (binary | Stripe.TransferReversal.t()) | nil, + status: binary | nil, + transfer_reversal: (binary | Stripe.TransferReversal.t()) | nil + } + ) + + ( + nil + + @doc "

You can see a list of the refunds belonging to a specific charge. Note that the 10 most recent refunds are always available by default on the charge object. If you need more than those 10, you can use this API method and the limit and starting_after parameters to page through additional refunds.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/charges/{charge}/refunds`\n" + ( + @spec list( + charge :: binary(), + params :: %{ + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.Refund.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(charge, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/charges/{charge}/refunds", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "charge", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "charge", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [charge] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves the details of an existing refund.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/charges/{charge}/refunds/{refund}`\n" + ( + @spec retrieve( + charge :: binary(), + refund :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: {:ok, Stripe.Refund.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def retrieve(charge, refund, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/charges/{charge}/refunds/{refund}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "charge", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "charge", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + }, + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "refund", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "refund", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [charge, refund] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + @doc "

Create a refund.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/refunds`\n" + ( + @spec create( + params :: %{ + optional(:amount) => integer, + optional(:charge) => binary, + optional(:currency) => binary, + optional(:customer) => binary, + optional(:expand) => list(binary), + optional(:instructions_email) => binary, + optional(:metadata) => %{optional(binary) => binary} | binary, + optional(:origin) => :customer_balance, + optional(:payment_intent) => binary, + optional(:reason) => :duplicate | :fraudulent | :requested_by_customer, + optional(:refund_application_fee) => boolean, + optional(:reverse_transfer) => boolean + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.Refund.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/refunds", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Updates the specified refund by setting the values of the parameters passed. Any parameters not provided will be left unchanged.

\n\n

This request only accepts metadata as an argument.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/refunds/{refund}`\n" + ( + @spec update( + refund :: binary(), + params :: %{ + optional(:expand) => list(binary), + optional(:metadata) => %{optional(binary) => binary} | binary + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.Refund.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def update(refund, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/refunds/{refund}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "refund", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "refund", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [refund] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Cancels a refund with a status of requires_action.

\n\n

Refunds in other states cannot be canceled, and only refunds for payment methods that require customer action will enter the requires_action state.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/refunds/{refund}/cancel`\n" + ( + @spec cancel( + refund :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: {:ok, Stripe.Refund.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def cancel(refund, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/refunds/{refund}/cancel", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "refund", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "refund", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [refund] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Expire a refund with a status of requires_action.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/test_helpers/refunds/{refund}/expire`\n" + ( + @spec expire( + refund :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: {:ok, Stripe.Refund.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def expire(refund, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/test_helpers/refunds/{refund}/expire", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "refund", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "refund", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [refund] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/reporting__report_run.ex b/lib/generated/reporting__report_run.ex new file mode 100644 index 00000000..eb3bd0eb --- /dev/null +++ b/lib/generated/reporting__report_run.ex @@ -0,0 +1,791 @@ +defmodule Stripe.Reporting.ReportRun do + use Stripe.Entity + + @moduledoc "The Report Run object represents an instance of a report type generated with\nspecific run parameters. Once the object is created, Stripe begins processing the report.\nWhen the report has finished running, it will give you a reference to a file\nwhere you can retrieve your results. For an overview, see\n[API Access to Reports](https://stripe.com/docs/reporting/statements/api).\n\nNote that certain report types can only be run based on your live-mode data (not test-mode\ndata), and will error when queried without a [live-mode API key](https://stripe.com/docs/keys#test-live-modes)." + ( + defstruct [ + :created, + :error, + :id, + :livemode, + :object, + :parameters, + :report_type, + :result, + :status, + :succeeded_at + ] + + @typedoc "The `reporting.report_run` type.\n\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `error` If something should go wrong during the run, a message about the failure (populated when\n `status=failed`).\n * `id` Unique identifier for the object.\n * `livemode` `true` if the report is run on live mode data and `false` if it is run on test mode data.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `parameters` \n * `report_type` The ID of the [report type](https://stripe.com/docs/reports/report-types) to run, such as `\"balance.summary.1\"`.\n * `result` The file object representing the result of the report run (populated when\n `status=succeeded`).\n * `status` Status of this report run. This will be `pending` when the run is initially created.\n When the run finishes, this will be set to `succeeded` and the `result` field will be populated.\n Rarely, we may encounter an error, at which point this will be set to `failed` and the `error` field will be populated.\n * `succeeded_at` Timestamp at which this run successfully finished (populated when\n `status=succeeded`). Measured in seconds since the Unix epoch.\n" + @type t :: %__MODULE__{ + created: integer, + error: binary | nil, + id: binary, + livemode: boolean, + object: binary, + parameters: term, + report_type: binary, + result: Stripe.File.t() | nil, + status: binary, + succeeded_at: integer | nil + } + ) + + ( + @typedoc nil + @type created :: %{ + optional(:gt) => integer, + optional(:gte) => integer, + optional(:lt) => integer, + optional(:lte) => integer + } + ) + + ( + @typedoc "Parameters specifying how the report should be run. Different Report Types have different required and optional parameters, listed in the [API Access to Reports](https://stripe.com/docs/reporting/statements/api) documentation." + @type parameters :: %{ + optional(:columns) => list(binary), + optional(:connected_account) => binary, + optional(:currency) => binary, + optional(:interval_end) => integer, + optional(:interval_start) => integer, + optional(:payout) => binary, + optional(:reporting_category) => + :advance + | :advance_funding + | :anticipation_repayment + | :charge + | :charge_failure + | :connect_collection_transfer + | :connect_reserved_funds + | :contribution + | :dispute + | :dispute_reversal + | :fee + | :financing_paydown + | :financing_paydown_reversal + | :financing_payout + | :financing_payout_reversal + | :issuing_authorization_hold + | :issuing_authorization_release + | :issuing_dispute + | :issuing_transaction + | :network_cost + | :other_adjustment + | :partial_capture_reversal + | :payout + | :payout_reversal + | :platform_earning + | :platform_earning_refund + | :refund + | :refund_failure + | :risk_reserved_funds + | :tax + | :topup + | :topup_reversal + | :transfer + | :transfer_reversal, + optional(:timezone) => + :"Africa/Abidjan" + | :"Africa/Accra" + | :"Africa/Addis_Ababa" + | :"Africa/Algiers" + | :"Africa/Asmara" + | :"Africa/Asmera" + | :"Africa/Bamako" + | :"Africa/Bangui" + | :"Africa/Banjul" + | :"Africa/Bissau" + | :"Africa/Blantyre" + | :"Africa/Brazzaville" + | :"Africa/Bujumbura" + | :"Africa/Cairo" + | :"Africa/Casablanca" + | :"Africa/Ceuta" + | :"Africa/Conakry" + | :"Africa/Dakar" + | :"Africa/Dar_es_Salaam" + | :"Africa/Djibouti" + | :"Africa/Douala" + | :"Africa/El_Aaiun" + | :"Africa/Freetown" + | :"Africa/Gaborone" + | :"Africa/Harare" + | :"Africa/Johannesburg" + | :"Africa/Juba" + | :"Africa/Kampala" + | :"Africa/Khartoum" + | :"Africa/Kigali" + | :"Africa/Kinshasa" + | :"Africa/Lagos" + | :"Africa/Libreville" + | :"Africa/Lome" + | :"Africa/Luanda" + | :"Africa/Lubumbashi" + | :"Africa/Lusaka" + | :"Africa/Malabo" + | :"Africa/Maputo" + | :"Africa/Maseru" + | :"Africa/Mbabane" + | :"Africa/Mogadishu" + | :"Africa/Monrovia" + | :"Africa/Nairobi" + | :"Africa/Ndjamena" + | :"Africa/Niamey" + | :"Africa/Nouakchott" + | :"Africa/Ouagadougou" + | :"Africa/Porto-Novo" + | :"Africa/Sao_Tome" + | :"Africa/Timbuktu" + | :"Africa/Tripoli" + | :"Africa/Tunis" + | :"Africa/Windhoek" + | :"America/Adak" + | :"America/Anchorage" + | :"America/Anguilla" + | :"America/Antigua" + | :"America/Araguaina" + | :"America/Argentina/Buenos_Aires" + | :"America/Argentina/Catamarca" + | :"America/Argentina/ComodRivadavia" + | :"America/Argentina/Cordoba" + | :"America/Argentina/Jujuy" + | :"America/Argentina/La_Rioja" + | :"America/Argentina/Mendoza" + | :"America/Argentina/Rio_Gallegos" + | :"America/Argentina/Salta" + | :"America/Argentina/San_Juan" + | :"America/Argentina/San_Luis" + | :"America/Argentina/Tucuman" + | :"America/Argentina/Ushuaia" + | :"America/Aruba" + | :"America/Asuncion" + | :"America/Atikokan" + | :"America/Atka" + | :"America/Bahia" + | :"America/Bahia_Banderas" + | :"America/Barbados" + | :"America/Belem" + | :"America/Belize" + | :"America/Blanc-Sablon" + | :"America/Boa_Vista" + | :"America/Bogota" + | :"America/Boise" + | :"America/Buenos_Aires" + | :"America/Cambridge_Bay" + | :"America/Campo_Grande" + | :"America/Cancun" + | :"America/Caracas" + | :"America/Catamarca" + | :"America/Cayenne" + | :"America/Cayman" + | :"America/Chicago" + | :"America/Chihuahua" + | :"America/Ciudad_Juarez" + | :"America/Coral_Harbour" + | :"America/Cordoba" + | :"America/Costa_Rica" + | :"America/Creston" + | :"America/Cuiaba" + | :"America/Curacao" + | :"America/Danmarkshavn" + | :"America/Dawson" + | :"America/Dawson_Creek" + | :"America/Denver" + | :"America/Detroit" + | :"America/Dominica" + | :"America/Edmonton" + | :"America/Eirunepe" + | :"America/El_Salvador" + | :"America/Ensenada" + | :"America/Fort_Nelson" + | :"America/Fort_Wayne" + | :"America/Fortaleza" + | :"America/Glace_Bay" + | :"America/Godthab" + | :"America/Goose_Bay" + | :"America/Grand_Turk" + | :"America/Grenada" + | :"America/Guadeloupe" + | :"America/Guatemala" + | :"America/Guayaquil" + | :"America/Guyana" + | :"America/Halifax" + | :"America/Havana" + | :"America/Hermosillo" + | :"America/Indiana/Indianapolis" + | :"America/Indiana/Knox" + | :"America/Indiana/Marengo" + | :"America/Indiana/Petersburg" + | :"America/Indiana/Tell_City" + | :"America/Indiana/Vevay" + | :"America/Indiana/Vincennes" + | :"America/Indiana/Winamac" + | :"America/Indianapolis" + | :"America/Inuvik" + | :"America/Iqaluit" + | :"America/Jamaica" + | :"America/Jujuy" + | :"America/Juneau" + | :"America/Kentucky/Louisville" + | :"America/Kentucky/Monticello" + | :"America/Knox_IN" + | :"America/Kralendijk" + | :"America/La_Paz" + | :"America/Lima" + | :"America/Los_Angeles" + | :"America/Louisville" + | :"America/Lower_Princes" + | :"America/Maceio" + | :"America/Managua" + | :"America/Manaus" + | :"America/Marigot" + | :"America/Martinique" + | :"America/Matamoros" + | :"America/Mazatlan" + | :"America/Mendoza" + | :"America/Menominee" + | :"America/Merida" + | :"America/Metlakatla" + | :"America/Mexico_City" + | :"America/Miquelon" + | :"America/Moncton" + | :"America/Monterrey" + | :"America/Montevideo" + | :"America/Montreal" + | :"America/Montserrat" + | :"America/Nassau" + | :"America/New_York" + | :"America/Nipigon" + | :"America/Nome" + | :"America/Noronha" + | :"America/North_Dakota/Beulah" + | :"America/North_Dakota/Center" + | :"America/North_Dakota/New_Salem" + | :"America/Nuuk" + | :"America/Ojinaga" + | :"America/Panama" + | :"America/Pangnirtung" + | :"America/Paramaribo" + | :"America/Phoenix" + | :"America/Port-au-Prince" + | :"America/Port_of_Spain" + | :"America/Porto_Acre" + | :"America/Porto_Velho" + | :"America/Puerto_Rico" + | :"America/Punta_Arenas" + | :"America/Rainy_River" + | :"America/Rankin_Inlet" + | :"America/Recife" + | :"America/Regina" + | :"America/Resolute" + | :"America/Rio_Branco" + | :"America/Rosario" + | :"America/Santa_Isabel" + | :"America/Santarem" + | :"America/Santiago" + | :"America/Santo_Domingo" + | :"America/Sao_Paulo" + | :"America/Scoresbysund" + | :"America/Shiprock" + | :"America/Sitka" + | :"America/St_Barthelemy" + | :"America/St_Johns" + | :"America/St_Kitts" + | :"America/St_Lucia" + | :"America/St_Thomas" + | :"America/St_Vincent" + | :"America/Swift_Current" + | :"America/Tegucigalpa" + | :"America/Thule" + | :"America/Thunder_Bay" + | :"America/Tijuana" + | :"America/Toronto" + | :"America/Tortola" + | :"America/Vancouver" + | :"America/Virgin" + | :"America/Whitehorse" + | :"America/Winnipeg" + | :"America/Yakutat" + | :"America/Yellowknife" + | :"Antarctica/Casey" + | :"Antarctica/Davis" + | :"Antarctica/DumontDUrville" + | :"Antarctica/Macquarie" + | :"Antarctica/Mawson" + | :"Antarctica/McMurdo" + | :"Antarctica/Palmer" + | :"Antarctica/Rothera" + | :"Antarctica/South_Pole" + | :"Antarctica/Syowa" + | :"Antarctica/Troll" + | :"Antarctica/Vostok" + | :"Arctic/Longyearbyen" + | :"Asia/Aden" + | :"Asia/Almaty" + | :"Asia/Amman" + | :"Asia/Anadyr" + | :"Asia/Aqtau" + | :"Asia/Aqtobe" + | :"Asia/Ashgabat" + | :"Asia/Ashkhabad" + | :"Asia/Atyrau" + | :"Asia/Baghdad" + | :"Asia/Bahrain" + | :"Asia/Baku" + | :"Asia/Bangkok" + | :"Asia/Barnaul" + | :"Asia/Beirut" + | :"Asia/Bishkek" + | :"Asia/Brunei" + | :"Asia/Calcutta" + | :"Asia/Chita" + | :"Asia/Choibalsan" + | :"Asia/Chongqing" + | :"Asia/Chungking" + | :"Asia/Colombo" + | :"Asia/Dacca" + | :"Asia/Damascus" + | :"Asia/Dhaka" + | :"Asia/Dili" + | :"Asia/Dubai" + | :"Asia/Dushanbe" + | :"Asia/Famagusta" + | :"Asia/Gaza" + | :"Asia/Harbin" + | :"Asia/Hebron" + | :"Asia/Ho_Chi_Minh" + | :"Asia/Hong_Kong" + | :"Asia/Hovd" + | :"Asia/Irkutsk" + | :"Asia/Istanbul" + | :"Asia/Jakarta" + | :"Asia/Jayapura" + | :"Asia/Jerusalem" + | :"Asia/Kabul" + | :"Asia/Kamchatka" + | :"Asia/Karachi" + | :"Asia/Kashgar" + | :"Asia/Kathmandu" + | :"Asia/Katmandu" + | :"Asia/Khandyga" + | :"Asia/Kolkata" + | :"Asia/Krasnoyarsk" + | :"Asia/Kuala_Lumpur" + | :"Asia/Kuching" + | :"Asia/Kuwait" + | :"Asia/Macao" + | :"Asia/Macau" + | :"Asia/Magadan" + | :"Asia/Makassar" + | :"Asia/Manila" + | :"Asia/Muscat" + | :"Asia/Nicosia" + | :"Asia/Novokuznetsk" + | :"Asia/Novosibirsk" + | :"Asia/Omsk" + | :"Asia/Oral" + | :"Asia/Phnom_Penh" + | :"Asia/Pontianak" + | :"Asia/Pyongyang" + | :"Asia/Qatar" + | :"Asia/Qostanay" + | :"Asia/Qyzylorda" + | :"Asia/Rangoon" + | :"Asia/Riyadh" + | :"Asia/Saigon" + | :"Asia/Sakhalin" + | :"Asia/Samarkand" + | :"Asia/Seoul" + | :"Asia/Shanghai" + | :"Asia/Singapore" + | :"Asia/Srednekolymsk" + | :"Asia/Taipei" + | :"Asia/Tashkent" + | :"Asia/Tbilisi" + | :"Asia/Tehran" + | :"Asia/Tel_Aviv" + | :"Asia/Thimbu" + | :"Asia/Thimphu" + | :"Asia/Tokyo" + | :"Asia/Tomsk" + | :"Asia/Ujung_Pandang" + | :"Asia/Ulaanbaatar" + | :"Asia/Ulan_Bator" + | :"Asia/Urumqi" + | :"Asia/Ust-Nera" + | :"Asia/Vientiane" + | :"Asia/Vladivostok" + | :"Asia/Yakutsk" + | :"Asia/Yangon" + | :"Asia/Yekaterinburg" + | :"Asia/Yerevan" + | :"Atlantic/Azores" + | :"Atlantic/Bermuda" + | :"Atlantic/Canary" + | :"Atlantic/Cape_Verde" + | :"Atlantic/Faeroe" + | :"Atlantic/Faroe" + | :"Atlantic/Jan_Mayen" + | :"Atlantic/Madeira" + | :"Atlantic/Reykjavik" + | :"Atlantic/South_Georgia" + | :"Atlantic/St_Helena" + | :"Atlantic/Stanley" + | :"Australia/ACT" + | :"Australia/Adelaide" + | :"Australia/Brisbane" + | :"Australia/Broken_Hill" + | :"Australia/Canberra" + | :"Australia/Currie" + | :"Australia/Darwin" + | :"Australia/Eucla" + | :"Australia/Hobart" + | :"Australia/LHI" + | :"Australia/Lindeman" + | :"Australia/Lord_Howe" + | :"Australia/Melbourne" + | :"Australia/NSW" + | :"Australia/North" + | :"Australia/Perth" + | :"Australia/Queensland" + | :"Australia/South" + | :"Australia/Sydney" + | :"Australia/Tasmania" + | :"Australia/Victoria" + | :"Australia/West" + | :"Australia/Yancowinna" + | :"Brazil/Acre" + | :"Brazil/DeNoronha" + | :"Brazil/East" + | :"Brazil/West" + | :CET + | :CST6CDT + | :"Canada/Atlantic" + | :"Canada/Central" + | :"Canada/Eastern" + | :"Canada/Mountain" + | :"Canada/Newfoundland" + | :"Canada/Pacific" + | :"Canada/Saskatchewan" + | :"Canada/Yukon" + | :"Chile/Continental" + | :"Chile/EasterIsland" + | :Cuba + | :EET + | :EST + | :EST5EDT + | :Egypt + | :Eire + | :"Etc/GMT" + | :"Etc/GMT+0" + | :"Etc/GMT+1" + | :"Etc/GMT+10" + | :"Etc/GMT+11" + | :"Etc/GMT+12" + | :"Etc/GMT+2" + | :"Etc/GMT+3" + | :"Etc/GMT+4" + | :"Etc/GMT+5" + | :"Etc/GMT+6" + | :"Etc/GMT+7" + | :"Etc/GMT+8" + | :"Etc/GMT+9" + | :"Etc/GMT-0" + | :"Etc/GMT-1" + | :"Etc/GMT-10" + | :"Etc/GMT-11" + | :"Etc/GMT-12" + | :"Etc/GMT-13" + | :"Etc/GMT-14" + | :"Etc/GMT-2" + | :"Etc/GMT-3" + | :"Etc/GMT-4" + | :"Etc/GMT-5" + | :"Etc/GMT-6" + | :"Etc/GMT-7" + | :"Etc/GMT-8" + | :"Etc/GMT-9" + | :"Etc/GMT0" + | :"Etc/Greenwich" + | :"Etc/UCT" + | :"Etc/UTC" + | :"Etc/Universal" + | :"Etc/Zulu" + | :"Europe/Amsterdam" + | :"Europe/Andorra" + | :"Europe/Astrakhan" + | :"Europe/Athens" + | :"Europe/Belfast" + | :"Europe/Belgrade" + | :"Europe/Berlin" + | :"Europe/Bratislava" + | :"Europe/Brussels" + | :"Europe/Bucharest" + | :"Europe/Budapest" + | :"Europe/Busingen" + | :"Europe/Chisinau" + | :"Europe/Copenhagen" + | :"Europe/Dublin" + | :"Europe/Gibraltar" + | :"Europe/Guernsey" + | :"Europe/Helsinki" + | :"Europe/Isle_of_Man" + | :"Europe/Istanbul" + | :"Europe/Jersey" + | :"Europe/Kaliningrad" + | :"Europe/Kiev" + | :"Europe/Kirov" + | :"Europe/Kyiv" + | :"Europe/Lisbon" + | :"Europe/Ljubljana" + | :"Europe/London" + | :"Europe/Luxembourg" + | :"Europe/Madrid" + | :"Europe/Malta" + | :"Europe/Mariehamn" + | :"Europe/Minsk" + | :"Europe/Monaco" + | :"Europe/Moscow" + | :"Europe/Nicosia" + | :"Europe/Oslo" + | :"Europe/Paris" + | :"Europe/Podgorica" + | :"Europe/Prague" + | :"Europe/Riga" + | :"Europe/Rome" + | :"Europe/Samara" + | :"Europe/San_Marino" + | :"Europe/Sarajevo" + | :"Europe/Saratov" + | :"Europe/Simferopol" + | :"Europe/Skopje" + | :"Europe/Sofia" + | :"Europe/Stockholm" + | :"Europe/Tallinn" + | :"Europe/Tirane" + | :"Europe/Tiraspol" + | :"Europe/Ulyanovsk" + | :"Europe/Uzhgorod" + | :"Europe/Vaduz" + | :"Europe/Vatican" + | :"Europe/Vienna" + | :"Europe/Vilnius" + | :"Europe/Volgograd" + | :"Europe/Warsaw" + | :"Europe/Zagreb" + | :"Europe/Zaporozhye" + | :"Europe/Zurich" + | :Factory + | :GB + | :"GB-Eire" + | :GMT + | :"GMT+0" + | :"GMT-0" + | :GMT0 + | :Greenwich + | :HST + | :Hongkong + | :Iceland + | :"Indian/Antananarivo" + | :"Indian/Chagos" + | :"Indian/Christmas" + | :"Indian/Cocos" + | :"Indian/Comoro" + | :"Indian/Kerguelen" + | :"Indian/Mahe" + | :"Indian/Maldives" + | :"Indian/Mauritius" + | :"Indian/Mayotte" + | :"Indian/Reunion" + | :Iran + | :Israel + | :Jamaica + | :Japan + | :Kwajalein + | :Libya + | :MET + | :MST + | :MST7MDT + | :"Mexico/BajaNorte" + | :"Mexico/BajaSur" + | :"Mexico/General" + | :NZ + | :"NZ-CHAT" + | :Navajo + | :PRC + | :PST8PDT + | :"Pacific/Apia" + | :"Pacific/Auckland" + | :"Pacific/Bougainville" + | :"Pacific/Chatham" + | :"Pacific/Chuuk" + | :"Pacific/Easter" + | :"Pacific/Efate" + | :"Pacific/Enderbury" + | :"Pacific/Fakaofo" + | :"Pacific/Fiji" + | :"Pacific/Funafuti" + | :"Pacific/Galapagos" + | :"Pacific/Gambier" + | :"Pacific/Guadalcanal" + | :"Pacific/Guam" + | :"Pacific/Honolulu" + | :"Pacific/Johnston" + | :"Pacific/Kanton" + | :"Pacific/Kiritimati" + | :"Pacific/Kosrae" + | :"Pacific/Kwajalein" + | :"Pacific/Majuro" + | :"Pacific/Marquesas" + | :"Pacific/Midway" + | :"Pacific/Nauru" + | :"Pacific/Niue" + | :"Pacific/Norfolk" + | :"Pacific/Noumea" + | :"Pacific/Pago_Pago" + | :"Pacific/Palau" + | :"Pacific/Pitcairn" + | :"Pacific/Pohnpei" + | :"Pacific/Ponape" + | :"Pacific/Port_Moresby" + | :"Pacific/Rarotonga" + | :"Pacific/Saipan" + | :"Pacific/Samoa" + | :"Pacific/Tahiti" + | :"Pacific/Tarawa" + | :"Pacific/Tongatapu" + | :"Pacific/Truk" + | :"Pacific/Wake" + | :"Pacific/Wallis" + | :"Pacific/Yap" + | :Poland + | :Portugal + | :ROC + | :ROK + | :Singapore + | :Turkey + | :UCT + | :"US/Alaska" + | :"US/Aleutian" + | :"US/Arizona" + | :"US/Central" + | :"US/East-Indiana" + | :"US/Eastern" + | :"US/Hawaii" + | :"US/Indiana-Starke" + | :"US/Michigan" + | :"US/Mountain" + | :"US/Pacific" + | :"US/Pacific-New" + | :"US/Samoa" + | :UTC + | :Universal + | :"W-SU" + | :WET + | :Zulu + } + ) + + ( + nil + + @doc "

Retrieves the details of an existing Report Run.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/reporting/report_runs/{report_run}`\n" + ( + @spec retrieve( + report_run :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Reporting.ReportRun.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def retrieve(report_run, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/reporting/report_runs/{report_run}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "report_run", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "report_run", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [report_run] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Creates a new object and begin running the report. (Certain report types require a live-mode API key.)

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/reporting/report_runs`\n" + ( + @spec create( + params :: %{ + optional(:expand) => list(binary), + optional(:parameters) => parameters, + optional(:report_type) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Reporting.ReportRun.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/reporting/report_runs", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Returns a list of Report Runs, with the most recent appearing first.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/reporting/report_runs`\n" + ( + @spec list( + params :: %{ + optional(:created) => created | integer, + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.Reporting.ReportRun.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/reporting/report_runs", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/reporting__report_type.ex b/lib/generated/reporting__report_type.ex new file mode 100644 index 00000000..92ff03ca --- /dev/null +++ b/lib/generated/reporting__report_type.ex @@ -0,0 +1,96 @@ +defmodule Stripe.Reporting.ReportType do + use Stripe.Entity + + @moduledoc "The Report Type resource corresponds to a particular type of report, such as\nthe \"Activity summary\" or \"Itemized payouts\" reports. These objects are\nidentified by an ID belonging to a set of enumerated values. See\n[API Access to Reports documentation](https://stripe.com/docs/reporting/statements/api)\nfor those Report Type IDs, along with required and optional parameters.\n\nNote that certain report types can only be run based on your live-mode data (not test-mode\ndata), and will error when queried without a [live-mode API key](https://stripe.com/docs/keys#test-live-modes)." + ( + defstruct [ + :data_available_end, + :data_available_start, + :default_columns, + :id, + :livemode, + :name, + :object, + :updated, + :version + ] + + @typedoc "The `reporting.report_type` type.\n\n * `data_available_end` Most recent time for which this Report Type is available. Measured in seconds since the Unix epoch.\n * `data_available_start` Earliest time for which this Report Type is available. Measured in seconds since the Unix epoch.\n * `default_columns` List of column names that are included by default when this Report Type gets run. (If the Report Type doesn't support the `columns` parameter, this will be null.)\n * `id` The [ID of the Report Type](https://stripe.com/docs/reporting/statements/api#available-report-types), such as `balance.summary.1`.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `name` Human-readable name of the Report Type\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `updated` When this Report Type was latest updated. Measured in seconds since the Unix epoch.\n * `version` Version of the Report Type. Different versions report with the same ID will have the same purpose, but may take different run parameters or have different result schemas.\n" + @type t :: %__MODULE__{ + data_available_end: integer, + data_available_start: integer, + default_columns: term | nil, + id: binary, + livemode: boolean, + name: binary, + object: binary, + updated: integer, + version: integer + } + ) + + ( + nil + + @doc "

Retrieves the details of a Report Type. (Certain report types require a live-mode API key.)

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/reporting/report_types/{report_type}`\n" + ( + @spec retrieve( + report_type :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Reporting.ReportType.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def retrieve(report_type, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/reporting/report_types/{report_type}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "report_type", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "report_type", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [report_type] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Returns a full list of Report Types.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/reporting/report_types`\n" + ( + @spec list(params :: %{optional(:expand) => list(binary)}, opts :: Keyword.t()) :: + {:ok, Stripe.List.t(Stripe.Reporting.ReportType.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/reporting/report_types", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/review.ex b/lib/generated/review.ex new file mode 100644 index 00000000..b037cdba --- /dev/null +++ b/lib/generated/review.ex @@ -0,0 +1,163 @@ +defmodule Stripe.Review do + use Stripe.Entity + + @moduledoc "Reviews can be used to supplement automated fraud detection with human expertise.\n\nLearn more about [Radar](/radar) and reviewing payments\n[here](https://stripe.com/docs/radar/reviews)." + ( + defstruct [ + :billing_zip, + :charge, + :closed_reason, + :created, + :id, + :ip_address, + :ip_address_location, + :livemode, + :object, + :open, + :opened_reason, + :payment_intent, + :reason, + :session + ] + + @typedoc "The `review` type.\n\n * `billing_zip` The ZIP or postal code of the card used, if applicable.\n * `charge` The charge associated with this review.\n * `closed_reason` The reason the review was closed, or null if it has not yet been closed. One of `approved`, `refunded`, `refunded_as_fraud`, `disputed`, or `redacted`.\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `id` Unique identifier for the object.\n * `ip_address` The IP address where the payment originated.\n * `ip_address_location` Information related to the location of the payment. Note that this information is an approximation and attempts to locate the nearest population center - it should not be used to determine a specific address.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `open` If `true`, the review needs action.\n * `opened_reason` The reason the review was opened. One of `rule` or `manual`.\n * `payment_intent` The PaymentIntent ID associated with this review, if one exists.\n * `reason` The reason the review is currently open or closed. One of `rule`, `manual`, `approved`, `refunded`, `refunded_as_fraud`, `disputed`, or `redacted`.\n * `session` Information related to the browsing session of the user who initiated the payment.\n" + @type t :: %__MODULE__{ + billing_zip: binary | nil, + charge: (binary | Stripe.Charge.t()) | nil, + closed_reason: binary | nil, + created: integer, + id: binary, + ip_address: binary | nil, + ip_address_location: term | nil, + livemode: boolean, + object: binary, + open: boolean, + opened_reason: binary, + payment_intent: binary | Stripe.PaymentIntent.t(), + reason: binary, + session: term | nil + } + ) + + ( + @typedoc nil + @type created :: %{ + optional(:gt) => integer, + optional(:gte) => integer, + optional(:lt) => integer, + optional(:lte) => integer + } + ) + + ( + nil + + @doc "

Returns a list of Review objects that have open set to true. The objects are sorted in descending order by creation date, with the most recently created object appearing first.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/reviews`\n" + ( + @spec list( + params :: %{ + optional(:created) => created | integer, + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.Review.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/reviews", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves a Review object.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/reviews/{review}`\n" + ( + @spec retrieve( + review :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: {:ok, Stripe.Review.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def retrieve(review, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/reviews/{review}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "review", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "review", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [review] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Approves a Review object, closing it and removing it from the list of reviews.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/reviews/{review}/approve`\n" + ( + @spec approve( + review :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: {:ok, Stripe.Review.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def approve(review, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/reviews/{review}/approve", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "review", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "review", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [review] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/scheduled_query_run.ex b/lib/generated/scheduled_query_run.ex new file mode 100644 index 00000000..0ececfa6 --- /dev/null +++ b/lib/generated/scheduled_query_run.ex @@ -0,0 +1,108 @@ +defmodule Stripe.ScheduledQueryRun do + use Stripe.Entity + + @moduledoc "If you have [scheduled a Sigma query](https://stripe.com/docs/sigma/scheduled-queries), you'll\nreceive a `sigma.scheduled_query_run.created` webhook each time the query\nruns. The webhook contains a `ScheduledQueryRun` object, which you can use to\nretrieve the query results." + ( + defstruct [ + :created, + :data_load_time, + :error, + :file, + :id, + :livemode, + :object, + :result_available_until, + :sql, + :status, + :title + ] + + @typedoc "The `scheduled_query_run` type.\n\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `data_load_time` When the query was run, Sigma contained a snapshot of your Stripe data at this time.\n * `error` \n * `file` The file object representing the results of the query.\n * `id` Unique identifier for the object.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `result_available_until` Time at which the result expires and is no longer available for download.\n * `sql` SQL for the query.\n * `status` The query's execution status, which will be `completed` for successful runs, and `canceled`, `failed`, or `timed_out` otherwise.\n * `title` Title of the query.\n" + @type t :: %__MODULE__{ + created: integer, + data_load_time: integer, + error: term, + file: Stripe.File.t() | nil, + id: binary, + livemode: boolean, + object: binary, + result_available_until: integer, + sql: binary, + status: binary, + title: binary + } + ) + + ( + nil + + @doc "

Returns a list of scheduled query runs.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/sigma/scheduled_query_runs`\n" + ( + @spec list( + params :: %{ + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.ScheduledQueryRun.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/sigma/scheduled_query_runs", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves the details of an scheduled query run.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/sigma/scheduled_query_runs/{scheduled_query_run}`\n" + ( + @spec retrieve( + scheduled_query_run :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.ScheduledQueryRun.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def retrieve(scheduled_query_run, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/sigma/scheduled_query_runs/{scheduled_query_run}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "scheduled_query_run", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "scheduled_query_run", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [scheduled_query_run] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/setup_attempt.ex b/lib/generated/setup_attempt.ex new file mode 100644 index 00000000..3ce8c1f7 --- /dev/null +++ b/lib/generated/setup_attempt.ex @@ -0,0 +1,84 @@ +defmodule Stripe.SetupAttempt do + use Stripe.Entity + + @moduledoc "A SetupAttempt describes one attempted confirmation of a SetupIntent,\nwhether that confirmation was successful or unsuccessful. You can use\nSetupAttempts to inspect details of a specific attempt at setting up a\npayment method using a SetupIntent." + ( + defstruct [ + :application, + :attach_to_self, + :created, + :customer, + :flow_directions, + :id, + :livemode, + :object, + :on_behalf_of, + :payment_method, + :payment_method_details, + :setup_error, + :setup_intent, + :status, + :usage + ] + + @typedoc "The `setup_attempt` type.\n\n * `application` The value of [application](https://stripe.com/docs/api/setup_intents/object#setup_intent_object-application) on the SetupIntent at the time of this confirmation.\n * `attach_to_self` If present, the SetupIntent's payment method will be attached to the in-context Stripe Account.\n\nIt can only be used for this Stripe Account’s own money movement flows like InboundTransfer and OutboundTransfers. It cannot be set to true when setting up a PaymentMethod for a Customer, and defaults to false when attaching a PaymentMethod to a Customer.\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `customer` The value of [customer](https://stripe.com/docs/api/setup_intents/object#setup_intent_object-customer) on the SetupIntent at the time of this confirmation.\n * `flow_directions` Indicates the directions of money movement for which this payment method is intended to be used.\n\nInclude `inbound` if you intend to use the payment method as the origin to pull funds from. Include `outbound` if you intend to use the payment method as the destination to send funds to. You can include both if you intend to use the payment method for both purposes.\n * `id` Unique identifier for the object.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `on_behalf_of` The value of [on_behalf_of](https://stripe.com/docs/api/setup_intents/object#setup_intent_object-on_behalf_of) on the SetupIntent at the time of this confirmation.\n * `payment_method` ID of the payment method used with this SetupAttempt.\n * `payment_method_details` \n * `setup_error` The error encountered during this attempt to confirm the SetupIntent, if any.\n * `setup_intent` ID of the SetupIntent that this attempt belongs to.\n * `status` Status of this SetupAttempt, one of `requires_confirmation`, `requires_action`, `processing`, `succeeded`, `failed`, or `abandoned`.\n * `usage` The value of [usage](https://stripe.com/docs/api/setup_intents/object#setup_intent_object-usage) on the SetupIntent at the time of this confirmation, one of `off_session` or `on_session`.\n" + @type t :: %__MODULE__{ + application: (binary | term) | nil, + attach_to_self: boolean, + created: integer, + customer: (binary | Stripe.Customer.t() | Stripe.DeletedCustomer.t()) | nil, + flow_directions: term | nil, + id: binary, + livemode: boolean, + object: binary, + on_behalf_of: (binary | Stripe.Account.t()) | nil, + payment_method: binary | Stripe.PaymentMethod.t(), + payment_method_details: term, + setup_error: Stripe.ApiErrors.t() | nil, + setup_intent: binary | Stripe.SetupIntent.t(), + status: binary, + usage: binary + } + ) + + ( + @typedoc nil + @type created :: %{ + optional(:gt) => integer, + optional(:gte) => integer, + optional(:lt) => integer, + optional(:lte) => integer + } + ) + + ( + nil + + @doc "

Returns a list of SetupAttempts associated with a provided SetupIntent.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/setup_attempts`\n" + ( + @spec list( + params :: %{ + optional(:created) => created | integer, + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:setup_intent) => binary, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.SetupAttempt.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/setup_attempts", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/setup_intent.ex b/lib/generated/setup_intent.ex new file mode 100644 index 00000000..34dd092d --- /dev/null +++ b/lib/generated/setup_intent.ex @@ -0,0 +1,763 @@ +defmodule Stripe.SetupIntent do + use Stripe.Entity + + @moduledoc "A SetupIntent guides you through the process of setting up and saving a customer's payment credentials for future payments.\nFor example, you could use a SetupIntent to set up and save your customer's card without immediately collecting a payment.\nLater, you can use [PaymentIntents](https://stripe.com/docs/api#payment_intents) to drive the payment flow.\n\nCreate a SetupIntent as soon as you're ready to collect your customer's payment credentials.\nDo not maintain long-lived, unconfirmed SetupIntents as they may no longer be valid.\nThe SetupIntent then transitions through multiple [statuses](https://stripe.com/docs/payments/intents#intent-statuses) as it guides\nyou through the setup process.\n\nSuccessful SetupIntents result in payment credentials that are optimized for future payments.\nFor example, cardholders in [certain regions](/guides/strong-customer-authentication) may need to be run through\n[Strong Customer Authentication](https://stripe.com/docs/strong-customer-authentication) at the time of payment method collection\nin order to streamline later [off-session payments](https://stripe.com/docs/payments/setup-intents).\nIf the SetupIntent is used with a [Customer](https://stripe.com/docs/api#setup_intent_object-customer), upon success,\nit will automatically attach the resulting payment method to that Customer.\nWe recommend using SetupIntents or [setup_future_usage](https://stripe.com/docs/api#payment_intent_object-setup_future_usage) on\nPaymentIntents to save payment methods in order to prevent saving invalid or unoptimized payment methods.\n\nBy using SetupIntents, you ensure that your customers experience the minimum set of required friction,\neven as regulations change over time.\n\nRelated guide: [Setup Intents API](https://stripe.com/docs/payments/setup-intents)" + ( + defstruct [ + :application, + :attach_to_self, + :automatic_payment_methods, + :cancellation_reason, + :client_secret, + :created, + :customer, + :description, + :flow_directions, + :id, + :last_setup_error, + :latest_attempt, + :livemode, + :mandate, + :metadata, + :next_action, + :object, + :on_behalf_of, + :payment_method, + :payment_method_options, + :payment_method_types, + :single_use_mandate, + :status, + :usage + ] + + @typedoc "The `setup_intent` type.\n\n * `application` ID of the Connect application that created the SetupIntent.\n * `attach_to_self` If present, the SetupIntent's payment method will be attached to the in-context Stripe Account.\n\nIt can only be used for this Stripe Account’s own money movement flows like InboundTransfer and OutboundTransfers. It cannot be set to true when setting up a PaymentMethod for a Customer, and defaults to false when attaching a PaymentMethod to a Customer.\n * `automatic_payment_methods` Settings for automatic payment methods compatible with this Setup Intent\n * `cancellation_reason` Reason for cancellation of this SetupIntent, one of `abandoned`, `requested_by_customer`, or `duplicate`.\n * `client_secret` The client secret of this SetupIntent. Used for client-side retrieval using a publishable key.\n\nThe client secret can be used to complete payment setup from your frontend. It should not be stored, logged, or exposed to anyone other than the customer. Make sure that you have TLS enabled on any page that includes the client secret.\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `customer` ID of the Customer this SetupIntent belongs to, if one exists.\n\nIf present, the SetupIntent's payment method will be attached to the Customer on successful setup. Payment methods attached to other Customers cannot be used with this SetupIntent.\n * `description` An arbitrary string attached to the object. Often useful for displaying to users.\n * `flow_directions` Indicates the directions of money movement for which this payment method is intended to be used.\n\nInclude `inbound` if you intend to use the payment method as the origin to pull funds from. Include `outbound` if you intend to use the payment method as the destination to send funds to. You can include both if you intend to use the payment method for both purposes.\n * `id` Unique identifier for the object.\n * `last_setup_error` The error encountered in the previous SetupIntent confirmation.\n * `latest_attempt` The most recent SetupAttempt for this SetupIntent.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `mandate` ID of the multi use Mandate generated by the SetupIntent.\n * `metadata` Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.\n * `next_action` If present, this property tells you what actions you need to take in order for your customer to continue payment setup.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `on_behalf_of` The account (if any) for which the setup is intended.\n * `payment_method` ID of the payment method used with this SetupIntent.\n * `payment_method_options` Payment-method-specific configuration for this SetupIntent.\n * `payment_method_types` The list of payment method types (e.g. card) that this SetupIntent is allowed to set up.\n * `single_use_mandate` ID of the single_use Mandate generated by the SetupIntent.\n * `status` [Status](https://stripe.com/docs/payments/intents#intent-statuses) of this SetupIntent, one of `requires_payment_method`, `requires_confirmation`, `requires_action`, `processing`, `canceled`, or `succeeded`.\n * `usage` Indicates how the payment method is intended to be used in the future.\n\nUse `on_session` if you intend to only reuse the payment method when the customer is in your checkout flow. Use `off_session` if your customer may or may not be in your checkout flow. If not provided, this value defaults to `off_session`.\n" + @type t :: %__MODULE__{ + application: (binary | term) | nil, + attach_to_self: boolean, + automatic_payment_methods: term | nil, + cancellation_reason: binary | nil, + client_secret: binary | nil, + created: integer, + customer: (binary | Stripe.Customer.t() | Stripe.DeletedCustomer.t()) | nil, + description: binary | nil, + flow_directions: term | nil, + id: binary, + last_setup_error: Stripe.ApiErrors.t() | nil, + latest_attempt: (binary | Stripe.SetupAttempt.t()) | nil, + livemode: boolean, + mandate: (binary | Stripe.Mandate.t()) | nil, + metadata: term | nil, + next_action: term | nil, + object: binary, + on_behalf_of: (binary | Stripe.Account.t()) | nil, + payment_method: (binary | Stripe.PaymentMethod.t()) | nil, + payment_method_options: term | nil, + payment_method_types: term, + single_use_mandate: (binary | Stripe.Mandate.t()) | nil, + status: binary, + usage: binary + } + ) + + ( + @typedoc "If this is a `acss_debit` SetupIntent, this sub-hash contains details about the ACSS Debit payment method options." + @type acss_debit :: %{ + optional(:currency) => :cad | :usd, + optional(:mandate_options) => mandate_options, + optional(:verification_method) => :automatic | :instant | :microdeposits + } + ) + + ( + @typedoc nil + @type address :: %{ + optional(:city) => binary, + optional(:country) => binary, + optional(:line1) => binary, + optional(:line2) => binary, + optional(:postal_code) => binary, + optional(:state) => binary + } + ) + + ( + @typedoc "If this is an `au_becs_debit` PaymentMethod, this hash contains details about the bank account." + @type au_becs_debit :: %{optional(:account_number) => binary, optional(:bsb_number) => binary} + ) + + ( + @typedoc "When enabled, this SetupIntent will accept payment methods that you have enabled in the Dashboard and are compatible with this SetupIntent's other parameters." + @type automatic_payment_methods :: %{ + optional(:allow_redirects) => :always | :never, + optional(:enabled) => boolean + } + ) + + ( + @typedoc "If this is a `bacs_debit` PaymentMethod, this hash contains details about the Bacs Direct Debit bank account." + @type bacs_debit :: %{optional(:account_number) => binary, optional(:sort_code) => binary} + ) + + ( + @typedoc "Billing information associated with the PaymentMethod that may be used or required by particular types of payment methods." + @type billing_details :: %{ + optional(:address) => address | binary, + optional(:email) => binary | binary, + optional(:name) => binary, + optional(:phone) => binary + } + ) + + ( + @typedoc "If this is a `blik` PaymentMethod, this hash contains details about the BLIK payment method." + @type blik :: %{optional(:code) => binary} + ) + + ( + @typedoc "If this is a `boleto` PaymentMethod, this hash contains details about the Boleto payment method." + @type boleto :: %{optional(:tax_id) => binary} + ) + + ( + @typedoc "Configuration for any card setup attempted on this SetupIntent." + @type card :: %{ + optional(:mandate_options) => mandate_options, + optional(:moto) => boolean, + optional(:network) => + :amex + | :cartes_bancaires + | :diners + | :discover + | :eftpos_au + | :interac + | :jcb + | :mastercard + | :unionpay + | :unknown + | :visa, + optional(:request_three_d_secure) => :any | :automatic + } + ) + + ( + @typedoc nil + @type created :: %{ + optional(:gt) => integer, + optional(:gte) => integer, + optional(:lt) => integer, + optional(:lte) => integer + } + ) + + ( + @typedoc "This hash contains details about the customer acceptance of the Mandate." + @type customer_acceptance :: %{ + optional(:accepted_at) => integer, + optional(:offline) => map(), + optional(:online) => online, + optional(:type) => :offline | :online + } + ) + + ( + @typedoc "Customer's date of birth" + @type dob :: %{ + optional(:day) => integer, + optional(:month) => integer, + optional(:year) => integer + } + ) + + ( + @typedoc "If this is an `eps` PaymentMethod, this hash contains details about the EPS payment method." + @type eps :: %{ + optional(:bank) => + :arzte_und_apotheker_bank + | :austrian_anadi_bank_ag + | :bank_austria + | :bankhaus_carl_spangler + | :bankhaus_schelhammer_und_schattera_ag + | :bawag_psk_ag + | :bks_bank_ag + | :brull_kallmus_bank_ag + | :btv_vier_lander_bank + | :capital_bank_grawe_gruppe_ag + | :deutsche_bank_ag + | :dolomitenbank + | :easybank_ag + | :erste_bank_und_sparkassen + | :hypo_alpeadriabank_international_ag + | :hypo_bank_burgenland_aktiengesellschaft + | :hypo_noe_lb_fur_niederosterreich_u_wien + | :hypo_oberosterreich_salzburg_steiermark + | :hypo_tirol_bank_ag + | :hypo_vorarlberg_bank_ag + | :marchfelder_bank + | :oberbank_ag + | :raiffeisen_bankengruppe_osterreich + | :schoellerbank_ag + | :sparda_bank_wien + | :volksbank_gruppe + | :volkskreditbank_ag + | :vr_bank_braunau + } + ) + + ( + @typedoc "Additional fields for Financial Connections Session creation" + @type financial_connections :: %{ + optional(:permissions) => + list(:balances | :ownership | :payment_method | :transactions), + optional(:return_url) => binary + } + ) + + ( + @typedoc "If this is an `fpx` PaymentMethod, this hash contains details about the FPX payment method." + @type fpx :: %{ + optional(:account_holder_type) => :company | :individual, + optional(:bank) => + :affin_bank + | :agrobank + | :alliance_bank + | :ambank + | :bank_islam + | :bank_muamalat + | :bank_of_china + | :bank_rakyat + | :bsn + | :cimb + | :deutsche_bank + | :hong_leong_bank + | :hsbc + | :kfh + | :maybank2e + | :maybank2u + | :ocbc + | :pb_enterprise + | :public_bank + | :rhb + | :standard_chartered + | :uob + } + ) + + ( + @typedoc "If this is an `ideal` PaymentMethod, this hash contains details about the iDEAL payment method." + @type ideal :: %{ + optional(:bank) => + :abn_amro + | :asn_bank + | :bunq + | :handelsbanken + | :ing + | :knab + | :moneyou + | :rabobank + | :regiobank + | :revolut + | :sns_bank + | :triodos_bank + | :van_lanschot + | :yoursafe + } + ) + + ( + @typedoc "If this is a `klarna` PaymentMethod, this hash contains details about the Klarna payment method." + @type klarna :: %{optional(:dob) => dob} + ) + + ( + @typedoc "If this is a `link` PaymentMethod, this sub-hash contains details about the Link payment method options." + @type link :: %{optional(:persistent_token) => binary} + ) + + ( + @typedoc "This hash contains details about the Mandate to create. This parameter can only be used with [`confirm=true`](https://stripe.com/docs/api/setup_intents/create#create_setup_intent-confirm)." + @type mandate_data :: %{optional(:customer_acceptance) => customer_acceptance} + ) + + ( + @typedoc "Configuration options for setting up an eMandate for cards issued in India." + @type mandate_options :: %{ + optional(:amount) => integer, + optional(:amount_type) => :fixed | :maximum, + optional(:currency) => binary, + optional(:description) => binary, + optional(:end_date) => integer, + optional(:interval) => :day | :month | :sporadic | :week | :year, + optional(:interval_count) => integer, + optional(:reference) => binary, + optional(:start_date) => integer, + optional(:supported_types) => list(:india) + } + ) + + ( + @typedoc "Additional fields for network related functions" + @type networks :: %{optional(:requested) => list(:ach | :us_domestic_wire)} + ) + + ( + @typedoc "If this is a Mandate accepted online, this hash contains details about the online acceptance." + @type online :: %{optional(:ip_address) => binary, optional(:user_agent) => binary} + ) + + ( + @typedoc "If this is a `p24` PaymentMethod, this hash contains details about the P24 payment method." + @type p24 :: %{ + optional(:bank) => + :alior_bank + | :bank_millennium + | :bank_nowy_bfg_sa + | :bank_pekao_sa + | :banki_spbdzielcze + | :blik + | :bnp_paribas + | :boz + | :citi_handlowy + | :credit_agricole + | :envelobank + | :etransfer_pocztowy24 + | :getin_bank + | :ideabank + | :ing + | :inteligo + | :mbank_mtransfer + | :nest_przelew + | :noble_pay + | :pbac_z_ipko + | :plus_bank + | :santander_przelew24 + | :tmobile_usbugi_bankowe + | :toyota_bank + | :volkswagen_bank + } + ) + + ( + @typedoc "When included, this hash creates a PaymentMethod that is set as the [`payment_method`](https://stripe.com/docs/api/setup_intents/object#setup_intent_object-payment_method)\nvalue in the SetupIntent." + @type payment_method_data :: %{ + optional(:pix) => map(), + optional(:fpx) => fpx, + optional(:affirm) => map(), + optional(:acss_debit) => acss_debit, + optional(:bacs_debit) => bacs_debit, + optional(:alipay) => map(), + optional(:giropay) => map(), + optional(:ideal) => ideal, + optional(:radar_options) => radar_options, + optional(:metadata) => %{optional(binary) => binary}, + optional(:link) => map(), + optional(:promptpay) => map(), + optional(:cashapp) => map(), + optional(:oxxo) => map(), + optional(:interac_present) => map(), + optional(:us_bank_account) => us_bank_account, + optional(:zip) => map(), + optional(:paypal) => map(), + optional(:boleto) => boleto, + optional(:konbini) => map(), + optional(:billing_details) => billing_details, + optional(:blik) => map(), + optional(:wechat_pay) => map(), + optional(:sofort) => sofort, + optional(:p24) => p24, + optional(:afterpay_clearpay) => map(), + optional(:type) => + :acss_debit + | :affirm + | :afterpay_clearpay + | :alipay + | :au_becs_debit + | :bacs_debit + | :bancontact + | :blik + | :boleto + | :cashapp + | :customer_balance + | :eps + | :fpx + | :giropay + | :grabpay + | :ideal + | :klarna + | :konbini + | :link + | :oxxo + | :p24 + | :paynow + | :paypal + | :pix + | :promptpay + | :sepa_debit + | :sofort + | :us_bank_account + | :wechat_pay + | :zip, + optional(:grabpay) => map(), + optional(:bancontact) => map(), + optional(:au_becs_debit) => au_becs_debit, + optional(:customer_balance) => map(), + optional(:sepa_debit) => sepa_debit, + optional(:klarna) => klarna, + optional(:paynow) => map(), + optional(:eps) => eps + } + ) + + ( + @typedoc "Payment-method-specific configuration for this SetupIntent." + @type payment_method_options :: %{ + optional(:acss_debit) => acss_debit, + optional(:blik) => blik, + optional(:card) => card, + optional(:link) => link, + optional(:paypal) => paypal, + optional(:sepa_debit) => sepa_debit, + optional(:us_bank_account) => us_bank_account + } + ) + + ( + @typedoc "If this is a `paypal` PaymentMethod, this sub-hash contains details about the PayPal payment method options." + @type paypal :: %{optional(:billing_agreement_id) => binary} + ) + + ( + @typedoc "Options to configure Radar. See [Radar Session](https://stripe.com/docs/radar/radar-session) for more information." + @type radar_options :: %{optional(:session) => binary} + ) + + ( + @typedoc "If this is a `sepa_debit` SetupIntent, this sub-hash contains details about the SEPA Debit payment method options." + @type sepa_debit :: %{optional(:mandate_options) => map()} + ) + + ( + @typedoc "If this hash is populated, this SetupIntent will generate a single_use Mandate on success." + @type single_use :: %{optional(:amount) => integer, optional(:currency) => binary} + ) + + ( + @typedoc "If this is a `sofort` PaymentMethod, this hash contains details about the SOFORT payment method." + @type sofort :: %{optional(:country) => :AT | :BE | :DE | :ES | :IT | :NL} + ) + + ( + @typedoc "If this is an `us_bank_account` PaymentMethod, this hash contains details about the US bank account payment method." + @type us_bank_account :: %{ + optional(:account_holder_type) => :company | :individual, + optional(:account_number) => binary, + optional(:account_type) => :checking | :savings, + optional(:financial_connections_account) => binary, + optional(:routing_number) => binary + } + ) + + ( + nil + + @doc "

Creates a SetupIntent object.

\n\n

After the SetupIntent is created, attach a payment method and confirm\nto collect any required permissions to charge the payment method later.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/setup_intents`\n" + ( + @spec create( + params :: %{ + optional(:attach_to_self) => boolean, + optional(:automatic_payment_methods) => automatic_payment_methods, + optional(:confirm) => boolean, + optional(:customer) => binary, + optional(:description) => binary, + optional(:expand) => list(binary), + optional(:flow_directions) => list(:inbound | :outbound), + optional(:mandate_data) => mandate_data, + optional(:metadata) => %{optional(binary) => binary}, + optional(:on_behalf_of) => binary, + optional(:payment_method) => binary, + optional(:payment_method_data) => payment_method_data, + optional(:payment_method_options) => payment_method_options, + optional(:payment_method_types) => list(binary), + optional(:return_url) => binary, + optional(:single_use) => single_use, + optional(:usage) => :off_session | :on_session, + optional(:use_stripe_sdk) => boolean + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.SetupIntent.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/setup_intents", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Returns a list of SetupIntents.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/setup_intents`\n" + ( + @spec list( + params :: %{ + optional(:attach_to_self) => boolean, + optional(:created) => created | integer, + optional(:customer) => binary, + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:payment_method) => binary, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.SetupIntent.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/setup_intents", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves the details of a SetupIntent that has previously been created.

\n\n

Client-side retrieval using a publishable key is allowed when the client_secret is provided in the query string.

\n\n

When retrieved with a publishable key, only a subset of properties will be returned. Please refer to the SetupIntent object reference for more details.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/setup_intents/{intent}`\n" + ( + @spec retrieve( + intent :: binary(), + params :: %{optional(:client_secret) => binary, optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: {:ok, Stripe.SetupIntent.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def retrieve(intent, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/setup_intents/{intent}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "intent", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "intent", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [intent] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Updates a SetupIntent object.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/setup_intents/{intent}`\n" + ( + @spec update( + intent :: binary(), + params :: %{ + optional(:attach_to_self) => boolean, + optional(:customer) => binary, + optional(:description) => binary, + optional(:expand) => list(binary), + optional(:flow_directions) => list(:inbound | :outbound), + optional(:metadata) => %{optional(binary) => binary} | binary, + optional(:payment_method) => binary, + optional(:payment_method_data) => payment_method_data, + optional(:payment_method_options) => payment_method_options, + optional(:payment_method_types) => list(binary) + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.SetupIntent.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def update(intent, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/setup_intents/{intent}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "intent", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "intent", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [intent] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Confirm that your customer intends to set up the current or\nprovided payment method. For example, you would confirm a SetupIntent\nwhen a customer hits the “Save” button on a payment method management\npage on your website.

\n\n

If the selected payment method does not require any additional\nsteps from the customer, the SetupIntent will transition to the\nsucceeded status.

\n\n

Otherwise, it will transition to the requires_action status and\nsuggest additional actions via next_action. If setup fails,\nthe SetupIntent will transition to the\nrequires_payment_method status or the canceled status if the\nconfirmation limit is reached.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/setup_intents/{intent}/confirm`\n" + ( + @spec confirm( + intent :: binary(), + params :: %{ + optional(:expand) => list(binary), + optional(:mandate_data) => mandate_data | mandate_data, + optional(:payment_method) => binary, + optional(:payment_method_data) => payment_method_data, + optional(:payment_method_options) => payment_method_options, + optional(:return_url) => binary, + optional(:use_stripe_sdk) => boolean + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.SetupIntent.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def confirm(intent, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/setup_intents/{intent}/confirm", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "intent", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "intent", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [intent] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

A SetupIntent object can be canceled when it is in one of these statuses: requires_payment_method, requires_confirmation, or requires_action.

\n\n

Once canceled, setup is abandoned and any operations on the SetupIntent will fail with an error.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/setup_intents/{intent}/cancel`\n" + ( + @spec cancel( + intent :: binary(), + params :: %{ + optional(:cancellation_reason) => + :abandoned | :duplicate | :requested_by_customer, + optional(:expand) => list(binary) + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.SetupIntent.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def cancel(intent, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/setup_intents/{intent}/cancel", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "intent", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "intent", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [intent] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Verifies microdeposits on a SetupIntent object.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/setup_intents/{intent}/verify_microdeposits`\n" + ( + @spec verify_microdeposits( + intent :: binary(), + params :: %{ + optional(:amounts) => list(integer), + optional(:descriptor_code) => binary, + optional(:expand) => list(binary) + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.SetupIntent.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def verify_microdeposits(intent, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/setup_intents/{intent}/verify_microdeposits", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "intent", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "intent", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [intent] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/shipping_rate.ex b/lib/generated/shipping_rate.ex new file mode 100644 index 00000000..921ae804 --- /dev/null +++ b/lib/generated/shipping_rate.ex @@ -0,0 +1,230 @@ +defmodule Stripe.ShippingRate do + use Stripe.Entity + + @moduledoc "Shipping rates describe the price of shipping presented to your customers and\napplied to a purchase. For more information, see [Charge for shipping](https://stripe.com/docs/payments/during-payment/charge-shipping)." + ( + defstruct [ + :active, + :created, + :delivery_estimate, + :display_name, + :fixed_amount, + :id, + :livemode, + :metadata, + :object, + :tax_behavior, + :tax_code, + :type + ] + + @typedoc "The `shipping_rate` type.\n\n * `active` Whether the shipping rate can be used for new purchases. Defaults to `true`.\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `delivery_estimate` The estimated range for how long shipping will take, meant to be displayable to the customer. This will appear on CheckoutSessions.\n * `display_name` The name of the shipping rate, meant to be displayable to the customer. This will appear on CheckoutSessions.\n * `fixed_amount` \n * `id` Unique identifier for the object.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `metadata` Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `tax_behavior` Specifies whether the rate is considered inclusive of taxes or exclusive of taxes. One of `inclusive`, `exclusive`, or `unspecified`.\n * `tax_code` A [tax code](https://stripe.com/docs/tax/tax-categories) ID. The Shipping tax code is `txcd_92010001`.\n * `type` The type of calculation to use on the shipping rate. Can only be `fixed_amount` for now.\n" + @type t :: %__MODULE__{ + active: boolean, + created: integer, + delivery_estimate: term | nil, + display_name: binary | nil, + fixed_amount: term, + id: binary, + livemode: boolean, + metadata: term, + object: binary, + tax_behavior: binary | nil, + tax_code: (binary | Stripe.TaxCode.t()) | nil, + type: binary + } + ) + + ( + @typedoc nil + @type created :: %{ + optional(:gt) => integer, + optional(:gte) => integer, + optional(:lt) => integer, + optional(:lte) => integer + } + ) + + ( + @typedoc "The estimated range for how long shipping will take, meant to be displayable to the customer. This will appear on CheckoutSessions." + @type delivery_estimate :: %{optional(:maximum) => maximum, optional(:minimum) => minimum} + ) + + ( + @typedoc "Describes a fixed amount to charge for shipping. Must be present if type is `fixed_amount`." + @type fixed_amount :: %{ + optional(:amount) => integer, + optional(:currency) => binary, + optional(:currency_options) => map() + } + ) + + ( + @typedoc "The upper bound of the estimated range. If empty, represents no upper bound i.e., infinite." + @type maximum :: %{ + optional(:unit) => :business_day | :day | :hour | :month | :week, + optional(:value) => integer + } + ) + + ( + @typedoc "The lower bound of the estimated range. If empty, represents no lower bound." + @type minimum :: %{ + optional(:unit) => :business_day | :day | :hour | :month | :week, + optional(:value) => integer + } + ) + + ( + nil + + @doc "

Returns a list of your shipping rates.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/shipping_rates`\n" + ( + @spec list( + params :: %{ + optional(:active) => boolean, + optional(:created) => created | integer, + optional(:currency) => binary, + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.ShippingRate.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/shipping_rates", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Returns the shipping rate object with the given ID.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/shipping_rates/{shipping_rate_token}`\n" + ( + @spec retrieve( + shipping_rate_token :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.ShippingRate.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def retrieve(shipping_rate_token, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/shipping_rates/{shipping_rate_token}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "shipping_rate_token", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "shipping_rate_token", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [shipping_rate_token] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Creates a new shipping rate object.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/shipping_rates`\n" + ( + @spec create( + params :: %{ + optional(:delivery_estimate) => delivery_estimate, + optional(:display_name) => binary, + optional(:expand) => list(binary), + optional(:fixed_amount) => fixed_amount, + optional(:metadata) => %{optional(binary) => binary}, + optional(:tax_behavior) => :exclusive | :inclusive | :unspecified, + optional(:tax_code) => binary, + optional(:type) => :fixed_amount + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.ShippingRate.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/shipping_rates", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Updates an existing shipping rate object.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/shipping_rates/{shipping_rate_token}`\n" + ( + @spec update( + shipping_rate_token :: binary(), + params :: %{ + optional(:active) => boolean, + optional(:expand) => list(binary), + optional(:fixed_amount) => fixed_amount, + optional(:metadata) => %{optional(binary) => binary} | binary, + optional(:tax_behavior) => :exclusive | :inclusive | :unspecified + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.ShippingRate.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def update(shipping_rate_token, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/shipping_rates/{shipping_rate_token}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "shipping_rate_token", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "shipping_rate_token", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [shipping_rate_token] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/source.ex b/lib/generated/source.ex new file mode 100644 index 00000000..76896338 --- /dev/null +++ b/lib/generated/source.ex @@ -0,0 +1,463 @@ +defmodule Stripe.Source do + use Stripe.Entity + + @moduledoc "`Source` objects allow you to accept a variety of payment methods. They\nrepresent a customer's payment instrument, and can be used with the Stripe API\njust like a `Card` object: once chargeable, they can be charged, or can be\nattached to customers.\n\nStripe doesn't recommend using the deprecated [Sources API](https://stripe.com/docs/api/sources).\nWe recommend that you adopt the [PaymentMethods API](https://stripe.com/docs/api/payment_methods).\nThis newer API provides access to our latest features and payment method types.\n\nRelated guides: [Sources API](https://stripe.com/docs/sources) and [Sources & Customers](https://stripe.com/docs/sources/customers)." + ( + defstruct [ + :eps, + :owner, + :id, + :source_order, + :klarna, + :sepa_debit, + :flow, + :card_present, + :au_becs_debit, + :three_d_secure, + :bancontact, + :status, + :type, + :created, + :currency, + :p24, + :sofort, + :object, + :client_secret, + :wechat, + :statement_descriptor, + :amount, + :ach_credit_transfer, + :customer, + :receiver, + :usage, + :sepa_credit_transfer, + :multibanco, + :metadata, + :card, + :code_verification, + :ideal, + :redirect, + :giropay, + :alipay, + :ach_debit, + :acss_debit, + :livemode + ] + + @typedoc "The `source` type.\n\n * `ach_credit_transfer` \n * `ach_debit` \n * `acss_debit` \n * `alipay` \n * `amount` A positive integer in the smallest currency unit (that is, 100 cents for $1.00, or 1 for ¥1, Japanese Yen being a zero-decimal currency) representing the total amount associated with the source. This is the amount for which the source will be chargeable once ready. Required for `single_use` sources.\n * `au_becs_debit` \n * `bancontact` \n * `card` \n * `card_present` \n * `client_secret` The client secret of the source. Used for client-side retrieval using a publishable key.\n * `code_verification` \n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `currency` Three-letter [ISO code for the currency](https://stripe.com/docs/currencies) associated with the source. This is the currency for which the source will be chargeable once ready. Required for `single_use` sources.\n * `customer` The ID of the customer to which this source is attached. This will not be present when the source has not been attached to a customer.\n * `eps` \n * `flow` The authentication `flow` of the source. `flow` is one of `redirect`, `receiver`, `code_verification`, `none`.\n * `giropay` \n * `id` Unique identifier for the object.\n * `ideal` \n * `klarna` \n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `metadata` Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.\n * `multibanco` \n * `object` String representing the object's type. Objects of the same type share the same value.\n * `owner` Information about the owner of the payment instrument that may be used or required by particular source types.\n * `p24` \n * `receiver` \n * `redirect` \n * `sepa_credit_transfer` \n * `sepa_debit` \n * `sofort` \n * `source_order` \n * `statement_descriptor` Extra information about a source. This will appear on your customer's statement every time you charge the source.\n * `status` The status of the source, one of `canceled`, `chargeable`, `consumed`, `failed`, or `pending`. Only `chargeable` sources can be used to create a charge.\n * `three_d_secure` \n * `type` The `type` of the source. The `type` is a payment method, one of `ach_credit_transfer`, `ach_debit`, `alipay`, `bancontact`, `card`, `card_present`, `eps`, `giropay`, `ideal`, `multibanco`, `klarna`, `p24`, `sepa_debit`, `sofort`, `three_d_secure`, or `wechat`. An additional hash is included on the source with a name matching this value. It contains additional information specific to the [payment method](https://stripe.com/docs/sources) used.\n * `usage` Either `reusable` or `single_use`. Whether this source should be reusable or not. Some source types may or may not be reusable by construction, while others may leave the option at creation. If an incompatible value is passed, an error will be returned.\n * `wechat` \n" + @type t :: %__MODULE__{ + ach_credit_transfer: term, + ach_debit: term, + acss_debit: term, + alipay: term, + amount: integer | nil, + au_becs_debit: term, + bancontact: term, + card: term, + card_present: term, + client_secret: binary, + code_verification: term, + created: integer, + currency: binary | nil, + customer: binary, + eps: term, + flow: binary, + giropay: term, + id: binary, + ideal: term, + klarna: term, + livemode: boolean, + metadata: term | nil, + multibanco: term, + object: binary, + owner: term | nil, + p24: term, + receiver: term, + redirect: term, + sepa_credit_transfer: term, + sepa_debit: term, + sofort: term, + source_order: term, + statement_descriptor: binary | nil, + status: binary, + three_d_secure: term, + type: binary, + usage: binary | nil, + wechat: term + } + ) + + ( + @typedoc "The parameters required to notify Stripe of a mandate acceptance or refusal by the customer." + @type acceptance :: %{ + optional(:date) => integer, + optional(:ip) => binary, + optional(:offline) => offline, + optional(:online) => online, + optional(:status) => :accepted | :pending | :refused | :revoked, + optional(:type) => :offline | :online, + optional(:user_agent) => binary + } + ) + + ( + @typedoc "Owner's address." + @type address :: %{ + optional(:city) => binary, + optional(:country) => binary, + optional(:line1) => binary, + optional(:line2) => binary, + optional(:postal_code) => binary, + optional(:state) => binary + } + ) + + ( + @typedoc nil + @type items :: %{ + optional(:amount) => integer, + optional(:currency) => binary, + optional(:description) => binary, + optional(:parent) => binary, + optional(:quantity) => integer, + optional(:type) => :discount | :shipping | :sku | :tax + } + ) + + ( + @typedoc "Information about a mandate possibility attached to a source object (generally for bank debits) as well as its acceptance status." + @type mandate :: %{ + optional(:acceptance) => acceptance, + optional(:amount) => integer | binary, + optional(:currency) => binary, + optional(:interval) => :one_time | :scheduled | :variable, + optional(:notification_method) => + :deprecated_none | :email | :manual | :none | :stripe_email + } + ) + + ( + @typedoc "The parameters required to store a mandate accepted offline. Should only be set if `mandate[type]` is `offline`" + @type offline :: %{optional(:contact_email) => binary} + ) + + ( + @typedoc "The parameters required to store a mandate accepted online. Should only be set if `mandate[type]` is `online`" + @type online :: %{ + optional(:date) => integer, + optional(:ip) => binary, + optional(:user_agent) => binary + } + ) + + ( + @typedoc "Information about the owner of the payment instrument that may be used or required by particular source types." + @type owner :: %{ + optional(:address) => address, + optional(:email) => binary, + optional(:name) => binary, + optional(:phone) => binary + } + ) + + ( + @typedoc "Optional parameters for the receiver flow. Can be set only if the source is a receiver (`flow` is `receiver`)." + @type receiver :: %{optional(:refund_attributes_method) => :email | :manual | :none} + ) + + ( + @typedoc "Parameters required for the redirect flow. Required if the source is authenticated by a redirect (`flow` is `redirect`)." + @type redirect :: %{optional(:return_url) => binary} + ) + + ( + @typedoc "Shipping address for the order. Required if any of the SKUs are for products that have `shippable` set to true." + @type shipping :: %{ + optional(:address) => address, + optional(:carrier) => binary, + optional(:name) => binary, + optional(:phone) => binary, + optional(:tracking_number) => binary + } + ) + + ( + @typedoc "Information about the items and shipping associated with the source. Required for transactional credit (for example Klarna) sources before you can charge it." + @type source_order :: %{optional(:items) => list(items), optional(:shipping) => shipping} + ) + + ( + nil + + @doc "

Delete a specified source for a given customer.

\n\n#### Details\n\n * Method: `delete`\n * Path: `/v1/customers/{customer}/sources/{id}`\n" + ( + @spec detach( + customer :: binary(), + id :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.PaymentSource.t() | Stripe.DeletedPaymentSource.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def detach(customer, id, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/customers/{customer}/sources/{id}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "customer", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "customer", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + }, + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "id", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "id", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [customer, id] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:delete) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves an existing source object. Supply the unique source ID from a source creation request and Stripe will return the corresponding up-to-date source object information.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/sources/{source}`\n" + ( + @spec retrieve( + source :: binary(), + params :: %{optional(:client_secret) => binary, optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: {:ok, Stripe.Source.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def retrieve(source, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/sources/{source}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "source", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "source", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [source] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Creates a new source object.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/sources`\n" + ( + @spec create( + params :: %{ + optional(:amount) => integer, + optional(:currency) => binary, + optional(:customer) => binary, + optional(:expand) => list(binary), + optional(:flow) => :code_verification | :none | :receiver | :redirect, + optional(:mandate) => mandate, + optional(:metadata) => %{optional(binary) => binary}, + optional(:original_source) => binary, + optional(:owner) => owner, + optional(:receiver) => receiver, + optional(:redirect) => redirect, + optional(:source_order) => source_order, + optional(:statement_descriptor) => binary, + optional(:token) => binary, + optional(:type) => binary, + optional(:usage) => :reusable | :single_use + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.Source.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/sources", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Updates the specified source by setting the values of the parameters passed. Any parameters not provided will be left unchanged.

\n\n

This request accepts the metadata and owner as arguments. It is also possible to update type specific information for selected payment methods. Please refer to our payment method guides for more detail.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/sources/{source}`\n" + ( + @spec update( + source :: binary(), + params :: %{ + optional(:amount) => integer, + optional(:expand) => list(binary), + optional(:mandate) => mandate, + optional(:metadata) => %{optional(binary) => binary} | binary, + optional(:owner) => owner, + optional(:source_order) => source_order + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.Source.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def update(source, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/sources/{source}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "source", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "source", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [source] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Verify a given source.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/sources/{source}/verify`\n" + ( + @spec verify( + source :: binary(), + params :: %{optional(:expand) => list(binary), optional(:values) => list(binary)}, + opts :: Keyword.t() + ) :: {:ok, Stripe.Source.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def verify(source, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/sources/{source}/verify", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "source", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "source", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [source] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

List source transactions for a given source.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/sources/{source}/source_transactions`\n" + ( + @spec source_transactions( + source :: binary(), + params :: %{ + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.SourceTransaction.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def source_transactions(source, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/sources/{source}/source_transactions", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "source", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "source", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [source] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/source_transaction.ex b/lib/generated/source_transaction.ex new file mode 100644 index 00000000..df69e660 --- /dev/null +++ b/lib/generated/source_transaction.ex @@ -0,0 +1,41 @@ +defmodule Stripe.SourceTransaction do + use Stripe.Entity + + @moduledoc "Some payment methods have no required amount that a customer must send.\nCustomers can be instructed to send any amount, and it can be made up of\nmultiple transactions. As such, sources can have multiple associated\ntransactions." + ( + defstruct [ + :ach_credit_transfer, + :amount, + :chf_credit_transfer, + :created, + :currency, + :gbp_credit_transfer, + :id, + :livemode, + :object, + :paper_check, + :sepa_credit_transfer, + :source, + :status, + :type + ] + + @typedoc "The `source_transaction` type.\n\n * `ach_credit_transfer` \n * `amount` A positive integer in the smallest currency unit (that is, 100 cents for $1.00, or 1 for ¥1, Japanese Yen being a zero-decimal currency) representing the amount your customer has pushed to the receiver.\n * `chf_credit_transfer` \n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `currency` Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).\n * `gbp_credit_transfer` \n * `id` Unique identifier for the object.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `paper_check` \n * `sepa_credit_transfer` \n * `source` The ID of the source this transaction is attached to.\n * `status` The status of the transaction, one of `succeeded`, `pending`, or `failed`.\n * `type` The type of source this transaction is attached to.\n" + @type t :: %__MODULE__{ + ach_credit_transfer: term, + amount: integer, + chf_credit_transfer: term, + created: integer, + currency: binary, + gbp_credit_transfer: term, + id: binary, + livemode: boolean, + object: binary, + paper_check: term, + sepa_credit_transfer: term, + source: binary, + status: binary, + type: binary + } + ) +end \ No newline at end of file diff --git a/lib/generated/subscription.ex b/lib/generated/subscription.ex new file mode 100644 index 00000000..f964e8ee --- /dev/null +++ b/lib/generated/subscription.ex @@ -0,0 +1,752 @@ +defmodule Stripe.Subscription do + use Stripe.Entity + + @moduledoc "Subscriptions allow you to charge a customer on a recurring basis.\n\nRelated guide: [Creating subscriptions](https://stripe.com/docs/billing/subscriptions/creating)" + ( + defstruct [ + :default_tax_rates, + :pending_update, + :id, + :transfer_data, + :items, + :status, + :current_period_start, + :trial_start, + :trial_settings, + :cancel_at, + :trial_end, + :created, + :currency, + :latest_invoice, + :current_period_end, + :canceled_at, + :schedule, + :automatic_tax, + :test_clock, + :billing_cycle_anchor, + :object, + :cancel_at_period_end, + :default_source, + :next_pending_invoice_item_invoice, + :billing_thresholds, + :pending_invoice_item_interval, + :application, + :payment_settings, + :days_until_due, + :ended_at, + :customer, + :pause_collection, + :on_behalf_of, + :start_date, + :discount, + :pending_setup_intent, + :cancellation_details, + :description, + :metadata, + :default_payment_method, + :collection_method, + :livemode, + :application_fee_percent + ] + + @typedoc "The `subscription` type.\n\n * `application` ID of the Connect Application that created the subscription.\n * `application_fee_percent` A non-negative decimal between 0 and 100, with at most two decimal places. This represents the percentage of the subscription invoice subtotal that will be transferred to the application owner's Stripe account.\n * `automatic_tax` \n * `billing_cycle_anchor` Determines the date of the first full invoice, and, for plans with `month` or `year` intervals, the day of the month for subsequent invoices. The timestamp is in UTC format.\n * `billing_thresholds` Define thresholds at which an invoice will be sent, and the subscription advanced to a new billing period\n * `cancel_at` A date in the future at which the subscription will automatically get canceled\n * `cancel_at_period_end` If the subscription has been canceled with the `at_period_end` flag set to `true`, `cancel_at_period_end` on the subscription will be true. You can use this attribute to determine whether a subscription that has a status of active is scheduled to be canceled at the end of the current period.\n * `canceled_at` If the subscription has been canceled, the date of that cancellation. If the subscription was canceled with `cancel_at_period_end`, `canceled_at` will reflect the time of the most recent update request, not the end of the subscription period when the subscription is automatically moved to a canceled state.\n * `cancellation_details` Details about why this subscription was cancelled\n * `collection_method` Either `charge_automatically`, or `send_invoice`. When charging automatically, Stripe will attempt to pay this subscription at the end of the cycle using the default source attached to the customer. When sending an invoice, Stripe will email your customer an invoice with payment instructions and mark the subscription as `active`.\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `currency` Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).\n * `current_period_end` End of the current period that the subscription has been invoiced for. At the end of this period, a new invoice will be created.\n * `current_period_start` Start of the current period that the subscription has been invoiced for.\n * `customer` ID of the customer who owns the subscription.\n * `days_until_due` Number of days a customer has to pay invoices generated by this subscription. This value will be `null` for subscriptions where `collection_method=charge_automatically`.\n * `default_payment_method` ID of the default payment method for the subscription. It must belong to the customer associated with the subscription. This takes precedence over `default_source`. If neither are set, invoices will use the customer's [invoice_settings.default_payment_method](https://stripe.com/docs/api/customers/object#customer_object-invoice_settings-default_payment_method) or [default_source](https://stripe.com/docs/api/customers/object#customer_object-default_source).\n * `default_source` ID of the default payment source for the subscription. It must belong to the customer associated with the subscription and be in a chargeable state. If `default_payment_method` is also set, `default_payment_method` will take precedence. If neither are set, invoices will use the customer's [invoice_settings.default_payment_method](https://stripe.com/docs/api/customers/object#customer_object-invoice_settings-default_payment_method) or [default_source](https://stripe.com/docs/api/customers/object#customer_object-default_source).\n * `default_tax_rates` The tax rates that will apply to any subscription item that does not have `tax_rates` set. Invoices created will have their `default_tax_rates` populated from the subscription.\n * `description` The subscription's description, meant to be displayable to the customer. Use this field to optionally store an explanation of the subscription for rendering in Stripe surfaces.\n * `discount` Describes the current discount applied to this subscription, if there is one. When billing, a discount applied to a subscription overrides a discount applied on a customer-wide basis.\n * `ended_at` If the subscription has ended, the date the subscription ended.\n * `id` Unique identifier for the object.\n * `items` List of subscription items, each with an attached price.\n * `latest_invoice` The most recent invoice this subscription has generated.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `metadata` Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.\n * `next_pending_invoice_item_invoice` Specifies the approximate timestamp on which any pending invoice items will be billed according to the schedule provided at `pending_invoice_item_interval`.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `on_behalf_of` The account (if any) the charge was made on behalf of for charges associated with this subscription. See the Connect documentation for details.\n * `pause_collection` If specified, payment collection for this subscription will be paused.\n * `payment_settings` Payment settings passed on to invoices created by the subscription.\n * `pending_invoice_item_interval` Specifies an interval for how often to bill for any pending invoice items. It is analogous to calling [Create an invoice](https://stripe.com/docs/api#create_invoice) for the given subscription at the specified interval.\n * `pending_setup_intent` You can use this [SetupIntent](https://stripe.com/docs/api/setup_intents) to collect user authentication when creating a subscription without immediate payment or updating a subscription's payment method, allowing you to optimize for off-session payments. Learn more in the [SCA Migration Guide](https://stripe.com/docs/billing/migration/strong-customer-authentication#scenario-2).\n * `pending_update` If specified, [pending updates](https://stripe.com/docs/billing/subscriptions/pending-updates) that will be applied to the subscription once the `latest_invoice` has been paid.\n * `schedule` The schedule attached to the subscription\n * `start_date` Date when the subscription was first created. The date might differ from the `created` date due to backdating.\n * `status` Possible values are `incomplete`, `incomplete_expired`, `trialing`, `active`, `past_due`, `canceled`, or `unpaid`. \n\nFor `collection_method=charge_automatically` a subscription moves into `incomplete` if the initial payment attempt fails. A subscription in this state can only have metadata and default_source updated. Once the first invoice is paid, the subscription moves into an `active` state. If the first invoice is not paid within 23 hours, the subscription transitions to `incomplete_expired`. This is a terminal state, the open invoice will be voided and no further invoices will be generated. \n\nA subscription that is currently in a trial period is `trialing` and moves to `active` when the trial period is over. \n\nIf subscription `collection_method=charge_automatically`, it becomes `past_due` when payment is required but cannot be paid (due to failed payment or awaiting additional user actions). Once Stripe has exhausted all payment retry attempts, the subscription will become `canceled` or `unpaid` (depending on your subscriptions settings). \n\nIf subscription `collection_method=send_invoice` it becomes `past_due` when its invoice is not paid by the due date, and `canceled` or `unpaid` if it is still not paid by an additional deadline after that. Note that when a subscription has a status of `unpaid`, no subsequent invoices will be attempted (invoices will be created, but then immediately automatically closed). After receiving updated payment information from a customer, you may choose to reopen and pay their closed invoices.\n * `test_clock` ID of the test clock this subscription belongs to.\n * `transfer_data` The account (if any) the subscription's payments will be attributed to for tax reporting, and where funds from each payment will be transferred to for each of the subscription's invoices.\n * `trial_end` If the subscription has a trial, the end of that trial.\n * `trial_settings` Settings related to subscription trials.\n * `trial_start` If the subscription has a trial, the beginning of that trial.\n" + @type t :: %__MODULE__{ + application: (binary | term | term) | nil, + application_fee_percent: term | nil, + automatic_tax: term, + billing_cycle_anchor: integer, + billing_thresholds: term | nil, + cancel_at: integer | nil, + cancel_at_period_end: boolean, + canceled_at: integer | nil, + cancellation_details: term | nil, + collection_method: binary, + created: integer, + currency: binary, + current_period_end: integer, + current_period_start: integer, + customer: binary | Stripe.Customer.t() | Stripe.DeletedCustomer.t(), + days_until_due: integer | nil, + default_payment_method: (binary | Stripe.PaymentMethod.t()) | nil, + default_source: (binary | Stripe.PaymentSource.t()) | nil, + default_tax_rates: term | nil, + description: binary | nil, + discount: term | nil, + ended_at: integer | nil, + id: binary, + items: term, + latest_invoice: (binary | Stripe.Invoice.t()) | nil, + livemode: boolean, + metadata: term, + next_pending_invoice_item_invoice: integer | nil, + object: binary, + on_behalf_of: (binary | Stripe.Account.t()) | nil, + pause_collection: term | nil, + payment_settings: term | nil, + pending_invoice_item_interval: term | nil, + pending_setup_intent: (binary | Stripe.SetupIntent.t()) | nil, + pending_update: term | nil, + schedule: (binary | Stripe.SubscriptionSchedule.t()) | nil, + start_date: integer, + status: binary, + test_clock: (binary | Stripe.TestHelpers.TestClock.t()) | nil, + transfer_data: term | nil, + trial_end: integer | nil, + trial_settings: term | nil, + trial_start: integer | nil + } + ) + + ( + @typedoc nil + @type acss_debit :: %{ + optional(:mandate_options) => mandate_options, + optional(:verification_method) => :automatic | :instant | :microdeposits + } + ) + + ( + @typedoc nil + @type add_invoice_items :: %{ + optional(:price) => binary, + optional(:price_data) => price_data, + optional(:quantity) => integer, + optional(:tax_rates) => list(binary) | binary + } + ) + + ( + @typedoc nil + @type automatic_tax :: %{optional(:enabled) => boolean} + ) + + ( + @typedoc nil + @type bancontact :: %{optional(:preferred_language) => :de | :en | :fr | :nl} + ) + + ( + @typedoc "Configuration for the bank transfer funding type, if the `funding_type` is set to `bank_transfer`." + @type bank_transfer :: %{ + optional(:eu_bank_transfer) => eu_bank_transfer, + optional(:type) => binary + } + ) + + ( + @typedoc nil + @type billing_thresholds :: %{ + optional(:amount_gte) => integer, + optional(:reset_billing_cycle_anchor) => boolean + } + ) + + ( + @typedoc "Details about why this subscription was cancelled" + @type cancellation_details :: %{ + optional(:comment) => binary, + optional(:feedback) => + :customer_service + | :low_quality + | :missing_features + | :other + | :switched_service + | :too_complex + | :too_expensive + | :unused + } + ) + + ( + @typedoc nil + @type card :: %{ + optional(:mandate_options) => mandate_options, + optional(:network) => + :amex + | :cartes_bancaires + | :diners + | :discover + | :eftpos_au + | :interac + | :jcb + | :mastercard + | :unionpay + | :unknown + | :visa, + optional(:request_three_d_secure) => :any | :automatic + } + ) + + ( + @typedoc nil + @type created :: %{ + optional(:gt) => integer, + optional(:gte) => integer, + optional(:lt) => integer, + optional(:lte) => integer + } + ) + + ( + @typedoc nil + @type current_period_end :: %{ + optional(:gt) => integer, + optional(:gte) => integer, + optional(:lt) => integer, + optional(:lte) => integer + } + ) + + ( + @typedoc nil + @type current_period_start :: %{ + optional(:gt) => integer, + optional(:gte) => integer, + optional(:lt) => integer, + optional(:lte) => integer + } + ) + + ( + @typedoc nil + @type customer_balance :: %{ + optional(:bank_transfer) => bank_transfer, + optional(:funding_type) => binary + } + ) + + ( + @typedoc "Defines how the subscription should behave when the user's free trial ends." + @type end_behavior :: %{ + optional(:missing_payment_method) => :cancel | :create_invoice | :pause + } + ) + + ( + @typedoc "Configuration for eu_bank_transfer funding type." + @type eu_bank_transfer :: %{optional(:country) => binary} + ) + + ( + @typedoc "Additional fields for Financial Connections Session creation" + @type financial_connections :: %{ + optional(:permissions) => + list(:balances | :ownership | :payment_method | :transactions) + } + ) + + ( + @typedoc nil + @type items :: %{ + optional(:billing_thresholds) => billing_thresholds | binary, + optional(:metadata) => %{optional(binary) => binary}, + optional(:plan) => binary, + optional(:price) => binary, + optional(:price_data) => price_data, + optional(:quantity) => integer, + optional(:tax_rates) => list(binary) | binary + } + ) + + ( + @typedoc "Additional fields for Mandate creation" + @type mandate_options :: %{optional(:transaction_type) => :business | :personal} + ) + + ( + @typedoc nil + @type pause_collection :: %{ + optional(:behavior) => :keep_as_draft | :mark_uncollectible | :void, + optional(:resumes_at) => integer + } + ) + + ( + @typedoc "Payment-method-specific configuration to provide to invoices created by the subscription." + @type payment_method_options :: %{ + optional(:acss_debit) => acss_debit | binary, + optional(:bancontact) => bancontact | binary, + optional(:card) => card | binary, + optional(:customer_balance) => customer_balance | binary, + optional(:konbini) => map() | binary, + optional(:us_bank_account) => us_bank_account | binary + } + ) + + ( + @typedoc "Payment settings to pass to invoices created by the subscription." + @type payment_settings :: %{ + optional(:payment_method_options) => payment_method_options, + optional(:payment_method_types) => + list( + :ach_credit_transfer + | :ach_debit + | :acss_debit + | :au_becs_debit + | :bacs_debit + | :bancontact + | :boleto + | :card + | :cashapp + | :customer_balance + | :fpx + | :giropay + | :grabpay + | :ideal + | :konbini + | :link + | :paynow + | :paypal + | :promptpay + | :sepa_credit_transfer + | :sepa_debit + | :sofort + | :us_bank_account + | :wechat_pay + ) + | binary, + optional(:save_default_payment_method) => :off | :on_subscription + } + ) + + ( + @typedoc nil + @type pending_invoice_item_interval :: %{ + optional(:interval) => :day | :month | :week | :year, + optional(:interval_count) => integer + } + ) + + ( + @typedoc "Data used to generate a new [Price](https://stripe.com/docs/api/prices) object inline." + @type price_data :: %{ + optional(:currency) => binary, + optional(:product) => binary, + optional(:recurring) => recurring, + optional(:tax_behavior) => :exclusive | :inclusive | :unspecified, + optional(:unit_amount) => integer, + optional(:unit_amount_decimal) => binary + } + ) + + ( + @typedoc "The recurring components of a price such as `interval` and `interval_count`." + @type recurring :: %{ + optional(:interval) => :day | :month | :week | :year, + optional(:interval_count) => integer + } + ) + + ( + @typedoc "If specified, the funds from the subscription's invoices will be transferred to the destination and the ID of the resulting transfers will be found on the resulting charges." + @type transfer_data :: %{ + optional(:amount_percent) => number, + optional(:destination) => binary + } + ) + + ( + @typedoc "Settings related to subscription trials." + @type trial_settings :: %{optional(:end_behavior) => end_behavior} + ) + + ( + @typedoc nil + @type us_bank_account :: %{ + optional(:financial_connections) => financial_connections, + optional(:verification_method) => :automatic | :instant | :microdeposits + } + ) + + ( + nil + + @doc "

Search for subscriptions you’ve previously created using Stripe’s Search Query Language.\nDon’t use search in read-after-write flows where strict consistency is necessary. Under normal operating\nconditions, data is searchable in less than a minute. Occasionally, propagation of new or updated data can be up\nto an hour behind during outages. Search functionality is not available to merchants in India.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/subscriptions/search`\n" + ( + @spec search( + params :: %{ + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:page) => binary, + optional(:query) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.SearchResult.t(Stripe.Subscription.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def search(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/subscriptions/search", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

By default, returns a list of subscriptions that have not been canceled. In order to list canceled subscriptions, specify status=canceled.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/subscriptions`\n" + ( + @spec list( + params :: %{ + optional(:automatic_tax) => automatic_tax, + optional(:collection_method) => :charge_automatically | :send_invoice, + optional(:created) => created | integer, + optional(:current_period_end) => current_period_end | integer, + optional(:current_period_start) => current_period_start | integer, + optional(:customer) => binary, + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:plan) => binary, + optional(:price) => binary, + optional(:starting_after) => binary, + optional(:status) => + :active + | :all + | :canceled + | :ended + | :incomplete + | :incomplete_expired + | :past_due + | :paused + | :trialing + | :unpaid, + optional(:test_clock) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.Subscription.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/subscriptions", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Creates a new subscription on an existing customer. Each customer can have up to 500 active or scheduled subscriptions.

\n\n

When you create a subscription with collection_method=charge_automatically, the first invoice is finalized as part of the request.\nThe payment_behavior parameter determines the exact behavior of the initial payment.

\n\n

To start subscriptions where the first invoice always begins in a draft status, use subscription schedules instead.\nSchedules provide the flexibility to model more complex billing configurations that change over time.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/subscriptions`\n" + ( + @spec create( + params :: %{ + optional(:add_invoice_items) => list(add_invoice_items), + optional(:application_fee_percent) => number, + optional(:automatic_tax) => automatic_tax, + optional(:backdate_start_date) => integer, + optional(:billing_cycle_anchor) => integer, + optional(:billing_thresholds) => billing_thresholds | binary, + optional(:cancel_at) => integer, + optional(:cancel_at_period_end) => boolean, + optional(:collection_method) => :charge_automatically | :send_invoice, + optional(:coupon) => binary, + optional(:currency) => binary, + optional(:customer) => binary, + optional(:days_until_due) => integer, + optional(:default_payment_method) => binary, + optional(:default_source) => binary, + optional(:default_tax_rates) => list(binary) | binary, + optional(:description) => binary, + optional(:expand) => list(binary), + optional(:items) => list(items), + optional(:metadata) => %{optional(binary) => binary} | binary, + optional(:off_session) => boolean, + optional(:on_behalf_of) => binary | binary, + optional(:payment_behavior) => + :allow_incomplete + | :default_incomplete + | :error_if_incomplete + | :pending_if_incomplete, + optional(:payment_settings) => payment_settings, + optional(:pending_invoice_item_interval) => + pending_invoice_item_interval | binary, + optional(:promotion_code) => binary, + optional(:proration_behavior) => :always_invoice | :create_prorations | :none, + optional(:transfer_data) => transfer_data, + optional(:trial_end) => :now | integer, + optional(:trial_from_plan) => boolean, + optional(:trial_period_days) => integer, + optional(:trial_settings) => trial_settings + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Subscription.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/subscriptions", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Updates an existing subscription on a customer to match the specified parameters. When changing plans or quantities, we will optionally prorate the price we charge next month to make up for any price changes. To preview how the proration will be calculated, use the upcoming invoice endpoint.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/subscriptions/{subscription_exposed_id}`\n" + ( + @spec update( + subscription_exposed_id :: binary(), + params :: %{ + optional(:add_invoice_items) => list(add_invoice_items), + optional(:application_fee_percent) => number, + optional(:automatic_tax) => automatic_tax, + optional(:billing_cycle_anchor) => :now | :unchanged, + optional(:billing_thresholds) => billing_thresholds | binary, + optional(:cancel_at) => integer | binary, + optional(:cancel_at_period_end) => boolean, + optional(:cancellation_details) => cancellation_details, + optional(:collection_method) => :charge_automatically | :send_invoice, + optional(:coupon) => binary, + optional(:days_until_due) => integer, + optional(:default_payment_method) => binary, + optional(:default_source) => binary, + optional(:default_tax_rates) => list(binary) | binary, + optional(:description) => binary, + optional(:expand) => list(binary), + optional(:items) => list(items), + optional(:metadata) => %{optional(binary) => binary} | binary, + optional(:off_session) => boolean, + optional(:on_behalf_of) => binary | binary, + optional(:pause_collection) => pause_collection | binary, + optional(:payment_behavior) => + :allow_incomplete + | :default_incomplete + | :error_if_incomplete + | :pending_if_incomplete, + optional(:payment_settings) => payment_settings, + optional(:pending_invoice_item_interval) => + pending_invoice_item_interval | binary, + optional(:promotion_code) => binary, + optional(:proration_behavior) => :always_invoice | :create_prorations | :none, + optional(:proration_date) => integer, + optional(:transfer_data) => transfer_data | binary, + optional(:trial_end) => :now | integer, + optional(:trial_from_plan) => boolean, + optional(:trial_settings) => trial_settings + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Subscription.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def update(subscription_exposed_id, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/subscriptions/{subscription_exposed_id}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "subscription_exposed_id", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "subscription_exposed_id", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [subscription_exposed_id] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves the subscription with the given ID.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/subscriptions/{subscription_exposed_id}`\n" + ( + @spec retrieve( + subscription_exposed_id :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Subscription.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def retrieve(subscription_exposed_id, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/subscriptions/{subscription_exposed_id}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "subscription_exposed_id", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "subscription_exposed_id", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [subscription_exposed_id] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Cancels a customer’s subscription immediately. The customer will not be charged again for the subscription.

\n\n

Note, however, that any pending invoice items that you’ve created will still be charged for at the end of the period, unless manually deleted. If you’ve set the subscription to cancel at the end of the period, any pending prorations will also be left in place and collected at the end of the period. But if the subscription is set to cancel immediately, pending prorations will be removed.

\n\n

By default, upon subscription cancellation, Stripe will stop automatic collection of all finalized invoices for the customer. This is intended to prevent unexpected payment attempts after the customer has canceled a subscription. However, you can resume automatic collection of the invoices manually after subscription cancellation to have us proceed. Or, you could check for unpaid invoices before allowing the customer to cancel the subscription at all.

\n\n#### Details\n\n * Method: `delete`\n * Path: `/v1/subscriptions/{subscription_exposed_id}`\n" + ( + @spec cancel( + subscription_exposed_id :: binary(), + params :: %{ + optional(:cancellation_details) => cancellation_details, + optional(:expand) => list(binary), + optional(:invoice_now) => boolean, + optional(:prorate) => boolean + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Subscription.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def cancel(subscription_exposed_id, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/subscriptions/{subscription_exposed_id}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "subscription_exposed_id", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "subscription_exposed_id", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [subscription_exposed_id] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:delete) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Initiates resumption of a paused subscription, optionally resetting the billing cycle anchor and creating prorations. If a resumption invoice is generated, it must be paid or marked uncollectible before the subscription will be unpaused. If payment succeeds the subscription will become active, and if payment fails the subscription will be past_due. The resumption invoice will void automatically if not paid by the expiration date.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/subscriptions/{subscription}/resume`\n" + ( + @spec resume( + subscription :: binary(), + params :: %{ + optional(:billing_cycle_anchor) => :now | :unchanged, + optional(:expand) => list(binary), + optional(:proration_behavior) => :always_invoice | :create_prorations | :none, + optional(:proration_date) => integer + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Subscription.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def resume(subscription, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/subscriptions/{subscription}/resume", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "subscription", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "subscription", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [subscription] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Removes the currently applied discount on a subscription.

\n\n#### Details\n\n * Method: `delete`\n * Path: `/v1/subscriptions/{subscription_exposed_id}/discount`\n" + ( + @spec delete_discount(subscription_exposed_id :: binary(), opts :: Keyword.t()) :: + {:ok, Stripe.DeletedDiscount.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def delete_discount(subscription_exposed_id, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/subscriptions/{subscription_exposed_id}/discount", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "subscription_exposed_id", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "subscription_exposed_id", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [subscription_exposed_id] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_method(:delete) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/subscription_item.ex b/lib/generated/subscription_item.ex new file mode 100644 index 00000000..cce532fb --- /dev/null +++ b/lib/generated/subscription_item.ex @@ -0,0 +1,331 @@ +defmodule Stripe.SubscriptionItem do + use Stripe.Entity + + @moduledoc "Subscription items allow you to create customer subscriptions with more than\none plan, making it easy to represent complex billing relationships." + ( + defstruct [ + :billing_thresholds, + :created, + :id, + :metadata, + :object, + :plan, + :price, + :quantity, + :subscription, + :tax_rates + ] + + @typedoc "The `subscription_item` type.\n\n * `billing_thresholds` Define thresholds at which an invoice will be sent, and the related subscription advanced to a new billing period\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `id` Unique identifier for the object.\n * `metadata` Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `plan` \n * `price` \n * `quantity` The [quantity](https://stripe.com/docs/subscriptions/quantities) of the plan to which the customer should be subscribed.\n * `subscription` The `subscription` this `subscription_item` belongs to.\n * `tax_rates` The tax rates which apply to this `subscription_item`. When set, the `default_tax_rates` on the subscription do not apply to this `subscription_item`.\n" + @type t :: %__MODULE__{ + billing_thresholds: term | nil, + created: integer, + id: binary, + metadata: term, + object: binary, + plan: Stripe.Plan.t(), + price: Stripe.Price.t(), + quantity: integer, + subscription: binary, + tax_rates: term | nil + } + ) + + ( + @typedoc nil + @type billing_thresholds :: %{optional(:usage_gte) => integer} + ) + + ( + @typedoc "Data used to generate a new [Price](https://stripe.com/docs/api/prices) object inline." + @type price_data :: %{ + optional(:currency) => binary, + optional(:product) => binary, + optional(:recurring) => recurring, + optional(:tax_behavior) => :exclusive | :inclusive | :unspecified, + optional(:unit_amount) => integer, + optional(:unit_amount_decimal) => binary + } + ) + + ( + @typedoc "The recurring components of a price such as `interval` and `interval_count`." + @type recurring :: %{ + optional(:interval) => :day | :month | :week | :year, + optional(:interval_count) => integer + } + ) + + ( + nil + + @doc "

Returns a list of your subscription items for a given subscription.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/subscription_items`\n" + ( + @spec list( + params :: %{ + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:starting_after) => binary, + optional(:subscription) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.SubscriptionItem.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/subscription_items", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves the subscription item with the given ID.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/subscription_items/{item}`\n" + ( + @spec retrieve( + item :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.SubscriptionItem.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def retrieve(item, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/subscription_items/{item}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "item", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "item", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [item] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Adds a new item to an existing subscription. No existing items will be changed or replaced.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/subscription_items`\n" + ( + @spec create( + params :: %{ + optional(:billing_thresholds) => billing_thresholds | binary, + optional(:expand) => list(binary), + optional(:metadata) => %{optional(binary) => binary}, + optional(:payment_behavior) => + :allow_incomplete + | :default_incomplete + | :error_if_incomplete + | :pending_if_incomplete, + optional(:plan) => binary, + optional(:price) => binary, + optional(:price_data) => price_data, + optional(:proration_behavior) => :always_invoice | :create_prorations | :none, + optional(:proration_date) => integer, + optional(:quantity) => integer, + optional(:subscription) => binary, + optional(:tax_rates) => list(binary) | binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.SubscriptionItem.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/subscription_items", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Updates the plan or quantity of an item on a current subscription.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/subscription_items/{item}`\n" + ( + @spec update( + item :: binary(), + params :: %{ + optional(:billing_thresholds) => billing_thresholds | binary, + optional(:expand) => list(binary), + optional(:metadata) => %{optional(binary) => binary} | binary, + optional(:off_session) => boolean, + optional(:payment_behavior) => + :allow_incomplete + | :default_incomplete + | :error_if_incomplete + | :pending_if_incomplete, + optional(:plan) => binary, + optional(:price) => binary, + optional(:price_data) => price_data, + optional(:proration_behavior) => :always_invoice | :create_prorations | :none, + optional(:proration_date) => integer, + optional(:quantity) => integer, + optional(:tax_rates) => list(binary) | binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.SubscriptionItem.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def update(item, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/subscription_items/{item}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "item", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "item", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [item] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Deletes an item from the subscription. Removing a subscription item from a subscription will not cancel the subscription.

\n\n#### Details\n\n * Method: `delete`\n * Path: `/v1/subscription_items/{item}`\n" + ( + @spec delete( + item :: binary(), + params :: %{ + optional(:clear_usage) => boolean, + optional(:proration_behavior) => :always_invoice | :create_prorations | :none, + optional(:proration_date) => integer + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.DeletedSubscriptionItem.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def delete(item, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/subscription_items/{item}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "item", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "item", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [item] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:delete) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

For the specified subscription item, returns a list of summary objects. Each object in the list provides usage information that’s been summarized from multiple usage records and over a subscription billing period (e.g., 15 usage records in the month of September).

\n\n

The list is sorted in reverse-chronological order (newest first). The first list item represents the most current usage period that hasn’t ended yet. Since new usage records can still be added, the returned summary information for the subscription item’s ID should be seen as unstable until the subscription billing period ends.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/subscription_items/{subscription_item}/usage_record_summaries`\n" + ( + @spec usage_record_summaries( + subscription_item :: binary(), + params :: %{ + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.UsageRecordSummary.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def usage_record_summaries(subscription_item, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/subscription_items/{subscription_item}/usage_record_summaries", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "subscription_item", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "subscription_item", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [subscription_item] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/subscription_schedule.ex b/lib/generated/subscription_schedule.ex new file mode 100644 index 00000000..52cf6abf --- /dev/null +++ b/lib/generated/subscription_schedule.ex @@ -0,0 +1,459 @@ +defmodule Stripe.SubscriptionSchedule do + use Stripe.Entity + + @moduledoc "A subscription schedule allows you to create and manage the lifecycle of a subscription by predefining expected changes.\n\nRelated guide: [Subscription schedules](https://stripe.com/docs/billing/subscriptions/subscription-schedules)" + ( + defstruct [ + :application, + :canceled_at, + :completed_at, + :created, + :current_phase, + :customer, + :default_settings, + :end_behavior, + :id, + :livemode, + :metadata, + :object, + :phases, + :released_at, + :released_subscription, + :status, + :subscription, + :test_clock + ] + + @typedoc "The `subscription_schedule` type.\n\n * `application` ID of the Connect Application that created the schedule.\n * `canceled_at` Time at which the subscription schedule was canceled. Measured in seconds since the Unix epoch.\n * `completed_at` Time at which the subscription schedule was completed. Measured in seconds since the Unix epoch.\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `current_phase` Object representing the start and end dates for the current phase of the subscription schedule, if it is `active`.\n * `customer` ID of the customer who owns the subscription schedule.\n * `default_settings` \n * `end_behavior` Behavior of the subscription schedule and underlying subscription when it ends. Possible values are `release` or `cancel` with the default being `release`. `release` will end the subscription schedule and keep the underlying subscription running.`cancel` will end the subscription schedule and cancel the underlying subscription.\n * `id` Unique identifier for the object.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `metadata` Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `phases` Configuration for the subscription schedule's phases.\n * `released_at` Time at which the subscription schedule was released. Measured in seconds since the Unix epoch.\n * `released_subscription` ID of the subscription once managed by the subscription schedule (if it is released).\n * `status` The present status of the subscription schedule. Possible values are `not_started`, `active`, `completed`, `released`, and `canceled`. You can read more about the different states in our [behavior guide](https://stripe.com/docs/billing/subscriptions/subscription-schedules).\n * `subscription` ID of the subscription managed by the subscription schedule.\n * `test_clock` ID of the test clock this subscription schedule belongs to.\n" + @type t :: %__MODULE__{ + application: (binary | term | term) | nil, + canceled_at: integer | nil, + completed_at: integer | nil, + created: integer, + current_phase: term | nil, + customer: binary | Stripe.Customer.t() | Stripe.DeletedCustomer.t(), + default_settings: term, + end_behavior: binary, + id: binary, + livemode: boolean, + metadata: term | nil, + object: binary, + phases: term, + released_at: integer | nil, + released_subscription: binary | nil, + status: binary, + subscription: (binary | Stripe.Subscription.t()) | nil, + test_clock: (binary | Stripe.TestHelpers.TestClock.t()) | nil + } + ) + + ( + @typedoc nil + @type add_invoice_items :: %{ + optional(:price) => binary, + optional(:price_data) => price_data, + optional(:quantity) => integer, + optional(:tax_rates) => list(binary) | binary + } + ) + + ( + @typedoc "Automatic tax settings for this phase." + @type automatic_tax :: %{optional(:enabled) => boolean} + ) + + ( + @typedoc nil + @type billing_thresholds :: %{ + optional(:amount_gte) => integer, + optional(:reset_billing_cycle_anchor) => boolean + } + ) + + ( + @typedoc nil + @type canceled_at :: %{ + optional(:gt) => integer, + optional(:gte) => integer, + optional(:lt) => integer, + optional(:lte) => integer + } + ) + + ( + @typedoc nil + @type completed_at :: %{ + optional(:gt) => integer, + optional(:gte) => integer, + optional(:lt) => integer, + optional(:lte) => integer + } + ) + + ( + @typedoc nil + @type created :: %{ + optional(:gt) => integer, + optional(:gte) => integer, + optional(:lt) => integer, + optional(:lte) => integer + } + ) + + ( + @typedoc "Object representing the subscription schedule's default settings." + @type default_settings :: %{ + optional(:application_fee_percent) => number, + optional(:automatic_tax) => automatic_tax, + optional(:billing_cycle_anchor) => :automatic | :phase_start, + optional(:billing_thresholds) => billing_thresholds | binary, + optional(:collection_method) => :charge_automatically | :send_invoice, + optional(:default_payment_method) => binary, + optional(:description) => binary, + optional(:invoice_settings) => invoice_settings, + optional(:on_behalf_of) => binary | binary, + optional(:transfer_data) => transfer_data | binary + } + ) + + ( + @typedoc "All invoices will be billed using the specified settings." + @type invoice_settings :: %{optional(:days_until_due) => integer} + ) + + ( + @typedoc nil + @type items :: %{ + optional(:billing_thresholds) => billing_thresholds | binary, + optional(:metadata) => %{optional(binary) => binary}, + optional(:plan) => binary, + optional(:price) => binary, + optional(:price_data) => price_data, + optional(:quantity) => integer, + optional(:tax_rates) => list(binary) | binary + } + ) + + ( + @typedoc nil + @type phases :: %{ + optional(:add_invoice_items) => list(add_invoice_items), + optional(:application_fee_percent) => number, + optional(:automatic_tax) => automatic_tax, + optional(:billing_cycle_anchor) => :automatic | :phase_start, + optional(:billing_thresholds) => billing_thresholds | binary, + optional(:collection_method) => :charge_automatically | :send_invoice, + optional(:coupon) => binary, + optional(:currency) => binary, + optional(:default_payment_method) => binary, + optional(:default_tax_rates) => list(binary) | binary, + optional(:description) => binary, + optional(:end_date) => integer, + optional(:invoice_settings) => invoice_settings, + optional(:items) => list(items), + optional(:iterations) => integer, + optional(:metadata) => %{optional(binary) => binary}, + optional(:on_behalf_of) => binary, + optional(:proration_behavior) => :always_invoice | :create_prorations | :none, + optional(:transfer_data) => transfer_data, + optional(:trial) => boolean, + optional(:trial_end) => integer + } + ) + + ( + @typedoc "Data used to generate a new [Price](https://stripe.com/docs/api/prices) object inline." + @type price_data :: %{ + optional(:currency) => binary, + optional(:product) => binary, + optional(:recurring) => recurring, + optional(:tax_behavior) => :exclusive | :inclusive | :unspecified, + optional(:unit_amount) => integer, + optional(:unit_amount_decimal) => binary + } + ) + + ( + @typedoc "The recurring components of a price such as `interval` and `interval_count`." + @type recurring :: %{ + optional(:interval) => :day | :month | :week | :year, + optional(:interval_count) => integer + } + ) + + ( + @typedoc nil + @type released_at :: %{ + optional(:gt) => integer, + optional(:gte) => integer, + optional(:lt) => integer, + optional(:lte) => integer + } + ) + + ( + @typedoc nil + @type transfer_data :: %{ + optional(:amount_percent) => number, + optional(:destination) => binary + } + ) + + ( + nil + + @doc "

Retrieves the list of your subscription schedules.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/subscription_schedules`\n" + ( + @spec list( + params :: %{ + optional(:canceled_at) => canceled_at | integer, + optional(:completed_at) => completed_at | integer, + optional(:created) => created | integer, + optional(:customer) => binary, + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:released_at) => released_at | integer, + optional(:scheduled) => boolean, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.SubscriptionSchedule.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/subscription_schedules", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Creates a new subscription schedule object. Each customer can have up to 500 active or scheduled subscriptions.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/subscription_schedules`\n" + ( + @spec create( + params :: %{ + optional(:customer) => binary, + optional(:default_settings) => default_settings, + optional(:end_behavior) => :cancel | :none | :release | :renew, + optional(:expand) => list(binary), + optional(:from_subscription) => binary, + optional(:metadata) => %{optional(binary) => binary} | binary, + optional(:phases) => list(phases), + optional(:start_date) => integer | :now + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.SubscriptionSchedule.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/subscription_schedules", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves the details of an existing subscription schedule. You only need to supply the unique subscription schedule identifier that was returned upon subscription schedule creation.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/subscription_schedules/{schedule}`\n" + ( + @spec retrieve( + schedule :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.SubscriptionSchedule.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def retrieve(schedule, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/subscription_schedules/{schedule}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "schedule", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "schedule", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [schedule] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Updates an existing subscription schedule.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/subscription_schedules/{schedule}`\n" + ( + @spec update( + schedule :: binary(), + params :: %{ + optional(:default_settings) => default_settings, + optional(:end_behavior) => :cancel | :none | :release | :renew, + optional(:expand) => list(binary), + optional(:metadata) => %{optional(binary) => binary} | binary, + optional(:phases) => list(phases), + optional(:proration_behavior) => :always_invoice | :create_prorations | :none + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.SubscriptionSchedule.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def update(schedule, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/subscription_schedules/{schedule}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "schedule", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "schedule", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [schedule] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Cancels a subscription schedule and its associated subscription immediately (if the subscription schedule has an active subscription). A subscription schedule can only be canceled if its status is not_started or active.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/subscription_schedules/{schedule}/cancel`\n" + ( + @spec cancel( + schedule :: binary(), + params :: %{ + optional(:expand) => list(binary), + optional(:invoice_now) => boolean, + optional(:prorate) => boolean + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.SubscriptionSchedule.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def cancel(schedule, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/subscription_schedules/{schedule}/cancel", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "schedule", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "schedule", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [schedule] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Releases the subscription schedule immediately, which will stop scheduling of its phases, but leave any existing subscription in place. A schedule can only be released if its status is not_started or active. If the subscription schedule is currently associated with a subscription, releasing it will remove its subscription property and set the subscription’s ID to the released_subscription property.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/subscription_schedules/{schedule}/release`\n" + ( + @spec release( + schedule :: binary(), + params :: %{ + optional(:expand) => list(binary), + optional(:preserve_cancel_date) => boolean + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.SubscriptionSchedule.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def release(schedule, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/subscription_schedules/{schedule}/release", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "schedule", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "schedule", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [schedule] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/tax__calculation.ex b/lib/generated/tax__calculation.ex new file mode 100644 index 00000000..a08384ef --- /dev/null +++ b/lib/generated/tax__calculation.ex @@ -0,0 +1,241 @@ +defmodule Stripe.Tax.Calculation do + use Stripe.Entity + + @moduledoc "A Tax Calculation allows you to calculate the tax to collect from your customer.\n\nRelated guide: [Calculate tax in your custom payment flow](https://stripe.com/docs/tax/custom)" + ( + defstruct [ + :amount_total, + :currency, + :customer, + :customer_details, + :expires_at, + :id, + :line_items, + :livemode, + :object, + :shipping_cost, + :tax_amount_exclusive, + :tax_amount_inclusive, + :tax_breakdown, + :tax_date + ] + + @typedoc "The `tax.calculation` type.\n\n * `amount_total` Total after taxes.\n * `currency` Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).\n * `customer` The ID of an existing [Customer](https://stripe.com/docs/api/customers/object) used for the resource.\n * `customer_details` \n * `expires_at` Timestamp of date at which the tax calculation will expire.\n * `id` Unique identifier for the calculation.\n * `line_items` The list of items the customer is purchasing.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `shipping_cost` The shipping cost details for the calculation.\n * `tax_amount_exclusive` The amount of tax to be collected on top of the line item prices.\n * `tax_amount_inclusive` The amount of tax already included in the line item prices.\n * `tax_breakdown` Breakdown of individual tax amounts that add up to the total.\n * `tax_date` Timestamp of date at which the tax rules and rates in effect applies for the calculation.\n" + @type t :: %__MODULE__{ + amount_total: integer, + currency: binary, + customer: binary | nil, + customer_details: term, + expires_at: integer | nil, + id: binary | nil, + line_items: term | nil, + livemode: boolean, + object: binary, + shipping_cost: term | nil, + tax_amount_exclusive: integer, + tax_amount_inclusive: integer, + tax_breakdown: term, + tax_date: integer + } + ) + + ( + @typedoc "The customer's postal address (for example, home or business location)." + @type address :: %{ + optional(:city) => binary, + optional(:country) => binary, + optional(:line1) => binary, + optional(:line2) => binary, + optional(:postal_code) => binary, + optional(:state) => binary + } + ) + + ( + @typedoc "Details about the customer, including address and tax IDs." + @type customer_details :: %{ + optional(:address) => address, + optional(:address_source) => :billing | :shipping, + optional(:ip_address) => binary, + optional(:tax_ids) => list(tax_ids), + optional(:taxability_override) => :customer_exempt | :none | :reverse_charge + } + ) + + ( + @typedoc nil + @type line_items :: %{ + optional(:amount) => integer, + optional(:product) => binary, + optional(:quantity) => integer, + optional(:reference) => binary, + optional(:tax_behavior) => :exclusive | :inclusive, + optional(:tax_code) => binary + } + ) + + ( + @typedoc "Shipping cost details to be used for the calculation." + @type shipping_cost :: %{ + optional(:amount) => integer, + optional(:shipping_rate) => binary, + optional(:tax_behavior) => :exclusive | :inclusive, + optional(:tax_code) => binary + } + ) + + ( + @typedoc nil + @type tax_ids :: %{ + optional(:type) => + :ad_nrt + | :ae_trn + | :ar_cuit + | :au_abn + | :au_arn + | :bg_uic + | :bo_tin + | :br_cnpj + | :br_cpf + | :ca_bn + | :ca_gst_hst + | :ca_pst_bc + | :ca_pst_mb + | :ca_pst_sk + | :ca_qst + | :ch_vat + | :cl_tin + | :cn_tin + | :co_nit + | :cr_tin + | :do_rcn + | :ec_ruc + | :eg_tin + | :es_cif + | :eu_oss_vat + | :eu_vat + | :gb_vat + | :ge_vat + | :hk_br + | :hu_tin + | :id_npwp + | :il_vat + | :in_gst + | :is_vat + | :jp_cn + | :jp_rn + | :jp_trn + | :ke_pin + | :kr_brn + | :li_uid + | :mx_rfc + | :my_frp + | :my_itn + | :my_sst + | :no_vat + | :nz_gst + | :pe_ruc + | :ph_tin + | :ro_tin + | :rs_pib + | :ru_inn + | :ru_kpp + | :sa_vat + | :sg_gst + | :sg_uen + | :si_tin + | :sv_nit + | :th_vat + | :tr_tin + | :tw_vat + | :ua_vat + | :us_ein + | :uy_ruc + | :ve_rif + | :vn_tin + | :za_vat, + optional(:value) => binary + } + ) + + ( + nil + + @doc "

Calculates tax based on input and returns a Tax Calculation object.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/tax/calculations`\n" + ( + @spec create( + params :: %{ + optional(:currency) => binary, + optional(:customer) => binary, + optional(:customer_details) => customer_details, + optional(:expand) => list(binary), + optional(:line_items) => list(line_items), + optional(:shipping_cost) => shipping_cost, + optional(:tax_date) => integer + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Tax.Calculation.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/tax/calculations", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves the line items of a persisted tax calculation as a collection.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/tax/calculations/{calculation}/line_items`\n" + ( + @spec list_line_items( + calculation :: binary(), + params :: %{ + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.Tax.CalculationLineItem.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list_line_items(calculation, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/tax/calculations/{calculation}/line_items", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "calculation", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "calculation", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [calculation] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/tax__calculation_line_item.ex b/lib/generated/tax__calculation_line_item.ex new file mode 100644 index 00000000..93ccc6a9 --- /dev/null +++ b/lib/generated/tax__calculation_line_item.ex @@ -0,0 +1,34 @@ +defmodule Stripe.Tax.CalculationLineItem do + use Stripe.Entity + @moduledoc "" + ( + defstruct [ + :amount, + :amount_tax, + :id, + :livemode, + :object, + :product, + :quantity, + :reference, + :tax_behavior, + :tax_breakdown, + :tax_code + ] + + @typedoc "The `tax.calculation_line_item` type.\n\n * `amount` The line item amount in integer cents. If `tax_behavior=inclusive`, then this amount includes taxes. Otherwise, taxes were calculated on top of this amount.\n * `amount_tax` The amount of tax calculated for this line item, in integer cents.\n * `id` Unique identifier for the object.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `product` The ID of an existing [Product](https://stripe.com/docs/api/products/object).\n * `quantity` The number of units of the item being purchased. For reversals, this is the quantity reversed.\n * `reference` A custom identifier for this line item.\n * `tax_behavior` Specifies whether the `amount` includes taxes. If `tax_behavior=inclusive`, then the amount includes taxes.\n * `tax_breakdown` Detailed account of taxes relevant to this line item.\n * `tax_code` The [tax code](https://stripe.com/docs/tax/tax-categories) ID used for this resource.\n" + @type t :: %__MODULE__{ + amount: integer, + amount_tax: integer, + id: binary, + livemode: boolean, + object: binary, + product: binary | nil, + quantity: integer, + reference: binary | nil, + tax_behavior: binary, + tax_breakdown: term | nil, + tax_code: binary + } + ) +end \ No newline at end of file diff --git a/lib/generated/tax__settings.ex b/lib/generated/tax__settings.ex new file mode 100644 index 00000000..a8c70c10 --- /dev/null +++ b/lib/generated/tax__settings.ex @@ -0,0 +1,88 @@ +defmodule Stripe.Tax.Settings do + use Stripe.Entity + + @moduledoc "You can use Tax `Settings` to manage configurations used by Stripe Tax calculations.\n\nRelated guide: [Using the Settings API](https://stripe.com/docs/tax/settings-api)" + ( + defstruct [:defaults, :head_office, :livemode, :object, :status, :status_details] + + @typedoc "The `tax.settings` type.\n\n * `defaults` \n * `head_office` The place where your business is located.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `status` The `active` status indicates you have all required settings to calculate tax. A status can transition out of `active` when new required settings are introduced.\n * `status_details` \n" + @type t :: %__MODULE__{ + defaults: term, + head_office: term | nil, + livemode: boolean, + object: binary, + status: binary, + status_details: term + } + ) + + ( + @typedoc "The location of the business for tax purposes." + @type address :: %{ + optional(:city) => binary, + optional(:country) => binary, + optional(:line1) => binary, + optional(:line2) => binary, + optional(:postal_code) => binary, + optional(:state) => binary + } + ) + + ( + @typedoc "Default configuration to be used on Stripe Tax calculations." + @type defaults :: %{ + optional(:tax_behavior) => :exclusive | :inclusive | :inferred_by_currency, + optional(:tax_code) => binary + } + ) + + ( + @typedoc "The place where your business is located." + @type head_office :: %{optional(:address) => address} + ) + + ( + nil + + @doc "

Retrieves Tax Settings for a merchant.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/tax/settings`\n" + ( + @spec retrieve(params :: %{optional(:expand) => list(binary)}, opts :: Keyword.t()) :: + {:ok, Stripe.Tax.Settings.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def retrieve(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/tax/settings", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Updates Tax Settings parameters used in tax calculations. All parameters are editable but none can be removed once set.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/tax/settings`\n" + ( + @spec update( + params :: %{ + optional(:defaults) => defaults, + optional(:expand) => list(binary), + optional(:head_office) => head_office + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Tax.Settings.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def update(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/tax/settings", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/tax__transaction.ex b/lib/generated/tax__transaction.ex new file mode 100644 index 00000000..36ef9c4b --- /dev/null +++ b/lib/generated/tax__transaction.ex @@ -0,0 +1,218 @@ +defmodule Stripe.Tax.Transaction do + use Stripe.Entity + + @moduledoc "A Tax Transaction records the tax collected from or refunded to your customer.\n\nRelated guide: [Calculate tax in your custom payment flow](https://stripe.com/docs/tax/custom#tax-transaction)" + ( + defstruct [ + :created, + :currency, + :customer, + :customer_details, + :id, + :line_items, + :livemode, + :metadata, + :object, + :reference, + :reversal, + :shipping_cost, + :tax_date, + :type + ] + + @typedoc "The `tax.transaction` type.\n\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `currency` Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).\n * `customer` The ID of an existing [Customer](https://stripe.com/docs/api/customers/object) used for the resource.\n * `customer_details` \n * `id` Unique identifier for the transaction.\n * `line_items` The tax collected or refunded, by line item.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `metadata` Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `reference` A custom unique identifier, such as 'myOrder_123'.\n * `reversal` If `type=reversal`, contains information about what was reversed.\n * `shipping_cost` The shipping cost details for the transaction.\n * `tax_date` Timestamp of date at which the tax rules and rates in effect applies for the calculation.\n * `type` If `reversal`, this transaction reverses an earlier transaction.\n" + @type t :: %__MODULE__{ + created: integer, + currency: binary, + customer: binary | nil, + customer_details: term, + id: binary, + line_items: term | nil, + livemode: boolean, + metadata: term | nil, + object: binary, + reference: binary, + reversal: term | nil, + shipping_cost: term | nil, + tax_date: integer, + type: binary + } + ) + + ( + @typedoc nil + @type line_items :: %{ + optional(:amount) => integer, + optional(:amount_tax) => integer, + optional(:metadata) => %{optional(binary) => binary}, + optional(:original_line_item) => binary, + optional(:quantity) => integer, + optional(:reference) => binary + } + ) + + ( + @typedoc "The shipping cost to reverse." + @type shipping_cost :: %{optional(:amount) => integer, optional(:amount_tax) => integer} + ) + + ( + nil + + @doc "

Retrieves a Tax Transaction object.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/tax/transactions/{transaction}`\n" + ( + @spec retrieve( + transaction :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Tax.Transaction.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def retrieve(transaction, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/tax/transactions/{transaction}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "transaction", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "transaction", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [transaction] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Partially or fully reverses a previously created Transaction.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/tax/transactions/create_reversal`\n" + ( + @spec create_reversal( + params :: %{ + optional(:expand) => list(binary), + optional(:line_items) => list(line_items), + optional(:metadata) => %{optional(binary) => binary}, + optional(:mode) => :full | :partial, + optional(:original_transaction) => binary, + optional(:reference) => binary, + optional(:shipping_cost) => shipping_cost + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Tax.Transaction.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def create_reversal(params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params("/v1/tax/transactions/create_reversal", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Creates a Tax Transaction from a calculation.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/tax/transactions/create_from_calculation`\n" + ( + @spec create_from_calculation( + params :: %{ + optional(:calculation) => binary, + optional(:expand) => list(binary), + optional(:metadata) => %{optional(binary) => binary}, + optional(:reference) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Tax.Transaction.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def create_from_calculation(params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/tax/transactions/create_from_calculation", + [], + [] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves the line items of a committed standalone transaction as a collection.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/tax/transactions/{transaction}/line_items`\n" + ( + @spec list_line_items( + transaction :: binary(), + params :: %{ + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.Tax.TransactionLineItem.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list_line_items(transaction, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/tax/transactions/{transaction}/line_items", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "transaction", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "transaction", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [transaction] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/tax__transaction_line_item.ex b/lib/generated/tax__transaction_line_item.ex new file mode 100644 index 00000000..e68c823f --- /dev/null +++ b/lib/generated/tax__transaction_line_item.ex @@ -0,0 +1,38 @@ +defmodule Stripe.Tax.TransactionLineItem do + use Stripe.Entity + @moduledoc "" + ( + defstruct [ + :amount, + :amount_tax, + :id, + :livemode, + :metadata, + :object, + :product, + :quantity, + :reference, + :reversal, + :tax_behavior, + :tax_code, + :type + ] + + @typedoc "The `tax.transaction_line_item` type.\n\n * `amount` The line item amount in integer cents. If `tax_behavior=inclusive`, then this amount includes taxes. Otherwise, taxes were calculated on top of this amount.\n * `amount_tax` The amount of tax calculated for this line item, in integer cents.\n * `id` Unique identifier for the object.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `metadata` Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `product` The ID of an existing [Product](https://stripe.com/docs/api/products/object).\n * `quantity` The number of units of the item being purchased. For reversals, this is the quantity reversed.\n * `reference` A custom identifier for this line item in the transaction.\n * `reversal` If `type=reversal`, contains information about what was reversed.\n * `tax_behavior` Specifies whether the `amount` includes taxes. If `tax_behavior=inclusive`, then the amount includes taxes.\n * `tax_code` The [tax code](https://stripe.com/docs/tax/tax-categories) ID used for this resource.\n * `type` If `reversal`, this line item reverses an earlier transaction.\n" + @type t :: %__MODULE__{ + amount: integer, + amount_tax: integer, + id: binary, + livemode: boolean, + metadata: term | nil, + object: binary, + product: binary | nil, + quantity: integer, + reference: binary, + reversal: term | nil, + tax_behavior: binary, + tax_code: binary, + type: binary + } + ) +end \ No newline at end of file diff --git a/lib/generated/tax_code.ex b/lib/generated/tax_code.ex new file mode 100644 index 00000000..9de1c238 --- /dev/null +++ b/lib/generated/tax_code.ex @@ -0,0 +1,81 @@ +defmodule Stripe.TaxCode do + use Stripe.Entity + + @moduledoc "[Tax codes](https://stripe.com/docs/tax/tax-categories) classify goods and services for tax purposes." + ( + defstruct [:description, :id, :name, :object] + + @typedoc "The `tax_code` type.\n\n * `description` A detailed description of which types of products the tax code represents.\n * `id` Unique identifier for the object.\n * `name` A short name for the tax code.\n * `object` String representing the object's type. Objects of the same type share the same value.\n" + @type t :: %__MODULE__{description: binary, id: binary, name: binary, object: binary} + ) + + ( + nil + + @doc "

A list of all tax codes available to add to Products in order to allow specific tax calculations.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/tax_codes`\n" + ( + @spec list( + params :: %{ + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.TaxCode.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/tax_codes", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves the details of an existing tax code. Supply the unique tax code ID and Stripe will return the corresponding tax code information.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/tax_codes/{id}`\n" + ( + @spec retrieve( + id :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: {:ok, Stripe.TaxCode.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def retrieve(id, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/tax_codes/{id}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "id", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "id", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [id] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/tax_id.ex b/lib/generated/tax_id.ex new file mode 100644 index 00000000..e583288a --- /dev/null +++ b/lib/generated/tax_id.ex @@ -0,0 +1,296 @@ +defmodule Stripe.TaxId do + use Stripe.Entity + + @moduledoc "You can add one or multiple tax IDs to a [customer](https://stripe.com/docs/api/customers).\nA customer's tax IDs are displayed on invoices and credit notes issued for the customer.\n\nRelated guide: [Customer tax identification numbers](https://stripe.com/docs/billing/taxes/tax-ids)" + ( + defstruct [ + :country, + :created, + :customer, + :id, + :livemode, + :object, + :type, + :value, + :verification + ] + + @typedoc "The `tax_id` type.\n\n * `country` Two-letter ISO code representing the country of the tax ID.\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `customer` ID of the customer.\n * `id` Unique identifier for the object.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `type` Type of the tax ID, one of `ad_nrt`, `ae_trn`, `ar_cuit`, `au_abn`, `au_arn`, `bg_uic`, `bo_tin`, `br_cnpj`, `br_cpf`, `ca_bn`, `ca_gst_hst`, `ca_pst_bc`, `ca_pst_mb`, `ca_pst_sk`, `ca_qst`, `ch_vat`, `cl_tin`, `cn_tin`, `co_nit`, `cr_tin`, `do_rcn`, `ec_ruc`, `eg_tin`, `es_cif`, `eu_oss_vat`, `eu_vat`, `gb_vat`, `ge_vat`, `hk_br`, `hu_tin`, `id_npwp`, `il_vat`, `in_gst`, `is_vat`, `jp_cn`, `jp_rn`, `jp_trn`, `ke_pin`, `kr_brn`, `li_uid`, `mx_rfc`, `my_frp`, `my_itn`, `my_sst`, `no_vat`, `nz_gst`, `pe_ruc`, `ph_tin`, `ro_tin`, `rs_pib`, `ru_inn`, `ru_kpp`, `sa_vat`, `sg_gst`, `sg_uen`, `si_tin`, `sv_nit`, `th_vat`, `tr_tin`, `tw_vat`, `ua_vat`, `us_ein`, `uy_ruc`, `ve_rif`, `vn_tin`, or `za_vat`. Note that some legacy tax IDs have type `unknown`\n * `value` Value of the tax ID.\n * `verification` Tax ID verification information.\n" + @type t :: %__MODULE__{ + country: binary | nil, + created: integer, + customer: (binary | Stripe.Customer.t()) | nil, + id: binary, + livemode: boolean, + object: binary, + type: binary, + value: binary, + verification: term | nil + } + ) + + ( + nil + + @doc "

Creates a new TaxID object for a customer.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/customers/{customer}/tax_ids`\n" + ( + @spec create( + customer :: binary(), + params :: %{ + optional(:expand) => list(binary), + optional(:type) => + :ad_nrt + | :ae_trn + | :ar_cuit + | :au_abn + | :au_arn + | :bg_uic + | :bo_tin + | :br_cnpj + | :br_cpf + | :ca_bn + | :ca_gst_hst + | :ca_pst_bc + | :ca_pst_mb + | :ca_pst_sk + | :ca_qst + | :ch_vat + | :cl_tin + | :cn_tin + | :co_nit + | :cr_tin + | :do_rcn + | :ec_ruc + | :eg_tin + | :es_cif + | :eu_oss_vat + | :eu_vat + | :gb_vat + | :ge_vat + | :hk_br + | :hu_tin + | :id_npwp + | :il_vat + | :in_gst + | :is_vat + | :jp_cn + | :jp_rn + | :jp_trn + | :ke_pin + | :kr_brn + | :li_uid + | :mx_rfc + | :my_frp + | :my_itn + | :my_sst + | :no_vat + | :nz_gst + | :pe_ruc + | :ph_tin + | :ro_tin + | :rs_pib + | :ru_inn + | :ru_kpp + | :sa_vat + | :sg_gst + | :sg_uen + | :si_tin + | :sv_nit + | :th_vat + | :tr_tin + | :tw_vat + | :ua_vat + | :us_ein + | :uy_ruc + | :ve_rif + | :vn_tin + | :za_vat, + optional(:value) => binary + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.TaxId.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def create(customer, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/customers/{customer}/tax_ids", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "customer", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "customer", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [customer] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves the TaxID object with the given identifier.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/customers/{customer}/tax_ids/{id}`\n" + ( + @spec retrieve( + customer :: binary(), + id :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: {:ok, Stripe.TaxId.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def retrieve(customer, id, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/customers/{customer}/tax_ids/{id}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "customer", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "customer", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + }, + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "id", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "id", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [customer, id] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Returns a list of tax IDs for a customer.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/customers/{customer}/tax_ids`\n" + ( + @spec list( + customer :: binary(), + params :: %{ + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.TaxId.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(customer, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/customers/{customer}/tax_ids", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "customer", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "customer", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [customer] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Deletes an existing TaxID object.

\n\n#### Details\n\n * Method: `delete`\n * Path: `/v1/customers/{customer}/tax_ids/{id}`\n" + ( + @spec delete(customer :: binary(), id :: binary(), opts :: Keyword.t()) :: + {:ok, Stripe.DeletedTaxId.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def delete(customer, id, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/customers/{customer}/tax_ids/{id}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "customer", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "customer", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + }, + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "id", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "id", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [customer, id] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_method(:delete) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/tax_rate.ex b/lib/generated/tax_rate.ex new file mode 100644 index 00000000..4ccefd5e --- /dev/null +++ b/lib/generated/tax_rate.ex @@ -0,0 +1,236 @@ +defmodule Stripe.TaxRate do + use Stripe.Entity + + @moduledoc "Tax rates can be applied to [invoices](https://stripe.com/docs/billing/invoices/tax-rates), [subscriptions](https://stripe.com/docs/billing/subscriptions/taxes) and [Checkout Sessions](https://stripe.com/docs/payments/checkout/set-up-a-subscription#tax-rates) to collect tax.\n\nRelated guide: [Tax rates](https://stripe.com/docs/billing/taxes/tax-rates)" + ( + defstruct [ + :active, + :country, + :created, + :description, + :display_name, + :effective_percentage, + :id, + :inclusive, + :jurisdiction, + :livemode, + :metadata, + :object, + :percentage, + :state, + :tax_type + ] + + @typedoc "The `tax_rate` type.\n\n * `active` Defaults to `true`. When set to `false`, this tax rate cannot be used with new applications or Checkout Sessions, but will still work for subscriptions and invoices that already have it set.\n * `country` Two-letter country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)).\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `description` An arbitrary string attached to the tax rate for your internal use only. It will not be visible to your customers.\n * `display_name` The display name of the tax rates as it will appear to your customer on their receipt email, PDF, and the hosted invoice page.\n * `effective_percentage` Actual/effective tax rate percentage out of 100. For tax calculations with automatic_tax[enabled]=true, this percentage does not include the statutory tax rate of non-taxable jurisdictions.\n * `id` Unique identifier for the object.\n * `inclusive` This specifies if the tax rate is inclusive or exclusive.\n * `jurisdiction` The jurisdiction for the tax rate. You can use this label field for tax reporting purposes. It also appears on your customer’s invoice.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `metadata` Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `percentage` Tax rate percentage out of 100. For tax calculations with automatic_tax[enabled]=true, this percentage includes the statutory tax rate of non-taxable jurisdictions.\n * `state` [ISO 3166-2 subdivision code](https://en.wikipedia.org/wiki/ISO_3166-2:US), without country prefix. For example, \"NY\" for New York, United States.\n * `tax_type` The high-level tax type, such as `vat` or `sales_tax`.\n" + @type t :: %__MODULE__{ + active: boolean, + country: binary | nil, + created: integer, + description: binary | nil, + display_name: binary, + effective_percentage: term | nil, + id: binary, + inclusive: boolean, + jurisdiction: binary | nil, + livemode: boolean, + metadata: term | nil, + object: binary, + percentage: term, + state: binary | nil, + tax_type: binary | nil + } + ) + + ( + @typedoc nil + @type created :: %{ + optional(:gt) => integer, + optional(:gte) => integer, + optional(:lt) => integer, + optional(:lte) => integer + } + ) + + ( + nil + + @doc "

Returns a list of your tax rates. Tax rates are returned sorted by creation date, with the most recently created tax rates appearing first.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/tax_rates`\n" + ( + @spec list( + params :: %{ + optional(:active) => boolean, + optional(:created) => created | integer, + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:inclusive) => boolean, + optional(:limit) => integer, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.TaxRate.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/tax_rates", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves a tax rate with the given ID

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/tax_rates/{tax_rate}`\n" + ( + @spec retrieve( + tax_rate :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: {:ok, Stripe.TaxRate.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def retrieve(tax_rate, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/tax_rates/{tax_rate}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "tax_rate", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "tax_rate", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [tax_rate] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Creates a new tax rate.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/tax_rates`\n" + ( + @spec create( + params :: %{ + optional(:active) => boolean, + optional(:country) => binary, + optional(:description) => binary, + optional(:display_name) => binary, + optional(:expand) => list(binary), + optional(:inclusive) => boolean, + optional(:jurisdiction) => binary, + optional(:metadata) => %{optional(binary) => binary}, + optional(:percentage) => number, + optional(:state) => binary, + optional(:tax_type) => + :amusement_tax + | :communications_tax + | :gst + | :hst + | :igst + | :jct + | :lease_tax + | :pst + | :qst + | :rst + | :sales_tax + | :service_tax + | :vat + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.TaxRate.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/tax_rates", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Updates an existing tax rate.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/tax_rates/{tax_rate}`\n" + ( + @spec update( + tax_rate :: binary(), + params :: %{ + optional(:active) => boolean, + optional(:country) => binary, + optional(:description) => binary, + optional(:display_name) => binary, + optional(:expand) => list(binary), + optional(:jurisdiction) => binary, + optional(:metadata) => %{optional(binary) => binary} | binary, + optional(:state) => binary, + optional(:tax_type) => + :amusement_tax + | :communications_tax + | :gst + | :hst + | :igst + | :jct + | :lease_tax + | :pst + | :qst + | :rst + | :sales_tax + | :service_tax + | :vat + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.TaxRate.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def update(tax_rate, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/tax_rates/{tax_rate}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "tax_rate", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "tax_rate", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [tax_rate] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/terminal__configuration.ex b/lib/generated/terminal__configuration.ex new file mode 100644 index 00000000..306218ad --- /dev/null +++ b/lib/generated/terminal__configuration.ex @@ -0,0 +1,374 @@ +defmodule Stripe.Terminal.Configuration do + use Stripe.Entity + + @moduledoc "A Configurations object represents how features should be configured for terminal readers." + ( + defstruct [ + :bbpos_wisepos_e, + :id, + :is_account_default, + :livemode, + :object, + :tipping, + :verifone_p400 + ] + + @typedoc "The `terminal.configuration` type.\n\n * `bbpos_wisepos_e` \n * `id` Unique identifier for the object.\n * `is_account_default` Whether this Configuration is the default for your account\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `tipping` \n * `verifone_p400` \n" + @type t :: %__MODULE__{ + bbpos_wisepos_e: term, + id: binary, + is_account_default: boolean | nil, + livemode: boolean, + object: binary, + tipping: term, + verifone_p400: term + } + ) + + ( + @typedoc "Tipping configuration for AUD" + @type aud :: %{ + optional(:fixed_amounts) => list(integer), + optional(:percentages) => list(integer), + optional(:smart_tip_threshold) => integer + } + ) + + ( + @typedoc "An object containing device type specific settings for BBPOS WisePOS E readers" + @type bbpos_wisepos_e :: %{optional(:splashscreen) => binary | binary} + ) + + ( + @typedoc "Tipping configuration for CAD" + @type cad :: %{ + optional(:fixed_amounts) => list(integer), + optional(:percentages) => list(integer), + optional(:smart_tip_threshold) => integer + } + ) + + ( + @typedoc "Tipping configuration for CHF" + @type chf :: %{ + optional(:fixed_amounts) => list(integer), + optional(:percentages) => list(integer), + optional(:smart_tip_threshold) => integer + } + ) + + ( + @typedoc "Tipping configuration for CZK" + @type czk :: %{ + optional(:fixed_amounts) => list(integer), + optional(:percentages) => list(integer), + optional(:smart_tip_threshold) => integer + } + ) + + ( + @typedoc "Tipping configuration for DKK" + @type dkk :: %{ + optional(:fixed_amounts) => list(integer), + optional(:percentages) => list(integer), + optional(:smart_tip_threshold) => integer + } + ) + + ( + @typedoc "Tipping configuration for EUR" + @type eur :: %{ + optional(:fixed_amounts) => list(integer), + optional(:percentages) => list(integer), + optional(:smart_tip_threshold) => integer + } + ) + + ( + @typedoc "Tipping configuration for GBP" + @type gbp :: %{ + optional(:fixed_amounts) => list(integer), + optional(:percentages) => list(integer), + optional(:smart_tip_threshold) => integer + } + ) + + ( + @typedoc "Tipping configuration for HKD" + @type hkd :: %{ + optional(:fixed_amounts) => list(integer), + optional(:percentages) => list(integer), + optional(:smart_tip_threshold) => integer + } + ) + + ( + @typedoc "Tipping configuration for MYR" + @type myr :: %{ + optional(:fixed_amounts) => list(integer), + optional(:percentages) => list(integer), + optional(:smart_tip_threshold) => integer + } + ) + + ( + @typedoc "Tipping configuration for NOK" + @type nok :: %{ + optional(:fixed_amounts) => list(integer), + optional(:percentages) => list(integer), + optional(:smart_tip_threshold) => integer + } + ) + + ( + @typedoc "Tipping configuration for NZD" + @type nzd :: %{ + optional(:fixed_amounts) => list(integer), + optional(:percentages) => list(integer), + optional(:smart_tip_threshold) => integer + } + ) + + ( + @typedoc "Tipping configuration for SEK" + @type sek :: %{ + optional(:fixed_amounts) => list(integer), + optional(:percentages) => list(integer), + optional(:smart_tip_threshold) => integer + } + ) + + ( + @typedoc "Tipping configuration for SGD" + @type sgd :: %{ + optional(:fixed_amounts) => list(integer), + optional(:percentages) => list(integer), + optional(:smart_tip_threshold) => integer + } + ) + + ( + @typedoc nil + @type tipping :: %{ + optional(:aud) => aud, + optional(:cad) => cad, + optional(:chf) => chf, + optional(:czk) => czk, + optional(:dkk) => dkk, + optional(:eur) => eur, + optional(:gbp) => gbp, + optional(:hkd) => hkd, + optional(:myr) => myr, + optional(:nok) => nok, + optional(:nzd) => nzd, + optional(:sek) => sek, + optional(:sgd) => sgd, + optional(:usd) => usd + } + ) + + ( + @typedoc "Tipping configuration for USD" + @type usd :: %{ + optional(:fixed_amounts) => list(integer), + optional(:percentages) => list(integer), + optional(:smart_tip_threshold) => integer + } + ) + + ( + @typedoc "An object containing device type specific settings for Verifone P400 readers" + @type verifone_p400 :: %{optional(:splashscreen) => binary | binary} + ) + + ( + nil + + @doc "

Creates a new Configuration object.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/terminal/configurations`\n" + ( + @spec create( + params :: %{ + optional(:bbpos_wisepos_e) => bbpos_wisepos_e, + optional(:expand) => list(binary), + optional(:tipping) => tipping | binary, + optional(:verifone_p400) => verifone_p400 + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Terminal.Configuration.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/terminal/configurations", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Returns a list of Configuration objects.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/terminal/configurations`\n" + ( + @spec list( + params :: %{ + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:is_account_default) => boolean, + optional(:limit) => integer, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.Terminal.Configuration.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/terminal/configurations", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves a Configuration object.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/terminal/configurations/{configuration}`\n" + ( + @spec retrieve( + configuration :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Terminal.Configuration.t() | Stripe.DeletedTerminal.Configuration.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def retrieve(configuration, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/terminal/configurations/{configuration}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "configuration", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "configuration", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [configuration] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Updates a new Configuration object.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/terminal/configurations/{configuration}`\n" + ( + @spec update( + configuration :: binary(), + params :: %{ + optional(:bbpos_wisepos_e) => bbpos_wisepos_e | binary, + optional(:expand) => list(binary), + optional(:tipping) => tipping | binary, + optional(:verifone_p400) => verifone_p400 | binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Terminal.Configuration.t() | Stripe.DeletedTerminal.Configuration.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def update(configuration, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/terminal/configurations/{configuration}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "configuration", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "configuration", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [configuration] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Deletes a Configuration object.

\n\n#### Details\n\n * Method: `delete`\n * Path: `/v1/terminal/configurations/{configuration}`\n" + ( + @spec delete(configuration :: binary(), opts :: Keyword.t()) :: + {:ok, Stripe.DeletedTerminal.Configuration.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def delete(configuration, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/terminal/configurations/{configuration}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "configuration", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "configuration", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [configuration] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_method(:delete) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/terminal__connection_token.ex b/lib/generated/terminal__connection_token.ex new file mode 100644 index 00000000..e4655c0f --- /dev/null +++ b/lib/generated/terminal__connection_token.ex @@ -0,0 +1,35 @@ +defmodule Stripe.Terminal.ConnectionToken do + use Stripe.Entity + + @moduledoc "A Connection Token is used by the Stripe Terminal SDK to connect to a reader.\n\nRelated guide: [Fleet management](https://stripe.com/docs/terminal/fleet/locations)" + ( + defstruct [:location, :object, :secret] + + @typedoc "The `terminal.connection_token` type.\n\n * `location` The id of the location that this connection token is scoped to. Note that location scoping only applies to internet-connected readers. For more details, see [the docs on scoping connection tokens](https://stripe.com/docs/terminal/fleet/locations#connection-tokens).\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `secret` Your application should pass this token to the Stripe Terminal SDK.\n" + @type t :: %__MODULE__{location: binary, object: binary, secret: binary} + ) + + ( + nil + + @doc "

To connect to a reader the Stripe Terminal SDK needs to retrieve a short-lived connection token from Stripe, proxied through your server. On your backend, add an endpoint that creates and returns a connection token.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/terminal/connection_tokens`\n" + ( + @spec create( + params :: %{optional(:expand) => list(binary), optional(:location) => binary}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Terminal.ConnectionToken.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/terminal/connection_tokens", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/terminal__location.ex b/lib/generated/terminal__location.ex new file mode 100644 index 00000000..17ed1033 --- /dev/null +++ b/lib/generated/terminal__location.ex @@ -0,0 +1,231 @@ +defmodule Stripe.Terminal.Location do + use Stripe.Entity + + @moduledoc "A Location represents a grouping of readers.\n\nRelated guide: [Fleet management](https://stripe.com/docs/terminal/fleet/locations)" + ( + defstruct [ + :address, + :configuration_overrides, + :display_name, + :id, + :livemode, + :metadata, + :object + ] + + @typedoc "The `terminal.location` type.\n\n * `address` \n * `configuration_overrides` The ID of a configuration that will be used to customize all readers in this location.\n * `display_name` The display name of the location.\n * `id` Unique identifier for the object.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `metadata` Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.\n * `object` String representing the object's type. Objects of the same type share the same value.\n" + @type t :: %__MODULE__{ + address: term, + configuration_overrides: binary, + display_name: binary, + id: binary, + livemode: boolean, + metadata: term, + object: binary + } + ) + + ( + @typedoc "The full address of the location." + @type address :: %{ + optional(:city) => binary, + optional(:country) => binary, + optional(:line1) => binary, + optional(:line2) => binary, + optional(:postal_code) => binary, + optional(:state) => binary + } + ) + + ( + nil + + @doc "

Retrieves a Location object.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/terminal/locations/{location}`\n" + ( + @spec retrieve( + location :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Terminal.Location.t() | Stripe.DeletedTerminal.Location.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def retrieve(location, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/terminal/locations/{location}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "location", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "location", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [location] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Creates a new Location object.\nFor further details, including which address fields are required in each country, see the Manage locations guide.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/terminal/locations`\n" + ( + @spec create( + params :: %{ + optional(:address) => address, + optional(:configuration_overrides) => binary, + optional(:display_name) => binary, + optional(:expand) => list(binary), + optional(:metadata) => %{optional(binary) => binary} | binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Terminal.Location.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/terminal/locations", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Updates a Location object by setting the values of the parameters passed. Any parameters not provided will be left unchanged.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/terminal/locations/{location}`\n" + ( + @spec update( + location :: binary(), + params :: %{ + optional(:address) => address, + optional(:configuration_overrides) => binary, + optional(:display_name) => binary, + optional(:expand) => list(binary), + optional(:metadata) => %{optional(binary) => binary} | binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Terminal.Location.t() | Stripe.DeletedTerminal.Location.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def update(location, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/terminal/locations/{location}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "location", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "location", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [location] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Returns a list of Location objects.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/terminal/locations`\n" + ( + @spec list( + params :: %{ + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.Terminal.Location.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/terminal/locations", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Deletes a Location object.

\n\n#### Details\n\n * Method: `delete`\n * Path: `/v1/terminal/locations/{location}`\n" + ( + @spec delete(location :: binary(), opts :: Keyword.t()) :: + {:ok, Stripe.DeletedTerminal.Location.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def delete(location, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/terminal/locations/{location}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "location", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "location", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [location] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_method(:delete) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/terminal__reader.ex b/lib/generated/terminal__reader.ex new file mode 100644 index 00000000..bbd032b2 --- /dev/null +++ b/lib/generated/terminal__reader.ex @@ -0,0 +1,565 @@ +defmodule Stripe.Terminal.Reader do + use Stripe.Entity + + @moduledoc "A Reader represents a physical device for accepting payment details.\n\nRelated guide: [Connecting to a reader](https://stripe.com/docs/terminal/payments/connect-reader)" + ( + defstruct [ + :action, + :device_sw_version, + :device_type, + :id, + :ip_address, + :label, + :livemode, + :location, + :metadata, + :object, + :serial_number, + :status + ] + + @typedoc "The `terminal.reader` type.\n\n * `action` The most recent action performed by the reader.\n * `device_sw_version` The current software version of the reader.\n * `device_type` Type of reader, one of `bbpos_wisepad3`, `stripe_m2`, `bbpos_chipper2x`, `bbpos_wisepos_e`, `verifone_P400`, or `simulated_wisepos_e`.\n * `id` Unique identifier for the object.\n * `ip_address` The local IP address of the reader.\n * `label` Custom label given to the reader for easier identification.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `location` The location identifier of the reader.\n * `metadata` Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `serial_number` Serial number of the reader.\n * `status` The networking status of the reader.\n" + @type t :: %__MODULE__{ + action: term | nil, + device_sw_version: binary | nil, + device_type: binary, + id: binary, + ip_address: binary | nil, + label: binary, + livemode: boolean, + location: (binary | Stripe.Terminal.Location.t()) | nil, + metadata: term, + object: binary, + serial_number: binary, + status: binary | nil + } + ) + + ( + @typedoc "Simulated data for the card_present payment method." + @type card_present :: %{optional(:number) => binary} + ) + + ( + @typedoc "Cart" + @type cart :: %{ + optional(:currency) => binary, + optional(:line_items) => list(line_items), + optional(:tax) => integer, + optional(:total) => integer + } + ) + + ( + @typedoc "Simulated data for the interac_present payment method." + @type interac_present :: %{optional(:number) => binary} + ) + + ( + @typedoc nil + @type line_items :: %{ + optional(:amount) => integer, + optional(:description) => binary, + optional(:quantity) => integer + } + ) + + ( + @typedoc "Configuration overrides" + @type process_config :: %{optional(:skip_tipping) => boolean, optional(:tipping) => tipping} + ) + + ( + @typedoc "Tipping configuration for this transaction." + @type tipping :: %{optional(:amount_eligible) => integer} + ) + + ( + nil + + @doc "

Updates a Reader object by setting the values of the parameters passed. Any parameters not provided will be left unchanged.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/terminal/readers/{reader}`\n" + ( + @spec update( + reader :: binary(), + params :: %{ + optional(:expand) => list(binary), + optional(:label) => binary, + optional(:metadata) => %{optional(binary) => binary} | binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Terminal.Reader.t() | Stripe.DeletedTerminal.Reader.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def update(reader, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/terminal/readers/{reader}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "reader", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "reader", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [reader] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves a Reader object.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/terminal/readers/{reader}`\n" + ( + @spec retrieve( + reader :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Terminal.Reader.t() | Stripe.DeletedTerminal.Reader.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def retrieve(reader, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/terminal/readers/{reader}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "reader", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "reader", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [reader] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Creates a new Reader object.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/terminal/readers`\n" + ( + @spec create( + params :: %{ + optional(:expand) => list(binary), + optional(:label) => binary, + optional(:location) => binary, + optional(:metadata) => %{optional(binary) => binary} | binary, + optional(:registration_code) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Terminal.Reader.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/terminal/readers", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Returns a list of Reader objects.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/terminal/readers`\n" + ( + @spec list( + params :: %{ + optional(:device_type) => + :bbpos_chipper2x + | :bbpos_wisepad3 + | :bbpos_wisepos_e + | :simulated_wisepos_e + | :stripe_m2 + | :verifone_P400, + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:location) => binary, + optional(:starting_after) => binary, + optional(:status) => :offline | :online + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.Terminal.Reader.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/terminal/readers", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Deletes a Reader object.

\n\n#### Details\n\n * Method: `delete`\n * Path: `/v1/terminal/readers/{reader}`\n" + ( + @spec delete(reader :: binary(), opts :: Keyword.t()) :: + {:ok, Stripe.DeletedTerminal.Reader.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def delete(reader, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/terminal/readers/{reader}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "reader", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "reader", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [reader] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_method(:delete) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Initiates a payment flow on a Reader.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/terminal/readers/{reader}/process_payment_intent`\n" + ( + @spec process_payment_intent( + reader :: binary(), + params :: %{ + optional(:expand) => list(binary), + optional(:payment_intent) => binary, + optional(:process_config) => process_config + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Terminal.Reader.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def process_payment_intent(reader, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/terminal/readers/{reader}/process_payment_intent", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "reader", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "reader", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [reader] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Initiates a setup intent flow on a Reader.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/terminal/readers/{reader}/process_setup_intent`\n" + ( + @spec process_setup_intent( + reader :: binary(), + params :: %{ + optional(:customer_consent_collected) => boolean, + optional(:expand) => list(binary), + optional(:setup_intent) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Terminal.Reader.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def process_setup_intent(reader, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/terminal/readers/{reader}/process_setup_intent", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "reader", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "reader", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [reader] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Cancels the current reader action.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/terminal/readers/{reader}/cancel_action`\n" + ( + @spec cancel_action( + reader :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Terminal.Reader.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def cancel_action(reader, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/terminal/readers/{reader}/cancel_action", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "reader", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "reader", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [reader] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Sets reader display to show cart details.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/terminal/readers/{reader}/set_reader_display`\n" + ( + @spec set_reader_display( + reader :: binary(), + params :: %{ + optional(:cart) => cart, + optional(:expand) => list(binary), + optional(:type) => :cart + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Terminal.Reader.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def set_reader_display(reader, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/terminal/readers/{reader}/set_reader_display", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "reader", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "reader", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [reader] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Initiates a refund on a Reader

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/terminal/readers/{reader}/refund_payment`\n" + ( + @spec refund_payment( + reader :: binary(), + params :: %{ + optional(:amount) => integer, + optional(:charge) => binary, + optional(:expand) => list(binary), + optional(:metadata) => %{optional(binary) => binary}, + optional(:payment_intent) => binary, + optional(:refund_application_fee) => boolean, + optional(:reverse_transfer) => boolean + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Terminal.Reader.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def refund_payment(reader, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/terminal/readers/{reader}/refund_payment", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "reader", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "reader", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [reader] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Presents a payment method on a simulated reader. Can be used to simulate accepting a payment, saving a card or refunding a transaction.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/test_helpers/terminal/readers/{reader}/present_payment_method`\n" + ( + @spec present_payment_method( + reader :: binary(), + params :: %{ + optional(:amount_tip) => integer, + optional(:card_present) => card_present, + optional(:expand) => list(binary), + optional(:interac_present) => interac_present, + optional(:type) => :card_present | :interac_present + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Terminal.Reader.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def present_payment_method(reader, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/test_helpers/terminal/readers/{reader}/present_payment_method", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "reader", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "reader", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [reader] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/test_helpers__test_clock.ex b/lib/generated/test_helpers__test_clock.ex new file mode 100644 index 00000000..a0feeeda --- /dev/null +++ b/lib/generated/test_helpers__test_clock.ex @@ -0,0 +1,204 @@ +defmodule Stripe.TestHelpers.TestClock do + use Stripe.Entity + + @moduledoc "A test clock enables deterministic control over objects in testmode. With a test clock, you can create\nobjects at a frozen time in the past or future, and advance to a specific future time to observe webhooks and state changes. After the clock advances,\nyou can either validate the current state of your scenario (and test your assumptions), change the current state of your scenario (and test more complex scenarios), or keep advancing forward in time." + ( + defstruct [:created, :deletes_after, :frozen_time, :id, :livemode, :name, :object, :status] + + @typedoc "The `test_helpers.test_clock` type.\n\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `deletes_after` Time at which this clock is scheduled to auto delete.\n * `frozen_time` Time at which all objects belonging to this clock are frozen.\n * `id` Unique identifier for the object.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `name` The custom name supplied at creation.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `status` The status of the Test Clock.\n" + @type t :: %__MODULE__{ + created: integer, + deletes_after: integer, + frozen_time: integer, + id: binary, + livemode: boolean, + name: binary | nil, + object: binary, + status: binary + } + ) + + ( + nil + + @doc "

Retrieves a test clock.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/test_helpers/test_clocks/{test_clock}`\n" + ( + @spec retrieve( + test_clock :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.TestHelpers.TestClock.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def retrieve(test_clock, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/test_helpers/test_clocks/{test_clock}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "test_clock", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "test_clock", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [test_clock] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Creates a new test clock that can be attached to new customers and quotes.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/test_helpers/test_clocks`\n" + ( + @spec create( + params :: %{ + optional(:expand) => list(binary), + optional(:frozen_time) => integer, + optional(:name) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.TestHelpers.TestClock.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/test_helpers/test_clocks", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Deletes a test clock.

\n\n#### Details\n\n * Method: `delete`\n * Path: `/v1/test_helpers/test_clocks/{test_clock}`\n" + ( + @spec delete(test_clock :: binary(), opts :: Keyword.t()) :: + {:ok, Stripe.DeletedTestHelpers.TestClock.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def delete(test_clock, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/test_helpers/test_clocks/{test_clock}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "test_clock", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "test_clock", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [test_clock] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_method(:delete) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Starts advancing a test clock to a specified time in the future. Advancement is done when status changes to Ready.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/test_helpers/test_clocks/{test_clock}/advance`\n" + ( + @spec advance( + test_clock :: binary(), + params :: %{optional(:expand) => list(binary), optional(:frozen_time) => integer}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.TestHelpers.TestClock.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def advance(test_clock, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/test_helpers/test_clocks/{test_clock}/advance", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "test_clock", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "test_clock", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [test_clock] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Returns a list of your test clocks.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/test_helpers/test_clocks`\n" + ( + @spec list( + params :: %{ + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.TestHelpers.TestClock.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/test_helpers/test_clocks", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/token.ex b/lib/generated/token.ex new file mode 100644 index 00000000..3e6c8f46 --- /dev/null +++ b/lib/generated/token.ex @@ -0,0 +1,367 @@ +defmodule Stripe.Token do + use Stripe.Entity + + @moduledoc "Tokenization is the process Stripe uses to collect sensitive card or bank\naccount details, or personally identifiable information (PII), directly from\nyour customers in a secure manner. A token representing this information is\nreturned to your server to use. You should use our\n[recommended payments integrations](https://stripe.com/docs/payments) to perform this process\nclient-side. This ensures that no sensitive card data touches your server,\nand allows your integration to operate in a PCI-compliant way.\n\nIf you cannot use client-side tokenization, you can also create tokens using\nthe API with either your publishable or secret API key. Keep in mind that if\nyour integration uses this method, you are responsible for any PCI compliance\nthat may be required, and you must keep your secret API key safe. Unlike with\nclient-side tokenization, your customer's information is not sent directly to\nStripe, so we cannot determine how it is handled or stored.\n\nTokens cannot be stored or used more than once. To store card or bank account\ninformation for later use, you can create [Customer](https://stripe.com/docs/api#customers)\nobjects or [Custom accounts](https://stripe.com/docs/api#external_accounts). Note that\n[Radar](https://stripe.com/docs/radar), our integrated solution for automatic fraud protection,\nperforms best with integrations that use client-side tokenization." + ( + defstruct [:bank_account, :card, :client_ip, :created, :id, :livemode, :object, :type, :used] + + @typedoc "The `token` type.\n\n * `bank_account` \n * `card` \n * `client_ip` IP address of the client that generated the token.\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `id` Unique identifier for the object.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `type` Type of the token: `account`, `bank_account`, `card`, or `pii`.\n * `used` Whether this token has already been used (tokens can be used only once).\n" + @type t :: %__MODULE__{ + bank_account: Stripe.BankAccount.t(), + card: Stripe.Card.t(), + client_ip: binary | nil, + created: integer, + id: binary, + livemode: boolean, + object: binary, + type: binary, + used: boolean + } + ) + + ( + @typedoc "Information for the account this token will represent." + @type account :: %{ + optional(:business_type) => :company | :government_entity | :individual | :non_profit, + optional(:company) => company, + optional(:individual) => individual, + optional(:tos_shown_and_accepted) => boolean + } + ) + + ( + @typedoc "A document showing address, either a passport, local ID card, or utility bill from a well-known utility company." + @type additional_document :: %{optional(:back) => binary, optional(:front) => binary} + ) + + ( + @typedoc "The company's primary address." + @type address :: %{ + optional(:city) => binary, + optional(:country) => binary, + optional(:line1) => binary, + optional(:line2) => binary, + optional(:postal_code) => binary, + optional(:state) => binary + } + ) + + ( + @typedoc "The Kana variation of the company's primary address (Japan only)." + @type address_kana :: %{ + optional(:city) => binary, + optional(:country) => binary, + optional(:line1) => binary, + optional(:line2) => binary, + optional(:postal_code) => binary, + optional(:state) => binary, + optional(:town) => binary + } + ) + + ( + @typedoc "The Kanji variation of the company's primary address (Japan only)." + @type address_kanji :: %{ + optional(:city) => binary, + optional(:country) => binary, + optional(:line1) => binary, + optional(:line2) => binary, + optional(:postal_code) => binary, + optional(:state) => binary, + optional(:town) => binary + } + ) + + ( + @typedoc "The bank account this token will represent." + @type bank_account :: %{ + optional(:account_holder_name) => binary, + optional(:account_holder_type) => :company | :individual, + optional(:account_number) => binary, + optional(:account_type) => :checking | :futsu | :savings | :toza, + optional(:country) => binary, + optional(:currency) => binary, + optional(:routing_number) => binary + } + ) + + ( + @typedoc nil + @type card :: %{ + optional(:address_city) => binary, + optional(:address_country) => binary, + optional(:address_line1) => binary, + optional(:address_line2) => binary, + optional(:address_state) => binary, + optional(:address_zip) => binary, + optional(:currency) => binary, + optional(:cvc) => binary, + optional(:exp_month) => binary, + optional(:exp_year) => binary, + optional(:name) => binary, + optional(:number) => binary + } + ) + + ( + @typedoc "Information about the company or business." + @type company :: %{ + optional(:address) => address, + optional(:address_kana) => address_kana, + optional(:address_kanji) => address_kanji, + optional(:directors_provided) => boolean, + optional(:executives_provided) => boolean, + optional(:export_license_id) => binary, + optional(:export_purpose_code) => binary, + optional(:name) => binary, + optional(:name_kana) => binary, + optional(:name_kanji) => binary, + optional(:owners_provided) => boolean, + optional(:ownership_declaration) => ownership_declaration, + optional(:ownership_declaration_shown_and_signed) => boolean, + optional(:phone) => binary, + optional(:registration_number) => binary, + optional(:structure) => + :free_zone_establishment + | :free_zone_llc + | :government_instrumentality + | :governmental_unit + | :incorporated_non_profit + | :limited_liability_partnership + | :llc + | :multi_member_llc + | :private_company + | :private_corporation + | :private_partnership + | :public_company + | :public_corporation + | :public_partnership + | :single_member_llc + | :sole_establishment + | :sole_proprietorship + | :tax_exempt_government_instrumentality + | :unincorporated_association + | :unincorporated_non_profit, + optional(:tax_id) => binary, + optional(:tax_id_registrar) => binary, + optional(:vat_id) => binary, + optional(:verification) => verification + } + ) + + ( + @typedoc "One or more documents that demonstrate proof that this person is authorized to represent the company." + @type company_authorization :: %{optional(:files) => list(binary)} + ) + + ( + @typedoc "The updated CVC value this token will represent." + @type cvc_update :: %{optional(:cvc) => binary} + ) + + ( + @typedoc nil + @type dob :: %{ + optional(:day) => integer, + optional(:month) => integer, + optional(:year) => integer + } + ) + + ( + @typedoc "A document verifying the business." + @type document :: %{optional(:back) => binary, optional(:front) => binary} + ) + + ( + @typedoc "Documents that may be submitted to satisfy various informational requests." + @type documents :: %{ + optional(:company_authorization) => company_authorization, + optional(:passport) => passport, + optional(:visa) => visa + } + ) + + ( + @typedoc "Information about the person represented by the account." + @type individual :: %{ + optional(:address) => address, + optional(:address_kana) => address_kana, + optional(:address_kanji) => address_kanji, + optional(:dob) => dob | binary, + optional(:email) => binary, + optional(:first_name) => binary, + optional(:first_name_kana) => binary, + optional(:first_name_kanji) => binary, + optional(:full_name_aliases) => list(binary) | binary, + optional(:gender) => binary, + optional(:id_number) => binary, + optional(:id_number_secondary) => binary, + optional(:last_name) => binary, + optional(:last_name_kana) => binary, + optional(:last_name_kanji) => binary, + optional(:maiden_name) => binary, + optional(:metadata) => %{optional(binary) => binary} | binary, + optional(:phone) => binary, + optional(:political_exposure) => :existing | :none, + optional(:registered_address) => registered_address, + optional(:ssn_last_4) => binary, + optional(:verification) => verification + } + ) + + ( + @typedoc "This hash is used to attest that the beneficial owner information provided to Stripe is both current and correct." + @type ownership_declaration :: %{ + optional(:date) => integer, + optional(:ip) => binary, + optional(:user_agent) => binary + } + ) + + ( + @typedoc "One or more documents showing the person's passport page with photo and personal data." + @type passport :: %{optional(:files) => list(binary)} + ) + + ( + @typedoc "Information for the person this token will represent." + @type person :: %{ + optional(:address) => address, + optional(:address_kana) => address_kana, + optional(:address_kanji) => address_kanji, + optional(:dob) => dob | binary, + optional(:documents) => documents, + optional(:email) => binary, + optional(:first_name) => binary, + optional(:first_name_kana) => binary, + optional(:first_name_kanji) => binary, + optional(:full_name_aliases) => list(binary) | binary, + optional(:gender) => binary, + optional(:id_number) => binary, + optional(:id_number_secondary) => binary, + optional(:last_name) => binary, + optional(:last_name_kana) => binary, + optional(:last_name_kanji) => binary, + optional(:maiden_name) => binary, + optional(:metadata) => %{optional(binary) => binary} | binary, + optional(:nationality) => binary, + optional(:phone) => binary, + optional(:political_exposure) => binary, + optional(:registered_address) => registered_address, + optional(:relationship) => relationship, + optional(:ssn_last_4) => binary, + optional(:verification) => verification + } + ) + + ( + @typedoc "The PII this token will represent." + @type pii :: %{optional(:id_number) => binary} + ) + + ( + @typedoc "The individual's registered address." + @type registered_address :: %{ + optional(:city) => binary, + optional(:country) => binary, + optional(:line1) => binary, + optional(:line2) => binary, + optional(:postal_code) => binary, + optional(:state) => binary + } + ) + + ( + @typedoc "The relationship that this person has with the account's legal entity." + @type relationship :: %{ + optional(:director) => boolean, + optional(:executive) => boolean, + optional(:owner) => boolean, + optional(:percent_ownership) => number | binary, + optional(:representative) => boolean, + optional(:title) => binary + } + ) + + ( + @typedoc "Information on the verification state of the company." + @type verification :: %{optional(:document) => document} + ) + + ( + @typedoc "One or more documents showing the person's visa required for living in the country where they are residing." + @type visa :: %{optional(:files) => list(binary)} + ) + + ( + nil + + @doc "

Retrieves the token with the given ID.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/tokens/{token}`\n" + ( + @spec retrieve( + token :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: {:ok, Stripe.Token.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def retrieve(token, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/tokens/{token}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "token", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "token", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [token] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Creates a single-use token that represents a bank account’s details.\nThis token can be used with any API method in place of a bank account dictionary. This token can be used only once, by attaching it to a Custom account.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/tokens`\n" + ( + @spec create( + params :: %{ + optional(:account) => account, + optional(:bank_account) => bank_account, + optional(:card) => card | binary, + optional(:customer) => binary, + optional(:cvc_update) => cvc_update, + optional(:expand) => list(binary), + optional(:person) => person, + optional(:pii) => pii + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.Token.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/tokens", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/topup.ex b/lib/generated/topup.ex new file mode 100644 index 00000000..c705ea6f --- /dev/null +++ b/lib/generated/topup.ex @@ -0,0 +1,254 @@ +defmodule Stripe.Topup do + use Stripe.Entity + + @moduledoc "To top up your Stripe balance, you create a top-up object. You can retrieve\nindividual top-ups, as well as list all top-ups. Top-ups are identified by a\nunique, random ID.\n\nRelated guide: [Topping up your platform account](https://stripe.com/docs/connect/top-ups)" + ( + defstruct [ + :amount, + :balance_transaction, + :created, + :currency, + :description, + :expected_availability_date, + :failure_code, + :failure_message, + :id, + :livemode, + :metadata, + :object, + :source, + :statement_descriptor, + :status, + :transfer_group + ] + + @typedoc "The `topup` type.\n\n * `amount` Amount transferred.\n * `balance_transaction` ID of the balance transaction that describes the impact of this top-up on your account balance. May not be specified depending on status of top-up.\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `currency` Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).\n * `description` An arbitrary string attached to the object. Often useful for displaying to users.\n * `expected_availability_date` Date the funds are expected to arrive in your Stripe account for payouts. This factors in delays like weekends or bank holidays. May not be specified depending on status of top-up.\n * `failure_code` Error code explaining reason for top-up failure if available (see [the errors section](https://stripe.com/docs/api#errors) for a list of codes).\n * `failure_message` Message to user further explaining reason for top-up failure if available.\n * `id` Unique identifier for the object.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `metadata` Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `source` For most Stripe users, the source of every top-up is a bank account. This hash is then the [source object](https://stripe.com/docs/api#source_object) describing that bank account.\n * `statement_descriptor` Extra information about a top-up. This will appear on your source's bank statement. It must contain at least one letter.\n * `status` The status of the top-up is either `canceled`, `failed`, `pending`, `reversed`, or `succeeded`.\n * `transfer_group` A string that identifies this top-up as part of a group.\n" + @type t :: %__MODULE__{ + amount: integer, + balance_transaction: (binary | Stripe.BalanceTransaction.t()) | nil, + created: integer, + currency: binary, + description: binary | nil, + expected_availability_date: integer | nil, + failure_code: binary | nil, + failure_message: binary | nil, + id: binary, + livemode: boolean, + metadata: term, + object: binary, + source: Stripe.Source.t() | nil, + statement_descriptor: binary | nil, + status: binary, + transfer_group: binary | nil + } + ) + + ( + @typedoc nil + @type amount :: %{ + optional(:gt) => integer, + optional(:gte) => integer, + optional(:lt) => integer, + optional(:lte) => integer + } + ) + + ( + @typedoc nil + @type created :: %{ + optional(:gt) => integer, + optional(:gte) => integer, + optional(:lt) => integer, + optional(:lte) => integer + } + ) + + ( + nil + + @doc "

Top up the balance of an account

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/topups`\n" + ( + @spec create( + params :: %{ + optional(:amount) => integer, + optional(:currency) => binary, + optional(:description) => binary, + optional(:expand) => list(binary), + optional(:metadata) => %{optional(binary) => binary} | binary, + optional(:source) => binary, + optional(:statement_descriptor) => binary, + optional(:transfer_group) => binary + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.Topup.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/topups", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Returns a list of top-ups.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/topups`\n" + ( + @spec list( + params :: %{ + optional(:amount) => amount | integer, + optional(:created) => created | integer, + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:starting_after) => binary, + optional(:status) => :canceled | :failed | :pending | :succeeded + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.Topup.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/topups", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves the details of a top-up that has previously been created. Supply the unique top-up ID that was returned from your previous request, and Stripe will return the corresponding top-up information.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/topups/{topup}`\n" + ( + @spec retrieve( + topup :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: {:ok, Stripe.Topup.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def retrieve(topup, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/topups/{topup}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "topup", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "topup", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [topup] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Updates the metadata of a top-up. Other top-up details are not editable by design.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/topups/{topup}`\n" + ( + @spec update( + topup :: binary(), + params :: %{ + optional(:description) => binary, + optional(:expand) => list(binary), + optional(:metadata) => %{optional(binary) => binary} | binary + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.Topup.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def update(topup, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/topups/{topup}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "topup", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "topup", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [topup] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Cancels a top-up. Only pending top-ups can be canceled.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/topups/{topup}/cancel`\n" + ( + @spec cancel( + topup :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: {:ok, Stripe.Topup.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def cancel(topup, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/topups/{topup}/cancel", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "topup", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "topup", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [topup] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/transfer.ex b/lib/generated/transfer.ex new file mode 100644 index 00000000..719eb715 --- /dev/null +++ b/lib/generated/transfer.ex @@ -0,0 +1,206 @@ +defmodule Stripe.Transfer do + use Stripe.Entity + + @moduledoc "A `Transfer` object is created when you move funds between Stripe accounts as\npart of Connect.\n\nBefore April 6, 2017, transfers also represented movement of funds from a\nStripe account to a card or bank account. This behavior has since been split\nout into a [Payout](https://stripe.com/docs/api#payout_object) object, with corresponding payout endpoints. For more\ninformation, read about the\n[transfer/payout split](https://stripe.com/docs/transfer-payout-split).\n\nRelated guide: [Creating separate charges and transfers](https://stripe.com/docs/connect/separate-charges-and-transfers)" + ( + defstruct [ + :amount, + :amount_reversed, + :balance_transaction, + :created, + :currency, + :description, + :destination, + :destination_payment, + :id, + :livemode, + :metadata, + :object, + :reversals, + :reversed, + :source_transaction, + :source_type, + :transfer_group + ] + + @typedoc "The `transfer` type.\n\n * `amount` Amount in %s to be transferred.\n * `amount_reversed` Amount in %s reversed (can be less than the amount attribute on the transfer if a partial reversal was issued).\n * `balance_transaction` Balance transaction that describes the impact of this transfer on your account balance.\n * `created` Time that this record of the transfer was first created.\n * `currency` Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).\n * `description` An arbitrary string attached to the object. Often useful for displaying to users.\n * `destination` ID of the Stripe account the transfer was sent to.\n * `destination_payment` If the destination is a Stripe account, this will be the ID of the payment that the destination account received for the transfer.\n * `id` Unique identifier for the object.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `metadata` Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `reversals` A list of reversals that have been applied to the transfer.\n * `reversed` Whether the transfer has been fully reversed. If the transfer is only partially reversed, this attribute will still be false.\n * `source_transaction` ID of the charge or payment that was used to fund the transfer. If null, the transfer was funded from the available balance.\n * `source_type` The source balance this transfer came from. One of `card`, `fpx`, or `bank_account`.\n * `transfer_group` A string that identifies this transaction as part of a group. See the [Connect documentation](https://stripe.com/docs/connect/separate-charges-and-transfers#transfer-options) for details.\n" + @type t :: %__MODULE__{ + amount: integer, + amount_reversed: integer, + balance_transaction: (binary | Stripe.BalanceTransaction.t()) | nil, + created: integer, + currency: binary, + description: binary | nil, + destination: (binary | Stripe.Account.t()) | nil, + destination_payment: binary | Stripe.Charge.t(), + id: binary, + livemode: boolean, + metadata: term, + object: binary, + reversals: term, + reversed: boolean, + source_transaction: (binary | Stripe.Charge.t()) | nil, + source_type: binary, + transfer_group: binary | nil + } + ) + + ( + @typedoc nil + @type created :: %{ + optional(:gt) => integer, + optional(:gte) => integer, + optional(:lt) => integer, + optional(:lte) => integer + } + ) + + ( + nil + + @doc "

To send funds from your Stripe account to a connected account, you create a new transfer object. Your Stripe balance must be able to cover the transfer amount, or you’ll receive an “Insufficient Funds” error.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/transfers`\n" + ( + @spec create( + params :: %{ + optional(:amount) => integer, + optional(:currency) => binary, + optional(:description) => binary, + optional(:destination) => binary, + optional(:expand) => list(binary), + optional(:metadata) => %{optional(binary) => binary}, + optional(:source_transaction) => binary, + optional(:source_type) => :bank_account | :card | :fpx, + optional(:transfer_group) => binary + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.Transfer.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/transfers", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Returns a list of existing transfers sent to connected accounts. The transfers are returned in sorted order, with the most recently created transfers appearing first.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/transfers`\n" + ( + @spec list( + params :: %{ + optional(:created) => created | integer, + optional(:destination) => binary, + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:starting_after) => binary, + optional(:transfer_group) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.Transfer.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/transfers", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves the details of an existing transfer. Supply the unique transfer ID from either a transfer creation request or the transfer list, and Stripe will return the corresponding transfer information.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/transfers/{transfer}`\n" + ( + @spec retrieve( + transfer :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: {:ok, Stripe.Transfer.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def retrieve(transfer, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/transfers/{transfer}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "transfer", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "transfer", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [transfer] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Updates the specified transfer by setting the values of the parameters passed. Any parameters not provided will be left unchanged.

\n\n

This request accepts only metadata as an argument.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/transfers/{transfer}`\n" + ( + @spec update( + transfer :: binary(), + params :: %{ + optional(:description) => binary, + optional(:expand) => list(binary), + optional(:metadata) => %{optional(binary) => binary} | binary + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.Transfer.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def update(transfer, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/transfers/{transfer}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "transfer", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "transfer", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [transfer] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/transfer_reversal.ex b/lib/generated/transfer_reversal.ex new file mode 100644 index 00000000..c56aa170 --- /dev/null +++ b/lib/generated/transfer_reversal.ex @@ -0,0 +1,251 @@ +defmodule Stripe.TransferReversal do + use Stripe.Entity + + @moduledoc "[Stripe Connect](https://stripe.com/docs/connect) platforms can reverse transfers made to a\nconnected account, either entirely or partially, and can also specify whether\nto refund any related application fees. Transfer reversals add to the\nplatform's balance and subtract from the destination account's balance.\n\nReversing a transfer that was made for a [destination\ncharge](/docs/connect/destination-charges) is allowed only up to the amount of\nthe charge. It is possible to reverse a\n[transfer_group](https://stripe.com/docs/connect/separate-charges-and-transfers#transfer-options)\ntransfer only if the destination account has enough balance to cover the\nreversal.\n\nRelated guide: [Reversing transfers](https://stripe.com/docs/connect/separate-charges-and-transfers#reversing-transfers)" + ( + defstruct [ + :amount, + :balance_transaction, + :created, + :currency, + :destination_payment_refund, + :id, + :metadata, + :object, + :source_refund, + :transfer + ] + + @typedoc "The `transfer_reversal` type.\n\n * `amount` Amount, in %s.\n * `balance_transaction` Balance transaction that describes the impact on your account balance.\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `currency` Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).\n * `destination_payment_refund` Linked payment refund for the transfer reversal.\n * `id` Unique identifier for the object.\n * `metadata` Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `source_refund` ID of the refund responsible for the transfer reversal.\n * `transfer` ID of the transfer that was reversed.\n" + @type t :: %__MODULE__{ + amount: integer, + balance_transaction: (binary | Stripe.BalanceTransaction.t()) | nil, + created: integer, + currency: binary, + destination_payment_refund: (binary | Stripe.Refund.t()) | nil, + id: binary, + metadata: term | nil, + object: binary, + source_refund: (binary | Stripe.Refund.t()) | nil, + transfer: binary | Stripe.Transfer.t() + } + ) + + ( + nil + + @doc "

When you create a new reversal, you must specify a transfer to create it on.

\n\n

When reversing transfers, you can optionally reverse part of the transfer. You can do so as many times as you wish until the entire transfer has been reversed.

\n\n

Once entirely reversed, a transfer can’t be reversed again. This method will return an error when called on an already-reversed transfer, or when trying to reverse more money than is left on a transfer.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/transfers/{id}/reversals`\n" + ( + @spec create( + id :: binary(), + params :: %{ + optional(:amount) => integer, + optional(:description) => binary, + optional(:expand) => list(binary), + optional(:metadata) => %{optional(binary) => binary} | binary, + optional(:refund_application_fee) => boolean + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.TransferReversal.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def create(id, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/transfers/{id}/reversals", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "id", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "id", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [id] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

You can see a list of the reversals belonging to a specific transfer. Note that the 10 most recent reversals are always available by default on the transfer object. If you need more than those 10, you can use this API method and the limit and starting_after parameters to page through additional reversals.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/transfers/{id}/reversals`\n" + ( + @spec list( + id :: binary(), + params :: %{ + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.TransferReversal.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(id, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/transfers/{id}/reversals", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "id", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "id", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [id] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

By default, you can see the 10 most recent reversals stored directly on the transfer object, but you can also retrieve details about a specific reversal stored on the transfer.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/transfers/{transfer}/reversals/{id}`\n" + ( + @spec retrieve( + id :: binary(), + transfer :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.TransferReversal.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def retrieve(id, transfer, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/transfers/{transfer}/reversals/{id}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "id", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "id", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + }, + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "transfer", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "transfer", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [id, transfer] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Updates the specified reversal by setting the values of the parameters passed. Any parameters not provided will be left unchanged.

\n\n

This request only accepts metadata and description as arguments.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/transfers/{transfer}/reversals/{id}`\n" + ( + @spec update( + id :: binary(), + transfer :: binary(), + params :: %{ + optional(:expand) => list(binary), + optional(:metadata) => %{optional(binary) => binary} | binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.TransferReversal.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def update(id, transfer, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/transfers/{transfer}/reversals/{id}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "id", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "id", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + }, + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "transfer", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "transfer", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [id, transfer] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/treasury__credit_reversal.ex b/lib/generated/treasury__credit_reversal.ex new file mode 100644 index 00000000..1a8ce33f --- /dev/null +++ b/lib/generated/treasury__credit_reversal.ex @@ -0,0 +1,145 @@ +defmodule Stripe.Treasury.CreditReversal do + use Stripe.Entity + + @moduledoc "You can reverse some [ReceivedCredits](https://stripe.com/docs/api#received_credits) depending on their network and source flow. Reversing a ReceivedCredit leads to the creation of a new object known as a CreditReversal." + ( + defstruct [ + :amount, + :created, + :currency, + :financial_account, + :hosted_regulatory_receipt_url, + :id, + :livemode, + :metadata, + :network, + :object, + :received_credit, + :status, + :status_transitions, + :transaction + ] + + @typedoc "The `treasury.credit_reversal` type.\n\n * `amount` Amount (in cents) transferred.\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `currency` Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).\n * `financial_account` The FinancialAccount to reverse funds from.\n * `hosted_regulatory_receipt_url` A [hosted transaction receipt](https://stripe.com/docs/treasury/moving-money/regulatory-receipts) URL that is provided when money movement is considered regulated under Stripe's money transmission licenses.\n * `id` Unique identifier for the object.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `metadata` Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.\n * `network` The rails used to reverse the funds.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `received_credit` The ReceivedCredit being reversed.\n * `status` Status of the CreditReversal\n * `status_transitions` \n * `transaction` The Transaction associated with this object.\n" + @type t :: %__MODULE__{ + amount: integer, + created: integer, + currency: binary, + financial_account: binary, + hosted_regulatory_receipt_url: binary | nil, + id: binary, + livemode: boolean, + metadata: term, + network: binary, + object: binary, + received_credit: binary, + status: binary, + status_transitions: term, + transaction: (binary | Stripe.Treasury.Transaction.t()) | nil + } + ) + + ( + nil + + @doc "

Returns a list of CreditReversals.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/treasury/credit_reversals`\n" + ( + @spec list( + params :: %{ + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:financial_account) => binary, + optional(:limit) => integer, + optional(:received_credit) => binary, + optional(:starting_after) => binary, + optional(:status) => :canceled | :posted | :processing + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.Treasury.CreditReversal.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/treasury/credit_reversals", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves the details of an existing CreditReversal by passing the unique CreditReversal ID from either the CreditReversal creation request or CreditReversal list

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/treasury/credit_reversals/{credit_reversal}`\n" + ( + @spec retrieve( + credit_reversal :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Treasury.CreditReversal.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def retrieve(credit_reversal, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/treasury/credit_reversals/{credit_reversal}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "credit_reversal", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "credit_reversal", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [credit_reversal] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Reverses a ReceivedCredit and creates a CreditReversal object.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/treasury/credit_reversals`\n" + ( + @spec create( + params :: %{ + optional(:expand) => list(binary), + optional(:metadata) => %{optional(binary) => binary}, + optional(:received_credit) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Treasury.CreditReversal.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/treasury/credit_reversals", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/treasury__debit_reversal.ex b/lib/generated/treasury__debit_reversal.ex new file mode 100644 index 00000000..8ad88c53 --- /dev/null +++ b/lib/generated/treasury__debit_reversal.ex @@ -0,0 +1,148 @@ +defmodule Stripe.Treasury.DebitReversal do + use Stripe.Entity + + @moduledoc "You can reverse some [ReceivedDebits](https://stripe.com/docs/api#received_debits) depending on their network and source flow. Reversing a ReceivedDebit leads to the creation of a new object known as a DebitReversal." + ( + defstruct [ + :amount, + :created, + :currency, + :financial_account, + :hosted_regulatory_receipt_url, + :id, + :linked_flows, + :livemode, + :metadata, + :network, + :object, + :received_debit, + :status, + :status_transitions, + :transaction + ] + + @typedoc "The `treasury.debit_reversal` type.\n\n * `amount` Amount (in cents) transferred.\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `currency` Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).\n * `financial_account` The FinancialAccount to reverse funds from.\n * `hosted_regulatory_receipt_url` A [hosted transaction receipt](https://stripe.com/docs/treasury/moving-money/regulatory-receipts) URL that is provided when money movement is considered regulated under Stripe's money transmission licenses.\n * `id` Unique identifier for the object.\n * `linked_flows` Other flows linked to a DebitReversal.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `metadata` Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.\n * `network` The rails used to reverse the funds.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `received_debit` The ReceivedDebit being reversed.\n * `status` Status of the DebitReversal\n * `status_transitions` \n * `transaction` The Transaction associated with this object.\n" + @type t :: %__MODULE__{ + amount: integer, + created: integer, + currency: binary, + financial_account: binary | nil, + hosted_regulatory_receipt_url: binary | nil, + id: binary, + linked_flows: term | nil, + livemode: boolean, + metadata: term, + network: binary, + object: binary, + received_debit: binary, + status: binary, + status_transitions: term, + transaction: (binary | Stripe.Treasury.Transaction.t()) | nil + } + ) + + ( + nil + + @doc "

Reverses a ReceivedDebit and creates a DebitReversal object.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/treasury/debit_reversals`\n" + ( + @spec create( + params :: %{ + optional(:expand) => list(binary), + optional(:metadata) => %{optional(binary) => binary}, + optional(:received_debit) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Treasury.DebitReversal.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/treasury/debit_reversals", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves a DebitReversal object.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/treasury/debit_reversals/{debit_reversal}`\n" + ( + @spec retrieve( + debit_reversal :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Treasury.DebitReversal.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def retrieve(debit_reversal, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/treasury/debit_reversals/{debit_reversal}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "debit_reversal", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "debit_reversal", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [debit_reversal] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Returns a list of DebitReversals.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/treasury/debit_reversals`\n" + ( + @spec list( + params :: %{ + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:financial_account) => binary, + optional(:limit) => integer, + optional(:received_debit) => binary, + optional(:resolution) => :lost | :won, + optional(:starting_after) => binary, + optional(:status) => :canceled | :completed | :processing + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.Treasury.DebitReversal.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/treasury/debit_reversals", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/treasury__financial_account.ex b/lib/generated/treasury__financial_account.ex new file mode 100644 index 00000000..902de75c --- /dev/null +++ b/lib/generated/treasury__financial_account.ex @@ -0,0 +1,382 @@ +defmodule Stripe.Treasury.FinancialAccount do + use Stripe.Entity + + @moduledoc "Stripe Treasury provides users with a container for money called a FinancialAccount that is separate from their Payments balance.\nFinancialAccounts serve as the source and destination of Treasury’s money movement APIs." + ( + defstruct [ + :active_features, + :balance, + :country, + :created, + :features, + :financial_addresses, + :id, + :livemode, + :metadata, + :object, + :pending_features, + :platform_restrictions, + :restricted_features, + :status, + :status_details, + :supported_currencies + ] + + @typedoc "The `treasury.financial_account` type.\n\n * `active_features` The array of paths to active Features in the Features hash.\n * `balance` \n * `country` Two-letter country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)).\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `features` \n * `financial_addresses` The set of credentials that resolve to a FinancialAccount.\n * `id` Unique identifier for the object.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `metadata` Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `pending_features` The array of paths to pending Features in the Features hash.\n * `platform_restrictions` The set of functionalities that the platform can restrict on the FinancialAccount.\n * `restricted_features` The array of paths to restricted Features in the Features hash.\n * `status` The enum specifying what state the account is in.\n * `status_details` \n * `supported_currencies` The currencies the FinancialAccount can hold a balance in. Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase.\n" + @type t :: %__MODULE__{ + active_features: term, + balance: term, + country: binary, + created: integer, + features: Stripe.Treasury.FinancialAccountFeatures.t(), + financial_addresses: term, + id: binary, + livemode: boolean, + metadata: term | nil, + object: binary, + pending_features: term, + platform_restrictions: term | nil, + restricted_features: term, + status: binary, + status_details: term, + supported_currencies: term + } + ) + + ( + @typedoc "Adds an ABA FinancialAddress to the FinancialAccount." + @type aba :: %{optional(:requested) => boolean} + ) + + ( + @typedoc "Enables ACH Debits via the InboundTransfers API." + @type ach :: %{optional(:requested) => boolean} + ) + + ( + @typedoc "Encodes the FinancialAccount's ability to be used with the Issuing product, including attaching cards to and drawing funds from the FinancialAccount." + @type card_issuing :: %{optional(:requested) => boolean} + ) + + ( + @typedoc nil + @type created :: %{ + optional(:gt) => integer, + optional(:gte) => integer, + optional(:lt) => integer, + optional(:lte) => integer + } + ) + + ( + @typedoc "Represents whether this FinancialAccount is eligible for deposit insurance. Various factors determine the insurance amount." + @type deposit_insurance :: %{optional(:requested) => boolean} + ) + + ( + @typedoc "Encodes whether a FinancialAccount has access to a particular feature. Stripe or the platform can control features via the requested field." + @type features :: %{ + optional(:card_issuing) => card_issuing, + optional(:deposit_insurance) => deposit_insurance, + optional(:financial_addresses) => financial_addresses, + optional(:inbound_transfers) => inbound_transfers, + optional(:intra_stripe_flows) => intra_stripe_flows, + optional(:outbound_payments) => outbound_payments, + optional(:outbound_transfers) => outbound_transfers + } + ) + + ( + @typedoc "Contains Features that add FinancialAddresses to the FinancialAccount." + @type financial_addresses :: %{optional(:aba) => aba} + ) + + ( + @typedoc "Contains settings related to adding funds to a FinancialAccount from another Account with the same owner." + @type inbound_transfers :: %{optional(:ach) => ach} + ) + + ( + @typedoc "Represents the ability for the FinancialAccount to send money to, or receive money from other FinancialAccounts (for example, via OutboundPayment)." + @type intra_stripe_flows :: %{optional(:requested) => boolean} + ) + + ( + @typedoc "Includes Features related to initiating money movement out of the FinancialAccount to someone else's bucket of money." + @type outbound_payments :: %{ + optional(:ach) => ach, + optional(:us_domestic_wire) => us_domestic_wire + } + ) + + ( + @typedoc "Contains a Feature and settings related to moving money out of the FinancialAccount into another Account with the same owner." + @type outbound_transfers :: %{ + optional(:ach) => ach, + optional(:us_domestic_wire) => us_domestic_wire + } + ) + + ( + @typedoc "The set of functionalities that the platform can restrict on the FinancialAccount." + @type platform_restrictions :: %{ + optional(:inbound_flows) => :restricted | :unrestricted, + optional(:outbound_flows) => :restricted | :unrestricted + } + ) + + ( + @typedoc "Enables US domestic wire tranfers via the OutboundPayments API." + @type us_domestic_wire :: %{optional(:requested) => boolean} + ) + + ( + nil + + @doc "

Creates a new FinancialAccount. For now, each connected account can only have one FinancialAccount.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/treasury/financial_accounts`\n" + ( + @spec create( + params :: %{ + optional(:expand) => list(binary), + optional(:features) => features, + optional(:metadata) => %{optional(binary) => binary}, + optional(:platform_restrictions) => platform_restrictions, + optional(:supported_currencies) => list(binary) + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Treasury.FinancialAccount.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/treasury/financial_accounts", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Updates the details of a FinancialAccount.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/treasury/financial_accounts/{financial_account}`\n" + ( + @spec update( + financial_account :: binary(), + params :: %{ + optional(:expand) => list(binary), + optional(:features) => features, + optional(:metadata) => %{optional(binary) => binary}, + optional(:platform_restrictions) => platform_restrictions + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Treasury.FinancialAccount.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def update(financial_account, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/treasury/financial_accounts/{financial_account}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "financial_account", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "financial_account", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [financial_account] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Updates the Features associated with a FinancialAccount.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/treasury/financial_accounts/{financial_account}/features`\n" + ( + @spec update_features( + financial_account :: binary(), + params :: %{ + optional(:card_issuing) => card_issuing, + optional(:deposit_insurance) => deposit_insurance, + optional(:expand) => list(binary), + optional(:financial_addresses) => financial_addresses, + optional(:inbound_transfers) => inbound_transfers, + optional(:intra_stripe_flows) => intra_stripe_flows, + optional(:outbound_payments) => outbound_payments, + optional(:outbound_transfers) => outbound_transfers + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Treasury.FinancialAccountFeatures.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def update_features(financial_account, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/treasury/financial_accounts/{financial_account}/features", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "financial_account", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "financial_account", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [financial_account] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Returns a list of FinancialAccounts.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/treasury/financial_accounts`\n" + ( + @spec list( + params :: %{ + optional(:created) => created | integer, + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.Treasury.FinancialAccount.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/treasury/financial_accounts", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves the details of a FinancialAccount.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/treasury/financial_accounts/{financial_account}`\n" + ( + @spec retrieve( + financial_account :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Treasury.FinancialAccount.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def retrieve(financial_account, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/treasury/financial_accounts/{financial_account}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "financial_account", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "financial_account", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [financial_account] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves Features information associated with the FinancialAccount.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/treasury/financial_accounts/{financial_account}/features`\n" + ( + @spec retrieve_features( + financial_account :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Treasury.FinancialAccountFeatures.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def retrieve_features(financial_account, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/treasury/financial_accounts/{financial_account}/features", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "financial_account", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "financial_account", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [financial_account] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/treasury__financial_account_features.ex b/lib/generated/treasury__financial_account_features.ex new file mode 100644 index 00000000..826b2143 --- /dev/null +++ b/lib/generated/treasury__financial_account_features.ex @@ -0,0 +1,29 @@ +defmodule Stripe.Treasury.FinancialAccountFeatures do + use Stripe.Entity + + @moduledoc "Encodes whether a FinancialAccount has access to a particular Feature, with a `status` enum and associated `status_details`.\nStripe or the platform can control Features via the requested field." + ( + defstruct [ + :card_issuing, + :deposit_insurance, + :financial_addresses, + :inbound_transfers, + :intra_stripe_flows, + :object, + :outbound_payments, + :outbound_transfers + ] + + @typedoc "The `treasury.financial_account_features` type.\n\n * `card_issuing` \n * `deposit_insurance` \n * `financial_addresses` \n * `inbound_transfers` \n * `intra_stripe_flows` \n * `object` String representing the object's type. Objects of the same type share the same value.\n * `outbound_payments` \n * `outbound_transfers` \n" + @type t :: %__MODULE__{ + card_issuing: term, + deposit_insurance: term, + financial_addresses: term, + inbound_transfers: term, + intra_stripe_flows: term, + object: binary, + outbound_payments: term, + outbound_transfers: term + } + ) +end \ No newline at end of file diff --git a/lib/generated/treasury__inbound_transfer.ex b/lib/generated/treasury__inbound_transfer.ex new file mode 100644 index 00000000..3ea55422 --- /dev/null +++ b/lib/generated/treasury__inbound_transfer.ex @@ -0,0 +1,360 @@ +defmodule Stripe.Treasury.InboundTransfer do + use Stripe.Entity + + @moduledoc "Use [InboundTransfers](https://stripe.com/docs/treasury/moving-money/financial-accounts/into/inbound-transfers) to add funds to your [FinancialAccount](https://stripe.com/docs/api#financial_accounts) via a PaymentMethod that is owned by you. The funds will be transferred via an ACH debit." + ( + defstruct [ + :amount, + :cancelable, + :created, + :currency, + :description, + :failure_details, + :financial_account, + :hosted_regulatory_receipt_url, + :id, + :linked_flows, + :livemode, + :metadata, + :object, + :origin_payment_method, + :origin_payment_method_details, + :returned, + :statement_descriptor, + :status, + :status_transitions, + :transaction + ] + + @typedoc "The `treasury.inbound_transfer` type.\n\n * `amount` Amount (in cents) transferred.\n * `cancelable` Returns `true` if the InboundTransfer is able to be canceled.\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `currency` Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).\n * `description` An arbitrary string attached to the object. Often useful for displaying to users.\n * `failure_details` Details about this InboundTransfer's failure. Only set when status is `failed`.\n * `financial_account` The FinancialAccount that received the funds.\n * `hosted_regulatory_receipt_url` A [hosted transaction receipt](https://stripe.com/docs/treasury/moving-money/regulatory-receipts) URL that is provided when money movement is considered regulated under Stripe's money transmission licenses.\n * `id` Unique identifier for the object.\n * `linked_flows` \n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `metadata` Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `origin_payment_method` The origin payment method to be debited for an InboundTransfer.\n * `origin_payment_method_details` Details about the PaymentMethod for an InboundTransfer.\n * `returned` Returns `true` if the funds for an InboundTransfer were returned after the InboundTransfer went to the `succeeded` state.\n * `statement_descriptor` Statement descriptor shown when funds are debited from the source. Not all payment networks support `statement_descriptor`.\n * `status` Status of the InboundTransfer: `processing`, `succeeded`, `failed`, and `canceled`. An InboundTransfer is `processing` if it is created and pending. The status changes to `succeeded` once the funds have been \"confirmed\" and a `transaction` is created and posted. The status changes to `failed` if the transfer fails.\n * `status_transitions` \n * `transaction` The Transaction associated with this object.\n" + @type t :: %__MODULE__{ + amount: integer, + cancelable: boolean, + created: integer, + currency: binary, + description: binary | nil, + failure_details: term | nil, + financial_account: binary, + hosted_regulatory_receipt_url: binary | nil, + id: binary, + linked_flows: term, + livemode: boolean, + metadata: term, + object: binary, + origin_payment_method: binary, + origin_payment_method_details: term | nil, + returned: boolean | nil, + statement_descriptor: binary, + status: binary, + status_transitions: term, + transaction: (binary | Stripe.Treasury.Transaction.t()) | nil + } + ) + + ( + @typedoc "Details about a failed InboundTransfer." + @type failure_details :: %{ + optional(:code) => + :account_closed + | :account_frozen + | :bank_account_restricted + | :bank_ownership_changed + | :debit_not_authorized + | :incorrect_account_holder_address + | :incorrect_account_holder_name + | :incorrect_account_holder_tax_id + | :insufficient_funds + | :invalid_account_number + | :invalid_currency + | :no_account + | :other + } + ) + + ( + nil + + @doc "

Cancels an InboundTransfer.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/treasury/inbound_transfers/{inbound_transfer}/cancel`\n" + ( + @spec cancel( + inbound_transfer :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Treasury.InboundTransfer.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def cancel(inbound_transfer, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/treasury/inbound_transfers/{inbound_transfer}/cancel", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "inbound_transfer", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "inbound_transfer", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [inbound_transfer] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Creates an InboundTransfer.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/treasury/inbound_transfers`\n" + ( + @spec create( + params :: %{ + optional(:amount) => integer, + optional(:currency) => binary, + optional(:description) => binary, + optional(:expand) => list(binary), + optional(:financial_account) => binary, + optional(:metadata) => %{optional(binary) => binary}, + optional(:origin_payment_method) => binary, + optional(:statement_descriptor) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Treasury.InboundTransfer.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/treasury/inbound_transfers", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves the details of an existing InboundTransfer.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/treasury/inbound_transfers/{id}`\n" + ( + @spec retrieve( + id :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Treasury.InboundTransfer.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def retrieve(id, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/treasury/inbound_transfers/{id}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "id", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "id", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [id] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Returns a list of InboundTransfers sent from the specified FinancialAccount.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/treasury/inbound_transfers`\n" + ( + @spec list( + params :: %{ + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:financial_account) => binary, + optional(:limit) => integer, + optional(:starting_after) => binary, + optional(:status) => :canceled | :failed | :processing | :succeeded + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.Treasury.InboundTransfer.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/treasury/inbound_transfers", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Transitions a test mode created InboundTransfer to the succeeded status. The InboundTransfer must already be in the processing state.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/test_helpers/treasury/inbound_transfers/{id}/succeed`\n" + ( + @spec succeed( + id :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Treasury.InboundTransfer.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def succeed(id, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/test_helpers/treasury/inbound_transfers/{id}/succeed", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "id", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "id", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [id] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Transitions a test mode created InboundTransfer to the failed status. The InboundTransfer must already be in the processing state.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/test_helpers/treasury/inbound_transfers/{id}/fail`\n" + ( + @spec fail( + id :: binary(), + params :: %{ + optional(:expand) => list(binary), + optional(:failure_details) => failure_details + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Treasury.InboundTransfer.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def fail(id, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/test_helpers/treasury/inbound_transfers/{id}/fail", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "id", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "id", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [id] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Marks the test mode InboundTransfer object as returned and links the InboundTransfer to a ReceivedDebit. The InboundTransfer must already be in the succeeded state.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/test_helpers/treasury/inbound_transfers/{id}/return`\n" + ( + @spec return_inbound_transfer( + id :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Treasury.InboundTransfer.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def return_inbound_transfer(id, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/test_helpers/treasury/inbound_transfers/{id}/return", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "id", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "id", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [id] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/treasury__outbound_payment.ex b/lib/generated/treasury__outbound_payment.ex new file mode 100644 index 00000000..f278f03c --- /dev/null +++ b/lib/generated/treasury__outbound_payment.ex @@ -0,0 +1,415 @@ +defmodule Stripe.Treasury.OutboundPayment do + use Stripe.Entity + + @moduledoc "Use OutboundPayments to send funds to another party's external bank account or [FinancialAccount](https://stripe.com/docs/api#financial_accounts). To send money to an account belonging to the same user, use an [OutboundTransfer](https://stripe.com/docs/api#outbound_transfers).\n\nSimulate OutboundPayment state changes with the `/v1/test_helpers/treasury/outbound_payments` endpoints. These methods can only be called on test mode objects." + ( + defstruct [ + :amount, + :cancelable, + :created, + :currency, + :customer, + :description, + :destination_payment_method, + :destination_payment_method_details, + :end_user_details, + :expected_arrival_date, + :financial_account, + :hosted_regulatory_receipt_url, + :id, + :livemode, + :metadata, + :object, + :returned_details, + :statement_descriptor, + :status, + :status_transitions, + :transaction + ] + + @typedoc "The `treasury.outbound_payment` type.\n\n * `amount` Amount (in cents) transferred.\n * `cancelable` Returns `true` if the object can be canceled, and `false` otherwise.\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `currency` Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).\n * `customer` ID of the [customer](https://stripe.com/docs/api/customers) to whom an OutboundPayment is sent.\n * `description` An arbitrary string attached to the object. Often useful for displaying to users.\n * `destination_payment_method` The PaymentMethod via which an OutboundPayment is sent. This field can be empty if the OutboundPayment was created using `destination_payment_method_data`.\n * `destination_payment_method_details` Details about the PaymentMethod for an OutboundPayment.\n * `end_user_details` Details about the end user.\n * `expected_arrival_date` The date when funds are expected to arrive in the destination account.\n * `financial_account` The FinancialAccount that funds were pulled from.\n * `hosted_regulatory_receipt_url` A [hosted transaction receipt](https://stripe.com/docs/treasury/moving-money/regulatory-receipts) URL that is provided when money movement is considered regulated under Stripe's money transmission licenses.\n * `id` Unique identifier for the object.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `metadata` Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `returned_details` Details about a returned OutboundPayment. Only set when the status is `returned`.\n * `statement_descriptor` The description that appears on the receiving end for an OutboundPayment (for example, bank statement for external bank transfer).\n * `status` Current status of the OutboundPayment: `processing`, `failed`, `posted`, `returned`, `canceled`. An OutboundPayment is `processing` if it has been created and is pending. The status changes to `posted` once the OutboundPayment has been \"confirmed\" and funds have left the account, or to `failed` or `canceled`. If an OutboundPayment fails to arrive at its destination, its status will change to `returned`.\n * `status_transitions` \n * `transaction` The Transaction associated with this object.\n" + @type t :: %__MODULE__{ + amount: integer, + cancelable: boolean, + created: integer, + currency: binary, + customer: binary | nil, + description: binary | nil, + destination_payment_method: binary | nil, + destination_payment_method_details: term | nil, + end_user_details: term | nil, + expected_arrival_date: integer, + financial_account: binary, + hosted_regulatory_receipt_url: binary | nil, + id: binary, + livemode: boolean, + metadata: term, + object: binary, + returned_details: term | nil, + statement_descriptor: binary, + status: binary, + status_transitions: term, + transaction: binary | Stripe.Treasury.Transaction.t() + } + ) + + ( + @typedoc nil + @type address :: %{ + optional(:city) => binary, + optional(:country) => binary, + optional(:line1) => binary, + optional(:line2) => binary, + optional(:postal_code) => binary, + optional(:state) => binary + } + ) + + ( + @typedoc "Billing information associated with the PaymentMethod that may be used or required by particular types of payment methods." + @type billing_details :: %{ + optional(:address) => address | binary, + optional(:email) => binary | binary, + optional(:name) => binary, + optional(:phone) => binary + } + ) + + ( + @typedoc "Hash used to generate the PaymentMethod to be used for this OutboundPayment. Exclusive with `destination_payment_method`." + @type destination_payment_method_data :: %{ + optional(:billing_details) => billing_details, + optional(:financial_account) => binary, + optional(:metadata) => %{optional(binary) => binary}, + optional(:type) => :financial_account | :us_bank_account, + optional(:us_bank_account) => us_bank_account + } + ) + + ( + @typedoc "Payment method-specific configuration for this OutboundPayment." + @type destination_payment_method_options :: %{ + optional(:us_bank_account) => us_bank_account | binary + } + ) + + ( + @typedoc "End user details." + @type end_user_details :: %{optional(:ip_address) => binary, optional(:present) => boolean} + ) + + ( + @typedoc "Optional hash to set the the return code." + @type returned_details :: %{ + optional(:code) => + :account_closed + | :account_frozen + | :bank_account_restricted + | :bank_ownership_changed + | :declined + | :incorrect_account_holder_name + | :invalid_account_number + | :invalid_currency + | :no_account + | :other + } + ) + + ( + @typedoc nil + @type us_bank_account :: %{optional(:network) => :ach | :us_domestic_wire} + ) + + ( + nil + + @doc "

Creates an OutboundPayment.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/treasury/outbound_payments`\n" + ( + @spec create( + params :: %{ + optional(:amount) => integer, + optional(:currency) => binary, + optional(:customer) => binary, + optional(:description) => binary, + optional(:destination_payment_method) => binary, + optional(:destination_payment_method_data) => destination_payment_method_data, + optional(:destination_payment_method_options) => + destination_payment_method_options, + optional(:end_user_details) => end_user_details, + optional(:expand) => list(binary), + optional(:financial_account) => binary, + optional(:metadata) => %{optional(binary) => binary}, + optional(:statement_descriptor) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Treasury.OutboundPayment.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/treasury/outbound_payments", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves the details of an existing OutboundPayment by passing the unique OutboundPayment ID from either the OutboundPayment creation request or OutboundPayment list.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/treasury/outbound_payments/{id}`\n" + ( + @spec retrieve( + id :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Treasury.OutboundPayment.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def retrieve(id, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/treasury/outbound_payments/{id}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "id", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "id", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [id] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Returns a list of OutboundPayments sent from the specified FinancialAccount.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/treasury/outbound_payments`\n" + ( + @spec list( + params :: %{ + optional(:customer) => binary, + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:financial_account) => binary, + optional(:limit) => integer, + optional(:starting_after) => binary, + optional(:status) => :canceled | :failed | :posted | :processing | :returned + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.Treasury.OutboundPayment.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/treasury/outbound_payments", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Cancel an OutboundPayment.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/treasury/outbound_payments/{id}/cancel`\n" + ( + @spec cancel( + id :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Treasury.OutboundPayment.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def cancel(id, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/treasury/outbound_payments/{id}/cancel", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "id", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "id", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [id] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Transitions a test mode created OutboundPayment to the failed status. The OutboundPayment must already be in the processing state.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/test_helpers/treasury/outbound_payments/{id}/fail`\n" + ( + @spec fail( + id :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Treasury.OutboundPayment.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def fail(id, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/test_helpers/treasury/outbound_payments/{id}/fail", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "id", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "id", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [id] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Transitions a test mode created OutboundPayment to the posted status. The OutboundPayment must already be in the processing state.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/test_helpers/treasury/outbound_payments/{id}/post`\n" + ( + @spec post( + id :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Treasury.OutboundPayment.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def post(id, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/test_helpers/treasury/outbound_payments/{id}/post", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "id", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "id", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [id] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Transitions a test mode created OutboundPayment to the returned status. The OutboundPayment must already be in the processing state.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/test_helpers/treasury/outbound_payments/{id}/return`\n" + ( + @spec return_outbound_payment( + id :: binary(), + params :: %{ + optional(:expand) => list(binary), + optional(:returned_details) => returned_details + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Treasury.OutboundPayment.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def return_outbound_payment(id, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/test_helpers/treasury/outbound_payments/{id}/return", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "id", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "id", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [id] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/treasury__outbound_transfer.ex b/lib/generated/treasury__outbound_transfer.ex new file mode 100644 index 00000000..7dad53ae --- /dev/null +++ b/lib/generated/treasury__outbound_transfer.ex @@ -0,0 +1,369 @@ +defmodule Stripe.Treasury.OutboundTransfer do + use Stripe.Entity + + @moduledoc "Use OutboundTransfers to transfer funds from a [FinancialAccount](https://stripe.com/docs/api#financial_accounts) to a PaymentMethod belonging to the same entity. To send funds to a different party, use [OutboundPayments](https://stripe.com/docs/api#outbound_payments) instead. You can send funds over ACH rails or through a domestic wire transfer to a user's own external bank account.\n\nSimulate OutboundTransfer state changes with the `/v1/test_helpers/treasury/outbound_transfers` endpoints. These methods can only be called on test mode objects." + ( + defstruct [ + :amount, + :cancelable, + :created, + :currency, + :description, + :destination_payment_method, + :destination_payment_method_details, + :expected_arrival_date, + :financial_account, + :hosted_regulatory_receipt_url, + :id, + :livemode, + :metadata, + :object, + :returned_details, + :statement_descriptor, + :status, + :status_transitions, + :transaction + ] + + @typedoc "The `treasury.outbound_transfer` type.\n\n * `amount` Amount (in cents) transferred.\n * `cancelable` Returns `true` if the object can be canceled, and `false` otherwise.\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `currency` Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).\n * `description` An arbitrary string attached to the object. Often useful for displaying to users.\n * `destination_payment_method` The PaymentMethod used as the payment instrument for an OutboundTransfer.\n * `destination_payment_method_details` \n * `expected_arrival_date` The date when funds are expected to arrive in the destination account.\n * `financial_account` The FinancialAccount that funds were pulled from.\n * `hosted_regulatory_receipt_url` A [hosted transaction receipt](https://stripe.com/docs/treasury/moving-money/regulatory-receipts) URL that is provided when money movement is considered regulated under Stripe's money transmission licenses.\n * `id` Unique identifier for the object.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `metadata` Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `returned_details` Details about a returned OutboundTransfer. Only set when the status is `returned`.\n * `statement_descriptor` Information about the OutboundTransfer to be sent to the recipient account.\n * `status` Current status of the OutboundTransfer: `processing`, `failed`, `canceled`, `posted`, `returned`. An OutboundTransfer is `processing` if it has been created and is pending. The status changes to `posted` once the OutboundTransfer has been \"confirmed\" and funds have left the account, or to `failed` or `canceled`. If an OutboundTransfer fails to arrive at its destination, its status will change to `returned`.\n * `status_transitions` \n * `transaction` The Transaction associated with this object.\n" + @type t :: %__MODULE__{ + amount: integer, + cancelable: boolean, + created: integer, + currency: binary, + description: binary | nil, + destination_payment_method: binary | nil, + destination_payment_method_details: term, + expected_arrival_date: integer, + financial_account: binary, + hosted_regulatory_receipt_url: binary | nil, + id: binary, + livemode: boolean, + metadata: term, + object: binary, + returned_details: term | nil, + statement_descriptor: binary, + status: binary, + status_transitions: term, + transaction: binary | Stripe.Treasury.Transaction.t() + } + ) + + ( + @typedoc "Hash describing payment method configuration details." + @type destination_payment_method_options :: %{ + optional(:us_bank_account) => us_bank_account | binary + } + ) + + ( + @typedoc "Details about a returned OutboundTransfer." + @type returned_details :: %{ + optional(:code) => + :account_closed + | :account_frozen + | :bank_account_restricted + | :bank_ownership_changed + | :declined + | :incorrect_account_holder_name + | :invalid_account_number + | :invalid_currency + | :no_account + | :other + } + ) + + ( + @typedoc nil + @type us_bank_account :: %{optional(:network) => :ach | :us_domestic_wire} + ) + + ( + nil + + @doc "

Creates an OutboundTransfer.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/treasury/outbound_transfers`\n" + ( + @spec create( + params :: %{ + optional(:amount) => integer, + optional(:currency) => binary, + optional(:description) => binary, + optional(:destination_payment_method) => binary, + optional(:destination_payment_method_options) => + destination_payment_method_options, + optional(:expand) => list(binary), + optional(:financial_account) => binary, + optional(:metadata) => %{optional(binary) => binary}, + optional(:statement_descriptor) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Treasury.OutboundTransfer.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/treasury/outbound_transfers", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves the details of an existing OutboundTransfer by passing the unique OutboundTransfer ID from either the OutboundTransfer creation request or OutboundTransfer list.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/treasury/outbound_transfers/{outbound_transfer}`\n" + ( + @spec retrieve( + outbound_transfer :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Treasury.OutboundTransfer.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def retrieve(outbound_transfer, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/treasury/outbound_transfers/{outbound_transfer}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "outbound_transfer", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "outbound_transfer", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [outbound_transfer] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Returns a list of OutboundTransfers sent from the specified FinancialAccount.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/treasury/outbound_transfers`\n" + ( + @spec list( + params :: %{ + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:financial_account) => binary, + optional(:limit) => integer, + optional(:starting_after) => binary, + optional(:status) => :canceled | :failed | :posted | :processing | :returned + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.Treasury.OutboundTransfer.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/treasury/outbound_transfers", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

An OutboundTransfer can be canceled if the funds have not yet been paid out.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/treasury/outbound_transfers/{outbound_transfer}/cancel`\n" + ( + @spec cancel( + outbound_transfer :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Treasury.OutboundTransfer.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def cancel(outbound_transfer, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/treasury/outbound_transfers/{outbound_transfer}/cancel", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "outbound_transfer", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "outbound_transfer", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [outbound_transfer] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Transitions a test mode created OutboundTransfer to the failed status. The OutboundTransfer must already be in the processing state.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/test_helpers/treasury/outbound_transfers/{outbound_transfer}/fail`\n" + ( + @spec fail( + outbound_transfer :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Treasury.OutboundTransfer.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def fail(outbound_transfer, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/test_helpers/treasury/outbound_transfers/{outbound_transfer}/fail", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "outbound_transfer", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "outbound_transfer", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [outbound_transfer] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Transitions a test mode created OutboundTransfer to the posted status. The OutboundTransfer must already be in the processing state.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/test_helpers/treasury/outbound_transfers/{outbound_transfer}/post`\n" + ( + @spec post( + outbound_transfer :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Treasury.OutboundTransfer.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def post(outbound_transfer, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/test_helpers/treasury/outbound_transfers/{outbound_transfer}/post", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "outbound_transfer", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "outbound_transfer", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [outbound_transfer] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Transitions a test mode created OutboundTransfer to the returned status. The OutboundTransfer must already be in the processing state.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/test_helpers/treasury/outbound_transfers/{outbound_transfer}/return`\n" + ( + @spec return_outbound_transfer( + outbound_transfer :: binary(), + params :: %{ + optional(:expand) => list(binary), + optional(:returned_details) => returned_details + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Treasury.OutboundTransfer.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def return_outbound_transfer(outbound_transfer, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/test_helpers/treasury/outbound_transfers/{outbound_transfer}/return", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "outbound_transfer", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "outbound_transfer", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [outbound_transfer] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/treasury__received_credit.ex b/lib/generated/treasury__received_credit.ex new file mode 100644 index 00000000..c0183fba --- /dev/null +++ b/lib/generated/treasury__received_credit.ex @@ -0,0 +1,182 @@ +defmodule Stripe.Treasury.ReceivedCredit do + use Stripe.Entity + + @moduledoc "ReceivedCredits represent funds sent to a [FinancialAccount](https://stripe.com/docs/api#financial_accounts) (for example, via ACH or wire). These money movements are not initiated from the FinancialAccount." + ( + defstruct [ + :amount, + :created, + :currency, + :description, + :failure_code, + :financial_account, + :hosted_regulatory_receipt_url, + :id, + :initiating_payment_method_details, + :linked_flows, + :livemode, + :network, + :object, + :reversal_details, + :status, + :transaction + ] + + @typedoc "The `treasury.received_credit` type.\n\n * `amount` Amount (in cents) transferred.\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `currency` Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).\n * `description` An arbitrary string attached to the object. Often useful for displaying to users.\n * `failure_code` Reason for the failure. A ReceivedCredit might fail because the receiving FinancialAccount is closed or frozen.\n * `financial_account` The FinancialAccount that received the funds.\n * `hosted_regulatory_receipt_url` A [hosted transaction receipt](https://stripe.com/docs/treasury/moving-money/regulatory-receipts) URL that is provided when money movement is considered regulated under Stripe's money transmission licenses.\n * `id` Unique identifier for the object.\n * `initiating_payment_method_details` \n * `linked_flows` \n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `network` The rails used to send the funds.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `reversal_details` Details describing when a ReceivedCredit may be reversed.\n * `status` Status of the ReceivedCredit. ReceivedCredits are created either `succeeded` (approved) or `failed` (declined). If a ReceivedCredit is declined, the failure reason can be found in the `failure_code` field.\n * `transaction` The Transaction associated with this object.\n" + @type t :: %__MODULE__{ + amount: integer, + created: integer, + currency: binary, + description: binary, + failure_code: binary | nil, + financial_account: binary | nil, + hosted_regulatory_receipt_url: binary | nil, + id: binary, + initiating_payment_method_details: term, + linked_flows: term, + livemode: boolean, + network: binary, + object: binary, + reversal_details: term | nil, + status: binary, + transaction: (binary | Stripe.Treasury.Transaction.t()) | nil + } + ) + + ( + @typedoc "Initiating payment method details for the object." + @type initiating_payment_method_details :: %{ + optional(:type) => :us_bank_account, + optional(:us_bank_account) => us_bank_account + } + ) + + ( + @typedoc nil + @type linked_flows :: %{ + optional(:source_flow_type) => :credit_reversal | :other | :outbound_payment | :payout + } + ) + + ( + @typedoc "Optional fields for `us_bank_account`." + @type us_bank_account :: %{ + optional(:account_holder_name) => binary, + optional(:account_number) => binary, + optional(:routing_number) => binary + } + ) + + ( + nil + + @doc "

Returns a list of ReceivedCredits.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/treasury/received_credits`\n" + ( + @spec list( + params :: %{ + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:financial_account) => binary, + optional(:limit) => integer, + optional(:linked_flows) => linked_flows, + optional(:starting_after) => binary, + optional(:status) => :failed | :succeeded + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.Treasury.ReceivedCredit.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/treasury/received_credits", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves the details of an existing ReceivedCredit by passing the unique ReceivedCredit ID from the ReceivedCredit list.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/treasury/received_credits/{id}`\n" + ( + @spec retrieve( + id :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Treasury.ReceivedCredit.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def retrieve(id, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/treasury/received_credits/{id}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "id", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "id", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [id] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Use this endpoint to simulate a test mode ReceivedCredit initiated by a third party. In live mode, you can’t directly create ReceivedCredits initiated by third parties.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/test_helpers/treasury/received_credits`\n" + ( + @spec create( + params :: %{ + optional(:amount) => integer, + optional(:currency) => binary, + optional(:description) => binary, + optional(:expand) => list(binary), + optional(:financial_account) => binary, + optional(:initiating_payment_method_details) => initiating_payment_method_details, + optional(:network) => :ach | :us_domestic_wire + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Treasury.ReceivedCredit.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/test_helpers/treasury/received_credits", + [], + [] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/treasury__received_debit.ex b/lib/generated/treasury__received_debit.ex new file mode 100644 index 00000000..71ed5d0d --- /dev/null +++ b/lib/generated/treasury__received_debit.ex @@ -0,0 +1,174 @@ +defmodule Stripe.Treasury.ReceivedDebit do + use Stripe.Entity + + @moduledoc "ReceivedDebits represent funds pulled from a [FinancialAccount](https://stripe.com/docs/api#financial_accounts). These are not initiated from the FinancialAccount." + ( + defstruct [ + :amount, + :created, + :currency, + :description, + :failure_code, + :financial_account, + :hosted_regulatory_receipt_url, + :id, + :initiating_payment_method_details, + :linked_flows, + :livemode, + :network, + :object, + :reversal_details, + :status, + :transaction + ] + + @typedoc "The `treasury.received_debit` type.\n\n * `amount` Amount (in cents) transferred.\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `currency` Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).\n * `description` An arbitrary string attached to the object. Often useful for displaying to users.\n * `failure_code` Reason for the failure. A ReceivedDebit might fail because the FinancialAccount doesn't have sufficient funds, is closed, or is frozen.\n * `financial_account` The FinancialAccount that funds were pulled from.\n * `hosted_regulatory_receipt_url` A [hosted transaction receipt](https://stripe.com/docs/treasury/moving-money/regulatory-receipts) URL that is provided when money movement is considered regulated under Stripe's money transmission licenses.\n * `id` Unique identifier for the object.\n * `initiating_payment_method_details` \n * `linked_flows` \n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `network` The network used for the ReceivedDebit.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `reversal_details` Details describing when a ReceivedDebit might be reversed.\n * `status` Status of the ReceivedDebit. ReceivedDebits are created with a status of either `succeeded` (approved) or `failed` (declined). The failure reason can be found under the `failure_code`.\n * `transaction` The Transaction associated with this object.\n" + @type t :: %__MODULE__{ + amount: integer, + created: integer, + currency: binary, + description: binary, + failure_code: binary | nil, + financial_account: binary | nil, + hosted_regulatory_receipt_url: binary | nil, + id: binary, + initiating_payment_method_details: term, + linked_flows: term, + livemode: boolean, + network: binary, + object: binary, + reversal_details: term | nil, + status: binary, + transaction: (binary | Stripe.Treasury.Transaction.t()) | nil + } + ) + + ( + @typedoc "Initiating payment method details for the object." + @type initiating_payment_method_details :: %{ + optional(:type) => :us_bank_account, + optional(:us_bank_account) => us_bank_account + } + ) + + ( + @typedoc "Optional fields for `us_bank_account`." + @type us_bank_account :: %{ + optional(:account_holder_name) => binary, + optional(:account_number) => binary, + optional(:routing_number) => binary + } + ) + + ( + nil + + @doc "

Returns a list of ReceivedDebits.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/treasury/received_debits`\n" + ( + @spec list( + params :: %{ + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:financial_account) => binary, + optional(:limit) => integer, + optional(:starting_after) => binary, + optional(:status) => :failed | :succeeded + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.Treasury.ReceivedDebit.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/treasury/received_debits", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves the details of an existing ReceivedDebit by passing the unique ReceivedDebit ID from the ReceivedDebit list

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/treasury/received_debits/{id}`\n" + ( + @spec retrieve( + id :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Treasury.ReceivedDebit.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def retrieve(id, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/treasury/received_debits/{id}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "id", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "id", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [id] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Use this endpoint to simulate a test mode ReceivedDebit initiated by a third party. In live mode, you can’t directly create ReceivedDebits initiated by third parties.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/test_helpers/treasury/received_debits`\n" + ( + @spec create( + params :: %{ + optional(:amount) => integer, + optional(:currency) => binary, + optional(:description) => binary, + optional(:expand) => list(binary), + optional(:financial_account) => binary, + optional(:initiating_payment_method_details) => initiating_payment_method_details, + optional(:network) => :ach + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Treasury.ReceivedDebit.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/test_helpers/treasury/received_debits", + [], + [] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/treasury__transaction.ex b/lib/generated/treasury__transaction.ex new file mode 100644 index 00000000..a11b8f3c --- /dev/null +++ b/lib/generated/treasury__transaction.ex @@ -0,0 +1,146 @@ +defmodule Stripe.Treasury.Transaction do + use Stripe.Entity + + @moduledoc "Transactions represent changes to a [FinancialAccount's](https://stripe.com/docs/api#financial_accounts) balance." + ( + defstruct [ + :amount, + :balance_impact, + :created, + :currency, + :description, + :entries, + :financial_account, + :flow, + :flow_details, + :flow_type, + :id, + :livemode, + :object, + :status, + :status_transitions + ] + + @typedoc "The `treasury.transaction` type.\n\n * `amount` Amount (in cents) transferred.\n * `balance_impact` \n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `currency` Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).\n * `description` An arbitrary string attached to the object. Often useful for displaying to users.\n * `entries` A list of TransactionEntries that are part of this Transaction. This cannot be expanded in any list endpoints.\n * `financial_account` The FinancialAccount associated with this object.\n * `flow` ID of the flow that created the Transaction.\n * `flow_details` Details of the flow that created the Transaction.\n * `flow_type` Type of the flow that created the Transaction.\n * `id` Unique identifier for the object.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `status` Status of the Transaction.\n * `status_transitions` \n" + @type t :: %__MODULE__{ + amount: integer, + balance_impact: term, + created: integer, + currency: binary, + description: binary, + entries: term | nil, + financial_account: binary, + flow: binary | nil, + flow_details: term | nil, + flow_type: binary, + id: binary, + livemode: boolean, + object: binary, + status: binary, + status_transitions: term + } + ) + + ( + @typedoc nil + @type created :: %{ + optional(:gt) => integer, + optional(:gte) => integer, + optional(:lt) => integer, + optional(:lte) => integer + } + ) + + ( + @typedoc nil + @type posted_at :: %{ + optional(:gt) => integer, + optional(:gte) => integer, + optional(:lt) => integer, + optional(:lte) => integer + } + ) + + ( + @typedoc nil + @type status_transitions :: %{optional(:posted_at) => posted_at | integer} + ) + + ( + nil + + @doc "

Retrieves the details of an existing Transaction.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/treasury/transactions/{id}`\n" + ( + @spec retrieve( + id :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Treasury.Transaction.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def retrieve(id, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/treasury/transactions/{id}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "id", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "id", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [id] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves a list of Transaction objects.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/treasury/transactions`\n" + ( + @spec list( + params :: %{ + optional(:created) => created | integer, + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:financial_account) => binary, + optional(:limit) => integer, + optional(:order_by) => :created | :posted_at, + optional(:starting_after) => binary, + optional(:status) => :open | :posted | :void, + optional(:status_transitions) => status_transitions + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.Treasury.Transaction.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/treasury/transactions", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/treasury__transaction_entry.ex b/lib/generated/treasury__transaction_entry.ex new file mode 100644 index 00000000..cf9441f2 --- /dev/null +++ b/lib/generated/treasury__transaction_entry.ex @@ -0,0 +1,137 @@ +defmodule Stripe.Treasury.TransactionEntry do + use Stripe.Entity + + @moduledoc "TransactionEntries represent individual units of money movements within a single [Transaction](https://stripe.com/docs/api#transactions)." + ( + defstruct [ + :balance_impact, + :created, + :currency, + :effective_at, + :financial_account, + :flow, + :flow_details, + :flow_type, + :id, + :livemode, + :object, + :transaction, + :type + ] + + @typedoc "The `treasury.transaction_entry` type.\n\n * `balance_impact` \n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `currency` Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).\n * `effective_at` When the TransactionEntry will impact the FinancialAccount's balance.\n * `financial_account` The FinancialAccount associated with this object.\n * `flow` Token of the flow associated with the TransactionEntry.\n * `flow_details` Details of the flow associated with the TransactionEntry.\n * `flow_type` Type of the flow associated with the TransactionEntry.\n * `id` Unique identifier for the object.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `transaction` The Transaction associated with this object.\n * `type` The specific money movement that generated the TransactionEntry.\n" + @type t :: %__MODULE__{ + balance_impact: term, + created: integer, + currency: binary, + effective_at: integer, + financial_account: binary, + flow: binary | nil, + flow_details: term | nil, + flow_type: binary, + id: binary, + livemode: boolean, + object: binary, + transaction: binary | Stripe.Treasury.Transaction.t(), + type: binary + } + ) + + ( + @typedoc nil + @type created :: %{ + optional(:gt) => integer, + optional(:gte) => integer, + optional(:lt) => integer, + optional(:lte) => integer + } + ) + + ( + @typedoc nil + @type effective_at :: %{ + optional(:gt) => integer, + optional(:gte) => integer, + optional(:lt) => integer, + optional(:lte) => integer + } + ) + + ( + nil + + @doc "

Retrieves a TransactionEntry object.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/treasury/transaction_entries/{id}`\n" + ( + @spec retrieve( + id :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.Treasury.TransactionEntry.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def retrieve(id, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/treasury/transaction_entries/{id}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "id", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "id", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [id] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves a list of TransactionEntry objects.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/treasury/transaction_entries`\n" + ( + @spec list( + params :: %{ + optional(:created) => created | integer, + optional(:effective_at) => effective_at | integer, + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:financial_account) => binary, + optional(:limit) => integer, + optional(:order_by) => :created | :effective_at, + optional(:starting_after) => binary, + optional(:transaction) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.Treasury.TransactionEntry.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/treasury/transaction_entries", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/usage_record.ex b/lib/generated/usage_record.ex new file mode 100644 index 00000000..593f085b --- /dev/null +++ b/lib/generated/usage_record.ex @@ -0,0 +1,64 @@ +defmodule Stripe.UsageRecord do + use Stripe.Entity + + @moduledoc "Usage records allow you to report customer usage and metrics to Stripe for\nmetered billing of subscription prices.\n\nRelated guide: [Metered billing](https://stripe.com/docs/billing/subscriptions/metered-billing)" + ( + defstruct [:id, :livemode, :object, :quantity, :subscription_item, :timestamp] + + @typedoc "The `usage_record` type.\n\n * `id` Unique identifier for the object.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `quantity` The usage quantity for the specified date.\n * `subscription_item` The ID of the subscription item this usage record contains data for.\n * `timestamp` The timestamp when this usage occurred.\n" + @type t :: %__MODULE__{ + id: binary, + livemode: boolean, + object: binary, + quantity: integer, + subscription_item: binary, + timestamp: integer + } + ) + + ( + nil + + @doc "

Creates a usage record for a specified subscription item and date, and fills it with a quantity.

\n\n

Usage records provide quantity information that Stripe uses to track how much a customer is using your service. With usage information and the pricing model set up by the metered billing plan, Stripe helps you send accurate invoices to your customers.

\n\n

The default calculation for usage is to add up all the quantity values of the usage records within a billing period. You can change this default behavior with the billing plan’s aggregate_usage parameter. When there is more than one usage record with the same timestamp, Stripe adds the quantity values together. In most cases, this is the desired resolution, however, you can change this behavior with the action parameter.

\n\n

The default pricing model for metered billing is per-unit pricing. For finer granularity, you can configure metered billing to have a tiered pricing model.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/subscription_items/{subscription_item}/usage_records`\n" + ( + @spec create( + subscription_item :: binary(), + params :: %{ + optional(:action) => :increment | :set, + optional(:expand) => list(binary), + optional(:quantity) => integer, + optional(:timestamp) => :now | integer + }, + opts :: Keyword.t() + ) :: {:ok, Stripe.UsageRecord.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()} + def create(subscription_item, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/subscription_items/{subscription_item}/usage_records", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "subscription_item", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "subscription_item", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [subscription_item] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/usage_record_summary.ex b/lib/generated/usage_record_summary.ex new file mode 100644 index 00000000..4f05a957 --- /dev/null +++ b/lib/generated/usage_record_summary.ex @@ -0,0 +1,67 @@ +defmodule Stripe.UsageRecordSummary do + use Stripe.Entity + @moduledoc "" + ( + defstruct [:id, :invoice, :livemode, :object, :period, :subscription_item, :total_usage] + + @typedoc "The `usage_record_summary` type.\n\n * `id` Unique identifier for the object.\n * `invoice` The invoice in which this usage period has been billed for.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `period` \n * `subscription_item` The ID of the subscription item this summary is describing.\n * `total_usage` The total usage within this usage period.\n" + @type t :: %__MODULE__{ + id: binary, + invoice: binary | nil, + livemode: boolean, + object: binary, + period: term, + subscription_item: binary, + total_usage: integer + } + ) + + ( + nil + + @doc "

For the specified subscription item, returns a list of summary objects. Each object in the list provides usage information that’s been summarized from multiple usage records and over a subscription billing period (e.g., 15 usage records in the month of September).

\n\n

The list is sorted in reverse-chronological order (newest first). The first list item represents the most current usage period that hasn’t ended yet. Since new usage records can still be added, the returned summary information for the subscription item’s ID should be seen as unstable until the subscription billing period ends.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/subscription_items/{subscription_item}/usage_record_summaries`\n" + ( + @spec list( + subscription_item :: binary(), + params :: %{ + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.UsageRecordSummary.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(subscription_item, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/subscription_items/{subscription_item}/usage_record_summaries", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "subscription_item", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "subscription_item", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [subscription_item] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/generated/webhook_endpoint.ex b/lib/generated/webhook_endpoint.ex new file mode 100644 index 00000000..683aa747 --- /dev/null +++ b/lib/generated/webhook_endpoint.ex @@ -0,0 +1,782 @@ +defmodule Stripe.WebhookEndpoint do + use Stripe.Entity + + @moduledoc "You can configure [webhook endpoints](https://stripe.com/docs/webhooks/) via the API to be\nnotified about events that happen in your Stripe account or connected\naccounts.\n\nMost users configure webhooks from [the dashboard](https://dashboard.stripe.com/webhooks), which provides a user interface for registering and testing your webhook endpoints.\n\nRelated guide: [Setting up webhooks](https://stripe.com/docs/webhooks/configure)" + ( + defstruct [ + :api_version, + :application, + :created, + :description, + :enabled_events, + :id, + :livemode, + :metadata, + :object, + :secret, + :status, + :url + ] + + @typedoc "The `webhook_endpoint` type.\n\n * `api_version` The API version events are rendered as for this webhook endpoint.\n * `application` The ID of the associated Connect application.\n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `description` An optional description of what the webhook is used for.\n * `enabled_events` The list of events to enable for this endpoint. `['*']` indicates that all events are enabled, except those that require explicit selection.\n * `id` Unique identifier for the object.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `metadata` Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.\n * `object` String representing the object's type. Objects of the same type share the same value.\n * `secret` The endpoint's secret, used to generate [webhook signatures](https://stripe.com/docs/webhooks/signatures). Only returned at creation.\n * `status` The status of the webhook. It can be `enabled` or `disabled`.\n * `url` The URL of the webhook endpoint.\n" + @type t :: %__MODULE__{ + api_version: binary | nil, + application: binary | nil, + created: integer, + description: binary | nil, + enabled_events: term, + id: binary, + livemode: boolean, + metadata: term, + object: binary, + secret: binary, + status: binary, + url: binary + } + ) + + ( + nil + + @doc "

Returns a list of your webhook endpoints.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/webhook_endpoints`\n" + ( + @spec list( + params :: %{ + optional(:ending_before) => binary, + optional(:expand) => list(binary), + optional(:limit) => integer, + optional(:starting_after) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.List.t(Stripe.WebhookEndpoint.t())} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def list(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/webhook_endpoints", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Retrieves the webhook endpoint with the given ID.

\n\n#### Details\n\n * Method: `get`\n * Path: `/v1/webhook_endpoints/{webhook_endpoint}`\n" + ( + @spec retrieve( + webhook_endpoint :: binary(), + params :: %{optional(:expand) => list(binary)}, + opts :: Keyword.t() + ) :: + {:ok, Stripe.WebhookEndpoint.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def retrieve(webhook_endpoint, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/webhook_endpoints/{webhook_endpoint}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "webhook_endpoint", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "webhook_endpoint", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [webhook_endpoint] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:get) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

A webhook endpoint must have a url and a list of enabled_events. You may optionally specify the Boolean connect parameter. If set to true, then a Connect webhook endpoint that notifies the specified url about events from all connected accounts is created; otherwise an account webhook endpoint that notifies the specified url only about events from your account is created. You can also create webhook endpoints in the webhooks settings section of the Dashboard.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/webhook_endpoints`\n" + ( + @spec create( + params :: %{ + optional(:api_version) => + :"2011-01-01" + | :"2011-06-21" + | :"2011-06-28" + | :"2011-08-01" + | :"2011-09-15" + | :"2011-11-17" + | :"2012-02-23" + | :"2012-03-25" + | :"2012-06-18" + | :"2012-06-28" + | :"2012-07-09" + | :"2012-09-24" + | :"2012-10-26" + | :"2012-11-07" + | :"2013-02-11" + | :"2013-02-13" + | :"2013-07-05" + | :"2013-08-12" + | :"2013-08-13" + | :"2013-10-29" + | :"2013-12-03" + | :"2014-01-31" + | :"2014-03-13" + | :"2014-03-28" + | :"2014-05-19" + | :"2014-06-13" + | :"2014-06-17" + | :"2014-07-22" + | :"2014-07-26" + | :"2014-08-04" + | :"2014-08-20" + | :"2014-09-08" + | :"2014-10-07" + | :"2014-11-05" + | :"2014-11-20" + | :"2014-12-08" + | :"2014-12-17" + | :"2014-12-22" + | :"2015-01-11" + | :"2015-01-26" + | :"2015-02-10" + | :"2015-02-16" + | :"2015-02-18" + | :"2015-03-24" + | :"2015-04-07" + | :"2015-06-15" + | :"2015-07-07" + | :"2015-07-13" + | :"2015-07-28" + | :"2015-08-07" + | :"2015-08-19" + | :"2015-09-03" + | :"2015-09-08" + | :"2015-09-23" + | :"2015-10-01" + | :"2015-10-12" + | :"2015-10-16" + | :"2016-02-03" + | :"2016-02-19" + | :"2016-02-22" + | :"2016-02-23" + | :"2016-02-29" + | :"2016-03-07" + | :"2016-06-15" + | :"2016-07-06" + | :"2016-10-19" + | :"2017-01-27" + | :"2017-02-14" + | :"2017-04-06" + | :"2017-05-25" + | :"2017-06-05" + | :"2017-08-15" + | :"2017-12-14" + | :"2018-01-23" + | :"2018-02-05" + | :"2018-02-06" + | :"2018-02-28" + | :"2018-05-21" + | :"2018-07-27" + | :"2018-08-23" + | :"2018-09-06" + | :"2018-09-24" + | :"2018-10-31" + | :"2018-11-08" + | :"2019-02-11" + | :"2019-02-19" + | :"2019-03-14" + | :"2019-05-16" + | :"2019-08-14" + | :"2019-09-09" + | :"2019-10-08" + | :"2019-10-17" + | :"2019-11-05" + | :"2019-12-03" + | :"2020-03-02" + | :"2020-08-27" + | :"2022-08-01" + | :"2022-11-15", + optional(:connect) => boolean, + optional(:description) => binary, + optional(:enabled_events) => + list( + :* + | :"account.application.authorized" + | :"account.application.deauthorized" + | :"account.external_account.created" + | :"account.external_account.deleted" + | :"account.external_account.updated" + | :"account.updated" + | :"application_fee.created" + | :"application_fee.refund.updated" + | :"application_fee.refunded" + | :"balance.available" + | :"billing_portal.configuration.created" + | :"billing_portal.configuration.updated" + | :"billing_portal.session.created" + | :"capability.updated" + | :"cash_balance.funds_available" + | :"charge.captured" + | :"charge.dispute.closed" + | :"charge.dispute.created" + | :"charge.dispute.funds_reinstated" + | :"charge.dispute.funds_withdrawn" + | :"charge.dispute.updated" + | :"charge.expired" + | :"charge.failed" + | :"charge.pending" + | :"charge.refund.updated" + | :"charge.refunded" + | :"charge.succeeded" + | :"charge.updated" + | :"checkout.session.async_payment_failed" + | :"checkout.session.async_payment_succeeded" + | :"checkout.session.completed" + | :"checkout.session.expired" + | :"coupon.created" + | :"coupon.deleted" + | :"coupon.updated" + | :"credit_note.created" + | :"credit_note.updated" + | :"credit_note.voided" + | :"customer.created" + | :"customer.deleted" + | :"customer.discount.created" + | :"customer.discount.deleted" + | :"customer.discount.updated" + | :"customer.source.created" + | :"customer.source.deleted" + | :"customer.source.expiring" + | :"customer.source.updated" + | :"customer.subscription.created" + | :"customer.subscription.deleted" + | :"customer.subscription.paused" + | :"customer.subscription.pending_update_applied" + | :"customer.subscription.pending_update_expired" + | :"customer.subscription.resumed" + | :"customer.subscription.trial_will_end" + | :"customer.subscription.updated" + | :"customer.tax_id.created" + | :"customer.tax_id.deleted" + | :"customer.tax_id.updated" + | :"customer.updated" + | :"customer_cash_balance_transaction.created" + | :"file.created" + | :"financial_connections.account.created" + | :"financial_connections.account.deactivated" + | :"financial_connections.account.disconnected" + | :"financial_connections.account.reactivated" + | :"financial_connections.account.refreshed_balance" + | :"identity.verification_session.canceled" + | :"identity.verification_session.created" + | :"identity.verification_session.processing" + | :"identity.verification_session.redacted" + | :"identity.verification_session.requires_input" + | :"identity.verification_session.verified" + | :"invoice.created" + | :"invoice.deleted" + | :"invoice.finalization_failed" + | :"invoice.finalized" + | :"invoice.marked_uncollectible" + | :"invoice.paid" + | :"invoice.payment_action_required" + | :"invoice.payment_failed" + | :"invoice.payment_succeeded" + | :"invoice.sent" + | :"invoice.upcoming" + | :"invoice.updated" + | :"invoice.voided" + | :"invoiceitem.created" + | :"invoiceitem.deleted" + | :"invoiceitem.updated" + | :"issuing_authorization.created" + | :"issuing_authorization.request" + | :"issuing_authorization.updated" + | :"issuing_card.created" + | :"issuing_card.updated" + | :"issuing_cardholder.created" + | :"issuing_cardholder.updated" + | :"issuing_dispute.closed" + | :"issuing_dispute.created" + | :"issuing_dispute.funds_reinstated" + | :"issuing_dispute.submitted" + | :"issuing_dispute.updated" + | :"issuing_transaction.created" + | :"issuing_transaction.updated" + | :"mandate.updated" + | :"order.created" + | :"payment_intent.amount_capturable_updated" + | :"payment_intent.canceled" + | :"payment_intent.created" + | :"payment_intent.partially_funded" + | :"payment_intent.payment_failed" + | :"payment_intent.processing" + | :"payment_intent.requires_action" + | :"payment_intent.succeeded" + | :"payment_link.created" + | :"payment_link.updated" + | :"payment_method.attached" + | :"payment_method.automatically_updated" + | :"payment_method.detached" + | :"payment_method.updated" + | :"payout.canceled" + | :"payout.created" + | :"payout.failed" + | :"payout.paid" + | :"payout.reconciliation_completed" + | :"payout.updated" + | :"person.created" + | :"person.deleted" + | :"person.updated" + | :"plan.created" + | :"plan.deleted" + | :"plan.updated" + | :"price.created" + | :"price.deleted" + | :"price.updated" + | :"product.created" + | :"product.deleted" + | :"product.updated" + | :"promotion_code.created" + | :"promotion_code.updated" + | :"quote.accepted" + | :"quote.canceled" + | :"quote.created" + | :"quote.finalized" + | :"radar.early_fraud_warning.created" + | :"radar.early_fraud_warning.updated" + | :"recipient.created" + | :"recipient.deleted" + | :"recipient.updated" + | :"refund.created" + | :"refund.updated" + | :"reporting.report_run.failed" + | :"reporting.report_run.succeeded" + | :"reporting.report_type.updated" + | :"review.closed" + | :"review.opened" + | :"setup_intent.canceled" + | :"setup_intent.created" + | :"setup_intent.requires_action" + | :"setup_intent.setup_failed" + | :"setup_intent.succeeded" + | :"sigma.scheduled_query_run.created" + | :"sku.created" + | :"sku.deleted" + | :"sku.updated" + | :"source.canceled" + | :"source.chargeable" + | :"source.failed" + | :"source.mandate_notification" + | :"source.refund_attributes_required" + | :"source.transaction.created" + | :"source.transaction.updated" + | :"subscription_schedule.aborted" + | :"subscription_schedule.canceled" + | :"subscription_schedule.completed" + | :"subscription_schedule.created" + | :"subscription_schedule.expiring" + | :"subscription_schedule.released" + | :"subscription_schedule.updated" + | :"tax.settings.updated" + | :"tax_rate.created" + | :"tax_rate.updated" + | :"terminal.reader.action_failed" + | :"terminal.reader.action_succeeded" + | :"test_helpers.test_clock.advancing" + | :"test_helpers.test_clock.created" + | :"test_helpers.test_clock.deleted" + | :"test_helpers.test_clock.internal_failure" + | :"test_helpers.test_clock.ready" + | :"topup.canceled" + | :"topup.created" + | :"topup.failed" + | :"topup.reversed" + | :"topup.succeeded" + | :"transfer.created" + | :"transfer.reversed" + | :"transfer.updated" + | :"treasury.credit_reversal.created" + | :"treasury.credit_reversal.posted" + | :"treasury.debit_reversal.completed" + | :"treasury.debit_reversal.created" + | :"treasury.debit_reversal.initial_credit_granted" + | :"treasury.financial_account.closed" + | :"treasury.financial_account.created" + | :"treasury.financial_account.features_status_updated" + | :"treasury.inbound_transfer.canceled" + | :"treasury.inbound_transfer.created" + | :"treasury.inbound_transfer.failed" + | :"treasury.inbound_transfer.succeeded" + | :"treasury.outbound_payment.canceled" + | :"treasury.outbound_payment.created" + | :"treasury.outbound_payment.expected_arrival_date_updated" + | :"treasury.outbound_payment.failed" + | :"treasury.outbound_payment.posted" + | :"treasury.outbound_payment.returned" + | :"treasury.outbound_transfer.canceled" + | :"treasury.outbound_transfer.created" + | :"treasury.outbound_transfer.expected_arrival_date_updated" + | :"treasury.outbound_transfer.failed" + | :"treasury.outbound_transfer.posted" + | :"treasury.outbound_transfer.returned" + | :"treasury.received_credit.created" + | :"treasury.received_credit.failed" + | :"treasury.received_credit.succeeded" + | :"treasury.received_debit.created" + ), + optional(:expand) => list(binary), + optional(:metadata) => %{optional(binary) => binary} | binary, + optional(:url) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.WebhookEndpoint.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def create(params \\ %{}, opts \\ []) do + path = Stripe.OpenApi.Path.replace_path_params("/v1/webhook_endpoints", [], []) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

Updates the webhook endpoint. You may edit the url, the list of enabled_events, and the status of your endpoint.

\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/webhook_endpoints/{webhook_endpoint}`\n" + ( + @spec update( + webhook_endpoint :: binary(), + params :: %{ + optional(:description) => binary, + optional(:disabled) => boolean, + optional(:enabled_events) => + list( + :* + | :"account.application.authorized" + | :"account.application.deauthorized" + | :"account.external_account.created" + | :"account.external_account.deleted" + | :"account.external_account.updated" + | :"account.updated" + | :"application_fee.created" + | :"application_fee.refund.updated" + | :"application_fee.refunded" + | :"balance.available" + | :"billing_portal.configuration.created" + | :"billing_portal.configuration.updated" + | :"billing_portal.session.created" + | :"capability.updated" + | :"cash_balance.funds_available" + | :"charge.captured" + | :"charge.dispute.closed" + | :"charge.dispute.created" + | :"charge.dispute.funds_reinstated" + | :"charge.dispute.funds_withdrawn" + | :"charge.dispute.updated" + | :"charge.expired" + | :"charge.failed" + | :"charge.pending" + | :"charge.refund.updated" + | :"charge.refunded" + | :"charge.succeeded" + | :"charge.updated" + | :"checkout.session.async_payment_failed" + | :"checkout.session.async_payment_succeeded" + | :"checkout.session.completed" + | :"checkout.session.expired" + | :"coupon.created" + | :"coupon.deleted" + | :"coupon.updated" + | :"credit_note.created" + | :"credit_note.updated" + | :"credit_note.voided" + | :"customer.created" + | :"customer.deleted" + | :"customer.discount.created" + | :"customer.discount.deleted" + | :"customer.discount.updated" + | :"customer.source.created" + | :"customer.source.deleted" + | :"customer.source.expiring" + | :"customer.source.updated" + | :"customer.subscription.created" + | :"customer.subscription.deleted" + | :"customer.subscription.paused" + | :"customer.subscription.pending_update_applied" + | :"customer.subscription.pending_update_expired" + | :"customer.subscription.resumed" + | :"customer.subscription.trial_will_end" + | :"customer.subscription.updated" + | :"customer.tax_id.created" + | :"customer.tax_id.deleted" + | :"customer.tax_id.updated" + | :"customer.updated" + | :"customer_cash_balance_transaction.created" + | :"file.created" + | :"financial_connections.account.created" + | :"financial_connections.account.deactivated" + | :"financial_connections.account.disconnected" + | :"financial_connections.account.reactivated" + | :"financial_connections.account.refreshed_balance" + | :"identity.verification_session.canceled" + | :"identity.verification_session.created" + | :"identity.verification_session.processing" + | :"identity.verification_session.redacted" + | :"identity.verification_session.requires_input" + | :"identity.verification_session.verified" + | :"invoice.created" + | :"invoice.deleted" + | :"invoice.finalization_failed" + | :"invoice.finalized" + | :"invoice.marked_uncollectible" + | :"invoice.paid" + | :"invoice.payment_action_required" + | :"invoice.payment_failed" + | :"invoice.payment_succeeded" + | :"invoice.sent" + | :"invoice.upcoming" + | :"invoice.updated" + | :"invoice.voided" + | :"invoiceitem.created" + | :"invoiceitem.deleted" + | :"invoiceitem.updated" + | :"issuing_authorization.created" + | :"issuing_authorization.request" + | :"issuing_authorization.updated" + | :"issuing_card.created" + | :"issuing_card.updated" + | :"issuing_cardholder.created" + | :"issuing_cardholder.updated" + | :"issuing_dispute.closed" + | :"issuing_dispute.created" + | :"issuing_dispute.funds_reinstated" + | :"issuing_dispute.submitted" + | :"issuing_dispute.updated" + | :"issuing_transaction.created" + | :"issuing_transaction.updated" + | :"mandate.updated" + | :"order.created" + | :"payment_intent.amount_capturable_updated" + | :"payment_intent.canceled" + | :"payment_intent.created" + | :"payment_intent.partially_funded" + | :"payment_intent.payment_failed" + | :"payment_intent.processing" + | :"payment_intent.requires_action" + | :"payment_intent.succeeded" + | :"payment_link.created" + | :"payment_link.updated" + | :"payment_method.attached" + | :"payment_method.automatically_updated" + | :"payment_method.detached" + | :"payment_method.updated" + | :"payout.canceled" + | :"payout.created" + | :"payout.failed" + | :"payout.paid" + | :"payout.reconciliation_completed" + | :"payout.updated" + | :"person.created" + | :"person.deleted" + | :"person.updated" + | :"plan.created" + | :"plan.deleted" + | :"plan.updated" + | :"price.created" + | :"price.deleted" + | :"price.updated" + | :"product.created" + | :"product.deleted" + | :"product.updated" + | :"promotion_code.created" + | :"promotion_code.updated" + | :"quote.accepted" + | :"quote.canceled" + | :"quote.created" + | :"quote.finalized" + | :"radar.early_fraud_warning.created" + | :"radar.early_fraud_warning.updated" + | :"recipient.created" + | :"recipient.deleted" + | :"recipient.updated" + | :"refund.created" + | :"refund.updated" + | :"reporting.report_run.failed" + | :"reporting.report_run.succeeded" + | :"reporting.report_type.updated" + | :"review.closed" + | :"review.opened" + | :"setup_intent.canceled" + | :"setup_intent.created" + | :"setup_intent.requires_action" + | :"setup_intent.setup_failed" + | :"setup_intent.succeeded" + | :"sigma.scheduled_query_run.created" + | :"sku.created" + | :"sku.deleted" + | :"sku.updated" + | :"source.canceled" + | :"source.chargeable" + | :"source.failed" + | :"source.mandate_notification" + | :"source.refund_attributes_required" + | :"source.transaction.created" + | :"source.transaction.updated" + | :"subscription_schedule.aborted" + | :"subscription_schedule.canceled" + | :"subscription_schedule.completed" + | :"subscription_schedule.created" + | :"subscription_schedule.expiring" + | :"subscription_schedule.released" + | :"subscription_schedule.updated" + | :"tax.settings.updated" + | :"tax_rate.created" + | :"tax_rate.updated" + | :"terminal.reader.action_failed" + | :"terminal.reader.action_succeeded" + | :"test_helpers.test_clock.advancing" + | :"test_helpers.test_clock.created" + | :"test_helpers.test_clock.deleted" + | :"test_helpers.test_clock.internal_failure" + | :"test_helpers.test_clock.ready" + | :"topup.canceled" + | :"topup.created" + | :"topup.failed" + | :"topup.reversed" + | :"topup.succeeded" + | :"transfer.created" + | :"transfer.reversed" + | :"transfer.updated" + | :"treasury.credit_reversal.created" + | :"treasury.credit_reversal.posted" + | :"treasury.debit_reversal.completed" + | :"treasury.debit_reversal.created" + | :"treasury.debit_reversal.initial_credit_granted" + | :"treasury.financial_account.closed" + | :"treasury.financial_account.created" + | :"treasury.financial_account.features_status_updated" + | :"treasury.inbound_transfer.canceled" + | :"treasury.inbound_transfer.created" + | :"treasury.inbound_transfer.failed" + | :"treasury.inbound_transfer.succeeded" + | :"treasury.outbound_payment.canceled" + | :"treasury.outbound_payment.created" + | :"treasury.outbound_payment.expected_arrival_date_updated" + | :"treasury.outbound_payment.failed" + | :"treasury.outbound_payment.posted" + | :"treasury.outbound_payment.returned" + | :"treasury.outbound_transfer.canceled" + | :"treasury.outbound_transfer.created" + | :"treasury.outbound_transfer.expected_arrival_date_updated" + | :"treasury.outbound_transfer.failed" + | :"treasury.outbound_transfer.posted" + | :"treasury.outbound_transfer.returned" + | :"treasury.received_credit.created" + | :"treasury.received_credit.failed" + | :"treasury.received_credit.succeeded" + | :"treasury.received_debit.created" + ), + optional(:expand) => list(binary), + optional(:metadata) => %{optional(binary) => binary} | binary, + optional(:url) => binary + }, + opts :: Keyword.t() + ) :: + {:ok, Stripe.WebhookEndpoint.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def update(webhook_endpoint, params \\ %{}, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/webhook_endpoints/{webhook_endpoint}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "webhook_endpoint", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "webhook_endpoint", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [webhook_endpoint] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_params(params) + |> Stripe.Request.put_method(:post) + |> Stripe.Request.make_request() + end + ) + ) + + ( + nil + + @doc "

You can also delete webhook endpoints via the webhook endpoint management page of the Stripe dashboard.

\n\n#### Details\n\n * Method: `delete`\n * Path: `/v1/webhook_endpoints/{webhook_endpoint}`\n" + ( + @spec delete(webhook_endpoint :: binary(), opts :: Keyword.t()) :: + {:ok, Stripe.DeletedWebhookEndpoint.t()} + | {:error, Stripe.ApiErrors.t()} + | {:error, term()} + def delete(webhook_endpoint, opts \\ []) do + path = + Stripe.OpenApi.Path.replace_path_params( + "/v1/webhook_endpoints/{webhook_endpoint}", + [ + %OpenApiGen.Blueprint.Parameter{ + in: "path", + name: "webhook_endpoint", + required: true, + schema: %OpenApiGen.Blueprint.Parameter.Schema{ + name: "webhook_endpoint", + title: nil, + type: "string", + items: [], + properties: [], + any_of: [] + } + } + ], + [webhook_endpoint] + ) + + Stripe.Request.new_request(opts) + |> Stripe.Request.put_endpoint(path) + |> Stripe.Request.put_method(:delete) + |> Stripe.Request.make_request() + end + ) + ) +end \ No newline at end of file diff --git a/lib/mix/tasks/generate.ex b/lib/mix/tasks/generate.ex new file mode 100644 index 00000000..0041eafd --- /dev/null +++ b/lib/mix/tasks/generate.ex @@ -0,0 +1,19 @@ +defmodule Mix.Tasks.Stripe.Generate do + @moduledoc "The hello mix task: `mix help hello`" + use Mix.Task + + def run(_) do + opts = [ + path: + [:code.priv_dir(:stripity_stripe), "openapi", "spec3.sdk.json"] + |> Path.join(), + base_url: "https://api.stripe.com" + ] + + pipeline = Stripe.OpenApi.pipeline(opts) + + {:ok, _blueprint} = Stripe.OpenApi.run(pipeline) + + IO.puts("Generated Stripe SDK successfully!") + end +end diff --git a/lib/openapi/phases/compile.ex b/lib/openapi/phases/compile.ex index 6eceddf8..48763eca 100644 --- a/lib/openapi/phases/compile.ex +++ b/lib/openapi/phases/compile.ex @@ -68,16 +68,9 @@ defmodule Stripe.OpenApi.Phases.Compile do object_types = MapSet.to_list(object_types) - ast = - quote do - if unquote(operation_definition.deprecated) do - @deprecated "Stripe has deprecated this operation" - end - - @operation unquote(Macro.escape(operation_definition)) - @doc unquote(operation_definition.description) - - if unquote(params?) do + function_code = + if params? do + quote do @spec unquote(function_name)( unquote_splicing(argument_specs), params :: unquote(to_inline_spec(param_specs)), @@ -93,19 +86,21 @@ defmodule Stripe.OpenApi.Phases.Compile do ) do path = Stripe.OpenApi.Path.replace_path_params( - @operation.path, - @operation.path_parameters, + unquote(operation_definition.path), + unquote(operation_definition.path_parameters), unquote(argument_names) ) Stripe.Request.new_request(opts) |> Stripe.Request.put_endpoint(path) |> Stripe.Request.put_params(params) - |> Stripe.Request.put_method(@operation.method) + |> Stripe.Request.put_method(unquote(operation_definition.method)) |> Stripe.Request.make_request() end - else - if @operation.path == "/v1/files" and @operation.method == :post do + end + else + if operation_definition.path == "/v1/files" and operation_definition.method == :post do + quote do @spec unquote(function_name)( unquote_splicing(argument_specs), opts :: Keyword.t() @@ -114,16 +109,18 @@ defmodule Stripe.OpenApi.Phases.Compile do | {:error, Stripe.ApiErrors.t()} | {:error, term()} def unquote(function_name)( - params \\ %{}, - opts \\ [] - ) do + params \\ %{}, + opts \\ [] + ) do Stripe.Request.new_request(opts) - |> Stripe.Request.put_endpoint(@operation.path) + |> Stripe.Request.put_endpoint(unquote(operation_definition.path)) |> Stripe.Request.put_params(params) - |> Stripe.Request.put_method(@operation.method) + |> Stripe.Request.put_method(unquote(operation_definition.method)) |> Stripe.Request.make_file_upload_request() end - else + end + else + quote do @spec unquote(function_name)( unquote_splicing(argument_specs), opts :: Keyword.t() @@ -137,20 +134,39 @@ defmodule Stripe.OpenApi.Phases.Compile do ) do path = Stripe.OpenApi.Path.replace_path_params( - @operation.path, - @operation.path_parameters, + unquote(operation_definition.path), + unquote(operation_definition.path_parameters), unquote(argument_values) ) Stripe.Request.new_request(opts) |> Stripe.Request.put_endpoint(path) - |> Stripe.Request.put_method(@operation.method) + |> Stripe.Request.put_method(unquote(operation_definition.method)) |> Stripe.Request.make_request() end end end end + deprecated = + if operation_definition.deprecated do + quote do + @deprecated "Stripe has deprecated this operation" + end + else + quote do + end + end + + ast = + quote do + unquote(deprecated) + + @doc unquote(operation_definition.description) + + unquote(function_code) + end + {ast, object_types} end @@ -161,15 +177,18 @@ defmodule Stripe.OpenApi.Phases.Compile do types = List.flatten(types) |> Enum.uniq_by(fn {_, meta, _} -> meta[:name] end) + |> Enum.sort() |> Enum.map(&to_type_spec/1) + specs = Enum.map(component.properties, fn {key, value} -> {String.to_atom(key), build_spec(value, modules)} end) + |> Enum.sort typedoc_fields = - component.properties |> Enum.map_join("\n", fn {key, value} -> typedoc(key, value) end) + component.properties |> Enum.sort |> Enum.map_join("\n", fn {key, value} -> typedoc(key, value) end) typedoc = """ The `#{component.name}` type. @@ -177,12 +196,9 @@ defmodule Stripe.OpenApi.Phases.Compile do #{typedoc_fields} """ - body = - quote do - use Stripe.Entity - - @moduledoc unquote(component.description) - if unquote(fields) != nil do + type_doc = + if fields != nil do + quote do defstruct unquote(fields) @typedoc unquote(typedoc) @@ -190,13 +206,40 @@ defmodule Stripe.OpenApi.Phases.Compile do unquote_splicing(specs) } end + else + quote do + end + end + + body = + quote do + use Stripe.Entity + + @moduledoc unquote(component.description) + unquote(type_doc) unquote_splicing(types) - (unquote_splicing(funcs)) + unquote_splicing(funcs) end - Module.create(component.module, body, Macro.Env.location(__ENV__)) + # Module.create(component.module, body, Macro.Env.location(__ENV__)) + code = + quote do + defmodule unquote(component.module) do + unquote(body) + end + end + + bin = + code + |> Macro.to_string() + |> Code.format_string!() + + [_ | names] = Module.split(component.module) + filename = names |> Enum.map_join("__", & Macro.underscore/1) + + File.write!("lib/generated/#{filename}.ex", bin) end {:ok, blueprint} diff --git a/lib/stripe.ex b/lib/stripe.ex index 7754cf75..45d923b2 100644 --- a/lib/stripe.ex +++ b/lib/stripe.ex @@ -64,12 +64,6 @@ defmodule Stripe do """ use Application - use Stripe.OpenApi, - path: - [:code.priv_dir(:stripity_stripe), "openapi", "spec3.sdk.json"] - |> Path.join(), - base_url: "https://api.stripe.com" - @type id :: String.t() @type search_query :: String.t() @type date_query :: %{ diff --git a/mix.exs b/mix.exs index 9c81bb56..2b0bf0b6 100644 --- a/mix.exs +++ b/mix.exs @@ -107,6 +107,15 @@ defmodule Stripe.Mixfile do defp groups_for_modules do [ + "Main": [ + Stripe, + Stripe.API, + Stripe.ApiErrors, + Stripe.Entity, + Stripe.List, + Stripe.Request, + Stripe.SearchResult + ], "Core Resources": [ Stripe.Balance, Stripe.BalanceTransaction, @@ -196,6 +205,9 @@ defmodule Stripe.Mixfile do Stripe.Config, Stripe.Converter, Stripe.Types + ], + Other: [ + ~r/.*/ ] ] end