defmodule Stripe.Treasury.OutboundPayment do use Stripe.Entity @moduledoc "Use [OutboundPayments](https://docs.stripe.com/docs/treasury/moving-money/financial-accounts/out-of/outbound-payments) 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.\n\nRelated guide: [Moving money with Treasury using OutboundPayment objects](https://docs.stripe.com/docs/treasury/moving-money/financial-accounts/out-of/outbound-payments)" ( 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, :tracking_details, :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 * `tracking_details` Details about network-specific tracking information if available.\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, tracking_details: term | nil, transaction: binary | Stripe.Treasury.Transaction.t() } ) ( @typedoc "ACH network tracking details." @type ach :: %{optional(:trace_id) => 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 "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 | binary, optional(:phone) => binary | binary } ) ( @typedoc nil @type created :: %{ optional(:gt) => integer, optional(:gte) => integer, optional(:lt) => integer, optional(:lte) => integer } ) ( @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 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 "Details about network-specific tracking information." @type tracking_details :: %{ optional(:ach) => ach, optional(:type) => :ach | :us_domestic_wire, optional(:us_domestic_wire) => us_domestic_wire } ) ( @typedoc nil @type us_bank_account :: %{optional(:network) => :ach | :us_domestic_wire} ) ( @typedoc "US domestic wire network tracking details." @type us_domestic_wire :: %{ optional(:chips) => binary, optional(:imad) => binary, optional(:omad) => binary } ) ( 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(:created) => created | integer, 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 "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}", [ %{ __struct__: OpenApiGen.Blueprint.Parameter, in: "path", name: "id", required: true, schema: %{ __struct__: OpenApiGen.Blueprint.Parameter.Schema, any_of: [], items: [], name: "id", properties: [], title: nil, type: "string" } } ], [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 a test mode created OutboundPayment with tracking details. The OutboundPayment must not be cancelable, and cannot be in the canceled or failed states.
Transitions a test mode created OutboundPayment to the failed status. The OutboundPayment must already be in the processing state.
Transitions a test mode created OutboundPayment to the posted status. The OutboundPayment must already be in the processing state.
Transitions a test mode created OutboundPayment to the returned status. The OutboundPayment must already be in the processing state.
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 "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", [ %{ __struct__: OpenApiGen.Blueprint.Parameter, in: "path", name: "id", required: true, schema: %{ __struct__: OpenApiGen.Blueprint.Parameter.Schema, any_of: [], items: [], name: "id", properties: [], title: nil, type: "string" } } ], [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