test/pagarme/transaction.rb in pagarme-1.9.5 vs test/pagarme/transaction.rb in pagarme-1.9.6

- old
+ new

@@ -59,10 +59,35 @@ transaction_2 = PagarMe::Transaction.find_by_id(transaction.id) assert transaction_2.id == transaction.id end + should 'accept parameters on the refund' do + transaction = PagarMe::Transaction.new({ + :payment_method => 'boleto', + :amount => '1000' + }) + + transaction2 = PagarMe::Transaction.new({ + :payment_method => 'boleto', + :amount => '1000', + :postback_url => 'http://url.com/postback' + }) + + transaction.charge + transaction2.charge + + transaction.status = 'paid' + transaction.save + + transaction2.status = 'paid' + transaction2.save + + transaction.refund({:bank_account => {:bank_code => '399', :agencia => '1234', :conta => '1234567', :conta_dv => '1', :legal_name => 'Jose da silva', :document_number => '68782915423'}}) + assert transaction.status == 'pending_refund' + end + should 'be able to create transaction with customer' do transaction = test_transaction_with_customer transaction.charge test_transaction_response(transaction) assert transaction.address.class == Address @@ -79,9 +104,18 @@ test_customer_response(transaction.customer) transaction.refund assert transaction.status == 'refunded' end + + should 'be able to capture a transaction and pass an amount' do + transaction = test_transaction({:capture => false}) + transaction.charge + assert transaction.status == 'authorized' + transaction.capture({:amount => 1000}) + assert transaction.status == 'paid' + assert transaction.amount == 1000 + end should 'validate invalid transaction' do #Test invalid card_number exception = assert_raises PagarMeError do