pagseguro-oficial 2.0.5 → 2.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/.gitignore +8 -0
 - data/.travis.yml +4 -1
 - data/CHANGELOG.md +36 -0
 - data/Gemfile +1 -1
 - data/README.md +27 -27
 - data/examples/payment_request.rb +5 -1
 - data/lib/pagseguro.rb +16 -11
 - data/lib/pagseguro/config.rb +14 -0
 - data/lib/pagseguro/payment_request.rb +3 -0
 - data/lib/pagseguro/payment_request/serializer.rb +9 -0
 - data/lib/pagseguro/version.rb +1 -1
 - data/spec/pagseguro/config_spec.rb +5 -0
 - data/spec/pagseguro/pagseguro_spec.rb +31 -3
 - data/spec/pagseguro/payment_request/serializer_spec.rb +14 -0
 - data/spec/pagseguro/payment_request_spec.rb +16 -0
 - data/spec/pagseguro/transaction/serializer_spec.rb +1 -1
 - data/spec/pagseguro/transaction_spec.rb +1 -1
 - data/spec/support/shared_examples_for_configuration.rb +8 -0
 - metadata +9 -3
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 788279b727dd7437ae09d37c26ae11bac42e8310
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: d2523d522ed794650fe5d807c64104e230a11824
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: e24fe077d815397578847a3d2e842803d2ba2894eb82a846ee521989d694891a551f3105d9ca9dda5b8a30c294c0b68a6c4c8de8811ba4ee94ea626e95e9663f
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 1fcd33a1722fd8d9b985f3385220ada6dc81a1b183f77f3bbb9b950a7bbb728a44ca6f3bbef02dc0405b3c36f33c26b1e3965abe80826fc4ebd95b264b695a5a
         
     | 
    
        data/.gitignore
    CHANGED
    
    
    
        data/.travis.yml
    CHANGED
    
    
    
        data/CHANGELOG.md
    ADDED
    
    | 
         @@ -0,0 +1,36 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ## Next release - 2.0.7
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
             - Suporte para adicionar parâmetros dinamicamente na criação de requisições de pagamentos (isso possibilita a utilização de parâmetros da api que ainda não foram mapeados na gem)
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            ## Stable
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            2.0.6
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
             - Adicionando environment sandbox, entre outras melhorias
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            2.0.5
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
             - Fixa a versão da biblioteca Aitch; a versão antiga não possui a mesma API utilizada nesta gem.
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            2.0.4
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
             - PaymentRequest com email e token alternativos
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            2.0.3
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
             - Ajuste no parser XML e paginação de relatórios.
         
     | 
| 
      
 22 
     | 
    
         
            +
             - Incluindo parâmetro para indicar a página inicial em uma busca de transações.
         
     | 
| 
      
 23 
     | 
    
         
            +
             - Correções de testes.
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
            2.0.2
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
             - Atualização dos tipos e códigos de meio de pagamento.
         
     | 
| 
      
 28 
     | 
    
         
            +
             - Correção do exemplo payment_request.
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
            2.0.1
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
             - Classes de domínios que representam pagamentos, notificações e transações.
         
     | 
| 
      
 33 
     | 
    
         
            +
             - Criação de checkouts via API.
         
     | 
| 
      
 34 
     | 
    
         
            +
             - Tratamento de notificações de pagamento enviadas pelo PagSeguro.
         
     | 
| 
      
 35 
     | 
    
         
            +
             - Consulta de transações.
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
    
        data/Gemfile
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | 
         @@ -58,7 +58,7 @@ class CheckoutController < ApplicationController 
     | 
|
| 
       58 
58 
     | 
    
         | 
| 
       59 
59 
     | 
    
         
             
                payment = PagSeguro::PaymentRequest.new
         
     | 
| 
       60 
60 
     | 
    
         | 
| 
       61 
     | 
    
         
            -
                # Você também pode fazer o request de pagamento usando credenciais 
     | 
| 
      
 61 
     | 
    
         
            +
                # Você também pode fazer o request de pagamento usando credenciais
         
     | 
| 
       62 
62 
     | 
    
         
             
                # diferentes, como no exemplo abaixo
         
     | 
| 
       63 
63 
     | 
    
         | 
| 
       64 
64 
     | 
    
         
             
                payment = PagSeguro::PaymentRequest.new(email: 'abc@email', token: 'token')
         
     | 
| 
         @@ -76,6 +76,12 @@ class CheckoutController < ApplicationController 
     | 
|
| 
       76 
76 
     | 
    
         
             
                  }
         
     | 
| 
       77 
77 
     | 
    
         
             
                end
         
     | 
| 
       78 
78 
     | 
    
         | 
| 
      
 79 
     | 
    
         
            +
                # Caso você precise passar parâmetros para a api que ainda não foram
         
     | 
| 
      
 80 
     | 
    
         
            +
                # mapeados na gem, você pode fazer de maneira dinâmica utilizando um
         
     | 
| 
      
 81 
     | 
    
         
            +
                # simples hash.
         
     | 
| 
      
 82 
     | 
    
         
            +
                payment.extra_params << { extraParam: 'value' }
         
     | 
| 
      
 83 
     | 
    
         
            +
                payment.extra_params << { itemExtra1: 'value1' }
         
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
       79 
