Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8465139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:57:23+00:00 2026-06-10T14:57:23+00:00

First off thanks for writing this class . It has made life much easier

  • 0

First off thanks for writing this class. It has made life much easier for me in building applications.

I have CIM set up and I have no problem adding users, processing payments, etc. However I am stuck on adding line items. The examples on github use static population of the array used to create the XML request EX:

'lineItems' => array(
    'itemId' => 'ITEM00001',
    'name' => 'name of item sold',
    'description' => 'Description of item sold',
    'quantity' => '1',
    'unitPrice' => '6.95',
    'taxable' => 'true'
 ),
 'lineItems' => array(
     'itemId' => 'ITEM00002',
     'name' => 'other name of item sold',
     'description' => 'Description of other item sold',
     'quantity' => '1',
     'unitPrice' => '1.00',
     'taxable' => 'true'
 ),

This works great if you are manually creating things but I am dynamically creating these line items based on user input. Unfortunately, I am unable do add multiple line items to the array due to the fact that the key (‘lineItems’) gets overwritten and I end up with one line item.

I have tried creating an array of lineItems and then merging it with no luck. Hopefully I am just missing a simple fix for this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T14:57:25+00:00Added an answer on June 10, 2026 at 2:57 pm

    Thanks for responding John! Once again, great work on this class it has made my life much easier.

    Here is what I ended up doing for simplicity. I am sure this can be expounded upon if necessary, but for me this worked perfect. Instead of passing multiple line items on the same level of the array I created line items as their own array and then modified setParamaters() to iterate through that array.

    private function setParameters($xml, $array)
    {
        if (is_array($array))
        {
            foreach ($array as $key => $value)
            {
                if (is_array($value))
                {
                    if($key == 'lineItems'){
                        foreach($value as $lineitems){
                            $line_item = $xml->addChild('lineItems');
                            foreach($lineitems as $itemkey => $itemvalue) {
                                $line_item->addChild($itemkey, $itemvalue);
                            }
                        }
                    }
                    else
                    {
                        $xml->addChild($key);
                        $this->setParameters($xml->$key, $value);
                    }
                }
                else
                {
                    $xml->$key = $value;
                }
            }
        }
    }
    

    This suited my needs perfectly and made it so I did not have to change anything on the front end except nesting the lineItems array. So the array I am sending looks more like this:

    ["lineItems"]=>
      array(2) {
        [0]=>
        array(6) {
          ["itemId"]=>
          string(9) "ITEM00010"
          ["name"]=>
          string(21) "Blah Blah"
          ["description"]=>
          string(21) "Blah Blah Description"
          ["quantity"]=>
          string(1) "1"
          ["unitPrice"]=>
          string(4) "100"
          ["taxable"]=>
          string(5) "false"
        }
        [1]=>
        array(6) {
          ["itemId"]=>
          string(9) "ITEM00011"
          ["name"]=>
          string(25) "Thing Thing"
          ["description"]=>
          string(25) "Thing Thing Description"
          ["quantity"]=>
          string(1) "2"
          ["unitPrice"]=>
          string(3) "50"
          ["taxable"]=>
          string(5) "false"
        }
      }
    

    Also, for anyone out there looking to build the arrays for the line items I did this:

    foreach ($services as $key => $service){
        $line_items["lineItems"][] = array(
            'itemId'        => 'ITEM000'.$key,
            'name'          => $service->name,
            'description'   => $service->name,
            'quantity'      => $service_count[$key],
            'unitPrice'     => $service->price,
            'taxable'       => 'false'
        );
    }
    

    And then just added it to the transaction_array that I passed to the AuthnetXML instance.

    Thanks again!

    Joel

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First off thanks to all the users who have made my android developing adventure
(First off, thanks so much. Stackoverflow has been very helpful to me in the
First off, thanks to whomever is reading this. I have a very strange problem
First off, thanks in advance for your help. This issue is driving me nuts.
and first off thanks for your time to look at this. For a research
First off thanks for any help provided. I have an array/loop issue. I'm trying
First off, let me start by saying, I know this exact question has been
JAVA: First off, Thanks so much for taking the time to look at my
first off thanks for helping. I am writing a prolog program describing family relationships,
first off third question I've asked and all have been answered well! So thanks

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.