Sha256: 461ea1d7a6797339e6db23319171c648baeba8935e89941950134f5b60f09dc2

Contents?: true

Size: 853 Bytes

Versions: 3

Compression:

Stored size: 853 Bytes

Contents

module Akatus

  module Services

    class Transaction < Akatus::Service

      PATH   = 'carrinho'
      METHOD = :post

      def self.form_url
        Akatus.config.base_url + PATH
      end

      def self.create(*args)
        self.new.create(*args)
      end

      def create(payment)

        @payment = payment

        data = send_request

        @payment.id             = data['carrinho']

        # TODO: improve; use constants?
        @payment.status         = data['status']
        @payment.transaction_id = data['transacao']

        if data['url_retorno']
          @payment.url = data['url_retorno'].sub("https://www.akatus.com/", Akatus.config.base_url)
        end

        @payment

      end

      def status
        # TODO: implement.
      end

      def to_payload
        @payment.to_payload
      end

    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
akatus-1.0.2 lib/akatus/services/transaction.rb
akatus-1.0.1 lib/akatus/services/transaction.rb
akatus-1.0.0 lib/akatus/services/transaction.rb