Sha256: 24d64458f7ca8d8f875281a52356bc194fe5aad22f1c317bdb86fa36b694e033
Contents?: true
Size: 1016 Bytes
Versions: 20
Compression:
Stored size: 1016 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.payment_id}/confirmacao" end end end end
Version data entries
20 entries across 20 versions & 1 rubygems