Module: PaymentKit::Resources::Payments
- Included in:
- Client
- Defined in:
- lib/payment_kit/resources/payments.rb
Overview
Payment intents, payment methods, refunds and checkout sessions.
Instance Method Summary collapse
-
#create_checkout_session(params = nil) ⇒ Object
Returns a session carrying the
secure_tokenused to initialise PaymentKit.js or redirect to hosted checkout. -
#create_payment_intent(params = nil) ⇒ Object
POST /payments/intents/ — takes
customer_id,amount_atom,currency,payment_method_id,processor_idandmetadata. -
#create_payment_method(params = nil) ⇒ Object
POST /payments/payment_methods/.
-
#deactivate_payment_method(id) ⇒ Object
Documented way to take a card out of use: flips
is_activeto false. -
#detach_payment_method(id) ⇒ Object
Removes the payment method outright.
-
#list_attempts_by_intent(payment_intent_id, params = {}) ⇒ Object
Auto-paginated Array of processor attempts for a payment intent.
-
#list_payment_intents(params = {}) ⇒ Object
GET /payments/intents/ — auto-paginated Array of payment intents.
-
#list_refunds_by_intent(payment_intent_id, params = {}) ⇒ Object
Auto-paginated Array of refunds recorded against a payment intent.
-
#retrieve_checkout_session(id) ⇒ Object
GET /checkout-sessions/id.
-
#retrieve_payment_intent(id, params = {}) ⇒ Object
Supports expand: "checkout_attempt".
-
#retrieve_payment_method(id) ⇒ Object
GET /payments/payment_methods/id.
-
#update_payment_method(id, params = nil) ⇒ Object
PUT /payments/payment_methods/id.
Instance Method Details
#create_checkout_session(params = nil) ⇒ Object
Returns a session carrying the secure_token used to initialise
PaymentKit.js or redirect to hosted checkout. line_items,
success_url and return_url are required.
63 64 65 |
# File 'lib/payment_kit/resources/payments.rb', line 63 def create_checkout_session(params = nil, **) post("/checkout-sessions", params, **) end |
#create_payment_intent(params = nil) ⇒ Object
POST /payments/intents/ — takes customer_id, amount_atom,
currency, payment_method_id, processor_id and metadata.
11 12 13 |
# File 'lib/payment_kit/resources/payments.rb', line 11 def create_payment_intent(params = nil, **) post("/payments/intents/", params, **) end |
#create_payment_method(params = nil) ⇒ Object
POST /payments/payment_methods/
34 35 36 |
# File 'lib/payment_kit/resources/payments.rb', line 34 def create_payment_method(params = nil, **) post("/payments/payment_methods/", params, **) end |
#deactivate_payment_method(id) ⇒ Object
Documented way to take a card out of use: flips is_active to false.
Prefer this over #detach_payment_method.
48 |
# File 'lib/payment_kit/resources/payments.rb', line 48 def deactivate_payment_method(id) = update_payment_method(id, is_active: false) |
#detach_payment_method(id) ⇒ Object
Removes the payment method outright.
NOTE: PaymentKit documents deletion only on the customer-portal surface (DELETE /billing-portal/token/{token}/payment-methods/{id}). This account-scoped delete is kept for backwards compatibility; if your account returns 404/405, use #deactivate_payment_method instead.
56 |
# File 'lib/payment_kit/resources/payments.rb', line 56 def detach_payment_method(id) = delete("/payments/payment_methods/#{id}") |
#list_attempts_by_intent(payment_intent_id, params = {}) ⇒ Object
Auto-paginated Array of processor attempts for a payment intent.
27 28 29 |
# File 'lib/payment_kit/resources/payments.rb', line 27 def list_attempts_by_intent(payment_intent_id, params = {}) list("/payments/processor_attempts/by_intent/#{payment_intent_id}", params) end |
#list_payment_intents(params = {}) ⇒ Object
GET /payments/intents/ — auto-paginated Array of payment intents.
19 |
# File 'lib/payment_kit/resources/payments.rb', line 19 def list_payment_intents(params = {}) = list("/payments/intents/", params) |
#list_refunds_by_intent(payment_intent_id, params = {}) ⇒ Object
Auto-paginated Array of refunds recorded against a payment intent.
22 23 24 |
# File 'lib/payment_kit/resources/payments.rb', line 22 def list_refunds_by_intent(payment_intent_id, params = {}) list("/payments/refunds/by_intent/#{payment_intent_id}", params) end |
#retrieve_checkout_session(id) ⇒ Object
GET /checkout-sessions/id
68 |
# File 'lib/payment_kit/resources/payments.rb', line 68 def retrieve_checkout_session(id) = get("/checkout-sessions/#{id}") |
#retrieve_payment_intent(id, params = {}) ⇒ Object
Supports expand: "checkout_attempt".
16 |
# File 'lib/payment_kit/resources/payments.rb', line 16 def retrieve_payment_intent(id, params = {}) = get("/payments/intents/#{id}", params) |
#retrieve_payment_method(id) ⇒ Object
GET /payments/payment_methods/id
39 |
# File 'lib/payment_kit/resources/payments.rb', line 39 def retrieve_payment_method(id) = get("/payments/payment_methods/#{id}") |
#update_payment_method(id, params = nil) ⇒ Object
PUT /payments/payment_methods/id
42 43 44 |
# File 'lib/payment_kit/resources/payments.rb', line 42 def update_payment_method(id, params = nil, **) put("/payments/payment_methods/#{id}", params, **) end |