test/pagarme/transaction.rb in pagarme-1.9.6 vs test/pagarme/transaction.rb in pagarme-1.9.7
- old
+ new
@@ -9,10 +9,44 @@
transaction.charge
assert transaction.status == 'paid'
test_transaction_response(transaction)
end
+ should 'be able to charge with a saved card' do
+ card = test_card
+ card.create
+
+ transaction = PagarMe::Transaction.new({
+ :card => card,
+ :amount => 1000,
+ :payment_method => 'credit_card'
+ })
+
+ transaction.charge
+ assert transaction.status == 'paid'
+ end
+
+ should 'be able to charge with an unsaved card' do
+ card = test_card
+ transaction = PagarMe::Transaction.new({
+ :card => card,
+ :amount => 1000,
+ :payment_method => 'credit_card'
+ })
+
+ transaction.charge
+ assert transaction.status == 'paid'
+ end
+
+ should 'return a card object' do
+ transaction = test_transaction
+ transaction.create
+ assert transaction.card.id
+ assert transaction.card.first_digits == '490172'
+ assert transaction.card.last_digits == '4448'
+ end
+
should 'be able to refund' do
transaction = test_transaction
transaction.charge
test_transaction_response(transaction)
transaction.refund
@@ -67,12 +101,11 @@
:amount => '1000'
})
transaction2 = PagarMe::Transaction.new({
:payment_method => 'boleto',
- :amount => '1000',
- :postback_url => 'http://url.com/postback'
+ :amount => '1000'
})
transaction.charge
transaction2.charge
@@ -80,10 +113,10 @@
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'}})
+ 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