Skip to content

Commit

Permalink
return payment object type for creating a charge
Browse files Browse the repository at this point in the history
  • Loading branch information
Jared King committed Dec 6, 2020
1 parent f736265 commit 9e0055c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions lib/invoiced/charge.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
module Invoiced
class Charge < Object
include Invoiced::Operations::Create

OBJECT_NAME = 'charge'

def create(body={}, opts={})
response = @client.request(:post, endpoint(), body, opts)

payment = Payment.new(@client)
Util.convert_to_object(payment, response[:body])
end
end
end
2 changes: 1 addition & 1 deletion test/invoiced/charge_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ChargeTest < Test::Unit::TestCase
charge = Charge.new(@client, 1234)
charge = charge.create(:amount => 100, :payment_source_type => "card")

assert_instance_of(Invoiced::Charge, charge)
assert_instance_of(Invoiced::Payment, charge)
assert_equal(charge.id, "a1b2c3")
end
end
Expand Down

0 comments on commit 9e0055c

Please sign in to comment.