Class: Stripe::PaymentMethod
- Inherits:
-
APIResource
- Object
- StripeObject
- APIResource
- Stripe::PaymentMethod
- Extended by:
- APIOperations::Create, APIOperations::List
- Includes:
- APIOperations::Save
- Defined in:
- lib/stripe/resources/payment_method.rb
Overview
PaymentMethod objects represent your customer’s payment instruments. You can use them with [PaymentIntents](stripe.com/docs/payments/payment-intents) to collect payments or save them to Customer objects to store instrument details for future payments.
Related guides: [Payment Methods](stripe.com/docs/payments/payment-methods) and [More Payment Scenarios](stripe.com/docs/payments/more-payment-scenarios).
Defined Under Namespace
Classes: AcssDebit, Affirm, AfterpayClearpay, Alipay, Alma, AmazonPay, AttachParams, AuBecsDebit, BacsDebit, Bancontact, Billie, BillingDetails, Blik, Boleto, Card, CardPresent, Cashapp, CreateParams, Crypto, CustomerBalance, DetachParams, Eps, Fpx, Giropay, Gopay, Grabpay, IdBankTransfer, Ideal, InteracPresent, KakaoPay, Klarna, Konbini, KrCard, Link, ListParams, MbWay, Mobilepay, Multibanco, NaverPay, NzBankAccount, Oxxo, P24, PayByBank, Payco, Paynow, Paypal, Payto, Pix, Promptpay, Qris, RadarOptions, Rechnung, RevolutPay, SamsungPay, Satispay, SepaDebit, Shopeepay, Sofort, StripeBalance, Swish, Twint, UpdateParams, UsBankAccount, WechatPay, Zip
Constant Summary collapse
- OBJECT_NAME =
"payment_method"
Constants inherited from StripeObject
StripeObject::RESERVED_FIELD_NAMES
Instance Attribute Summary collapse
-
#acss_debit ⇒ Object
readonly
Attribute for field acss_debit.
-
#affirm ⇒ Object
readonly
Attribute for field affirm.
-
#afterpay_clearpay ⇒ Object
readonly
Attribute for field afterpay_clearpay.
-
#alipay ⇒ Object
readonly
Attribute for field alipay.
-
#allow_redisplay ⇒ Object
readonly
This field indicates whether this payment method can be shown again to its customer in a checkout flow.
-
#alma ⇒ Object
readonly
Attribute for field alma.
-
#amazon_pay ⇒ Object
readonly
Attribute for field amazon_pay.
-
#au_becs_debit ⇒ Object
readonly
Attribute for field au_becs_debit.
-
#bacs_debit ⇒ Object
readonly
Attribute for field bacs_debit.
-
#bancontact ⇒ Object
readonly
Attribute for field bancontact.
-
#billie ⇒ Object
readonly
Attribute for field billie.
-
#billing_details ⇒ Object
readonly
Attribute for field billing_details.
-
#blik ⇒ Object
readonly
Attribute for field blik.
-
#boleto ⇒ Object
readonly
Attribute for field boleto.
-
#card ⇒ Object
readonly
Attribute for field card.
-
#card_present ⇒ Object
readonly
Attribute for field card_present.
-
#cashapp ⇒ Object
readonly
Attribute for field cashapp.
-
#created ⇒ Object
readonly
Time at which the object was created.
-
#crypto ⇒ Object
readonly
Attribute for field crypto.
-
#customer ⇒ Object
readonly
The ID of the Customer to which this PaymentMethod is saved.
-
#customer_account ⇒ Object
readonly
Attribute for field customer_account.
-
#customer_balance ⇒ Object
readonly
Attribute for field customer_balance.
-
#eps ⇒ Object
readonly
Attribute for field eps.
-
#fpx ⇒ Object
readonly
Attribute for field fpx.
-
#giropay ⇒ Object
readonly
Attribute for field giropay.
-
#gopay ⇒ Object
readonly
Attribute for field gopay.
-
#grabpay ⇒ Object
readonly
Attribute for field grabpay.
-
#id ⇒ Object
readonly
Unique identifier for the object.
-
#id_bank_transfer ⇒ Object
readonly
Attribute for field id_bank_transfer.
-
#ideal ⇒ Object
readonly
Attribute for field ideal.
-
#interac_present ⇒ Object
readonly
Attribute for field interac_present.
-
#kakao_pay ⇒ Object
readonly
Attribute for field kakao_pay.
-
#klarna ⇒ Object
readonly
Attribute for field klarna.
-
#konbini ⇒ Object
readonly
Attribute for field konbini.
-
#kr_card ⇒ Object
readonly
Attribute for field kr_card.
-
#latest_active_mandate ⇒ Object
readonly
The Mandate object of the most recently created Mandate associated with this payment method.
-
#link ⇒ Object
readonly
Attribute for field link.
-
#livemode ⇒ Object
readonly
Has the value ‘true` if the object exists in live mode or the value `false` if the object exists in test mode.
-
#mb_way ⇒ Object
readonly
Attribute for field mb_way.
-
#metadata ⇒ Object
readonly
Set of [key-value pairs](stripe.com/docs/api/metadata) that you can attach to an object.
-
#mobilepay ⇒ Object
readonly
Attribute for field mobilepay.
-
#multibanco ⇒ Object
readonly
Attribute for field multibanco.
-
#naver_pay ⇒ Object
readonly
Attribute for field naver_pay.
-
#nz_bank_account ⇒ Object
readonly
Attribute for field nz_bank_account.
-
#object ⇒ Object
readonly
String representing the object’s type.
-
#oxxo ⇒ Object
readonly
Attribute for field oxxo.
-
#p24 ⇒ Object
readonly
Attribute for field p24.
-
#pay_by_bank ⇒ Object
readonly
Attribute for field pay_by_bank.
-
#payco ⇒ Object
readonly
Attribute for field payco.
-
#paynow ⇒ Object
readonly
Attribute for field paynow.
-
#paypal ⇒ Object
readonly
Attribute for field paypal.
-
#payto ⇒ Object
readonly
Attribute for field payto.
-
#pix ⇒ Object
readonly
Attribute for field pix.
-
#promptpay ⇒ Object
readonly
Attribute for field promptpay.
-
#qris ⇒ Object
readonly
Attribute for field qris.
-
#radar_options ⇒ Object
readonly
Options to configure Radar.
-
#rechnung ⇒ Object
readonly
Attribute for field rechnung.
-
#revolut_pay ⇒ Object
readonly
Attribute for field revolut_pay.
-
#samsung_pay ⇒ Object
readonly
Attribute for field samsung_pay.
-
#satispay ⇒ Object
readonly
Attribute for field satispay.
-
#sepa_debit ⇒ Object
readonly
Attribute for field sepa_debit.
-
#shopeepay ⇒ Object
readonly
Attribute for field shopeepay.
-
#sofort ⇒ Object
readonly
Attribute for field sofort.
-
#stripe_balance ⇒ Object
readonly
Attribute for field stripe_balance.
-
#swish ⇒ Object
readonly
Attribute for field swish.
-
#twint ⇒ Object
readonly
Attribute for field twint.
-
#type ⇒ Object
readonly
The type of the PaymentMethod.
-
#us_bank_account ⇒ Object
readonly
Attribute for field us_bank_account.
-
#wechat_pay ⇒ Object
readonly
Attribute for field wechat_pay.
-
#zip ⇒ Object
readonly
Attribute for field zip.
Attributes inherited from APIResource
Attributes inherited from StripeObject
Class Method Summary collapse
-
.attach(payment_method, params = {}, opts = {}) ⇒ Object
Attaches a PaymentMethod object to a Customer.
-
.create(params = {}, opts = {}) ⇒ Object
Creates a PaymentMethod object.
-
.detach(payment_method, params = {}, opts = {}) ⇒ Object
Detaches a PaymentMethod object from a Customer.
- .field_remappings ⇒ Object
- .inner_class_types ⇒ Object
-
.list(params = {}, opts = {}) ⇒ Object
Returns a list of PaymentMethods for Treasury flows.
- .object_name ⇒ Object
-
.update(payment_method, params = {}, opts = {}) ⇒ Object
Updates a PaymentMethod object.
Instance Method Summary collapse
-
#attach(params = {}, opts = {}) ⇒ Object
Attaches a PaymentMethod object to a Customer.
-
#detach(params = {}, opts = {}) ⇒ Object
Detaches a PaymentMethod object from a Customer.
Methods included from APIOperations::Create
Methods included from APIOperations::List
Methods included from APIOperations::Save
Methods inherited from APIResource
class_name, custom_method, #refresh, #request_stripe_object, resource_url, #resource_url, retrieve, save_nested_resource
Methods included from APIOperations::Request
Methods inherited from StripeObject
#==, #[], #[]=, #_get_inner_class_type, additive_object_param, additive_object_param?, #as_json, construct_from, #deleted?, #dirty!, #each, #eql?, #hash, #initialize, #inspect, #keys, #marshal_dump, #marshal_load, protected_fields, #serialize_params, #to_hash, #to_json, #to_s, #update_attributes, #values
Constructor Details
This class inherits a constructor from Stripe::StripeObject
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Stripe::StripeObject
Instance Attribute Details
#acss_debit ⇒ Object (readonly)
Attribute for field acss_debit
2351 2352 2353 |
# File 'lib/stripe/resources/payment_method.rb', line 2351 def acss_debit @acss_debit end |
#affirm ⇒ Object (readonly)
Attribute for field affirm
2353 2354 2355 |
# File 'lib/stripe/resources/payment_method.rb', line 2353 def affirm @affirm end |
#afterpay_clearpay ⇒ Object (readonly)
Attribute for field afterpay_clearpay
2355 2356 2357 |
# File 'lib/stripe/resources/payment_method.rb', line 2355 def afterpay_clearpay @afterpay_clearpay end |
#alipay ⇒ Object (readonly)
Attribute for field alipay
2357 2358 2359 |
# File 'lib/stripe/resources/payment_method.rb', line 2357 def alipay @alipay end |
#allow_redisplay ⇒ Object (readonly)
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”.
2359 2360 2361 |
# File 'lib/stripe/resources/payment_method.rb', line 2359 def allow_redisplay @allow_redisplay end |
#alma ⇒ Object (readonly)
Attribute for field alma
2361 2362 2363 |
# File 'lib/stripe/resources/payment_method.rb', line 2361 def alma @alma end |
#amazon_pay ⇒ Object (readonly)
Attribute for field amazon_pay
2363 2364 2365 |
# File 'lib/stripe/resources/payment_method.rb', line 2363 def amazon_pay @amazon_pay end |
#au_becs_debit ⇒ Object (readonly)
Attribute for field au_becs_debit
2365 2366 2367 |
# File 'lib/stripe/resources/payment_method.rb', line 2365 def au_becs_debit @au_becs_debit end |
#bacs_debit ⇒ Object (readonly)
Attribute for field bacs_debit
2367 2368 2369 |
# File 'lib/stripe/resources/payment_method.rb', line 2367 def bacs_debit @bacs_debit end |
#bancontact ⇒ Object (readonly)
Attribute for field bancontact
2369 2370 2371 |
# File 'lib/stripe/resources/payment_method.rb', line 2369 def bancontact @bancontact end |
#billie ⇒ Object (readonly)
Attribute for field billie
2371 2372 2373 |
# File 'lib/stripe/resources/payment_method.rb', line 2371 def billie @billie end |
#billing_details ⇒ Object (readonly)
Attribute for field billing_details
2373 2374 2375 |
# File 'lib/stripe/resources/payment_method.rb', line 2373 def billing_details @billing_details end |
#blik ⇒ Object (readonly)
Attribute for field blik
2375 2376 2377 |
# File 'lib/stripe/resources/payment_method.rb', line 2375 def blik @blik end |
#boleto ⇒ Object (readonly)
Attribute for field boleto
2377 2378 2379 |
# File 'lib/stripe/resources/payment_method.rb', line 2377 def boleto @boleto end |
#card ⇒ Object (readonly)
Attribute for field card
2379 2380 2381 |
# File 'lib/stripe/resources/payment_method.rb', line 2379 def card @card end |
#card_present ⇒ Object (readonly)
Attribute for field card_present
2381 2382 2383 |
# File 'lib/stripe/resources/payment_method.rb', line 2381 def card_present @card_present end |
#cashapp ⇒ Object (readonly)
Attribute for field cashapp
2383 2384 2385 |
# File 'lib/stripe/resources/payment_method.rb', line 2383 def cashapp @cashapp end |
#created ⇒ Object (readonly)
Time at which the object was created. Measured in seconds since the Unix epoch.
2385 2386 2387 |
# File 'lib/stripe/resources/payment_method.rb', line 2385 def created @created end |
#crypto ⇒ Object (readonly)
Attribute for field crypto
2387 2388 2389 |
# File 'lib/stripe/resources/payment_method.rb', line 2387 def crypto @crypto end |
#customer ⇒ Object (readonly)
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.
2389 2390 2391 |
# File 'lib/stripe/resources/payment_method.rb', line 2389 def customer @customer end |
#customer_account ⇒ Object (readonly)
Attribute for field customer_account
2391 2392 2393 |
# File 'lib/stripe/resources/payment_method.rb', line 2391 def customer_account @customer_account end |
#customer_balance ⇒ Object (readonly)
Attribute for field customer_balance
2393 2394 2395 |
# File 'lib/stripe/resources/payment_method.rb', line 2393 def customer_balance @customer_balance end |
#eps ⇒ Object (readonly)
Attribute for field eps
2395 2396 2397 |
# File 'lib/stripe/resources/payment_method.rb', line 2395 def eps @eps end |
#fpx ⇒ Object (readonly)
Attribute for field fpx
2397 2398 2399 |
# File 'lib/stripe/resources/payment_method.rb', line 2397 def fpx @fpx end |
#giropay ⇒ Object (readonly)
Attribute for field giropay
2399 2400 2401 |
# File 'lib/stripe/resources/payment_method.rb', line 2399 def giropay @giropay end |
#gopay ⇒ Object (readonly)
Attribute for field gopay
2401 2402 2403 |
# File 'lib/stripe/resources/payment_method.rb', line 2401 def gopay @gopay end |
#grabpay ⇒ Object (readonly)
Attribute for field grabpay
2403 2404 2405 |
# File 'lib/stripe/resources/payment_method.rb', line 2403 def grabpay @grabpay end |
#id ⇒ Object (readonly)
Unique identifier for the object.
2405 2406 2407 |
# File 'lib/stripe/resources/payment_method.rb', line 2405 def id @id end |
#id_bank_transfer ⇒ Object (readonly)
Attribute for field id_bank_transfer
2407 2408 2409 |
# File 'lib/stripe/resources/payment_method.rb', line 2407 def id_bank_transfer @id_bank_transfer end |
#ideal ⇒ Object (readonly)
Attribute for field ideal
2409 2410 2411 |
# File 'lib/stripe/resources/payment_method.rb', line 2409 def ideal @ideal end |
#interac_present ⇒ Object (readonly)
Attribute for field interac_present
2411 2412 2413 |
# File 'lib/stripe/resources/payment_method.rb', line 2411 def interac_present @interac_present end |
#kakao_pay ⇒ Object (readonly)
Attribute for field kakao_pay
2413 2414 2415 |
# File 'lib/stripe/resources/payment_method.rb', line 2413 def kakao_pay @kakao_pay end |
#klarna ⇒ Object (readonly)
Attribute for field klarna
2415 2416 2417 |
# File 'lib/stripe/resources/payment_method.rb', line 2415 def klarna @klarna end |
#konbini ⇒ Object (readonly)
Attribute for field konbini
2417 2418 2419 |
# File 'lib/stripe/resources/payment_method.rb', line 2417 def konbini @konbini end |
#kr_card ⇒ Object (readonly)
Attribute for field kr_card
2419 2420 2421 |
# File 'lib/stripe/resources/payment_method.rb', line 2419 def kr_card @kr_card end |
#latest_active_mandate ⇒ Object (readonly)
The Mandate object of the most recently created Mandate associated with this payment method
2421 2422 2423 |
# File 'lib/stripe/resources/payment_method.rb', line 2421 def latest_active_mandate @latest_active_mandate end |
#link ⇒ Object (readonly)
Attribute for field link
2423 2424 2425 |
# File 'lib/stripe/resources/payment_method.rb', line 2423 def link @link end |
#livemode ⇒ Object (readonly)
Has the value ‘true` if the object exists in live mode or the value `false` if the object exists in test mode.
2425 2426 2427 |
# File 'lib/stripe/resources/payment_method.rb', line 2425 def livemode @livemode end |
#mb_way ⇒ Object (readonly)
Attribute for field mb_way
2427 2428 2429 |
# File 'lib/stripe/resources/payment_method.rb', line 2427 def mb_way @mb_way end |
#metadata ⇒ Object (readonly)
Set of [key-value pairs](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.
2429 2430 2431 |
# File 'lib/stripe/resources/payment_method.rb', line 2429 def @metadata end |
#mobilepay ⇒ Object (readonly)
Attribute for field mobilepay
2431 2432 2433 |
# File 'lib/stripe/resources/payment_method.rb', line 2431 def mobilepay @mobilepay end |
#multibanco ⇒ Object (readonly)
Attribute for field multibanco
2433 2434 2435 |
# File 'lib/stripe/resources/payment_method.rb', line 2433 def multibanco @multibanco end |
#naver_pay ⇒ Object (readonly)
Attribute for field naver_pay
2435 2436 2437 |
# File 'lib/stripe/resources/payment_method.rb', line 2435 def naver_pay @naver_pay end |
#nz_bank_account ⇒ Object (readonly)
Attribute for field nz_bank_account
2437 2438 2439 |
# File 'lib/stripe/resources/payment_method.rb', line 2437 def nz_bank_account @nz_bank_account end |
#object ⇒ Object (readonly)
String representing the object’s type. Objects of the same type share the same value.
2439 2440 2441 |
# File 'lib/stripe/resources/payment_method.rb', line 2439 def object @object end |
#oxxo ⇒ Object (readonly)
Attribute for field oxxo
2441 2442 2443 |
# File 'lib/stripe/resources/payment_method.rb', line 2441 def oxxo @oxxo end |
#p24 ⇒ Object (readonly)
Attribute for field p24
2443 2444 2445 |
# File 'lib/stripe/resources/payment_method.rb', line 2443 def p24 @p24 end |
#pay_by_bank ⇒ Object (readonly)
Attribute for field pay_by_bank
2445 2446 2447 |
# File 'lib/stripe/resources/payment_method.rb', line 2445 def pay_by_bank @pay_by_bank end |
#payco ⇒ Object (readonly)
Attribute for field payco
2447 2448 2449 |
# File 'lib/stripe/resources/payment_method.rb', line 2447 def payco @payco end |
#paynow ⇒ Object (readonly)
Attribute for field paynow
2449 2450 2451 |
# File 'lib/stripe/resources/payment_method.rb', line 2449 def paynow @paynow end |
#paypal ⇒ Object (readonly)
Attribute for field paypal
2451 2452 2453 |
# File 'lib/stripe/resources/payment_method.rb', line 2451 def paypal @paypal end |
#payto ⇒ Object (readonly)
Attribute for field payto
2453 2454 2455 |
# File 'lib/stripe/resources/payment_method.rb', line 2453 def payto @payto end |
#pix ⇒ Object (readonly)
Attribute for field pix
2455 2456 2457 |
# File 'lib/stripe/resources/payment_method.rb', line 2455 def pix @pix end |
#promptpay ⇒ Object (readonly)
Attribute for field promptpay
2457 2458 2459 |
# File 'lib/stripe/resources/payment_method.rb', line 2457 def promptpay @promptpay end |
#qris ⇒ Object (readonly)
Attribute for field qris
2459 2460 2461 |
# File 'lib/stripe/resources/payment_method.rb', line 2459 def qris @qris end |
#radar_options ⇒ Object (readonly)
Options to configure Radar. See [Radar Session](stripe.com/docs/radar/radar-session) for more information.
2461 2462 2463 |
# File 'lib/stripe/resources/payment_method.rb', line 2461 def @radar_options end |
#rechnung ⇒ Object (readonly)
Attribute for field rechnung
2463 2464 2465 |
# File 'lib/stripe/resources/payment_method.rb', line 2463 def rechnung @rechnung end |
#revolut_pay ⇒ Object (readonly)
Attribute for field revolut_pay
2465 2466 2467 |
# File 'lib/stripe/resources/payment_method.rb', line 2465 def revolut_pay @revolut_pay end |
#samsung_pay ⇒ Object (readonly)
Attribute for field samsung_pay
2467 2468 2469 |
# File 'lib/stripe/resources/payment_method.rb', line 2467 def samsung_pay @samsung_pay end |
#satispay ⇒ Object (readonly)
Attribute for field satispay
2469 2470 2471 |
# File 'lib/stripe/resources/payment_method.rb', line 2469 def satispay @satispay end |
#sepa_debit ⇒ Object (readonly)
Attribute for field sepa_debit
2471 2472 2473 |
# File 'lib/stripe/resources/payment_method.rb', line 2471 def sepa_debit @sepa_debit end |
#shopeepay ⇒ Object (readonly)
Attribute for field shopeepay
2473 2474 2475 |
# File 'lib/stripe/resources/payment_method.rb', line 2473 def shopeepay @shopeepay end |
#sofort ⇒ Object (readonly)
Attribute for field sofort
2475 2476 2477 |
# File 'lib/stripe/resources/payment_method.rb', line 2475 def sofort @sofort end |
#stripe_balance ⇒ Object (readonly)
Attribute for field stripe_balance
2477 2478 2479 |
# File 'lib/stripe/resources/payment_method.rb', line 2477 def stripe_balance @stripe_balance end |
#swish ⇒ Object (readonly)
Attribute for field swish
2479 2480 2481 |
# File 'lib/stripe/resources/payment_method.rb', line 2479 def swish @swish end |
#twint ⇒ Object (readonly)
Attribute for field twint
2481 2482 2483 |
# File 'lib/stripe/resources/payment_method.rb', line 2481 def twint @twint end |
#type ⇒ Object (readonly)
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.
2483 2484 2485 |
# File 'lib/stripe/resources/payment_method.rb', line 2483 def type @type end |
#us_bank_account ⇒ Object (readonly)
Attribute for field us_bank_account
2485 2486 2487 |
# File 'lib/stripe/resources/payment_method.rb', line 2485 def us_bank_account @us_bank_account end |
#wechat_pay ⇒ Object (readonly)
Attribute for field wechat_pay
2487 2488 2489 |
# File 'lib/stripe/resources/payment_method.rb', line 2487 def wechat_pay @wechat_pay end |
#zip ⇒ Object (readonly)
Attribute for field zip
2489 2490 2491 |
# File 'lib/stripe/resources/payment_method.rb', line 2489 def zip @zip end |
Class Method Details
.attach(payment_method, params = {}, opts = {}) ⇒ Object
Attaches a PaymentMethod object to a Customer.
To attach a new PaymentMethod to a customer for future payments, we recommend you use a [SetupIntent](docs.stripe.com/docs/api/setup_intents) or a PaymentIntent with [setup_future_usage](docs.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](docs.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](docs.stripe.com/docs/api/customers/update#update_customer-invoice_settings-default_payment_method), on the Customer to the PaymentMethod’s ID.
2526 2527 2528 2529 2530 2531 2532 2533 |
# File 'lib/stripe/resources/payment_method.rb', line 2526 def self.attach(payment_method, params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/payment_methods/%<payment_method>s/attach", { payment_method: CGI.escape(payment_method) }), params: params, opts: opts ) end |
.create(params = {}, opts = {}) ⇒ Object
Creates a PaymentMethod object. Read the [Stripe.js reference](docs.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](docs.stripe.com/docs/payments/accept-a-payment) API to collect payment method details ahead of a future payment.
2538 2539 2540 |
# File 'lib/stripe/resources/payment_method.rb', line 2538 def self.create(params = {}, opts = {}) request_stripe_object(method: :post, path: "/v1/payment_methods", params: params, opts: opts) end |
.detach(payment_method, params = {}, opts = {}) ⇒ Object
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.
2553 2554 2555 2556 2557 2558 2559 2560 |
# File 'lib/stripe/resources/payment_method.rb', line 2553 def self.detach(payment_method, params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/payment_methods/%<payment_method>s/detach", { payment_method: CGI.escape(payment_method) }), params: params, opts: opts ) end |
.field_remappings ⇒ Object
2642 2643 2644 |
# File 'lib/stripe/resources/payment_method.rb', line 2642 def self.field_remappings @field_remappings = {} end |
.inner_class_types ⇒ Object
2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 |
# File 'lib/stripe/resources/payment_method.rb', line 2577 def self.inner_class_types @inner_class_types = { acss_debit: AcssDebit, affirm: Affirm, afterpay_clearpay: AfterpayClearpay, alipay: Alipay, alma: Alma, amazon_pay: AmazonPay, au_becs_debit: AuBecsDebit, bacs_debit: BacsDebit, bancontact: Bancontact, billie: Billie, billing_details: BillingDetails, blik: Blik, boleto: Boleto, card: Card, card_present: CardPresent, cashapp: Cashapp, crypto: Crypto, customer_balance: CustomerBalance, eps: Eps, fpx: Fpx, giropay: Giropay, gopay: Gopay, grabpay: Grabpay, id_bank_transfer: IdBankTransfer, ideal: Ideal, interac_present: InteracPresent, kakao_pay: KakaoPay, klarna: Klarna, konbini: Konbini, kr_card: KrCard, link: Link, mb_way: MbWay, mobilepay: Mobilepay, multibanco: Multibanco, naver_pay: NaverPay, nz_bank_account: NzBankAccount, oxxo: Oxxo, p24: P24, pay_by_bank: PayByBank, payco: Payco, paynow: Paynow, paypal: Paypal, payto: Payto, pix: Pix, promptpay: Promptpay, qris: Qris, radar_options: RadarOptions, rechnung: Rechnung, revolut_pay: RevolutPay, samsung_pay: SamsungPay, satispay: Satispay, sepa_debit: SepaDebit, shopeepay: Shopeepay, sofort: Sofort, stripe_balance: StripeBalance, swish: Swish, twint: Twint, us_bank_account: UsBankAccount, wechat_pay: WechatPay, zip: Zip, } end |
.list(params = {}, opts = {}) ⇒ Object
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](docs.stripe.com/docs/api/payment_methods/customer_list) API instead.
2563 2564 2565 |
# File 'lib/stripe/resources/payment_method.rb', line 2563 def self.list(params = {}, opts = {}) request_stripe_object(method: :get, path: "/v1/payment_methods", params: params, opts: opts) end |
.object_name ⇒ Object
16 17 18 |
# File 'lib/stripe/resources/payment_method.rb', line 16 def self.object_name "payment_method" end |
.update(payment_method, params = {}, opts = {}) ⇒ Object
Updates a PaymentMethod object. A PaymentMethod must be attached to a customer to be updated.
2568 2569 2570 2571 2572 2573 2574 2575 |
# File 'lib/stripe/resources/payment_method.rb', line 2568 def self.update(payment_method, params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/payment_methods/%<payment_method>s", { payment_method: CGI.escape(payment_method) }), params: params, opts: opts ) end |
Instance Method Details
#attach(params = {}, opts = {}) ⇒ Object
Attaches a PaymentMethod object to a Customer.
To attach a new PaymentMethod to a customer for future payments, we recommend you use a [SetupIntent](docs.stripe.com/docs/api/setup_intents) or a PaymentIntent with [setup_future_usage](docs.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](docs.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](docs.stripe.com/docs/api/customers/update#update_customer-invoice_settings-default_payment_method), on the Customer to the PaymentMethod’s ID.
2504 2505 2506 2507 2508 2509 2510 2511 |
# File 'lib/stripe/resources/payment_method.rb', line 2504 def attach(params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/payment_methods/%<payment_method>s/attach", { payment_method: CGI.escape(self["id"]) }), params: params, opts: opts ) end |
#detach(params = {}, opts = {}) ⇒ Object
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.
2543 2544 2545 2546 2547 2548 2549 2550 |
# File 'lib/stripe/resources/payment_method.rb', line 2543 def detach(params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/payment_methods/%<payment_method>s/detach", { payment_method: CGI.escape(self["id"]) }), params: params, opts: opts ) end |