Sha256: 95de38496f35a3293506f9b6faff64895163ab9ae0d46a7fad26208f46edb543
Contents?: true
Size: 1008 Bytes
Versions: 2
Compression:
Stored size: 1008 Bytes
Contents
module Bs2Api module Payment class Confirmation < Base attr_reader :success def initialize payment, value: 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 end def call response = post_request raise Bs2Api::Errors::ConfirmationError, ::Util::Response.parse_error(response) unless response.accepted? @success = true self end def success? !!@success end private def payload @payment.to_hash .except!("pagamentoId", "endToEndId") .merge("valor": @value) end def url "#{Bs2Api.endpoint}/pix/direto/forintegration/v1/pagamentos/#{@payment.id}/confirmacao" end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
bs2_api-0.4.0 | lib/bs2_api/payment/confirmation.rb |
bs2_api-0.3.4 | lib/bs2_api/payment/confirmation.rb |