crafters / cielo

Gem para integração com os WebServices da Cielo
www.crafters.com.br
MIT License
85 stars 52 forks source link

Allow partial cancellations and no CVV transactions #24

Closed viniciusnz closed 9 years ago

viniciusnz commented 9 years ago

Allow sending no CVV:

Transactions without CVV are not allowed starting at version 1.2.0, so we must use an earlier version. In order to use an earlier version of the API, one could do:

transaction = Cielo::Transaction.new(Cielo.numero_afiliacao, Cielo.chave_acesso, versao = '1.1.1')

Allow partial cancelations

In order to do partial cancelations one could do:

transaction = Cielo::Transaction.new tid = 'XXXX' value_in_cents = '100' # for R$ 1,00 response = transaction.cancel!(tid, value_in_cents)

Since the valor field comes after the ec, and the tid comes before, I had to change the topology of the :after and :before to send it along to the block, and add an if inside the block. The block now gets called twice for each method, which has somewhat of a performance penalty but I believe it's nothing big.