stripe-ruby/lib/stripe/services/payment_method_service.rb
2024-12-20 19:41:09 +00:00

951 lines
36 KiB
Ruby

# File generated from our OpenAPI spec
# frozen_string_literal: true
module Stripe
class PaymentMethodService < StripeService
class ListParams < Stripe::RequestParams
# The ID of the customer whose PaymentMethods will be retrieved.
attr_accessor :customer
# A cursor for use in pagination. `ending_before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list.
attr_accessor :ending_before
# Specifies which fields in the response should be expanded.
attr_accessor :expand
# A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10.
attr_accessor :limit
# A cursor for use in pagination. `starting_after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list.
attr_accessor :starting_after
# An optional filter on the list, based on the object `type` field. Without the filter, the list includes all current and future payment method types. If your integration expects only one type of payment method in the response, make sure to provide a type value in the request.
attr_accessor :type
def initialize(
customer: nil,
ending_before: nil,
expand: nil,
limit: nil,
starting_after: nil,
type: nil
)
@customer = customer
@ending_before = ending_before
@expand = expand
@limit = limit
@starting_after = starting_after
@type = type
end
end
class CreateParams < Stripe::RequestParams
class AcssDebit < Stripe::RequestParams
# Customer's bank account number.
attr_accessor :account_number
# Institution number of the customer's bank.
attr_accessor :institution_number
# Transit number of the customer's bank.
attr_accessor :transit_number
def initialize(account_number: nil, institution_number: nil, transit_number: nil)
@account_number = account_number
@institution_number = institution_number
@transit_number = transit_number
end
end
class Affirm < Stripe::RequestParams
end
class AfterpayClearpay < Stripe::RequestParams
end
class Alipay < Stripe::RequestParams
end
class Alma < Stripe::RequestParams
end
class AmazonPay < Stripe::RequestParams
end
class AuBecsDebit < Stripe::RequestParams
# The account number for the bank account.
attr_accessor :account_number
# Bank-State-Branch number of the bank account.
attr_accessor :bsb_number
def initialize(account_number: nil, bsb_number: nil)
@account_number = account_number
@bsb_number = bsb_number
end
end
class BacsDebit < Stripe::RequestParams
# Account number of the bank account that the funds will be debited from.
attr_accessor :account_number
# Sort code of the bank account. (e.g., `10-20-30`)
attr_accessor :sort_code
def initialize(account_number: nil, sort_code: nil)
@account_number = account_number
@sort_code = sort_code
end
end
class Bancontact < Stripe::RequestParams
end
class BillingDetails < Stripe::RequestParams
class Address < Stripe::RequestParams
# City, district, suburb, town, or village.
attr_accessor :city
# Two-letter country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)).
attr_accessor :country
# Address line 1 (e.g., street, PO Box, or company name).
attr_accessor :line1
# Address line 2 (e.g., apartment, suite, unit, or building).
attr_accessor :line2
# ZIP or postal code.
attr_accessor :postal_code
# State, county, province, or region.
attr_accessor :state
def initialize(
city: nil,
country: nil,
line1: nil,
line2: nil,
postal_code: nil,
state: nil
)
@city = city
@country = country
@line1 = line1
@line2 = line2
@postal_code = postal_code
@state = state
end
end
# Billing address.
attr_accessor :address
# Email address.
attr_accessor :email
# Full name.
attr_accessor :name
# Billing phone number (including extension).
attr_accessor :phone
def initialize(address: nil, email: nil, name: nil, phone: nil)
@address = address
@email = email
@name = name
@phone = phone
end
end
class Blik < Stripe::RequestParams
end
class Boleto < Stripe::RequestParams
# The tax ID of the customer (CPF for individual consumers or CNPJ for businesses consumers)
attr_accessor :tax_id
def initialize(tax_id: nil)
@tax_id = tax_id
end
end
class Card < Stripe::RequestParams
class Networks < Stripe::RequestParams
# The customer's preferred card network for co-branded cards. Supports `cartes_bancaires`, `mastercard`, or `visa`. Selection of a network that does not apply to the card will be stored as `invalid_preference` on the card.
attr_accessor :preferred
def initialize(preferred: nil)
@preferred = preferred
end
end
# The card's CVC. It is highly recommended to always include this value.
attr_accessor :cvc
# Two-digit number representing the card's expiration month.
attr_accessor :exp_month
# Four-digit number representing the card's expiration year.
attr_accessor :exp_year
# Contains information about card networks used to process the payment.
attr_accessor :networks
# The card number, as a string without any separators.
attr_accessor :number
# For backwards compatibility, you can alternatively provide a Stripe token (e.g., for Apple Pay, Amex Express Checkout, or legacy Checkout) into the card hash with format card: {token: "tok_visa"}.
attr_accessor :token
def initialize(
cvc: nil,
exp_month: nil,
exp_year: nil,
networks: nil,
number: nil,
token: nil
)
@cvc = cvc
@exp_month = exp_month
@exp_year = exp_year
@networks = networks
@number = number
@token = token
end
end
class Cashapp < Stripe::RequestParams
end
class CustomerBalance < Stripe::RequestParams
end
class Eps < Stripe::RequestParams
# The customer's bank.
attr_accessor :bank
def initialize(bank: nil)
@bank = bank
end
end
class Fpx < Stripe::RequestParams
# Account holder type for FPX transaction
attr_accessor :account_holder_type
# The customer's bank.
attr_accessor :bank
def initialize(account_holder_type: nil, bank: nil)
@account_holder_type = account_holder_type
@bank = bank
end
end
class Giropay < Stripe::RequestParams
end
class Gopay < Stripe::RequestParams
end
class Grabpay < Stripe::RequestParams
end
class IdBankTransfer < Stripe::RequestParams
# Bank where the account is held.
attr_accessor :bank
def initialize(bank: nil)
@bank = bank
end
end
class Ideal < Stripe::RequestParams
# The customer's bank. Only use this parameter for existing customers. Don't use it for new customers.
attr_accessor :bank
def initialize(bank: nil)
@bank = bank
end
end
class InteracPresent < Stripe::RequestParams
end
class KakaoPay < Stripe::RequestParams
end
class Klarna < Stripe::RequestParams
class Dob < Stripe::RequestParams
# The day of birth, between 1 and 31.
attr_accessor :day
# The month of birth, between 1 and 12.
attr_accessor :month
# The four-digit year of birth.
attr_accessor :year
def initialize(day: nil, month: nil, year: nil)
@day = day
@month = month
@year = year
end
end
# Customer's date of birth
attr_accessor :dob
def initialize(dob: nil)
@dob = dob
end
end
class Konbini < Stripe::RequestParams
end
class KrCard < Stripe::RequestParams
end
class Link < Stripe::RequestParams
end
class MbWay < Stripe::RequestParams
end
class Mobilepay < Stripe::RequestParams
end
class Multibanco < Stripe::RequestParams
end
class NaverPay < Stripe::RequestParams
# Whether to use Naver Pay points or a card to fund this transaction. If not provided, this defaults to `card`.
attr_accessor :funding
def initialize(funding: nil)
@funding = funding
end
end
class Oxxo < Stripe::RequestParams
end
class P24 < Stripe::RequestParams
# The customer's bank.
attr_accessor :bank
def initialize(bank: nil)
@bank = bank
end
end
class Payco < Stripe::RequestParams
end
class Paynow < Stripe::RequestParams
end
class Paypal < Stripe::RequestParams
end
class Payto < Stripe::RequestParams
# The account number for the bank account.
attr_accessor :account_number
# Bank-State-Branch number of the bank account.
attr_accessor :bsb_number
# The PayID alias for the bank account.
attr_accessor :pay_id
def initialize(account_number: nil, bsb_number: nil, pay_id: nil)
@account_number = account_number
@bsb_number = bsb_number
@pay_id = pay_id
end
end
class Pix < Stripe::RequestParams
end
class Promptpay < Stripe::RequestParams
end
class Qris < Stripe::RequestParams
end
class RadarOptions < Stripe::RequestParams
# A [Radar Session](https://stripe.com/docs/radar/radar-session) is a snapshot of the browser metadata and device details that help Radar make more accurate predictions on your payments.
attr_accessor :session
def initialize(session: nil)
@session = session
end
end
class Rechnung < Stripe::RequestParams
class Dob < Stripe::RequestParams
# The day of birth, between 1 and 31.
attr_accessor :day
# The month of birth, between 1 and 12.
attr_accessor :month
# The four-digit year of birth.
attr_accessor :year
def initialize(day: nil, month: nil, year: nil)
@day = day
@month = month
@year = year
end
end
# Customer's date of birth
attr_accessor :dob
def initialize(dob: nil)
@dob = dob
end
end
class RevolutPay < Stripe::RequestParams
end
class SamsungPay < Stripe::RequestParams
end
class SepaDebit < Stripe::RequestParams
# IBAN of the bank account.
attr_accessor :iban
def initialize(iban: nil)
@iban = iban
end
end
class Shopeepay < Stripe::RequestParams
end
class Sofort < Stripe::RequestParams
# Two-letter ISO code representing the country the bank account is located in.
attr_accessor :country
def initialize(country: nil)
@country = country
end
end
class Swish < Stripe::RequestParams
end
class Twint < Stripe::RequestParams
end
class UsBankAccount < Stripe::RequestParams
# Account holder type: individual or company.
attr_accessor :account_holder_type
# Account number of the bank account.
attr_accessor :account_number
# Account type: checkings or savings. Defaults to checking if omitted.
attr_accessor :account_type
# The ID of a Financial Connections Account to use as a payment method.
attr_accessor :financial_connections_account
# Routing number of the bank account.
attr_accessor :routing_number
def initialize(
account_holder_type: nil,
account_number: nil,
account_type: nil,
financial_connections_account: nil,
routing_number: nil
)
@account_holder_type = account_holder_type
@account_number = account_number
@account_type = account_type
@financial_connections_account = financial_connections_account
@routing_number = routing_number
end
end
class WechatPay < Stripe::RequestParams
end
class Zip < Stripe::RequestParams
end
# If this is an `acss_debit` PaymentMethod, this hash contains details about the ACSS Debit payment method.
attr_accessor :acss_debit
# If this is an `affirm` PaymentMethod, this hash contains details about the Affirm payment method.
attr_accessor :affirm
# If this is an `AfterpayClearpay` PaymentMethod, this hash contains details about the AfterpayClearpay payment method.
attr_accessor :afterpay_clearpay
# If this is an `Alipay` PaymentMethod, this hash contains details about the Alipay payment method.
attr_accessor :alipay
# This field indicates whether this payment method can be shown again to its customer in a checkout flow. Stripe products such as Checkout and Elements use this field to determine whether a payment method can be shown as a saved payment method in a checkout flow. The field defaults to `unspecified`.
attr_accessor :allow_redisplay
# If this is a Alma PaymentMethod, this hash contains details about the Alma payment method.
attr_accessor :alma
# If this is a AmazonPay PaymentMethod, this hash contains details about the AmazonPay payment method.
attr_accessor :amazon_pay
# If this is an `au_becs_debit` PaymentMethod, this hash contains details about the bank account.
attr_accessor :au_becs_debit
# If this is a `bacs_debit` PaymentMethod, this hash contains details about the Bacs Direct Debit bank account.
attr_accessor :bacs_debit
# If this is a `bancontact` PaymentMethod, this hash contains details about the Bancontact payment method.
attr_accessor :bancontact
# Billing information associated with the PaymentMethod that may be used or required by particular types of payment methods.
attr_accessor :billing_details
# If this is a `blik` PaymentMethod, this hash contains details about the BLIK payment method.
attr_accessor :blik
# If this is a `boleto` PaymentMethod, this hash contains details about the Boleto payment method.
attr_accessor :boleto
# If this is a `card` PaymentMethod, this hash contains the user's card details. For backwards compatibility, you can alternatively provide a Stripe token (e.g., for Apple Pay, Amex Express Checkout, or legacy Checkout) into the card hash with format `card: {token: "tok_visa"}`. When providing a card number, you must meet the requirements for [PCI compliance](https://stripe.com/docs/security#validating-pci-compliance). We strongly recommend using Stripe.js instead of interacting with this API directly.
attr_accessor :card
# If this is a `cashapp` PaymentMethod, this hash contains details about the Cash App Pay payment method.
attr_accessor :cashapp
# The `Customer` to whom the original PaymentMethod is attached.
attr_accessor :customer
# If this is a `customer_balance` PaymentMethod, this hash contains details about the CustomerBalance payment method.
attr_accessor :customer_balance
# If this is an `eps` PaymentMethod, this hash contains details about the EPS payment method.
attr_accessor :eps
# Specifies which fields in the response should be expanded.
attr_accessor :expand
# If this is an `fpx` PaymentMethod, this hash contains details about the FPX payment method.
attr_accessor :fpx
# If this is a `giropay` PaymentMethod, this hash contains details about the Giropay payment method.
attr_accessor :giropay
# If this is a Gopay PaymentMethod, this hash contains details about the Gopay payment method.
attr_accessor :gopay
# If this is a `grabpay` PaymentMethod, this hash contains details about the GrabPay payment method.
attr_accessor :grabpay
# If this is an `IdBankTransfer` PaymentMethod, this hash contains details about the IdBankTransfer payment method.
attr_accessor :id_bank_transfer
# If this is an `ideal` PaymentMethod, this hash contains details about the iDEAL payment method.
attr_accessor :ideal
# If this is an `interac_present` PaymentMethod, this hash contains details about the Interac Present payment method.
attr_accessor :interac_present
# If this is a `kakao_pay` PaymentMethod, this hash contains details about the Kakao Pay payment method.
attr_accessor :kakao_pay
# If this is a `klarna` PaymentMethod, this hash contains details about the Klarna payment method.
attr_accessor :klarna
# If this is a `konbini` PaymentMethod, this hash contains details about the Konbini payment method.
attr_accessor :konbini
# If this is a `kr_card` PaymentMethod, this hash contains details about the Korean Card payment method.
attr_accessor :kr_card
# If this is an `Link` PaymentMethod, this hash contains details about the Link payment method.
attr_accessor :link
# If this is a MB WAY PaymentMethod, this hash contains details about the MB WAY payment method.
attr_accessor :mb_way
# 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. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to `metadata`.
attr_accessor :metadata
# If this is a `mobilepay` PaymentMethod, this hash contains details about the MobilePay payment method.
attr_accessor :mobilepay
# If this is a `multibanco` PaymentMethod, this hash contains details about the Multibanco payment method.
attr_accessor :multibanco
# If this is a `naver_pay` PaymentMethod, this hash contains details about the Naver Pay payment method.
attr_accessor :naver_pay
# If this is an `oxxo` PaymentMethod, this hash contains details about the OXXO payment method.
attr_accessor :oxxo
# If this is a `p24` PaymentMethod, this hash contains details about the P24 payment method.
attr_accessor :p24
# If this is a `payco` PaymentMethod, this hash contains details about the PAYCO payment method.
attr_accessor :payco
# The PaymentMethod to share.
attr_accessor :payment_method
# If this is a `paynow` PaymentMethod, this hash contains details about the PayNow payment method.
attr_accessor :paynow
# If this is a `paypal` PaymentMethod, this hash contains details about the PayPal payment method.
attr_accessor :paypal
# If this is a `payto` PaymentMethod, this hash contains details about the PayTo payment method.
attr_accessor :payto
# If this is a `pix` PaymentMethod, this hash contains details about the Pix payment method.
attr_accessor :pix
# If this is a `promptpay` PaymentMethod, this hash contains details about the PromptPay payment method.
attr_accessor :promptpay
# If this is a `qris` PaymentMethod, this hash contains details about the QRIS payment method.
attr_accessor :qris
# Options to configure Radar. See [Radar Session](https://stripe.com/docs/radar/radar-session) for more information.
attr_accessor :radar_options
# If this is a `rechnung` PaymentMethod, this hash contains details about the Rechnung payment method.
attr_accessor :rechnung
# If this is a `Revolut Pay` PaymentMethod, this hash contains details about the Revolut Pay payment method.
attr_accessor :revolut_pay
# If this is a `samsung_pay` PaymentMethod, this hash contains details about the SamsungPay payment method.
attr_accessor :samsung_pay
# If this is a `sepa_debit` PaymentMethod, this hash contains details about the SEPA debit bank account.
attr_accessor :sepa_debit
# If this is a Shopeepay PaymentMethod, this hash contains details about the Shopeepay payment method.
attr_accessor :shopeepay
# If this is a `sofort` PaymentMethod, this hash contains details about the SOFORT payment method.
attr_accessor :sofort
# If this is a `swish` PaymentMethod, this hash contains details about the Swish payment method.
attr_accessor :swish
# If this is a TWINT PaymentMethod, this hash contains details about the TWINT payment method.
attr_accessor :twint
# 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.
attr_accessor :type
# If this is an `us_bank_account` PaymentMethod, this hash contains details about the US bank account payment method.
attr_accessor :us_bank_account
# If this is an `wechat_pay` PaymentMethod, this hash contains details about the wechat_pay payment method.
attr_accessor :wechat_pay
# If this is a `zip` PaymentMethod, this hash contains details about the Zip payment method.
attr_accessor :zip
def initialize(
acss_debit: nil,
affirm: nil,
afterpay_clearpay: nil,
alipay: nil,
allow_redisplay: nil,
alma: nil,
amazon_pay: nil,
au_becs_debit: nil,
bacs_debit: nil,
bancontact: nil,
billing_details: nil,
blik: nil,
boleto: nil,
card: nil,
cashapp: nil,
customer: nil,
customer_balance: nil,
eps: nil,
expand: nil,
fpx: nil,
giropay: nil,
gopay: nil,
grabpay: nil,
id_bank_transfer: nil,
ideal: nil,
interac_present: nil,
kakao_pay: nil,
klarna: nil,
konbini: nil,
kr_card: nil,
link: nil,
mb_way: nil,
metadata: nil,
mobilepay: nil,
multibanco: nil,
naver_pay: nil,
oxxo: nil,
p24: nil,
payco: nil,
payment_method: nil,
paynow: nil,
paypal: nil,
payto: nil,
pix: nil,
promptpay: nil,
qris: nil,
radar_options: nil,
rechnung: nil,
revolut_pay: nil,
samsung_pay: nil,
sepa_debit: nil,
shopeepay: nil,
sofort: nil,
swish: nil,
twint: nil,
type: nil,
us_bank_account: nil,
wechat_pay: nil,
zip: nil
)
@acss_debit = acss_debit
@affirm = affirm
@afterpay_clearpay = afterpay_clearpay
@alipay = alipay
@allow_redisplay = allow_redisplay
@alma = alma
@amazon_pay = amazon_pay
@au_becs_debit = au_becs_debit
@bacs_debit = bacs_debit
@bancontact = bancontact
@billing_details = billing_details
@blik = blik
@boleto = boleto
@card = card
@cashapp = cashapp
@customer = customer
@customer_balance = customer_balance
@eps = eps
@expand = expand
@fpx = fpx
@giropay = giropay
@gopay = gopay
@grabpay = grabpay
@id_bank_transfer = id_bank_transfer
@ideal = ideal
@interac_present = interac_present
@kakao_pay = kakao_pay
@klarna = klarna
@konbini = konbini
@kr_card = kr_card
@link = link
@mb_way = mb_way
@metadata = metadata
@mobilepay = mobilepay
@multibanco = multibanco
@naver_pay = naver_pay
@oxxo = oxxo
@p24 = p24
@payco = payco
@payment_method = payment_method
@paynow = paynow
@paypal = paypal
@payto = payto
@pix = pix
@promptpay = promptpay
@qris = qris
@radar_options = radar_options
@rechnung = rechnung
@revolut_pay = revolut_pay
@samsung_pay = samsung_pay
@sepa_debit = sepa_debit
@shopeepay = shopeepay
@sofort = sofort
@swish = swish
@twint = twint
@type = type
@us_bank_account = us_bank_account
@wechat_pay = wechat_pay
@zip = zip
end
end
class RetrieveParams < Stripe::RequestParams
# Specifies which fields in the response should be expanded.
attr_accessor :expand
def initialize(expand: nil)
@expand = expand
end
end
class UpdateParams < Stripe::RequestParams
class BillingDetails < Stripe::RequestParams
class Address < Stripe::RequestParams
# City, district, suburb, town, or village.
attr_accessor :city
# Two-letter country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)).
attr_accessor :country
# Address line 1 (e.g., street, PO Box, or company name).
attr_accessor :line1
# Address line 2 (e.g., apartment, suite, unit, or building).
attr_accessor :line2
# ZIP or postal code.
attr_accessor :postal_code
# State, county, province, or region.
attr_accessor :state
def initialize(
city: nil,
country: nil,
line1: nil,
line2: nil,
postal_code: nil,
state: nil
)
@city = city
@country = country
@line1 = line1
@line2 = line2
@postal_code = postal_code
@state = state
end
end
# Billing address.
attr_accessor :address
# Email address.
attr_accessor :email
# Full name.
attr_accessor :name
# Billing phone number (including extension).
attr_accessor :phone
def initialize(address: nil, email: nil, name: nil, phone: nil)
@address = address
@email = email
@name = name
@phone = phone
end
end
class Card < Stripe::RequestParams
class Networks < Stripe::RequestParams
# The customer's preferred card network for co-branded cards. Supports `cartes_bancaires`, `mastercard`, or `visa`. Selection of a network that does not apply to the card will be stored as `invalid_preference` on the card.
attr_accessor :preferred
def initialize(preferred: nil)
@preferred = preferred
end
end
# Two-digit number representing the card's expiration month.
attr_accessor :exp_month
# Four-digit number representing the card's expiration year.
attr_accessor :exp_year
# Contains information about card networks used to process the payment.
attr_accessor :networks
def initialize(exp_month: nil, exp_year: nil, networks: nil)
@exp_month = exp_month
@exp_year = exp_year
@networks = networks
end
end
class Link < Stripe::RequestParams
end
class NaverPay < Stripe::RequestParams
# Whether to use Naver Pay points or a card to fund this transaction. If not provided, this defaults to `card`.
attr_accessor :funding
def initialize(funding: nil)
@funding = funding
end
end
class Payto < Stripe::RequestParams
# The account number for the bank account.
attr_accessor :account_number
# Bank-State-Branch number of the bank account.
attr_accessor :bsb_number
# The PayID alias for the bank account.
attr_accessor :pay_id
def initialize(account_number: nil, bsb_number: nil, pay_id: nil)
@account_number = account_number
@bsb_number = bsb_number
@pay_id = pay_id
end
end
class UsBankAccount < Stripe::RequestParams
# Bank account holder type.
attr_accessor :account_holder_type
# Bank account type.
attr_accessor :account_type
def initialize(account_holder_type: nil, account_type: nil)
@account_holder_type = account_holder_type
@account_type = account_type
end
end
# This field indicates whether this payment method can be shown again to its customer in a checkout flow. Stripe products such as Checkout and Elements use this field to determine whether a payment method can be shown as a saved payment method in a checkout flow. The field defaults to `unspecified`.
attr_accessor :allow_redisplay
# Billing information associated with the PaymentMethod that may be used or required by particular types of payment methods.
attr_accessor :billing_details
# If this is a `card` PaymentMethod, this hash contains the user's card details.
attr_accessor :card
# Specifies which fields in the response should be expanded.
attr_accessor :expand
# If this is an `Link` PaymentMethod, this hash contains details about the Link payment method.
attr_accessor :link
# 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. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to `metadata`.
attr_accessor :metadata
# If this is a `naver_pay` PaymentMethod, this hash contains details about the Naver Pay payment method.
attr_accessor :naver_pay
# If this is a `payto` PaymentMethod, this hash contains details about the PayTo payment method.
attr_accessor :payto
# If this is an `us_bank_account` PaymentMethod, this hash contains details about the US bank account payment method.
attr_accessor :us_bank_account
def initialize(
allow_redisplay: nil,
billing_details: nil,
card: nil,
expand: nil,
link: nil,
metadata: nil,
naver_pay: nil,
payto: nil,
us_bank_account: nil
)
@allow_redisplay = allow_redisplay
@billing_details = billing_details
@card = card
@expand = expand
@link = link
@metadata = metadata
@naver_pay = naver_pay
@payto = payto
@us_bank_account = us_bank_account
end
end
class AttachParams < Stripe::RequestParams
# The ID of the customer to which to attach the PaymentMethod.
attr_accessor :customer
# Specifies which fields in the response should be expanded.
attr_accessor :expand
def initialize(customer: nil, expand: nil)
@customer = customer
@expand = expand
end
end
class DetachParams < Stripe::RequestParams
# Specifies which fields in the response should be expanded.
attr_accessor :expand
def initialize(expand: nil)
@expand = expand
end
end
# Attaches a PaymentMethod object to a Customer.
#
# To attach a new PaymentMethod to a customer for future payments, we recommend you use a [SetupIntent](https://stripe.com/docs/api/setup_intents)
# or a PaymentIntent with [setup_future_usage](https://stripe.com/docs/api/payment_intents/create#create_payment_intent-setup_future_usage).
# These approaches will perform any necessary steps to set up the PaymentMethod for future payments. Using the /v1/payment_methods/:id/attach
# endpoint without first using a SetupIntent or PaymentIntent with setup_future_usage does not optimize the PaymentMethod for
# future use, which makes later declines and payment friction more likely.
# See [Optimizing cards for future payments](https://stripe.com/docs/payments/payment-intents#future-usage) for more information about setting up
# future payments.
#
# To use this PaymentMethod as the default for invoice or subscription payments,
# set [invoice_settings.default_payment_method](https://stripe.com/docs/api/customers/update#update_customer-invoice_settings-default_payment_method),
# on the Customer to the PaymentMethod's ID.
def attach(payment_method, params = {}, opts = {})
request(
method: :post,
path: format("/v1/payment_methods/%<payment_method>s/attach", { payment_method: CGI.escape(payment_method) }),
params: params,
opts: opts,
base_address: :api
)
end
# Creates a PaymentMethod object. Read the [Stripe.js reference](https://stripe.com/docs/stripe-js/reference#stripe-create-payment-method) to learn how to create PaymentMethods via Stripe.js.
#
# Instead of creating a PaymentMethod directly, we recommend using the [PaymentIntents API to accept a payment immediately or the <a href="/docs/payments/save-and-reuse">SetupIntent](https://stripe.com/docs/payments/accept-a-payment) API to collect payment method details ahead of a future payment.
def create(params = {}, opts = {})
request(
method: :post,
path: "/v1/payment_methods",
params: params,
opts: opts,
base_address: :api
)
end
# 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.
def detach(payment_method, params = {}, opts = {})
request(
method: :post,
path: format("/v1/payment_methods/%<payment_method>s/detach", { payment_method: CGI.escape(payment_method) }),
params: params,
opts: opts,
base_address: :api
)
end
# 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](https://stripe.com/docs/api/payment_methods/customer_list) API instead.
def list(params = {}, opts = {})
request(
method: :get,
path: "/v1/payment_methods",
params: params,
opts: opts,
base_address: :api
)
end
# 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](https://stripe.com/docs/api/payment_methods/customer)
def retrieve(payment_method, params = {}, opts = {})
request(
method: :get,
path: format("/v1/payment_methods/%<payment_method>s", { payment_method: CGI.escape(payment_method) }),
params: params,
opts: opts,
base_address: :api
)
end
# Updates a PaymentMethod object. A PaymentMethod must be attached a customer to be updated.
def update(payment_method, params = {}, opts = {})
request(
method: :post,
path: format("/v1/payment_methods/%<payment_method>s", { payment_method: CGI.escape(payment_method) }),
params: params,
opts: opts,
base_address: :api
)
end
end
end