Skip to content

Commit c22729d

Browse files
committed
Add specs to Iugu::Charge.create using credit card
1 parent 013a654 commit c22729d

File tree

4 files changed

+164
-8
lines changed

4 files changed

+164
-8
lines changed

spec/cassettes/Iugu_Charge/_create/should_create_a_charge_with_credit_card.yml

Lines changed: 122 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/cassettes/Iugu_PaymentToken/_create/should_create_a_payment_token.yml

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/charge_spec.rb

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,39 @@
1818
expect(charge.invoice_id).to_not be_nil
1919
expect(charge.identification).to_not be_nil
2020
end
21+
22+
it 'should create a charge with credit card', :vcr do
23+
token = Iugu::PaymentToken.create(account_id: '842C5942D8E34372A8E554A1BC959086',
24+
method: 'credit_card',
25+
test: 'true',
26+
data: {
27+
number: '4111111111111111',
28+
verification_value: '123',
29+
first_name: 'Walter',
30+
last_name: 'White',
31+
month: '02',
32+
year: '2020'
33+
})
34+
35+
36+
charge = Iugu::Charge.create(token: token.id,
37+
payer: { name: 'Awesome Customer',
38+
cpf_cnpj: '15111975000164',
39+
address: { zip_code: '29190560', number: '100'} },
40+
items: [[{ quantity: 1,
41+
price_cents: 5000,
42+
description: 'item 1' }]],
43+
currency: 'BRL',
44+
45+
46+
expect(charge.success).to be_truthy
47+
expect(charge.message).to eq('Autorizado')
48+
expect(charge.url).to_not be_nil
49+
expect(charge.pdf).to_not be_nil
50+
expect(charge.invoice_id).to_not be_nil
51+
expect(charge.identification).to be_nil
52+
expect(charge.LR).to eq('00')
53+
end
54+
2155
end
2256
end

spec/payment_token_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
describe Iugu::PaymentToken do
44
describe '.create' do
55
it 'should create a payment token', :vcr do
6-
token = Iugu::PaymentToken.create(account_id: '',
6+
token = Iugu::PaymentToken.create(account_id: '842C5942D8E34372A8E554A1BC959086',
77
method: 'credit_card',
88
test: 'true',
99
data: {

0 commit comments

Comments
 (0)