85 
     | 
    
         
             
                response = payment.register
         
     | 
| 
       80 
86 
     | 
    
         | 
| 
       81 
87 
     | 
    
         
             
                # Caso o processo de checkout tenha dado errado, lança uma exceção.
         
     | 
| 
         @@ -257,29 +263,20 @@ payment.max_uses = 100 
     | 
|
| 
       257 
263 
     | 
    
         
             
            payment.max_age = 3600  # em segundos
         
     | 
| 
       258 
264 
     | 
    
         
             
            ```
         
     | 
| 
       259 
265 
     | 
    
         | 
| 
       260 
     | 
    
         
            -
             
     | 
| 
       261 
     | 
    
         
            -
             
     | 
| 
       262 
     | 
    
         
            -
            2.0.4
         
     | 
| 
      
 266 
     | 
    
         
            +
            #### Definindo environment e/ou encoding
         
     | 
| 
       263 
267 
     | 
    
         | 
| 
       264 
     | 
    
         
            -
             
     | 
| 
       265 
     | 
    
         
            -
             
     | 
| 
       266 
     | 
    
         
            -
             
     | 
| 
      
 268 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 269 
     | 
    
         
            +
            PagSeguro.environment = "production" # production ou sandbox
         
     | 
| 
      
 270 
     | 
    
         
            +
            PagSeguro.encoding = "UTF-8" # UTF-8 ou ISO-8859-1
         
     | 
| 
      
 271 
     | 
    
         
            +
            ```
         
     | 
| 
       267 
272 
     | 
    
         | 
| 
       268 
     | 
    
         
            -
              
     | 
| 
       269 
     | 
    
         
            -
             - Incluindo parâmetro para indicar a página inicial em uma busca de transações.
         
     | 
| 
       270 
     | 
    
         
            -
             - Correções de testes.
         
     | 
| 
       271 
     | 
    
         
            -
             
         
     | 
| 
       272 
     | 
    
         
            -
            2.0.2
         
     | 
| 
      
 273 
     | 
    
         
            +
            ## Dúvidas?
         
     | 
| 
       273 
274 
     | 
    
         | 
| 
       274 
     | 
    
         
            -
              
     | 
| 
       275 
     | 
    
         
            -
             - Correção do exemplo payment_request.
         
     | 
| 
      
 275 
     | 
    
         
            +
            Caso tenha dúvidas ou precise de suporte, acesse nosso [fórum].
         
     | 
| 
       276 
276 
     | 
    
         | 
| 
       277 
     | 
    
         
            -
             
     | 
| 
      
 277 
     | 
    
         
            +
            ## Changelog
         
     | 
| 
       278 
278 
     | 
    
         | 
| 
       279 
     | 
    
         
            -
             
     | 
| 
       280 
     | 
    
         
            -
             - Criação de checkouts via API.
         
     | 
| 
       281 
     | 
    
         
            -
             - Tratamento de notificações de pagamento enviadas pelo PagSeguro.
         
     | 
| 
       282 
     | 
    
         
            -
             - Consulta de transações.
         
     | 
| 
      
 279 
     | 
    
         
            +
            https://github.com/pagseguro/ruby/blob/master/CHANGELOG.md
         
     | 
| 
       283 
280 
     | 
    
         | 
| 
       284 
281 
     | 
    
         
             
            ## Licença
         
     | 
| 
       285 
282 
     | 
    
         | 
| 
         @@ -297,16 +294,19 @@ Unless required by applicable law or agreed to in writing, software distributed 
     | 
|
| 
       297 
294 
     | 
    
         
             
             - Certifique-se que tenha definido corretamente o charset de acordo com a codificação (ISO-8859-1 ou UTF-8) do seu sistema. Isso irá prevenir que as transações gerem possíveis erros ou quebras ou ainda que caracteres especiais possam ser apresentados de maneira diferente do habitual.
         
     | 
| 
       298 
295 
     | 
    
         
             
             - Para que ocorra normalmente a geração de logs, certifique-se que o diretório e o arquivo de log tenham permissões de leitura e escrita.
         
     | 
| 
       299 
296 
     | 
    
         | 
| 
       300 
     | 
    
         
            -
            ## [Dúvidas?]
         
     | 
| 
       301 
     | 
    
         
            -
             
     | 
| 
       302 
     | 
    
         
            -
             
     | 
| 
       303 
297 
     | 
    
         
             
            ## Contribuições
         
     | 
| 
       304 
298 
     | 
    
         | 
| 
       305 
299 
     | 
    
         
             
            Achou e corrigiu um bug ou tem alguma feature em mente e deseja contribuir?
         
     | 
| 
       306 
300 
     | 
    
         | 
| 
       307 
     | 
    
         
            -
            * Faça um fork 
     | 
| 
       308 
     | 
    
         
            -
            * Adicione sua feature ou correção de bug 
     | 
| 
       309 
     | 
    
         
            -
            *  
     | 
| 
      
 301 
     | 
    
         
            +
            * Faça um fork
         
     | 
| 
      
 302 
     | 
    
         
            +
            * Adicione sua feature ou correção de bug (`git checkout -b my-new-feature`)
         
     | 
