From 9e0055c9068dcc61f412c92bbb6fe251b8d818b8 Mon Sep 17 00:00:00 2001 From: Jared King Date: Sun, 6 Dec 2020 11:27:14 -0600 Subject: [PATCH] return payment object type for creating a charge --- lib/invoiced/charge.rb | 9 +++++++-- test/invoiced/charge_test.rb | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/invoiced/charge.rb b/lib/invoiced/charge.rb index 0b3a969..43dbaa8 100644 --- a/lib/invoiced/charge.rb +++ b/lib/invoiced/charge.rb @@ -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 \ No newline at end of file diff --git a/test/invoiced/charge_test.rb b/test/invoiced/charge_test.rb index df12ac5..f4af97a 100644 --- a/test/invoiced/charge_test.rb +++ b/test/invoiced/charge_test.rb @@ -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