Packages
Complete Stripe SDK for Elixir with parity to the official Ruby SDK. V1+V2 coverage (193 services, 320 resource structs, 525 documented params). Per-event modules, Finch HTTP/2, RustyJSON, automatic retries, OAuth, webhooks, telemetry, per-client config, streaming pagination.
Current section
Files
Jump to
Current section
Files
lib/stripe/resources/refund.ex
# File generated from our OpenAPI spec
defmodule Stripe.Resources.Refund do
@moduledoc """
Refund
Refund objects allow you to refund a previously created charge that isn't
refunded yet. Funds are refunded to the credit or debit card that's
initially charged.
Related guide: [Refunds](https://docs.stripe.com/refunds)
"""
@typedoc """
* `amount` - Amount, in cents (or local equivalent).
* `balance_transaction` - Balance transaction that describes the impact on your account balance. Nullable. Expandable.
* `charge` - ID of the charge that's refunded. Nullable. Expandable.
* `created` - Time at which the object was created. Measured in seconds since the Unix epoch. Format: Unix timestamp.
* `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). Format: ISO 4217 currency code.
* `description` - An arbitrary string attached to the object. You can use this for displaying to users (available on non-card refunds only). Max length: 5000.
* `destination_details` - Expandable.
* `failure_balance_transaction` - After the refund fails, this balance transaction describes the adjustment made on your account balance that reverses the initial balance transaction. Expandable.
* `failure_reason` - Provides the reason for the refund failure. Possible values are: `lost_or_stolen_card`, `expired_or_canceled_card`, `charge_for_pending_refund_disputed`, `insufficient_funds`, `declined`, `merchant_request`, or `unknown`. Max length: 5000.
* `id` - Unique identifier for the object. Max length: 5000.
* `instructions_email` - For payment methods without native refund support (for example, Konbini, PromptPay), provide an email address for the customer to receive refund instructions. Max length: 5000.
* `metadata` - Set of [key-value pairs](https://docs.stripe.com/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Nullable.
* `next_action` - Expandable.
* `object` - String representing the object's type. Objects of the same type share the same value. Possible values: `refund`.
* `payment_intent` - ID of the PaymentIntent that's refunded. Nullable. Expandable.
* `pending_reason` - Provides the reason for why the refund is pending. Possible values are: `processing`, `insufficient_funds`, or `charge_pending`. Possible values: `charge_pending`, `insufficient_funds`, `processing`.
* `presentment_details` - Expandable.
* `reason` - Reason for the refund, which is either user-provided (`duplicate`, `fraudulent`, or `requested_by_customer`) or generated by Stripe internally (`expired_uncaptured_charge`). Possible values: `duplicate`, `expired_uncaptured_charge`, `fraudulent`, `requested_by_customer`. Nullable.
* `receipt_number` - This is the transaction number that appears on email receipts sent for this refund. Max length: 5000. Nullable.
* `source_transfer_reversal` - The transfer reversal that's associated with the refund. Only present if the charge came from another Stripe account. Nullable. Expandable.
* `status` - Status of the refund. This can be `pending`, `requires_action`, `succeeded`, `failed`, or `canceled`. Learn more about [failed refunds](https://docs.stripe.com/refunds#failed-refunds). Max length: 5000. Nullable.
* `transfer_reversal` - This refers to the transfer reversal object if the accompanying transfer reverses. This is only applicable if the charge was created using the destination parameter. Nullable. Expandable.
"""
@type t :: %__MODULE__{
amount: integer(),
balance_transaction: String.t() | Stripe.Resources.BalanceTransaction.t(),
charge: String.t() | Stripe.Resources.Charge.t(),
created: integer(),
currency: String.t(),
description: String.t() | nil,
destination_details: __MODULE__.DestinationDetails.t() | nil,
failure_balance_transaction: String.t() | Stripe.Resources.BalanceTransaction.t() | nil,
failure_reason: String.t() | nil,
id: String.t(),
instructions_email: String.t() | nil,
metadata: map(),
next_action: __MODULE__.NextAction.t() | nil,
object: String.t(),
payment_intent: String.t() | Stripe.Resources.PaymentIntent.t(),
pending_reason: String.t() | nil,
presentment_details: __MODULE__.PresentmentDetails.t() | nil,
reason: String.t(),
receipt_number: String.t(),
source_transfer_reversal: String.t() | Stripe.Resources.TransferReversal.t(),
status: String.t(),
transfer_reversal: String.t() | Stripe.Resources.TransferReversal.t()
}
defstruct [
:amount,
:balance_transaction,
:charge,
:created,
:currency,
:description,
:destination_details,
:failure_balance_transaction,
:failure_reason,
:id,
:instructions_email,
:metadata,
:next_action,
:object,
:payment_intent,
:pending_reason,
:presentment_details,
:reason,
:receipt_number,
:source_transfer_reversal,
:status,
:transfer_reversal
]
@object_name "refund"
def object_name, do: @object_name
def expandable_fields,
do: [
"balance_transaction",
"charge",
"destination_details",
"failure_balance_transaction",
"next_action",
"payment_intent",
"presentment_details",
"source_transfer_reversal",
"transfer_reversal"
]
defmodule DestinationDetails do
@moduledoc "Nested struct within the parent resource."
@typedoc """
* `affirm`
* `afterpay_clearpay`
* `alipay`
* `alma`
* `amazon_pay`
* `au_bank_transfer`
* `blik`
* `br_bank_transfer`
* `card`
* `cashapp`
* `crypto`
* `customer_cash_balance`
* `eps`
* `eu_bank_transfer`
* `gb_bank_transfer`
* `giropay`
* `grabpay`
* `jp_bank_transfer`
* `klarna`
* `mb_way`
* `multibanco`
* `mx_bank_transfer`
* `nz_bank_transfer`
* `p24`
* `paynow`
* `paypal`
* `pix`
* `revolut`
* `sofort`
* `swish`
* `th_bank_transfer`
* `twint`
* `type` - The type of transaction-specific details of the payment method used in the refund (e.g., `card`). An additional hash is included on `destination_details` with a name matching this value. It contains information specific to the refund transaction. Max length: 5000.
* `us_bank_transfer`
* `wechat_pay`
* `zip`
"""
@type t :: %__MODULE__{
affirm: map() | nil,
afterpay_clearpay: map() | nil,
alipay: map() | nil,
alma: map() | nil,
amazon_pay: map() | nil,
au_bank_transfer: map() | nil,
blik: __MODULE__.Blik.t() | nil,
br_bank_transfer: __MODULE__.BrBankTransfer.t() | nil,
card: __MODULE__.Card.t() | nil,
cashapp: map() | nil,
crypto: __MODULE__.Crypto.t() | nil,
customer_cash_balance: map() | nil,
eps: map() | nil,
eu_bank_transfer: __MODULE__.EuBankTransfer.t() | nil,
gb_bank_transfer: __MODULE__.GbBankTransfer.t() | nil,
giropay: map() | nil,
grabpay: map() | nil,
jp_bank_transfer: __MODULE__.JpBankTransfer.t() | nil,
klarna: map() | nil,
mb_way: __MODULE__.MbWay.t() | nil,
multibanco: __MODULE__.Multibanco.t() | nil,
mx_bank_transfer: __MODULE__.MxBankTransfer.t() | nil,
nz_bank_transfer: map() | nil,
p24: __MODULE__.P24.t() | nil,
paynow: map() | nil,
paypal: __MODULE__.Paypal.t() | nil,
pix: map() | nil,
revolut: map() | nil,
sofort: map() | nil,
swish: __MODULE__.Swish.t() | nil,
th_bank_transfer: __MODULE__.ThBankTransfer.t() | nil,
twint: map() | nil,
type: String.t() | nil,
us_bank_transfer: __MODULE__.UsBankTransfer.t() | nil,
wechat_pay: map() | nil,
zip: map() | nil
}
defstruct [
:affirm,
:afterpay_clearpay,
:alipay,
:alma,
:amazon_pay,
:au_bank_transfer,
:blik,
:br_bank_transfer,
:card,
:cashapp,
:crypto,
:customer_cash_balance,
:eps,
:eu_bank_transfer,
:gb_bank_transfer,
:giropay,
:grabpay,
:jp_bank_transfer,
:klarna,
:mb_way,
:multibanco,
:mx_bank_transfer,
:nz_bank_transfer,
:p24,
:paynow,
:paypal,
:pix,
:revolut,
:sofort,
:swish,
:th_bank_transfer,
:twint,
:type,
:us_bank_transfer,
:wechat_pay,
:zip
]
defmodule Blik do
@moduledoc "Nested struct within the parent resource."
@typedoc """
* `network_decline_code` - For refunds declined by the network, a decline code provided by the network which indicates the reason the refund failed. Max length: 5000. Nullable.
* `reference` - The reference assigned to the refund. Max length: 5000. Nullable.
* `reference_status` - Status of the reference on the refund. This can be `pending`, `available` or `unavailable`. Max length: 5000. Nullable.
"""
@type t :: %__MODULE__{
network_decline_code: String.t() | nil,
reference: String.t() | nil,
reference_status: String.t() | nil
}
defstruct [:network_decline_code, :reference, :reference_status]
end
defmodule BrBankTransfer do
@moduledoc "Nested struct within the parent resource."
@typedoc """
* `reference` - The reference assigned to the refund. Max length: 5000. Nullable.
* `reference_status` - Status of the reference on the refund. This can be `pending`, `available` or `unavailable`. Max length: 5000. Nullable.
"""
@type t :: %__MODULE__{
reference: String.t() | nil,
reference_status: String.t() | nil
}
defstruct [:reference, :reference_status]
end
defmodule Card do
@moduledoc "Nested struct within the parent resource."
@typedoc """
* `reference` - Value of the reference number assigned to the refund. Max length: 5000.
* `reference_status` - Status of the reference number on the refund. This can be `pending`, `available` or `unavailable`. Max length: 5000.
* `reference_type` - Type of the reference number assigned to the refund. Max length: 5000.
* `type` - The type of refund. This can be `refund`, `reversal`, or `pending`. Possible values: `pending`, `refund`, `reversal`.
"""
@type t :: %__MODULE__{
reference: String.t() | nil,
reference_status: String.t() | nil,
reference_type: String.t() | nil,
type: String.t() | nil
}
defstruct [:reference, :reference_status, :reference_type, :type]
end
defmodule Crypto do
@moduledoc "Nested struct within the parent resource."
@typedoc """
* `reference` - The transaction hash of the refund. Max length: 5000. Nullable.
"""
@type t :: %__MODULE__{
reference: String.t() | nil
}
defstruct [:reference]
end
defmodule EuBankTransfer do
@moduledoc "Nested struct within the parent resource."
@typedoc """
* `reference` - The reference assigned to the refund. Max length: 5000. Nullable.
* `reference_status` - Status of the reference on the refund. This can be `pending`, `available` or `unavailable`. Max length: 5000. Nullable.
"""
@type t :: %__MODULE__{
reference: String.t() | nil,
reference_status: String.t() | nil
}
defstruct [:reference, :reference_status]
end
defmodule GbBankTransfer do
@moduledoc "Nested struct within the parent resource."
@typedoc """
* `reference` - The reference assigned to the refund. Max length: 5000. Nullable.
* `reference_status` - Status of the reference on the refund. This can be `pending`, `available` or `unavailable`. Max length: 5000. Nullable.
"""
@type t :: %__MODULE__{
reference: String.t() | nil,
reference_status: String.t() | nil
}
defstruct [:reference, :reference_status]
end
defmodule JpBankTransfer do
@moduledoc "Nested struct within the parent resource."
@typedoc """
* `reference` - The reference assigned to the refund. Max length: 5000. Nullable.
* `reference_status` - Status of the reference on the refund. This can be `pending`, `available` or `unavailable`. Max length: 5000. Nullable.
"""
@type t :: %__MODULE__{
reference: String.t() | nil,
reference_status: String.t() | nil
}
defstruct [:reference, :reference_status]
end
defmodule MbWay do
@moduledoc "Nested struct within the parent resource."
@typedoc """
* `reference` - The reference assigned to the refund. Max length: 5000. Nullable.
* `reference_status` - Status of the reference on the refund. This can be `pending`, `available` or `unavailable`. Max length: 5000. Nullable.
"""
@type t :: %__MODULE__{
reference: String.t() | nil,
reference_status: String.t() | nil
}
defstruct [:reference, :reference_status]
end
defmodule Multibanco do
@moduledoc "Nested struct within the parent resource."
@typedoc """
* `reference` - The reference assigned to the refund. Max length: 5000. Nullable.
* `reference_status` - Status of the reference on the refund. This can be `pending`, `available` or `unavailable`. Max length: 5000. Nullable.
"""
@type t :: %__MODULE__{
reference: String.t() | nil,
reference_status: String.t() | nil
}
defstruct [:reference, :reference_status]
end
defmodule MxBankTransfer do
@moduledoc "Nested struct within the parent resource."
@typedoc """
* `reference` - The reference assigned to the refund. Max length: 5000. Nullable.
* `reference_status` - Status of the reference on the refund. This can be `pending`, `available` or `unavailable`. Max length: 5000. Nullable.
"""
@type t :: %__MODULE__{
reference: String.t() | nil,
reference_status: String.t() | nil
}
defstruct [:reference, :reference_status]
end
defmodule P24 do
@moduledoc "Nested struct within the parent resource."
@typedoc """
* `reference` - The reference assigned to the refund. Max length: 5000. Nullable.
* `reference_status` - Status of the reference on the refund. This can be `pending`, `available` or `unavailable`. Max length: 5000. Nullable.
"""
@type t :: %__MODULE__{
reference: String.t() | nil,
reference_status: String.t() | nil
}
defstruct [:reference, :reference_status]
end
defmodule Paypal do
@moduledoc "Nested struct within the parent resource."
@typedoc """
* `network_decline_code` - For refunds declined by the network, a decline code provided by the network which indicates the reason the refund failed. Max length: 5000. Nullable.
"""
@type t :: %__MODULE__{
network_decline_code: String.t() | nil
}
defstruct [:network_decline_code]
end
defmodule Swish do
@moduledoc "Nested struct within the parent resource."
@typedoc """
* `network_decline_code` - For refunds declined by the network, a decline code provided by the network which indicates the reason the refund failed. Max length: 5000. Nullable.
* `reference` - The reference assigned to the refund. Max length: 5000. Nullable.
* `reference_status` - Status of the reference on the refund. This can be `pending`, `available` or `unavailable`. Max length: 5000. Nullable.
"""
@type t :: %__MODULE__{
network_decline_code: String.t() | nil,
reference: String.t() | nil,
reference_status: String.t() | nil
}
defstruct [:network_decline_code, :reference, :reference_status]
end
defmodule ThBankTransfer do
@moduledoc "Nested struct within the parent resource."
@typedoc """
* `reference` - The reference assigned to the refund. Max length: 5000. Nullable.
* `reference_status` - Status of the reference on the refund. This can be `pending`, `available` or `unavailable`. Max length: 5000. Nullable.
"""
@type t :: %__MODULE__{
reference: String.t() | nil,
reference_status: String.t() | nil
}
defstruct [:reference, :reference_status]
end
defmodule UsBankTransfer do
@moduledoc "Nested struct within the parent resource."
@typedoc """
* `reference` - The reference assigned to the refund. Max length: 5000. Nullable.
* `reference_status` - Status of the reference on the refund. This can be `pending`, `available` or `unavailable`. Max length: 5000. Nullable.
"""
@type t :: %__MODULE__{
reference: String.t() | nil,
reference_status: String.t() | nil
}
defstruct [:reference, :reference_status]
end
def __inner_types__ do
%{
"blik" => __MODULE__.Blik,
"br_bank_transfer" => __MODULE__.BrBankTransfer,
"card" => __MODULE__.Card,
"crypto" => __MODULE__.Crypto,
"eu_bank_transfer" => __MODULE__.EuBankTransfer,
"gb_bank_transfer" => __MODULE__.GbBankTransfer,
"jp_bank_transfer" => __MODULE__.JpBankTransfer,
"mb_way" => __MODULE__.MbWay,
"multibanco" => __MODULE__.Multibanco,
"mx_bank_transfer" => __MODULE__.MxBankTransfer,
"p24" => __MODULE__.P24,
"paypal" => __MODULE__.Paypal,
"swish" => __MODULE__.Swish,
"th_bank_transfer" => __MODULE__.ThBankTransfer,
"us_bank_transfer" => __MODULE__.UsBankTransfer
}
end
end
defmodule NextAction do
@moduledoc "Nested struct within the parent resource."
@typedoc """
* `display_details`
* `type` - Type of the next action to perform. Max length: 5000.
"""
@type t :: %__MODULE__{
display_details: __MODULE__.DisplayDetails.t() | nil,
type: String.t() | nil
}
defstruct [:display_details, :type]
defmodule DisplayDetails do
@moduledoc "Nested struct within the parent resource."
@typedoc """
* `email_sent`
* `expires_at` - The expiry timestamp. Format: Unix timestamp.
"""
@type t :: %__MODULE__{
email_sent: __MODULE__.EmailSent.t() | nil,
expires_at: integer() | nil
}
defstruct [:email_sent, :expires_at]
defmodule EmailSent do
@moduledoc "Nested struct within the parent resource."
@typedoc """
* `email_sent_at` - The timestamp when the email was sent. Format: Unix timestamp.
* `email_sent_to` - The recipient's email address. Max length: 5000.
"""
@type t :: %__MODULE__{
email_sent_at: integer() | nil,
email_sent_to: String.t() | nil
}
defstruct [:email_sent_at, :email_sent_to]
end
def __inner_types__ do
%{
"email_sent" => __MODULE__.EmailSent
}
end
end
def __inner_types__ do
%{
"display_details" => __MODULE__.DisplayDetails
}
end
end
defmodule PresentmentDetails do
@moduledoc "Nested struct within the parent resource."
@typedoc """
* `presentment_amount` - Amount intended to be collected by this payment, denominated in `presentment_currency`.
* `presentment_currency` - Currency presented to the customer during payment. Max length: 5000.
"""
@type t :: %__MODULE__{
presentment_amount: integer() | nil,
presentment_currency: String.t() | nil
}
defstruct [:presentment_amount, :presentment_currency]
end
def __inner_types__ do
%{
"destination_details" => __MODULE__.DestinationDetails,
"next_action" => __MODULE__.NextAction,
"presentment_details" => __MODULE__.PresentmentDetails
}
end
end