| 
      
 303 
     | 
    
         
            +
            * Commit suas mudanças (`git commit -am 'Added some feature'`)
         
     | 
| 
      
 304 
     | 
    
         
            +
            * Rode um push para o branch (`git push origin my-new-feature`)
         
     | 
| 
      
 305 
     | 
    
         
            +
            * Envie um Pull Request
         
     | 
| 
      
 306 
     | 
    
         
            +
             
     | 
| 
      
 307 
     | 
    
         
            +
            O código, os commits e os comentários devem ser em inglês.
         
     | 
| 
      
 308 
     | 
    
         
            +
            Adicione exemplos para sua nova feature.
         
     | 
| 
      
 309 
     | 
    
         
            +
            Se seu Pull Request for relacionado a uma versão específica, o Pull Request não deve ser enviado para o branch master e sim para o branch correspondente a versão.
         
     | 
| 
       310 
310 
     | 
    
         | 
| 
       311 
311 
     | 
    
         | 
| 
       312 
312 
     | 
    
         
             
              [requisições de pagamentos]: https://pagseguro.uol.com.br/v2/guia-de-integracao/api-de-pagamentos.html
         
     | 
| 
         @@ -314,7 +314,7 @@ Achou e corrigiu um bug ou tem alguma feature em mente e deseja contribuir? 
     | 
|
| 
       314 
314 
     | 
    
         
             
              [transações por código]: https://pagseguro.uol.com.br/v2/guia-de-integracao/consulta-de-transacoes-por-codigo.html
         
     | 
| 
       315 
315 
     | 
    
         
             
              [transações por intervalo de datas]: https://pagseguro.uol.com.br/v2/guia-de-integracao/consulta-de-transacoes-por-intervalo-de-datas.html
         
     | 
| 
       316 
316 
     | 
    
         
             
              [transações abandonadas]: https://pagseguro.uol.com.br/v2/guia-de-integracao/consulta-de-transacoes-abandonadas.html
         
     | 
| 
       317 
     | 
    
         
            -
              [ 
     | 
| 
      
 317 
     | 
    
         
            +
              [fórum]: http://forum.pagseguro.uol.com.br/
         
     | 
| 
       318 
318 
     | 
    
         
             
              [Ruby]: http://www.ruby-lang.org/pt/
         
     | 
| 
       319 
319 
     | 
    
         
             
              [GitHub]: https://github.com/pagseguro/ruby/
         
     | 
| 
       320 
     | 
    
         
            -
              [Aitch]: https://github.com/fnando/aitch
         
     | 
| 
      
 320 
     | 
    
         
            +
              [Aitch]: https://github.com/fnando/aitch
         
     | 
    
        data/examples/payment_request.rb
    CHANGED
    
    | 
         @@ -1,4 +1,4 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # -*- encoding : utf-8 -*- 
     | 
| 
      
 1 
     | 
    
         
            +
            # -*- encoding : utf-8 -*-
         
     | 
| 
       2 
2 
     | 
    
         
             
            require_relative "boot"
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
4 
     | 
    
         
             
            payment = PagSeguro::PaymentRequest.new
         
     | 
| 
         @@ -36,6 +36,10 @@ payment.shipping = { 
     | 
|
| 
       36 
36 
     | 
    
         
             
              }
         
     | 
| 
       37 
37 
     | 
    
         
             
            }
         
     | 
| 
       38 
38 
     | 
    
         | 
| 
      
 39 
     | 
    
         
            +
            # Add extras params to request
         
     | 
| 
      
 40 
     | 
    
         
            +
            # payment.extra_params << { extraParam: 'value' }
         
     | 
| 
      
 41 
     | 
    
         
            +
            # payment.extra_params << { itemExtra1: 'value1' }
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
       39 
43 
     | 
    
         
             
            puts "=> REQUEST"
         
     | 
| 
       40 
44 
     | 
    
         
             
            puts PagSeguro::PaymentRequest::Serializer.new(payment).to_params
         
     | 
| 
       41 
45 
     | 
    
         | 
    
        data/lib/pagseguro.rb
    CHANGED
    
    | 
         @@ -7,6 +7,7 @@ require "aitch" 
     | 
|
| 
       7 
7 
     | 
    
         
             
            require "i18n"
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
9 
     | 
    
         
             
            require "pagseguro/version"
         
     | 
| 
      
 10 
     | 
    
         
            +
            require "pagseguro/config"
         
     | 
| 
       10 
11 
     | 
    
         
             
            require "pagseguro/errors"
         
     | 
| 
       11 
12 
     | 
    
         
             
            require "pagseguro/exceptions"
         
     | 
| 
       12 
13 
     | 
    
         
             
            require "pagseguro/extensions/mass_assignment"
         
     | 
| 
         @@ -33,21 +34,16 @@ I18n.load_path += Dir[File.expand_path("../../locales/*.yml", __FILE__)] 
     | 
|
| 
       33 
34 
     | 
    
         | 
| 
       34 
35 
     | 
    
         
             
            module PagSeguro
         
     | 
| 
       35 
36 
     | 
    
         
             
              class << self
         
     | 
| 
       36 
     | 
    
         
            -
                #  
     | 
| 
       37 
     | 
    
         
            -
                 
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
       39 
     | 
    
         
            -
                 
     | 
