Sha256: b5bea1441e8b1fb5348b63e27003a8b986375adec29911e70a5fa6e29e547a9a

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

module Justa
  class Pix < OrderCommom
    # def self.url(*params)
    #   ["/#{ CGI.escape underscored_class_name }", *params].join '/'
    # end

    def primary_key
      tx_id
    end

    #
    # Request approve to Justa api for this pix ( Only in DEVELOPMENT)
    #
    # @param [Hash] params Parameters for function
    # @option params [Numeric] :value (Required) The amount that will be approved in cents format
    # @option params [String] :end_to_end_id (Optional) The reference for the payment transaction
    # @return [Pix] Return model pix instance
    # @example Pay 1.0 of pix
    #     pix_instance.approve(value: 1.0)
    def approve(**params)
      raise JustaError, "Can't approve value in Production environment" if Justa.production?
      raise ParamError.new("Missing value param", :value, :integer, url("approve")) unless params.has_key? :value

      Justa::Request.post(url("approve"),
                          { append_document: false,
                            params: params.merge({ client_key: @client_key }) }).call underscored_class_name
      fetch
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
justa-ruby-0.1.9 lib/justa/resources/pix.rb