Class: Yookassa::Resources::Payment
- Defined in:
- lib/yookassa/resources/payment.rb
Overview
REST resource for the /v3/payments endpoint.
Supports creating, finding, capturing, canceling, and listing payments.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#cancel(payment_id, idempotency_key: nil) ⇒ Entities::Payment
Cancels a payment that has not yet been captured.
-
#capture(payment_id, params = {}, idempotency_key: nil) ⇒ Entities::Payment
Captures an authorized payment (for two-stage payments).
-
#create(params, idempotency_key: nil) ⇒ Entities::Payment
Creates a new payment.
-
#find(payment_id) ⇒ Entities::Payment
Retrieves a payment by ID.
-
#list(**filters) ⇒ Entities::Collection<Entities::Payment>
Lists payments matching the given filters.
Methods inherited from Base
entity_class, #initialize, resource_path
Constructor Details
This class inherits a constructor from Yookassa::Resources::Base
Instance Method Details
#cancel(payment_id, idempotency_key: nil) ⇒ Entities::Payment
Cancels a payment that has not yet been captured.
50 51 52 53 |
# File 'lib/yookassa/resources/payment.rb', line 50 def cancel(payment_id, idempotency_key: nil) data = request(:post, "payments/#{payment_id}/cancel", idempotency_key: idempotency_key) Entities::Payment.new(data) end |
#capture(payment_id, params = {}, idempotency_key: nil) ⇒ Entities::Payment
Captures an authorized payment (for two-stage payments).
39 40 41 42 |
# File 'lib/yookassa/resources/payment.rb', line 39 def capture(payment_id, params = {}, idempotency_key: nil) data = request(:post, "payments/#{payment_id}/capture", body: params, idempotency_key: idempotency_key) Entities::Payment.new(data) end |
#create(params, idempotency_key: nil) ⇒ Entities::Payment
Creates a new payment.
17 18 19 20 |
# File 'lib/yookassa/resources/payment.rb', line 17 def create(params, idempotency_key: nil) data = request(:post, "payments", body: params, idempotency_key: idempotency_key) Entities::Payment.new(data) end |
#find(payment_id) ⇒ Entities::Payment
Retrieves a payment by ID.
27 28 29 30 |
# File 'lib/yookassa/resources/payment.rb', line 27 def find(payment_id) data = request(:get, "payments/#{payment_id}") Entities::Payment.new(data) end |
#list(**filters) ⇒ Entities::Collection<Entities::Payment>
Lists payments matching the given filters.
59 60 61 |
# File 'lib/yookassa/resources/payment.rb', line 59 def list(**filters) build_collection("payments", entity_class: Entities::Payment, query: filters) end |