Class: Bs2Api::Payment::Confirmation
- Defined in:
- lib/bs2_api/payment/confirmation.rb
Instance Attribute Summary collapse
-
#success ⇒ Object
readonly
Returns the value of attribute success.
Attributes inherited from Base
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(payment, value: nil, client_id: Bs2Api.configuration.client_id, client_secret: Bs2Api.configuration.client_secret, proxy: nil) ⇒ Confirmation
constructor
A new instance of Confirmation.
- #success? ⇒ Boolean
Constructor Details
#initialize(payment, value: nil, client_id: Bs2Api.configuration.client_id, client_secret: Bs2Api.configuration.client_secret, proxy: nil) ⇒ Confirmation
Returns a new instance of Confirmation.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/bs2_api/payment/confirmation.rb', line 6 def initialize( payment, value: nil, client_id: Bs2Api.configuration.client_id, client_secret: Bs2Api.configuration.client_secret, proxy: nil ) raise Bs2Api::Errors::ConfirmationError, 'invalid payment' unless payment.present? && payment.is_a?(Bs2Api::Entities::Payment) raise Bs2Api::Errors::ConfirmationError, 'invalid value' unless value.to_f.positive? @payment = payment @value = value.to_f @client_id = client_id @client_secret = client_secret @proxy = proxy end |
Instance Attribute Details
#success ⇒ Object (readonly)
Returns the value of attribute success.
4 5 6 |
# File 'lib/bs2_api/payment/confirmation.rb', line 4 def success @success end |
Instance Method Details
#call ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/bs2_api/payment/confirmation.rb', line 24 def call response = post_request raise Bs2Api::Errors::ConfirmationError, ::Util::Response.parse_error(response) unless response.accepted? @success = true self end |
#success? ⇒ Boolean
32 33 34 |
# File 'lib/bs2_api/payment/confirmation.rb', line 32 def success? !!@success end |