Skip to content

Commit

Permalink
Add amount_in_cents to payments for partial payments (#102)
Browse files Browse the repository at this point in the history
* add amount_in_cents attribute to payments for partial payments

* add amount_in_cents to refund & update version
  • Loading branch information
ntomas authored Mar 8, 2021
1 parent becc95b commit 0b28c13
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/chartmogul/transactions/payment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Payment < APIResource
writeable_attr :date, type: :time
writeable_attr :result
writeable_attr :external_id

writeable_attr :amount_in_cents
writeable_attr :invoice_uuid

def initialize(attributes = {})
Expand Down
2 changes: 1 addition & 1 deletion lib/chartmogul/transactions/refund.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Refund < APIResource
writeable_attr :date, type: :time
writeable_attr :result
writeable_attr :external_id

writeable_attr :amount_in_cents
writeable_attr :invoice_uuid

def initialize(attributes = {})
Expand Down
2 changes: 1 addition & 1 deletion lib/chartmogul/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module ChartMogul
VERSION = '1.7.0'
VERSION = '1.7.1'
end
14 changes: 12 additions & 2 deletions spec/chartmogul/transactions/payment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
date: '2016-01-01 12:00:00',
result: 'successful',
external_id: 'pay_ext_id',
uuid: 'tr_1234-5678-9012-34567'
uuid: 'tr_1234-5678-9012-34567',
amount_in_cents: 500
}
end

Expand All @@ -35,6 +36,10 @@
it 'sets the external_id attribute' do
expect(subject.external_id).to eq('pay_ext_id')
end

it 'sets the amount_in_cents attribute' do
expect(subject.amount_in_cents).to eq(500)
end
end

describe '.new_from_json' do
Expand All @@ -58,6 +63,10 @@
it 'sets the external_id attribute' do
expect(subject.external_id).to eq('pay_ext_id')
end

it 'sets the amount_in_cents attribute' do
expect(subject.amount_in_cents).to eq(500)
end
end

describe 'API Interactions', vcr: true do
Expand Down Expand Up @@ -90,7 +99,8 @@
date: Time.utc(2016, 1, 1, 12),
result: 'successful',
external_id: 'test_tr_ext_id',
invoice_uuid: invoice.uuid
invoice_uuid: invoice.uuid,
amount_in_cents: 500
).create!

expect(transaction.uuid).to be
Expand Down
11 changes: 10 additions & 1 deletion spec/chartmogul/transactions/refund_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
date: '2016-01-01 12:00:00',
result: 'successful',
external_id: 'ref_ext_id',
uuid: 'tr_1234-5678-9012-34567'
uuid: 'tr_1234-5678-9012-34567',
amount_in_cents: 500
}
end

Expand All @@ -35,6 +36,10 @@
it 'sets the external_id attribute' do
expect(subject.external_id).to eq('ref_ext_id')
end

it 'sets the amount_in_cents attribute' do
expect(subject.amount_in_cents).to eq(500)
end
end

describe '.new_from_json' do
Expand All @@ -58,5 +63,9 @@
it 'sets the external_id attribute' do
expect(subject.external_id).to eq('ref_ext_id')
end

it 'sets the amount_in_cents attribute' do
expect(subject.amount_in_cents).to eq(500)
end
end
end

0 comments on commit 0b28c13

Please sign in to comment.