Zoho Creator: eBay: Get Item Transaction

Zoho Creator: eBay: Get Item Transaction

What?
This is the function to get the line item order/transaction from eBay if you give it the eBay Item ID as a parameter.

Why?
Mostly for debugging but here's the code that will quickly get the XML of a GetItemTransactions request to eBay.

How?
You'll need an access token for eBay which I documented on how you can generate one in my article: Zoho Creator: Push to eBay Listings. Then you can use the following code, note that the parameter is the eBay Item ID:
copyraw
void API.fn_eBayQuery_GetItemTransaction(int p_ItemID)
{
	/*
    Function: fn_eBayQuery_GetItemTransaction()
    Input: int p_ItemID (eBay Item ID)
    Purpose: Fetches a line item transaction per item ID
    Date Created:   2022-01-22 (Joellipman - Joel Lipman)
                    - Initial release

    More Info:
    - API Explorer Test Tool: https://developer.ebay.com/DevZone/build-test/test-tool/default.aspx?index=0&env=production&api=trading
    - GetItemTransactions Documentation: https://developer.ebay.com/devzone/xml/docs/Reference/eBay/GetItemTransactions.html
    */
	v_Found = 0;
	v_Updated = 0;
	v_Page = 1;
	v_PerPage = 10;
	m_Output = Map();
	r_Api = API_Integration[Connection_Name == "eBay API (Production)"];
	if(r_Api.count() > 0)
	{
		v_AccessToken = thisapp.API.fn_eBayConnect_AccessToken();
		v_TradingAPIVersion = r_Api.API_Version;
		v_Endpoint = "https://api.ebay.com/ws/api.dll";
		//
		// build header
		m_Headers = Map();
		m_Headers.put("X-EBAY-API-SITEID",3);
		m_Headers.put("X-EBAY-API-COMPATIBILITY-LEVEL",v_TradingAPIVersion);
		v_ApiCall = "GetItemTransactions";
		m_Headers.put("X-EBAY-API-CALL-NAME",v_ApiCall);
		m_Headers.put("X-EBAY-API-IAF-TOKEN",v_AccessToken);
		//
		// build params
		m_Params = Map();
		m_Params.put("WarningLevel","High");
		m_Params.put("ErrorLanguage","en_GB");
		m_Params.put("DetailLevel","ItemReturnCategories");
		//
		// include fixed price items
		m_Pagination = Map();
		m_Pagination.put("PageNumber",v_Page);
		m_Pagination.put("EntriesPerPage",v_PerPage);
		m_Params.put("Pagination",m_Pagination);
		//m_ActiveList.put("Sort","ItemID");
		m_Params.put("ItemID",p_ItemID);
		//
		// convert to xml and replace root nodes
		x_Params = m_Params.toXML();
		x_Params = x_Params.toString().replaceFirst("<root>","<?xml version=\"1.0\" encoding=\"utf-8\"?><" + v_ApiCall + "Request xmlns=\"urn:ebay:apis:eBLBaseComponents\">");
		x_Params = x_Params.toString().replaceFirst("</root>","</" + v_ApiCall + "Request>");
		//
		// send the request XML as a string
		r_ResponseXML = invokeurl
		[
			url :v_Endpoint
			type :POST
			parameters:x_Params
			headers:m_Headers
		];
		//
		// output response
		info r_ResponseXML;
		/*
		//
		// if successful then read the response
		if(r_ResponseXML.contains("<Ack>Success</Ack>"))
		{
			//
			// parse the data
			v_MainNode = "Item";
			x_MainNode = r_ResponseXML.subString(r_ResponseXML.indexOf("<" + v_MainNode),r_ResponseXML.lastIndexOf("</" + v_MainNode) + v_MainNode.length() + 3);

		}
		*/
	}	
}
  1.  void API.fn_eBayQuery_GetItemTransaction(int p_ItemID) 
  2.  { 
  3.      /* 
  4.      Function: fn_eBayQuery_GetItemTransaction() 
  5.      Input: int p_ItemID (eBay Item ID) 
  6.      Purpose: Fetches a line item transaction per item ID 
  7.      Date Created:   2022-01-22 (Joellipman - Joel Lipman) 
  8.                      - Initial release 
  9.   
  10.      More Info: 
  11.      - API Explorer Test Tool: https://developer.ebay.com/DevZone/build-test/test-tool/default.aspx?index=0&env=production&api=trading 
  12.      - GetItemTransactions Documentation: https://developer.ebay.com/devzone/xml/docs/Reference/eBay/GetItemTransactions.html 
  13.      */ 
  14.      v_Found = 0
  15.      v_Updated = 0
  16.      v_Page = 1
  17.      v_PerPage = 10
  18.      m_Output = Map()
  19.      r_Api = API_Integration[Connection_Name == "eBay API (Production)"]
  20.      if(r_Api.count() > 0) 
  21.      { 
  22.          v_AccessToken = thisapp.API.fn_eBayConnect_AccessToken()
  23.          v_TradingAPIVersion = r_Api.API_Version; 
  24.          v_Endpoint = "https://api.ebay.com/ws/api.dll"
  25.          // 
  26.          // build header 
  27.          m_Headers = Map()
  28.          m_Headers.put("X-EBAY-API-SITEID",3)
  29.          m_Headers.put("X-EBAY-API-COMPATIBILITY-LEVEL",v_TradingAPIVersion)
  30.          v_ApiCall = "GetItemTransactions"
  31.          m_Headers.put("X-EBAY-API-CALL-NAME",v_ApiCall)
  32.          m_Headers.put("X-EBAY-API-IAF-TOKEN",v_AccessToken)
  33.          // 
  34.          // build params 
  35.          m_Params = Map()
  36.          m_Params.put("WarningLevel","High")
  37.          m_Params.put("ErrorLanguage","en_GB")
  38.          m_Params.put("DetailLevel","ItemReturnCategories")
  39.          // 
  40.          // include fixed price items 
  41.          m_Pagination = Map()
  42.          m_Pagination.put("PageNumber",v_Page)
  43.          m_Pagination.put("EntriesPerPage",v_PerPage)
  44.          m_Params.put("Pagination",m_Pagination)
  45.          //m_ActiveList.put("Sort","ItemID")
  46.          m_Params.put("ItemID",p_ItemID)
  47.          // 
  48.          // convert to xml and replace root nodes 
  49.          x_Params = m_Params.toXML()
  50.          x_Params = x_Params.toString().replaceFirst("<root>","<?xml version=\"1.0\" encoding=\"utf-8\"?><" + v_ApiCall + "Request xmlns=\"urn:ebay:apis:eBLBaseComponents\">")
  51.          x_Params = x_Params.toString().replaceFirst("</root>","</" + v_ApiCall + "Request>")
  52.          // 
  53.          // send the request XML as a string 
  54.          r_ResponseXML = invokeUrl 
  55.          [ 
  56.              url :v_Endpoint 
  57.              type :POST 
  58.              parameters:x_Params 
  59.              headers:m_Headers 
  60.          ]
  61.          // 
  62.          // output response 
  63.          info r_ResponseXML; 
  64.          /* 
  65.          // 
  66.          // if successful then read the response 
  67.          if(r_ResponseXML.contains("<Ack>Success</Ack>")) 
  68.          { 
  69.              // 
  70.              // parse the data 
  71.              v_MainNode = "Item"; 
  72.              x_MainNode = r_ResponseXML.subString(r_ResponseXML.indexOf("<+ v_MainNode),r_ResponseXML.lastIndexOf("</" + v_MainNode) + v_MainNode.length() + 3)
  73.   
  74.          } 
  75.          */ 
  76.      } 
  77.  } 
Category: Zoho :: Article: 798

Please publish modules in offcanvas position.