Skip to content

Commit ecdaad9

Browse files
authored
Merge pull request iugu#28 from iugu/charge-with-installments
Add spec for when we create a charge with installments
2 parents 175e661 + 61ac37c commit ecdaad9

File tree

2 files changed

+226
-0
lines changed

2 files changed

+226
-0
lines changed

spec/cassettes/Iugu_Charge/_create/should_create_a_charge_with_credit_card_with_installments.yml

Lines changed: 195 additions & 0 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: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,36 @@
5252
expect(charge.LR).to eq('00')
5353
end
5454

55+
it 'should create a charge with credit card with installments', :vcr do
56+
token = Iugu::PaymentToken.create(account_id: 'F17761200EC74469823D469BF2B211AC',
57+
method: 'credit_card',
58+
test: 'true',
59+
data: {
60+
number: '4111111111111111',
61+
verification_value: '123',
62+
first_name: 'Walter',
63+
last_name: 'White',
64+
month: '02',
65+
year: '2020'
66+
})
67+
68+
69+
charge = Iugu::Charge.create(token: token.id,
70+
payer: { name: 'Awesome Customer',
71+
cpf_cnpj: '15111975000164',
72+
address: { zip_code: '29190560', number: '100'} },
73+
items: [[{ quantity: 1,
74+
price_cents: 5000,
75+
description: 'item 1' }]],
76+
currency: 'BRL',
77+
months: 3, # 3 installments
78+
79+
80+
invoice = Iugu::Invoice.fetch(id: charge.invoice_id)
81+
82+
expect(charge.success).to be_truthy
83+
expect(invoice.status).to eq('paid')
84+
expect(invoice.installments).to eq('3')
85+
end
5586
end
5687
end

0 commit comments

Comments
 (0)