Reply
Member
Posts: 3
Registered: ‎11-17-2020
Accepted Solution

The element transactionRequest has invalid child element lineItems

This is the JSON that I send:

{
    "createTransactionRequest": {
        "merchantAuthentication": {
            "name": "test",
            "transactionKey": "test"
        },
        "refId": "0000",
        "transactionRequest": {
            "transactionType": "authCaptureTransaction",
            "amount": "100.00",
            "payment": {
                "opaqueData": {
                    "dataDescriptor": "COMMON.ACCEPT.INAPP.PAYMENT",
                    "dataValue": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
                }
            },
            "lineItems": [
                {
                    "lineItem": {
                        "itemId": "item1",
                        "name": "item1",
                        "description": "item1",
                        "quantity": "1",
                        "unitPrice": "10"
                    }
                },
                {
                    "lineItem": {
                        "itemId": "item2",
                        "name": "item2",
                        "description": "item2",
                        "quantity": "1",
                        "unitPrice": "10"
                    }
                },
                {
                    "lineItem": {
                        "itemId": "item3",
                        "name": "item3",
                        "description": "item3",
                        "quantity": "1",
                        "unitPrice": "10"
                    }
                },
                {
                    "lineItem": {
                        "itemId": "item4",
                        "name": "item4",
                        "description": "item4",
                        "quantity": "1",
                        "unitPrice": "10"
                    }
                }, {
                    "lineItem": {
                        "itemId": "item5",
                        "name": "item5",
                        "description": "item5",
                        "quantity": "1",
                        "unitPrice": "10"
                    }
                }
            ],
            "userFields": {
                "userField": [
                    {
                        "name": "custom_data_1",
                        "value": "1"
                    }, {
                        "name": "custom_data_2",
                        "value": "2"
                    }
                ]
            }
        }
    }
}

Can someone explain what's wrong?


Accepted Solutions
Solution
Accepted by topic author electricodeapi2
‎11-18-2020 05:16 PM
Regular Contributor
Posts: 68
Registered: ‎05-29-2015

Re: The element transactionRequest has invalid child element lineItems

[ Edited ]

Maybe this example will help?

 

var obj = {};
obj.lineItems = {};
obj.lineItems.lineItem = [ {itemId: "1", name: "one"}, {itemId: "2",name: "two"}, {itemId: "3",name: "three"} ];
var myJSON = JSON.stringify(obj);

 

View solution in original post


All Replies
Regular Contributor
Posts: 68
Registered: ‎05-29-2015

Re: The element transactionRequest has invalid child element lineItems

[ Edited ]

Is it the "[ ]" (braces).  I think it only curly braces an lineitems and brace lineItem? i mainly use XML.

Regular Contributor
Posts: 68
Registered: ‎05-29-2015

Re: The element transactionRequest has invalid child element lineItems

Yep. See getTransactionDetailsResponse example in the API Reference.

lineItem will be the array with brace.

Member
Posts: 3
Registered: ‎11-17-2020

Re: The element transactionRequest has invalid child element lineItems

Thank you for your answer,

You are right and I need to change the square brackets,

The issue now is how do I do it using javascript,

I have multiple inputs related to the lineitems and the "JSON.stringify" generate it automatically,

Is there another way to do it?

Solution
Accepted by topic author electricodeapi2
‎11-18-2020 05:16 PM
Regular Contributor
Posts: 68
Registered: ‎05-29-2015

Re: The element transactionRequest has invalid child element lineItems

[ Edited ]

Maybe this example will help?

 

var obj = {};
obj.lineItems = {};
obj.lineItems.lineItem = [ {itemId: "1", name: "one"}, {itemId: "2",name: "two"}, {itemId: "3",name: "three"} ];
var myJSON = JSON.stringify(obj);

 

Member
Posts: 3
Registered: ‎11-17-2020

Re: The element transactionRequest has invalid child element lineItems

[ Edited ]

I had to change it a little bit but it actually works,
I'm suprised, it seems that they want the wanted like this (with lineItem for each set):

"lineItems": {
    {
        "lineItem": {
            "itemId": "item1",
            "name": "item1",
            "description": "item1",
            "quantity": "1",
            "unitPrice": "10"
        }
    },
    {
        "lineItem": {
            "itemId": "item2",
            "name": "item2",
            "description": "item2",
            "quantity": "1",
            "unitPrice": "10"
        }
    }
},

While yours generate this:

    "lineItems": {
        "lineItem": [
            {
                "itemId": "1",
                "name": "one",
                "description": "desc1",
                "quantity": "1",
                "unitPrice": "11.00"
            },
            {
                "itemId": "2",
                "name": "two",
                "description": "desc2",
                "quantity": "1",
                "unitPrice": "12.00"
            },
            {
                "itemId": "3",
                "name": "three",
                "description": "desc3",
                "quantity": "1",
                "unitPrice": "13.00"
            }
        ]
    },


This is what I changed:

 

var lineItems = {};
lineItems.lineItem = [ {itemId: "1", name: "one", description: "desc1", quantity: "1", unitPrice: "11.00"}, {itemId: "2",name: "two", description: "desc2", quantity: "1", unitPrice: "12.00"}, {itemId: "3",name: "three", description: "desc3", quantity: "1", unitPrice: "13.00"} ];
var myJSON = JSON.stringify(lineItems);

Thank you!


 

New Member
Posts: 2
Registered: ‎11-19-2020

Re: The element transactionRequest has invalid child element lineItems

Key elements of Request Management . ... Service Manager is HP's enterprise service management solution. Its integrated ... Handling database transactions. ... orders are generated to fulfill the requested line items from one or more quotes. ... Advise the Requester that the proposal is either invalid or. surveyz.onl 
New Member
Posts: 1
Registered: ‎11-19-2020

Re: The element transactionRequest has invalid child element lineItems

We're certain that you will figure out how to make some extraordinary memories with this particular Madden NFL 21 Mobile Football Resources madden 21 cheats Generator and as you will do as such, you will see this one will be chipping away at any gadget that you have. There are positively not a ton of hack ios accessible to the web.

New Member
Posts: 10
Registered: ‎11-21-2020

Re: The element transactionRequest has invalid child element lineItems

thanks for sharing great information

https://www.vanced.pro/