Skip to content

Commit

Permalink
Add new fields on credit card model and payment model
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonio Filho committed Jun 26, 2015
1 parent dd98ece commit c28cc8c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/braspag-rest/credit_card.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class CreditCard < Hashie::IUTrash
property :number, from: 'CardNumber'
property :holder, from: 'Holder'
property :expiration_date, from: 'ExpirationDate'
property :security_code
property :security_code, from: 'SecurityCode'
property :brand, from: 'Brand'
property :saved, from: 'SaveCard'
property :token, from: 'CardToken'
Expand Down
2 changes: 2 additions & 0 deletions lib/braspag-rest/payment.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
module BraspagRest
class Payment < Hashie::IUTrash
property :id, from: 'PaymentId'
property :type, from: 'Type'
property :amount, from: 'Amount'
property :status, from: 'Status'
property :provider, from: 'Provider'
property :installments, from: 'Installments'
property :credit_card, from: 'CreditCard', with: ->(values) { BraspagRest::CreditCard.new(values) }
Expand Down
4 changes: 3 additions & 1 deletion spec/credit_card_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
'Brand' => 'Visa',
'CardNumber' => '000000******0001',
'Holder' => 'Teste Holder',
'CardToken' => '123456'
'CardToken' => '123456',
'SecurityCode' => 123
}
}

Expand All @@ -22,6 +23,7 @@
expect(credit_card.number).to eq('000000******0001')
expect(credit_card.holder).to eq('Teste Holder')
expect(credit_card.token).to eq('123456')
expect(credit_card.security_code).to eq(123)
end
end
end
2 changes: 2 additions & 0 deletions spec/payment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@
expect(payment.provider).to eq('Simulado')
expect(payment.installments).to eq(1)
expect(payment.credit_card).to be_an_instance_of(BraspagRest::CreditCard)
expect(payment.status).to eq(1)
expect(payment.id).to eq('1ff114b4-32bb-4fe2-b1f2-ef79822ad5e1')
end
end
end

0 comments on commit c28cc8c

Please sign in to comment.