| 
       40 
     | 
    
         
            -
                # to PagSeguro.
         
     | 
| 
       41 
     | 
    
         
            -
                attr_accessor :receiver_email
         
     | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
       43 
     | 
    
         
            -
                # The API token associated with this account.
         
     | 
| 
       44 
     | 
    
         
            -
                attr_accessor :token
         
     | 
| 
      
 37 
     | 
    
         
            +
                # Delegates some calls to the config object
         
     | 
| 
      
 38 
     | 
    
         
            +
                extend Forwardable
         
     | 
| 
      
 39 
     | 
    
         
            +
                def_delegators :configuration, :email, :receiver_email, :token
         
     | 
| 
      
 40 
     | 
    
         
            +
                def_delegators :configuration, :email=, :receiver_email=, :token=
         
     | 
| 
       45 
41 
     | 
    
         | 
| 
       46 
42 
     | 
    
         
             
                # The encoding that will be used.
         
     | 
| 
       47 
43 
     | 
    
         
             
                attr_accessor :encoding
         
     | 
| 
       48 
44 
     | 
    
         | 
| 
       49 
45 
     | 
    
         
             
                # The PagSeguro environment.
         
     | 
| 
       50 
     | 
    
         
            -
                #  
     | 
| 
      
 46 
     | 
    
         
            +
                # +production+ or +sandbox+.
         
     | 
| 
       51 
47 
     | 
    
         
             
                attr_accessor :environment
         
     | 
| 
       52 
48 
     | 
    
         
             
              end
         
     | 
| 
       53 
49 
     | 
    
         | 
| 
         @@ -60,6 +56,10 @@ module PagSeguro 
     | 
|
| 
       60 
56 
     | 
    
         
             
                  production: {
         
     | 
| 
       61 
57 
     | 
    
         
             
                    api: "https://ws.pagseguro.uol.com.br/v2",
         
     | 
| 
       62 
58 
     | 
    
         
             
                    site: "https://pagseguro.uol.com.br/v2"
         
     | 
| 
      
 59 
     | 
    
         
            +
                  },
         
     | 
| 
      
 60 
     | 
    
         
            +
                  sandbox: {
         
     | 
| 
      
 61 
     | 
    
         
            +
                    site: 'https://sandbox.pagseguro.uol.com.br/v2',
         
     | 
| 
      
 62 
     | 
    
         
            +
                    api:  'https://ws.sandbox.pagseguro.uol.com.br/v2'
         
     | 
| 
       63 
63 
     | 
    
         
             
                  }
         
     | 
| 
       64 
64 
     | 
    
         
             
                }
         
     | 
| 
       65 
65 
     | 
    
         
             
              end
         
     | 
| 
         @@ -71,6 +71,11 @@ module PagSeguro 
     | 
|
| 
       71 
71 
     | 
    
         
             
                root[type.to_sym]
         
     | 
| 
       72 
72 
     | 
    
         
             
              end
         
     | 
| 
       73 
73 
     | 
    
         | 
| 
      
 74 
     | 
    
         
            +
              # The configuration intance for the thread
         
     | 
| 
      
 75 
     | 
    
         
            +
              def self.configuration
         
     | 
| 
      
 76 
     | 
    
         
            +
                Thread.current[:pagseguro_config] ||= PagSeguro::Config.new
         
     | 
| 
      
 77 
     | 
    
         
            +
              end
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
       74 
79 
     | 
    
         
             
              # Set the global configuration.
         
     | 
| 
       75 
80 
     | 
    
         
             
              #
         
     | 
| 
       76 
81 
     | 
    
         
             
              #   PagSeguro.configure do |config|
         
     | 
| 
         @@ -79,7 +84,7 @@ module PagSeguro 
     | 
|
| 
       79 
84 
     | 
    
         
             
              #   end
         
     | 
| 
       80 
85 
     | 
    
         
             
              #
         
     | 
| 
       81 
86 
     | 
    
         
             
              def self.configure(&block)
         
     | 
| 
       82 
     | 
    
         
            -
                yield  
     | 
| 
      
 87 
     | 
    
         
            +
                yield configuration
         
     | 
| 
       83 
88 
     | 
    
         
             
              end
         
     | 
| 
       84 
89 
     | 
    
         | 
| 
       85 
90 
     | 
    
         
             
              # The API endpoint.
         
     | 
| 
         @@ -0,0 +1,14 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module PagSeguro
         
     | 
| 
      
 2 
     | 
    
         
            +
              # Holds the configuration of the user
         
     | 
| 
      
 3 
     | 
    
         
            +
              class Config
         
     | 
| 
      
 4 
     | 
    
         
            +
                # Primary e-mail associated with this account.
         
     | 
| 
      
 5 
     | 
    
         
            +
                attr_accessor :email
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
                # The e-mail that will be displayed when sender is redirected
         
     | 
| 
      
 8 
     | 
    
         
            +
                # to PagSeguro.
         
     | 
| 
      
 9 
     | 
    
         
            +
                attr_accessor :receiver_email
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                # The API token associated with this account.
         
     | 
| 
      
 12 
     | 
    
         
            +
                attr_accessor :token
         
     | 
| 
      
 13 
     | 
    
         
            +
              end
         
     | 
