cancel
Showing results for 
Search instead for 
Did you mean: 

Adding lineItems in python sdk

Anyone have an example of this?

 

 

tobiah
Member
2 REPLIES 2

Hi @tobiah,

 

I'm not in front of a computer with Python at this moment, but could you try the following?

 

# setup individual items
	lineItem1 = apicontractsv1.lineItemType()
	lineItem1.itemId = "12345"
	lineItem1.name = "first"
	lineItem1.description = "Here's the first line item"
	lineItem1.quantity = "2"
	lineItem1.unitPrice = "12.95"
	lineItem2 = apicontractsv1.lineItemType()
	lineItem2.itemId = "67890"
	lineItem2.name = "second"
	lineItem2.description = "Here's the second line item"
	lineItem2.quantity = "3"
	lineItem2.unitPrice = "7.95"

# build the array
	lineItems = apicontractsv1.ArrayOfLineItem()
	lineItems.lineItem.append(lineItem1)
	lineItems.lineItem.append(lineItem2)

# Add the lineItems to whatever variable holds the full transaction request.
	transactionrequest.lineItems = lineItems

Let me know if it works! If not, I'll get to a Python machine when I get back from my current trip and figure out how it's actually supposed to work.

Aaron
All Star

Update: I got a proper sample made in our sample code repo at https://github.com/AuthorizeNet/sample-code-python. The charge-credit-card.py sample has now been updated to include examples of setting lineItems.