Class: Yookassa::Entities::Payment

Inherits:
Base
  • Object
show all
Defined in:
lib/yookassa/entities/payment.rb

Overview

Payment entity with status helpers and confirmation URL access.

All attributes from the API response (id, status, amount, description, etc.) are accessible as methods via the inherited Base dynamic dispatch.

Instance Attribute Summary

Attributes inherited from Base

#attributes

Instance Method Summary collapse

Methods inherited from Base

#[], #initialize, #respond_to_missing?, #to_h

Constructor Details

This class inherits a constructor from Yookassa::Entities::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Yookassa::Entities::Base

Instance Method Details

#canceled?Boolean

Returns true if the payment was canceled.

Returns:

  • true if the payment was canceled



32
33
34
# File 'lib/yookassa/entities/payment.rb', line 32

def canceled?
  status == "canceled"
end

#confirmation_urlString?

Returns the confirmation URL for redirect-based payment flows.

Returns:

  • the URL to redirect the user to, or nil if not available



15
16
17
18
19
# File 'lib/yookassa/entities/payment.rb', line 15

def confirmation_url
  return nil unless attributes["confirmation"]

  attributes.dig("confirmation", "confirmation_url")
end

#pending?Boolean

Returns true if the payment is awaiting user action.

Returns:

  • true if the payment is awaiting user action



27
28
29
# File 'lib/yookassa/entities/payment.rb', line 27

def pending?
  status == "pending"
end

#succeeded?Boolean

Returns true if the payment completed successfully.

Returns:

  • true if the payment completed successfully



22
23
24
# File 'lib/yookassa/entities/payment.rb', line 22

def succeeded?
  status == "succeeded"
end

#waiting_for_capture?Boolean

Returns true if the payment is authorized and awaiting capture.

Returns:

  • true if the payment is authorized and awaiting capture



37
38
39
# File 'lib/yookassa/entities/payment.rb', line 37

def waiting_for_capture?
  status == "waiting_for_capture"
end