| 
      
 14 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -57,6 +57,8 @@ module PagSeguro 
     | 
|
| 
       57 
57 
     | 
    
         
             
                # The token that identifies the request. Defaults to PagSeguro.token
         
     | 
| 
       58 
58 
     | 
    
         
             
                attr_accessor :token
         
     | 
| 
       59 
59 
     | 
    
         | 
| 
      
 60 
     | 
    
         
            +
                # The extra parameters for payment request
         
     | 
| 
      
 61 
     | 
    
         
            +
                attr_accessor :extra_params
         
     | 
| 
       60 
62 
     | 
    
         | 
| 
       61 
63 
     | 
    
         
             
                # Products/items in this payment request.
         
     | 
| 
       62 
64 
     | 
    
         
             
                def items
         
     | 
| 
         @@ -84,6 +86,7 @@ module PagSeguro 
     | 
|
| 
       84 
86 
     | 
    
         | 
| 
       85 
87 
     | 
    
         
             
                private
         
     | 
| 
       86 
88 
     | 
    
         
             
                def before_initialize
         
     | 
| 
      
 89 
     | 
    
         
            +
                  self.extra_params = []
         
     | 
| 
       87 
90 
     | 
    
         
             
                  self.currency = "BRL"
         
     | 
| 
       88 
91 
     | 
    
         
             
                  self.email    = PagSeguro.email
         
     | 
| 
       89 
92 
     | 
    
         
             
                  self.token    = PagSeguro.token
         
     | 
| 
         @@ -24,6 +24,7 @@ module PagSeguro 
     | 
|
| 
       24 
24 
     | 
    
         | 
| 
       25 
25 
     | 
    
         
             
                    serialize_sender(payment_request.sender)
         
     | 
| 
       26 
26 
     | 
    
         
             
                    serialize_shipping(payment_request.shipping)
         
     | 
| 
      
 27 
     | 
    
         
            +
                    serialize_extra_params(payment_request.extra_params)
         
     | 
| 
       27 
28 
     | 
    
         | 
| 
       28 
29 
     | 
    
         
             
                    params.delete_if {|key, value| value.nil? }
         
     | 
| 
       29 
30 
     | 
    
         | 
| 
         @@ -83,6 +84,14 @@ module PagSeguro 
     | 
|
| 
       83 
84 
     | 
    
         
             
                    params[:shippingAddressComplement] = address.complement
         
     | 
| 
       84 
85 
     | 
    
         
             
                  end
         
     | 
| 
       85 
86 
     | 
    
         | 
| 
      
 87 
     | 
    
         
            +
                  def serialize_extra_params(extra_params)
         
     | 
| 
      
 88 
     | 
    
         
            +
                    return unless extra_params
         
     | 
| 
      
 89 
     | 
    
         
            +
             
     | 
| 
      
 90 
     | 
    
         
            +
                    extra_params.each do |extra_param|
         
     | 
| 
      
 91 
     | 
    
         
            +
                      params[extra_param.keys.first] = extra_param.values.first
         
     | 
| 
      
 92 
     | 
    
         
            +
                    end
         
     | 
| 
      
 93 
     | 
    
         
            +
                  end
         
     | 
| 
      
 94 
     | 
    
         
            +
             
     | 
| 
       86 
95 
     | 
    
         
             
                  def to_amount(amount)
         
     | 
| 
       87 
96 
     | 
    
         
             
                    "%.2f" % BigDecimal(amount.to_s).round(2).to_s("F") if amount
         
     | 
| 
       88 
97 
     | 
    
         
             
                  end
         
     | 
    
        data/lib/pagseguro/version.rb
    CHANGED
    
    
| 
         @@ -11,11 +11,27 @@ describe PagSeguro do 
     | 
|
| 
       11 
11 
     | 
    
         
             
              it { expect(PagSeguro.token).to eql("TOKEN") }
         
     | 
| 
       12 
12 
     | 
    
         
             
              it { expect(PagSeguro.receiver_email).to eql("RECEIVER_EMAIL") }
         
     | 
| 
       13 
13 
     | 
    
         | 
| 
      
 14 
     | 
    
         
            +
              context "config delegation" do
         
     | 
| 
      
 15 
     | 
    
         
            +
                subject { PagSeguro }
         
     | 
| 
      
 16 
     | 
    
         
            +
                it_behaves_like "a configuration"
         
     | 
| 
      
 17 
     | 
    
         
            +
              end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
       14 
19 
     | 
    
         
             
              context "configuring library" do
         
     | 
| 
       15 
20 
     | 
    
         
             
                it "yields PagSeguro" do
         
     | 
| 
       16 
21 
     | 
    
         
             
                  expect {|block|
         
     | 
| 
       17 
22 
     | 
    
         
             
                    PagSeguro.configure(&block)
         
     | 
| 
       18 
     | 
    
         
            -
                  }.to yield_with_args(PagSeguro)
         
     | 
| 
      
 23 
     | 
    
         
            +
                  }.to yield_with_args(PagSeguro::Config)
         
     | 
| 
      
 24 
     | 
    
         
            +
                end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                it "is threadsafe" do
         
     | 
| 
      
 27 
     | 
    
         
            +
                  thread = Thread.new do
         
     | 
