lib/stripe/resources/payment_method.rb in stripe-10.11.0 vs lib/stripe/resources/payment_method.rb in stripe-10.12.0.pre.beta.1
- old
+ new
@@ -37,20 +37,10 @@
params: params,
opts: opts
)
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(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
-
# 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
@@ -69,24 +59,34 @@
params: params,
opts: opts
)
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 self.create(params = {}, opts = {})
+ request_stripe_object(method: :post, path: "/v1/payment_methods", params: params, opts: opts)
+ 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 self.detach(payment_method, params = {}, opts = {})
+ def detach(params = {}, opts = {})
request_stripe_object(
method: :post,
- path: format("/v1/payment_methods/%<payment_method>s/detach", { payment_method: CGI.escape(payment_method) }),
+ path: format("/v1/payment_methods/%<payment_method>s/detach", { payment_method: CGI.escape(self["id"]) }),
params: params,
opts: opts
)
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 self.create(params = {}, opts = {})
- request_stripe_object(method: :post, path: "/v1/payment_methods", params: params, opts: opts)
+ # 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 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
# 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 self.list(filters = {}, opts = {})
request_stripe_object(method: :get, path: "/v1/payment_methods", params: filters, opts: opts)