Skip to content

Commit

Permalink
+ merged fix from AuthorizeNet#48
Browse files Browse the repository at this point in the history
+ added test case for it
  • Loading branch information
namanbansal committed Nov 19, 2015
1 parent aec24c9 commit 7ff8ac5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/authorize_net/line_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def to_hash
:line_item_name => @name,
:line_item_description => @description,
:line_item_quantity => @quantity,
:line_item_price => @price,
:line_item_unit_price => @price,
:line_item_taxable => @taxable
}
hash.delete_if {|k, v| v.nil?}
Expand Down
2 changes: 1 addition & 1 deletion lib/authorize_net/order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def add_line_item(id = nil, name = nil, description = nil, quantity = nil, price
if id.kind_of?(AuthorizeNet::LineItem)
line_item = id
else
line_item = AuthorizeNet::LineItem.new({:line_item_id => id, :line_item_name => name, :line_item_description => description, :line_item_quantity => quantity, :line_item_price => price, :line_item_taxable => taxable})
line_item = AuthorizeNet::LineItem.new({:id => id, :name => name, :description => description, :quantity => quantity, :price => price, :taxable => taxable})
end
@line_items = @line_items.to_a << line_item
end
Expand Down
15 changes: 13 additions & 2 deletions spec/cim_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,18 @@ def delete_profile(profile)
expect(response.success?).to eq true
expect(response.token).not_to be_empty
end

it "should be able to add line items to the order" do
transaction = AuthorizeNet::CIM::Transaction.new(api_login, api_key, :gateway => :sandbox)
#build a order with line item
order = AuthorizeNet::Order.new().add_line_item(101,'Abc','Xyz',2,25.2,1)
expect(order[0].id).to eq 101
expect(order[0].name).to eq 'Abc'
expect(order[0].description).to eq 'Xyz'
expect(order[0].quantity).to eq 2
expect(order[0].price).to eq 25.2
expect(order[0].taxable).to eq 1

end
describe "performing actions on payment profiles" do

def create_payment_profile(payment_profile, profile, validation_mode = :none)
Expand Down Expand Up @@ -457,7 +468,7 @@ def create_address(address, profile)
it "should be able to get zero profile ids when a merchant has zero customer profiles" do
#Using specific credentials for a Merchant which has zero customer profiles
#NOTE: These credentials are specific to this test
transaction = AuthorizeNet::CIM::Transaction.new("3qkNY3db6jB", "7s8B76QvsPet82HH", :gateway => :sandbox)
transaction = AuthorizeNet::CIM::Transaction.new("982fNqW7sZ", "3k2549N82e53gKHa", :gateway => :sandbox)
expect(transaction).to respond_to(:get_profile_ids)
response = transaction.get_profile_ids
expect(response).to be_kind_of(AuthorizeNet::CIM::Response)
Expand Down

0 comments on commit 7ff8ac5

Please sign in to comment.