| 
      
 28 
     | 
    
         
            +
                    PagSeguro.configure do |config|
         
     | 
| 
      
 29 
     | 
    
         
            +
                      config.receiver_email = 'ANOTHER_RECEIVER_EMAIL'
         
     | 
| 
      
 30 
     | 
    
         
            +
                    end
         
     | 
| 
      
 31 
     | 
    
         
            +
                  end
         
     | 
| 
      
 32 
     | 
    
         
            +
                  thread.join
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                  expect(PagSeguro.receiver_email).to eql("RECEIVER_EMAIL")
         
     | 
| 
       19 
35 
     | 
    
         
             
                end
         
     | 
| 
       20 
36 
     | 
    
         
             
              end
         
     | 
| 
       21 
37 
     | 
    
         | 
| 
         @@ -33,9 +49,16 @@ describe PagSeguro do 
     | 
|
| 
       33 
49 
     | 
    
         
             
                  }.to raise_exception(PagSeguro::InvalidEnvironmentError)
         
     | 
| 
       34 
50 
     | 
    
         
             
                end
         
     | 
| 
       35 
51 
     | 
    
         | 
| 
       36 
     | 
    
         
            -
                it "returns api url" do
         
     | 
| 
      
 52 
     | 
    
         
            +
                it "returns production api url when the environment is :production" do
         
     | 
| 
       37 
53 
     | 
    
         
             
                  expect(PagSeguro.api_url("/some/path")).to eql("https://ws.pagseguro.uol.com.br/v2/some/path")
         
     | 
| 
       38 
54 
     | 
    
         
             
                end
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
                it "returns sandbox api url when the environment is :sandbox" do
         
     | 
| 
      
 57 
     | 
    
         
            +
                  PagSeguro.environment = :sandbox
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
                  expect(PagSeguro.api_url("/some/path")).to eql("https://ws.sandbox.pagseguro.uol.com.br/v2/some/path")
         
     | 
| 
      
 60 
     | 
    
         
            +
                end
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
       39 
62 
     | 
    
         
             
              end
         
     | 
| 
       40 
63 
     | 
    
         | 
| 
       41 
64 
     | 
    
         
             
              describe ".site_url" do
         
     | 
| 
         @@ -47,8 +70,13 @@ describe PagSeguro do 
     | 
|
| 
       47 
70 
     | 
    
         
             
                  }.to raise_exception(PagSeguro::InvalidEnvironmentError)
         
     | 
| 
       48 
71 
     | 
    
         
             
                end
         
     | 
| 
       49 
72 
     | 
    
         | 
| 
       50 
     | 
    
         
            -
                it "returns site url" do
         
     | 
| 
      
 73 
     | 
    
         
            +
                it "returns production site url when the environment is production" do
         
     | 
| 
       51 
74 
     | 
    
         
             
                  expect(PagSeguro.site_url("/some/path")).to eql("https://pagseguro.uol.com.br/v2/some/path")
         
     | 
| 
       52 
75 
     | 
    
         
             
                end
         
     | 
| 
      
 76 
     | 
    
         
            +
             
     | 
| 
      
 77 
     | 
    
         
            +
                it "returns sandbox site url when the environment is :sandbox" do
         
     | 
| 
      
 78 
     | 
    
         
            +
                  PagSeguro.environment = :sandbox
         
     | 
| 
      
 79 
     | 
    
         
            +
                  expect(PagSeguro.site_url("/some/path")).to eql("https://sandbox.pagseguro.uol.com.br/v2/some/path")
         
     | 
| 
      
 80 
     | 
    
         
            +
                end
         
     | 
| 
       53 
81 
     | 
    
         
             
              end
         
     | 
| 
       54 
82 
     | 
    
         
             
            end
         
     | 
| 
         @@ -139,4 +139,18 @@ describe PagSeguro::PaymentRequest::Serializer do 
     | 
|
| 
       139 
139 
     | 
    
         
             
                it_behaves_like "item serialization", 1
         
     | 
| 
       140 
140 
     | 
    
         
             
                it_behaves_like "item serialization", 2
         
     | 
| 
       141 
141 
     | 
    
         
             
              end
         
     | 
| 
      
 142 
     | 
    
         
            +
             
     | 
| 
      
 143 
     | 
    
         
            +
              context "extra params serialization" do
         
     | 
| 
      
 144 
     | 
    
         
            +
                before do
         
     | 
| 
      
 145 
     | 
    
         
            +
                  payment_request.stub({
         
     | 
| 
      
 146 
     | 
    
         
            +
                    extra_params: [
         
     | 
| 
      
 147 
     | 
    
         
            +
                      { extraParam: 'param_value' },
         
     | 
| 
      
 148 
     | 
    
         
            +
                      { newExtraParam: 'extra_param_value' }
         
     | 
| 
      
 149 
     | 
    
         
            +
                    ]
         
     | 
| 
      
 150 
     | 
    
         
            +
                  })
         
     | 
| 
      
 151 
     | 
    
         
            +
                end
         
     | 
| 
      
 152 
     | 
    
         
            +
             
     | 
| 
      
 153 
     | 
    
         
            +
                it { expect(params).to include(extraParam: 'param_value') }
         
     | 
