0
votes

I am trying to charge for Authorize .net Gateway using active merchant gem.

Here is the link for gem - https://github.com/activemerchant/active_merchant

I am sending email,invoice,description,billing_address, shipping_address as option parameter and transaction is successfully done also but when I see the transaction detail, I found every parameter on authorize .net other than invoice number.

here is my code for option -

  options = {:email => "[email protected]",:invoice => "INV-12345",:description => "Amount 50 for INV-12345",:billing_address => { :name => "Sunil Kumar", :address1 => "9888 America Ave. NW",:city => "Oakland", :state => "AK",
:country => "United States", :zip => "94605",:phone => "1234567890"}} 

While charging we are using below code -

   gateway.purchase((amount*100), creditcard,options)

Now after successful transaction when I see the transaction detail I found every thing other than Invoice#.

Please suggest if any thing left.

1

1 Answers

0
votes

You need to change invoice to order_id. so your code would look like.

options = {:email => "[email protected]",:order_id => "INV-12345",:description => "Amount 50 for INV-12345",:billing_address => { :name => "Sunil Kumar", :address1 => "9888 America Ave. NW",:city => "Oakland", :state => "AK",
:country => "United States", :zip => "94605",:phone => "1234567890"}} 

Here is the code from ActiveMerchant.

  def add_invoice(xml, options)
    xml.order do
      xml.invoiceNumber(truncate(options[:order_id], 20))
      xml.description(truncate(options[:description], 255))
    end

    # Authorize.net API requires lineItems to be placed directly after order tag
    if options[:line_items]
      xml.lineItems do
        options[:line_items].each do |line_item|
          xml.lineItem do
            line_item.each do |key, value|
              xml.send(camel_case_lower(key), value)
            end
          end
        end
      end
    end
  end

https://github.com/activemerchant/active_merchant/blob/master/lib/active_merchant/billing/gateways/authorize_net.rb