| 
      
 154 
     | 
    
         
            +
                it { expect(params).to include(newExtraParam: 'extra_param_value') }
         
     | 
| 
      
 155 
     | 
    
         
            +
              end
         
     | 
| 
       142 
156 
     | 
    
         
             
            end
         
     | 
| 
         @@ -104,4 +104,20 @@ describe PagSeguro::PaymentRequest do 
     | 
|
| 
       104 
104 
     | 
    
         
             
                  expect(payment.register).to eql(response)
         
     | 
| 
       105 
105 
     | 
    
         
             
                end
         
     | 
| 
       106 
106 
     | 
    
         
             
              end
         
     | 
| 
      
 107 
     | 
    
         
            +
             
     | 
| 
      
 108 
     | 
    
         
            +
              describe "#extra_params" do
         
     | 
| 
      
 109 
     | 
    
         
            +
                it "is empty before initialization" do
         
     | 
| 
      
 110 
     | 
    
         
            +
                  expect(subject.extra_params).to eql([])
         
     | 
| 
      
 111 
     | 
    
         
            +
                end
         
     | 
| 
      
 112 
     | 
    
         
            +
             
     | 
| 
      
 113 
     | 
    
         
            +
                it "allows extra parameter addition" do
         
     | 
| 
      
 114 
     | 
    
         
            +
                  subject.extra_params << { extraParam: 'value' }
         
     | 
| 
      
 115 
     | 
    
         
            +
                  subject.extra_params << { itemParam1: 'value1' }
         
     | 
| 
      
 116 
     | 
    
         
            +
             
     | 
| 
      
 117 
     | 
    
         
            +
                  expect(subject.extra_params).to eql([
         
     | 
| 
      
 118 
     | 
    
         
            +
                    { extraParam: 'value' },
         
     | 
| 
      
 119 
     | 
    
         
            +
                    { itemParam1: 'value1' }
         
     | 
| 
      
 120 
     | 
    
         
            +
                  ])
         
     | 
| 
      
 121 
     | 
    
         
            +
                end
         
     | 
| 
      
 122 
     | 
    
         
            +
              end
         
     | 
| 
       107 
123 
     | 
    
         
             
            end
         
     | 
| 
         @@ -26,7 +26,7 @@ describe PagSeguro::Transaction::Serializer do 
     | 
|
| 
       26 
26 
     | 
    
         
             
                it { expect(data.keys).not_to include(:cancellation_source) }
         
     | 
| 
       27 
27 
     | 
    
         
             
                it { expect(data.keys).not_to include(:escrow_end_date) }
         
     | 
| 
       28 
28 
     | 
    
         | 
| 
       29 
     | 
    
         
            -
                it { expect(data[:items]).to  
     | 
| 
      
 29 
     | 
    
         
            +
                it { expect(data[:items].size).to eq(1) }
         
     | 
| 
       30 
30 
     | 
    
         
             
                it { expect(data[:items].first).to include(id: "1234") }
         
     | 
| 
       31 
31 
     | 
    
         
             
                it { expect(data[:items].first).to include(description: "Some product") }
         
     | 
| 
       32 
32 
     | 
    
         
             
                it { expect(data[:items].first).to include(quantity: 1) }
         
     | 
| 
         @@ -112,7 +112,7 @@ describe PagSeguro::Transaction do 
     | 
|
| 
       112 
112 
     | 
    
         
             
                it { expect(transaction.items).to be_a(PagSeguro::Items) }
         
     | 
| 
       113 
113 
     | 
    
         
             
                it { expect(transaction.payment_method).to be_a(PagSeguro::PaymentMethod) }
         
     | 
| 
       114 
114 
     | 
    
         
             
                it { expect(transaction.status).to be_a(PagSeguro::PaymentStatus) }
         
     | 
| 
       115 
     | 
    
         
            -
                it { expect(transaction.items).to  
     | 
| 
      
 115 
     | 
    
         
            +
                it { expect(transaction.items.size).to eq(1) }
         
     | 
| 
       116 
116 
     | 
    
         
             
                it { expect(transaction).to respond_to(:escrow_end_date) }
         
     | 
| 
       117 
117 
     | 
    
         
             
              end
         
     | 
| 
       118 
118 
     | 
    
         
             
            end
         
     | 
| 
         @@ -0,0 +1,8 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            RSpec.shared_examples "a configuration" do
         
     | 
| 
      
 2 
     | 
    
         
            +
              it { is_expected.to respond_to(:email) }
         
     | 
| 
      
 3 
     | 
    
         
            +
              it { is_expected.to respond_to(:email=) }
         
     | 
| 
      
 4 
     | 
    
         
            +
              it { is_expected.to respond_to(:receiver_email) }
         
     | 
| 
      
 5 
     | 
    
         
            +
              it { is_expected.to respond_to(:receiver_email=) }
         
     | 
| 
      
 6 
     | 
    
         
            +
              it { is_expected.to respond_to(:token) }
         
     | 
| 
      
 7 
     | 
    
         
            +
              it { is_expected.to respond_to(:token=) } 
         
     | 
| 
      
 8 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: pagseguro-oficial
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 2.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 2.0.6
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Nando Vieira
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date:  
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2015-03-02 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: aitch
         
     | 
| 
         @@ -174,6 +174,7 @@ files: 
     | 
|
| 
       174 
174 
     | 
    
         
             
            - ".gitignore"
         
     | 
| 
       175 
175 
     | 
    
         
             
            - ".rspec"
         
     | 
| 
       176 
176 
     | 
    
         
             
            - ".travis.yml"
         
     | 
| 
      
 177 
     | 
    
         
            +
            - CHANGELOG.md
         
     | 
| 
       177 
178 
     | 
    
         
             
            - Gemfile
         
     | 
| 
       178 
179 
     | 
    
         
             
            - LICENSE-2.0.txt
         
     | 
| 
       179 
180 
     | 
    
         
             
            - README.md
         
     | 
| 
         @@ -187,6 +188,7 @@ files: 
     | 
|
| 
       187 
188 
     | 
    
         
             
            - lib/pagseguro-oficial.rb
         
     | 
| 
       188 
189 
     | 
    
         
             
            - lib/pagseguro.rb
         
     | 
| 
       189 
190 
     | 
    
         
             
            - lib/pagseguro/address.rb
         
     | 
| 
      
 191 
     | 
    
         
            +
            - lib/pagseguro/config.rb
         
     | 
| 
       190 
192 
     | 
    
         
             
            - lib/pagseguro/errors.rb
         
     | 
| 
       191 
193 
     | 
    
         
             
            - lib/pagseguro/exceptions.rb
         
     | 
| 
       192 
194 
     | 
    
         
             
            - lib/pagseguro/extensions/ensure_type.rb
         
     | 
| 
         @@ -217,6 +219,7 @@ files: 
     | 
|
| 
       217 
219 
     | 
    
         
             
            - spec/fixtures/transactions/additional.xml
         
     | 
| 
       218 
220 
     | 
    
         
             
            - spec/fixtures/transactions/success.xml
         
     | 
| 
       219 
221 
     | 
    
         
             
            - spec/pagseguro/address_spec.rb
         
     | 
| 
      
 222 
     | 
    
         
            +
            - spec/pagseguro/config_spec.rb
         
     | 
| 
       220 
223 
     | 
    
         
             
            - spec/pagseguro/errors_spec.rb
         
     | 
| 
       221 
224 
     | 
    
         
             
            - spec/pagseguro/item_spec.rb
         
     | 
| 
       222 
225 
     | 
    
         
             
            - spec/pagseguro/items_spec.rb
         
     | 
| 
         @@ -236,6 +239,7 @@ files: 
     | 
|
| 
       236 
239 
     | 
    
         
             
            - spec/spec_helper.rb
         
     | 
| 
       237 
240 
     | 
    
         
             
            - spec/support/ensure_type_macro.rb
         
     | 
| 
       238 
241 
     | 
    
         
             
            - spec/support/mass_assignment_macro.rb
         
     | 
| 
      
 242 
     | 
    
         
            +
            - spec/support/shared_examples_for_configuration.rb
         
     | 
| 
       239 
243 
     | 
    
         
             
            homepage: http://www.pagseguro.com.br
         
     | 
| 
       240 
244 
     | 
    
         
             
            licenses:
         
     | 
| 
       241 
245 
     | 
    
         
             
            - ASL
         
     | 
| 
         @@ -256,7 +260,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       256 
260 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       257 
261 
     | 
    
         
             
            requirements: []
         
     | 
| 
       258 
262 
     | 
    
         
             
            rubyforge_project: 
         
     | 
| 
       259 
     | 
    
         
            -
            rubygems_version: 2. 
     | 
| 
      
 263 
     | 
    
         
            +
            rubygems_version: 2.4.3
         
     | 
| 
       260 
264 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       261 
265 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       262 
266 
     | 
    
         
             
            summary: Biblioteca oficial de integração PagSeguro em Ruby
         
     | 
| 
         @@ -268,6 +272,7 @@ test_files: 
     | 
|
| 
       268 
272 
     | 
    
         
             
            - spec/fixtures/transactions/additional.xml
         
     | 
| 
       269 
273 
     | 
    
         
             
            - spec/fixtures/transactions/success.xml
         
     | 
| 
       270 
274 
     | 
    
         
             
            - spec/pagseguro/address_spec.rb
         
     | 
| 
      
 275 
     | 
    
         
            +
            - spec/pagseguro/config_spec.rb
         
     | 
| 
       271 
276 
     | 
    
         
             
            - spec/pagseguro/errors_spec.rb
         
     | 
| 
       272 
277 
     | 
    
         
             
            - spec/pagseguro/item_spec.rb
         
     | 
| 
       273 
278 
     | 
    
         
             
            - spec/pagseguro/items_spec.rb
         
     | 
| 
         @@ -287,3 +292,4 @@ test_files: 
     | 
|
| 
       287 
292 
     | 
    
         
             
            - spec/spec_helper.rb
         
     | 
| 
       288 
293 
     | 
    
         
             
            - spec/support/ensure_type_macro.rb
         
     | 
| 
       289 
294 
     | 
    
         
             
            - spec/support/mass_assignment_macro.rb
         
     | 
| 
      
 295 
     | 
    
         
            +
            - spec/support/shared_examples_for_configuration.rb
         
     |