For Zoho Services only:


I'm actually part of a bigger team at Ascent Business Solutions where we have support technicians and project consultants. Support is for smaller technical fixes but this can include developments, reports or integrations; depending on the size of the task. Projects are for more time-consuming developments such as revamps of the Zoho Suite of apps or on-site training. The advantage of a team is that if I am out-of-office for a day or so, there is always someone at Ascent Business Solutions who can deal with any queries/issues you may have.

Our support rates can be found and purchased at http://ascentbusiness.co.uk/zoho-support-2. A support bundle doesn't have an expiry date. So whether we can do what you want within the bundle and a year later need further support, if there are minutes left on the bundle then there is no additional charge.

Our project rates for bigger developments can be found at http://ascentbusiness.co.uk/crm-solutions/zoho-crm-packages-prices and will involve a dedicated project consultant along with developers who will hold your hand through the development process.

If you want help building a solution for one of the Zoho Apps in the Zoho Suite, contact us on 0121 293 8140 (UK) or by email at info@ascentbusiness.co.uk. You can also visit our website at http://ascentbusiness.co.uk.

I regularly build and specialize in 2-way API integrations for Xero, Shopify and eBay.

Zoho Creator: Receive eBay Order Notifications via Webhook

What?
This is an article to document how I got a client's eBay to notify the seller every time a buyer bought a fixed price item. This uses the Trading API even though I'm aiming for the Platform Notifications API...

Why?
A follow on from my article Zoho Creator: Push to eBay Listings. I have a Creator app that needs to receive the orders from an eBay account as soon as the order or transaction is made on a Fixed Price item.

How?
So first of all, you'll need an access token: please visit my article and read the first part on how to get a valid Access Token for the rest of these steps. Once we have an access token, we will check what notifications already exist (if any), and then we will create a function that subscribes the application so that any order is sent to a URL, specifically a CRM REST API function that will forward the payload data to Zoho Creator (Yes you will need CRM version Enterprise or Zoho One [that supports functions] for this process).

So first off, here's a reminder on the function that generates an access token from a refresh token:
copyraw
string API.fn_eBayConnect_AccessToken()
{
	b_SandboxMode = false;
	v_Output = "";
	if(b_SandboxMode)
	{
		r_Api = API_Integration[Connection_Name == "eBay API (Sandbox)"];
		//info "Sandbox Mode";
	}
	else
	{
		r_Api = API_Integration[Connection_Name == "eBay API (Production)"];
		//info "Production Mode";
	}
	if(r_Api.count() > 0)
	{
		//info "Access Token Expires at: " + r_Api.Access_Token_Expiry;
		v_Output = r_Api.Access_Token;
		//
		// zoho.currentttime can be server time as this function will check expiry against the server time anyway
		if(zoho.currenttime >= r_Api.Access_Token_Expiry)
		{
			v_Base64Auth = zoho.encryption.base64encode(r_Api.Client_ID + ":" + r_Api.Client_Secret);
			v_TokenEndpoint = r_Api.Token_Endpoint;
			m_Headers = Map();
			m_Headers.put("Content-Type","application/x-www-form-urlencoded");
			m_Headers.put("Authorization","Basic " + v_Base64Auth);
			m_Params = Map();
			m_Params.put("grant_type","refresh_token");
			m_Params.put("refresh_token",r_Api.Refresh_Token);
			m_Params.put("scope",r_Api.Scope_s);
			r_eBayResponse = invokeurl
			[
				url :v_TokenEndpoint
				type :POST
				parameters:m_Params
				headers:m_Headers
			];
			//info r_eBayResponse;
			if(!isnull(r_eBayResponse.get("access_token")))
			{
				// info "New Token Generated";
				r_Api.Access_Token=r_eBayResponse.get("access_token");
				v_AccessSeconds = r_eBayResponse.get("expires_in").toLong();
				r_Api.Access_Token_Expiry=zoho.currenttime.addSeconds(v_AccessSeconds);
				v_Output = r_Api.Access_Token;
			}
		}
		else
		{
			//info "Re-using Token";
		}
	}
	return v_Output;
}
  1.  string API.fn_eBayConnect_AccessToken() 
  2.  { 
  3.      b_SandboxMode = false
  4.      v_Output = ""
  5.      if(b_SandboxMode) 
  6.      { 
  7.          r_Api = API_Integration[Connection_Name == "eBay API (Sandbox)"]
  8.          //info "Sandbox Mode"; 
  9.      } 
  10.      else 
  11.      { 
  12.          r_Api = API_Integration[Connection_Name == "eBay API (Production)"]
  13.          //info "Production Mode"; 
  14.      } 
  15.      if(r_Api.count() > 0) 
  16.      { 
  17.          //info "Access Token Expires at: " + r_Api.Access_Token_Expiry; 
  18.          v_Output = r_Api.Access_Token; 
  19.          // 
  20.          // zoho.currentttime can be server time as this function will check expiry against the server time anyway 
  21.          if(zoho.currenttime >= r_Api.Access_Token_Expiry) 
  22.          { 
  23.              v_Base64Auth = zoho.encryption.base64encode(r_Api.Client_ID + ":" + r_Api.Client_Secret)
  24.              v_TokenEndpoint = r_Api.Token_Endpoint; 
  25.              m_Headers = Map()
  26.              m_Headers.put("Content-Type","application/x-www-form-urlencoded")
  27.              m_Headers.put("Authorization","Basic " + v_Base64Auth)
  28.              m_Params = Map()
  29.              m_Params.put("grant_type","refresh_token")
  30.              m_Params.put("refresh_token",r_Api.Refresh_Token)
  31.              m_Params.put("scope",r_Api.Scope_s)
  32.              r_eBayResponse = invokeUrl 
  33.              [ 
  34.                  url :v_TokenEndpoint 
  35.                  type :POST 
  36.                  parameters:m_Params 
  37.                  headers:m_Headers 
  38.              ]
  39.              //info r_eBayResponse; 
  40.              if(!isnull(r_eBayResponse.get("access_token"))) 
  41.              { 
  42.                  // info "New Token Generated"; 
  43.                  r_Api.Access_Token=r_eBayResponse.get("access_token")
  44.                  v_AccessSeconds = r_eBayResponse.get("expires_in").toLong()
  45.                  r_Api.Access_Token_Expiry=zoho.currenttime.addSeconds(v_AccessSeconds)
  46.                  v_Output = r_Api.Access_Token; 
  47.              } 
  48.          } 
  49.          else 
  50.          { 
  51.              //info "Re-using Token"; 
  52.          } 
  53.      } 
  54.      return v_Output; 
  55.  } 

Get Notification Preferences [Optional]
Here's a function to run just to see what the current notification preferences are setup. This one didn't tell me much first time I ran it but I can use it later on to check if my "setting the notifications" process worked.
copyraw
void API.fn_eBayQuery_GetNotificationPreferences()
{
	/*
    Function: fn_eBayQuery_GetNotificationPreferences()
    Purpose: Retrieves the requesting application's notification preferences
    Date Created:   2021-09-20 (Joellipman.com - 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
    - GetNotificationPreferences Documentation: https://developer.ebay.com/Devzone/XML/docs/Reference/eBay/GetNotificationPreferences.html
    */
	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";
		v_APICallName = "GetNotificationPreferences";
		//
		// build header
		m_Headers = Map();
		// siteID 3=UK, 0=US, check API Explorer Test Tool for others
		m_Headers.put("X-EBAY-API-SITEID",3);
		m_Headers.put("X-EBAY-API-COMPATIBILITY-LEVEL",v_TradingAPIVersion);
		m_Headers.put("X-EBAY-API-CALL-NAME",v_APICallName);
		m_Headers.put("X-EBAY-API-IAF-TOKEN",v_AccessToken);
		//
		// build params
		m_Params = Map();
		// set to application or user to see the notifications for each
		m_Params.put("PreferenceLevel","User");
		m_Params.put("WarningLevel","High");
		m_Params.put("ErrorLanguage","en_GB");
		//
		// 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_APICallName + "Request xmlns=\"urn:ebay:apis:eBLBaseComponents\">");
		x_Params = x_Params.toString().replaceFirst("</root>","</" + v_APICallName + "Request>");
		//
		// send the request XML as a string
		r_ResponseXML = invokeurl
		[
			url :v_Endpoint
			type :POST
			parameters:x_Params
			headers:m_Headers
		];
		info r_ResponseXML;
	}
}
  1.  void API.fn_eBayQuery_GetNotificationPreferences() 
  2.  { 
  3.      /* 
  4.      Function: fn_eBayQuery_GetNotificationPreferences() 
  5.      Purpose: Retrieves the requesting application's notification preferences 
  6.      Date Created:   2021-09-20 (Joellipman.com - Joel Lipman) 
  7.                      - Initial release 
  8.   
  9.      More Info: 
  10.      - API Explorer Test Tool: https://developer.ebay.com/DevZone/build-test/test-tool/default.aspx?index=0&env=production&api=trading 
  11.      - GetNotificationPreferences Documentation: https://developer.ebay.com/Devzone/XML/docs/Reference/eBay/GetNotificationPreferences.html 
  12.      */ 
  13.      r_Api = API_Integration[Connection_Name == "eBay API (Production)"]
  14.      if(r_Api.count() > 0) 
  15.      { 
  16.          v_AccessToken = thisapp.API.fn_eBayConnect_AccessToken()
  17.          v_TradingAPIVersion = r_Api.API_Version; 
  18.          v_Endpoint = "https://api.ebay.com/ws/api.dll"
  19.          v_APICallName = "GetNotificationPreferences"
  20.          // 
  21.          // build header 
  22.          m_Headers = Map()
  23.          // siteID 3=UK, 0=US, check API Explorer Test Tool for others 
  24.          m_Headers.put("X-EBAY-API-SITEID",3)
  25.          m_Headers.put("X-EBAY-API-COMPATIBILITY-LEVEL",v_TradingAPIVersion)
  26.          m_Headers.put("X-EBAY-API-CALL-NAME",v_APICallName)
  27.          m_Headers.put("X-EBAY-API-IAF-TOKEN",v_AccessToken)
  28.          // 
  29.          // build params 
  30.          m_Params = Map()
  31.          // set to application or user to see the notifications for each 
  32.          m_Params.put("PreferenceLevel","User")
  33.          m_Params.put("WarningLevel","High")
  34.          m_Params.put("ErrorLanguage","en_GB")
  35.          // 
  36.          // convert to xml and replace root nodes 
  37.          x_Params = m_Params.toXML()
  38.          x_Params = x_Params.toString().replaceFirst("<root>","<?xml version=\"1.0\" encoding=\"utf-8\"?><" + v_APICallName + "Request xmlns=\"urn:ebay:apis:eBLBaseComponents\">")
  39.          x_Params = x_Params.toString().replaceFirst("</root>","</" + v_APICallName + "Request>")
  40.          // 
  41.          // send the request XML as a string 
  42.          r_ResponseXML = invokeUrl 
  43.          [ 
  44.              url :v_Endpoint 
  45.              type :POST 
  46.              parameters:x_Params 
  47.              headers:m_Headers 
  48.          ]
  49.          info r_ResponseXML; 
  50.      } 
  51.  } 

Setup Creator form to receive data
  1. Login to your Zoho Creator and setup a form, I've called mine "eBay Webhook Payloads"
  2. Add a Single-Line field called "Event Type"
  3. Add a Multi-line field called "Payload"
  4. Click Done
  5. Make a note of the name of this form (the form link name, eg. "eBay_Webhook_Payloads")

Setup a CRM function to receive data
  1. Login to your ZohoCRM > Setup > Developer Space > Functions
  2. Click on "New Function"
  3. Give it a function name, I'm calling mine "fn_eBay_Webhook_OrderNotification"
  4. Give it a display name, I'll give it "eBay - Webhook - Order Notification"
  5. Set the Category to "Standalone"
  6. Set the parameters to crmAPIRequest (string)
  7. Give it the following code, though you will need to replace the AppOwner, AppName, FormName and connection name (which has scopes "ZohoCreator.form.CREATE" and "ZohoCreator.report.CREATE")
    copyraw
    v_AppOwner = "myCreatorAppOwner";
    v_AppName = "myCreatorAppName";
    v_FormName = "eBay_Webhook_Payloads";
    v_ReportName = "eBay_Webhook_Payloads_Report";
    m_Payload = crmAPIRequest;
    v_Type = "Unknown";
    l_SoapActions = List();
    if(!isnull(m_Payload.getJSON("headers")))
    {
    	l_SoapActions = m_Payload.getJSON("headers").getJSON("soapaction");
    	for each  v_SoapAction in l_SoapActions
    	{
    		l_SoapActionParts = v_SoapAction.toList("/");
    		v_Type = l_SoapActionParts.get(l_SoapActionParts.size() - 1);
    	}
    }
    m_Blank = Map();
    m_CreateRecord = Map();
    m_CreateRecord.put("Event_Type",v_Type);
    m_CreateRecord.put("Payload",m_Payload.toString());
    r_CreateRecord = zoho.creator.createRecord(v_AppOwner,v_AppName,v_FormName,m_CreateRecord,m_Blank,"joels_connector");
    /*
    // Email yourself as a test but remember to remove this before going Live.
    sendmail
    [
    	from :zoho.adminuserid
    	to :"This email address is being protected from spambots. You need JavaScript enabled to view it."
    	subject :"TEST ebay Webhook Notification"
    	message :m_Payload
    ]
    */
    return r_CreateRecord;
    1.  v_AppOwner = "myCreatorAppOwner"
    2.  v_AppName = "myCreatorAppName"
    3.  v_FormName = "eBay_Webhook_Payloads"
    4.  v_ReportName = "eBay_Webhook_Payloads_Report"
    5.  m_Payload = crmAPIRequest; 
    6.  v_Type = "Unknown"
    7.  l_SoapActions = List()
    8.  if(!isnull(m_Payload.getJSON("headers"))) 
    9.  { 
    10.      l_SoapActions = m_Payload.getJSON("headers").getJSON("soapaction")
    11.      for each  v_SoapAction in l_SoapActions 
    12.      { 
    13.          l_SoapActionParts = v_SoapAction.toList("/")
    14.          v_Type = l_SoapActionParts.get(l_SoapActionParts.size() - 1)
    15.      } 
    16.  } 
    17.  m_Blank = Map()
    18.  m_CreateRecord = Map()
    19.  m_CreateRecord.put("Event_Type",v_Type)
    20.  m_CreateRecord.put("Payload",m_Payload.toString())
    21.  r_CreateRecord = zoho.creator.createRecord(v_AppOwner,v_AppName,v_FormName,m_CreateRecord,m_Blank,"joels_connector")
    22.  /* 
    23.  // Email yourself as a test but remember to remove this before going Live. 
    24.  sendmail 
    25.  [ 
    26.      from :zoho.adminuserid 
    27.      to :"This email address is being protected from spambots. You need JavaScript enabled to view it.
    28.      subject :"TEST ebay Webhook Notification" 
    29.      message :m_Payload 
    30.  ] 
    31.  */ 
    32.  return r_CreateRecord; 
  8. Save the function
  9. While still on the CRM functions page, hover your mouse over the function name you just created and click on the ellipsis/three dots icon
  10. Select REST API and enable the API Key, this will return a URL that you want to copy to clipboard or notepad for later use.
    Zoho Creator: Receive eBay Order Notifications via Webhook - Setup a CRM REST API function and get API Key

Set Notification Preferences
Finally, here's the function that subscribed my application so that every time an order/transaction was made on eBay for a fixed price item, it sent a payload (like a webhook) to my CRM REST API function. The following includes UserDeliveryPreferenceArray but I've successfully subscribed without this. I'm just including it because I want to be notified if feedback is left:

OAuth Method (requires contacting eBay to enable this once run)
copyraw
void API.fn_eBayQuery_SetNotificationPreferences()
{
	/*
    Function: fn_eBayQuery_SetNotificationPreferences()
    Purpose: Manage notification and alert preferences for a user or an application
    Date Created:   2021-09-20 (Joellipman.com - 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
    - GetNotificationPreferences Documentation: https://developer.ebay.com/Devzone/XML/docs/Reference/eBay/GetNotificationPreferences.html
    - SetNotificationPreferences Documentation: https://developer.ebay.com/devzone/xml/docs/reference/ebay/SetNotificationPreferences.html
    - Event Types Documentation: https://developer.ebay.com/Devzone/XML/docs/Reference/eBay/extra/stntfctnprfrncs.rqst.evntprprty.evnttyp.html
    */
	r_Api = API_Integration[Connection_Name == "eBay API (Production)"];
	if(r_Api.count() > 0)
	{
		v_AccessToken = thisapp.API.fn_eBayConnect_AccessToken();
		//info v_AccessToken;
		v_TradingAPIVersion = r_Api.API_Version;
		v_Endpoint = "https://api.ebay.com/ws/api.dll";
		v_APICallName = "SetNotificationPreferences";
		//
		// specify the URL of the CRM REST API Function here (can be a mailto:email@address)
		v_CrmRestFunction = "https://www.zohoapis.com/crm/v2/functions/fn_ebay_webhook_ordernotification/actions/execute?auth_type=apikey&zapikey=1003.aaaabbbbccccddddeeeeffff11112222.33334444555566667777888899990000";
		//
		// build header
		m_Headers = Map();
		m_Headers.put("X-EBAY-API-SITEID",3);
		m_Headers.put("X-EBAY-API-COMPATIBILITY-LEVEL",v_TradingAPIVersion);
		m_Headers.put("X-EBAY-API-CALL-NAME",v_APICallName);
		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_AppDeliveryPrefs = Map();
		m_AppDeliveryPrefs.put("AlertEmail","mailto:This email address is being protected from spambots. You need JavaScript enabled to view it.");
		m_AppDeliveryPrefs.put("AlertEnable","Enable");
		m_AppDeliveryPrefs.put("ApplicationEnable","Enable");
		m_AppDeliveryPrefs.put("ApplicationURL",v_CrmRestFunction);
		m_AppDeliveryPrefs.put("DeviceType","Platform");
		m_DeliveryURL = Map();
		m_DeliveryURL.put("DeliveryURL",v_CrmRestFunction);
		m_DeliveryURL.put("DeliveryURLName","eBayToZoho");
		m_AppDeliveryPrefs.put("DeliveryURLDetails",m_DeliveryURL);
		m_Params.put("ApplicationDeliveryPreferences",m_AppDeliveryPrefs);
		/* only used for wireless applications? 
		m_EventProperty=Map();
		m_EventProperty.put("EventType","FixedPriceTransaction");
		m_Params.put("EventProperty",m_EventProperty);
		*/
		// include the User Delivery Preference Array
		l_UserDeliveryPreferenceArray = List();
		m_EventPair = Map();
		m_EventPair.put("EventType","FixedPriceTransaction");
		m_EventPair.put("EventEnable","Enable");
		l_UserDeliveryPreferenceArray.add(m_EventPair);
		m_EventPair = Map();
		m_EventPair.put("EventType","Feedback");
		m_EventPair.put("EventEnable","Enable");
		l_UserDeliveryPreferenceArray.add(m_EventPair);
		m_NotificationEnable = Map();
		m_NotificationEnable.put("NotificationEnable",l_UserDeliveryPreferenceArray);
		m_Params.put("UserDeliveryPreferenceArray",m_NotificationEnable);
		//
		// 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_APICallName + "Request xmlns=\"urn:ebay:apis:eBLBaseComponents\">");
		x_Params = x_Params.toString().replaceFirst("</root>","</" + v_APICallName + "Request>");
		//info x_Params;
		//
		// send the request XML as a string
		r_ResponseXML = invokeurl
		[
			url :v_Endpoint
			type :POST
			parameters:x_Params
			headers:m_Headers
		];
		info r_ResponseXML;
	}
}
  1.  void API.fn_eBayQuery_SetNotificationPreferences() 
  2.  { 
  3.      /* 
  4.      Function: fn_eBayQuery_SetNotificationPreferences() 
  5.      Purpose: Manage notification and alert preferences for a user or an application 
  6.      Date Created:   2021-09-20 (Joellipman.com - Joel Lipman) 
  7.                      - Initial release 
  8.   
  9.      More Info: 
  10.      - API Explorer Test Tool: https://developer.ebay.com/DevZone/build-test/test-tool/default.aspx?index=0&env=production&api=trading 
  11.      - GetNotificationPreferences Documentation: https://developer.ebay.com/Devzone/XML/docs/Reference/eBay/GetNotificationPreferences.html 
  12.      - SetNotificationPreferences Documentation: https://developer.ebay.com/devzone/xml/docs/reference/ebay/SetNotificationPreferences.html 
  13.      - Event Types Documentation: https://developer.ebay.com/Devzone/XML/docs/Reference/eBay/extra/stntfctnprfrncs.rqst.evntprprty.evnttyp.html 
  14.      */ 
  15.      r_Api = API_Integration[Connection_Name == "eBay API (Production)"]
  16.      if(r_Api.count() > 0) 
  17.      { 
  18.          v_AccessToken = thisapp.API.fn_eBayConnect_AccessToken()
  19.          //info v_AccessToken; 
  20.          v_TradingAPIVersion = r_Api.API_Version; 
  21.          v_Endpoint = "https://api.ebay.com/ws/api.dll"
  22.          v_APICallName = "SetNotificationPreferences"
  23.          // 
  24.          // specify the URL of the CRM REST API Function here (can be a mailto:email@address) 
  25.          v_CrmRestFunction = "https://www.zohoapis.com/crm/v2/functions/fn_ebay_webhook_ordernotification/actions/execute?auth_type=apikey&zapikey=1003.aaaabbbbccccddddeeeeffff11112222.33334444555566667777888899990000"
  26.          // 
  27.          // build header 
  28.          m_Headers = Map()
  29.          m_Headers.put("X-EBAY-API-SITEID",3)
  30.          m_Headers.put("X-EBAY-API-COMPATIBILITY-LEVEL",v_TradingAPIVersion)
  31.          m_Headers.put("X-EBAY-API-CALL-NAME",v_APICallName)
  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_AppDeliveryPrefs = Map()
  39.          m_AppDeliveryPrefs.put("AlertEmail","mailto:This email address is being protected from spambots. You need JavaScript enabled to view it.")
  40.          m_AppDeliveryPrefs.put("AlertEnable","Enable")
  41.          m_AppDeliveryPrefs.put("ApplicationEnable","Enable")
  42.          m_AppDeliveryPrefs.put("ApplicationURL",v_CrmRestFunction)
  43.          m_AppDeliveryPrefs.put("DeviceType","Platform")
  44.          m_DeliveryURL = Map()
  45.          m_DeliveryURL.put("DeliveryURL",v_CrmRestFunction)
  46.          m_DeliveryURL.put("DeliveryURLName","eBayToZoho")
  47.          m_AppDeliveryPrefs.put("DeliveryURLDetails",m_DeliveryURL)
  48.          m_Params.put("ApplicationDeliveryPreferences",m_AppDeliveryPrefs)
  49.          /* only used for wireless applications? 
  50.          m_EventProperty=Map()
  51.          m_EventProperty.put("EventType","FixedPriceTransaction")
  52.          m_Params.put("EventProperty",m_EventProperty)
  53.          */ 
  54.          // include the User Delivery Preference Array 
  55.          l_UserDeliveryPreferenceArray = List()
  56.          m_EventPair = Map()
  57.          m_EventPair.put("EventType","FixedPriceTransaction")
  58.          m_EventPair.put("EventEnable","Enable")
  59.          l_UserDeliveryPreferenceArray.add(m_EventPair)
  60.          m_EventPair = Map()
  61.          m_EventPair.put("EventType","Feedback")
  62.          m_EventPair.put("EventEnable","Enable")
  63.          l_UserDeliveryPreferenceArray.add(m_EventPair)
  64.          m_NotificationEnable = Map()
  65.          m_NotificationEnable.put("NotificationEnable",l_UserDeliveryPreferenceArray)
  66.          m_Params.put("UserDeliveryPreferenceArray",m_NotificationEnable)
  67.          // 
  68.          // convert to xml and replace root nodes 
  69.          x_Params = m_Params.toXML()
  70.          x_Params = x_Params.toString().replaceFirst("<root>","<?xml version=\"1.0\" encoding=\"utf-8\"?><" + v_APICallName + "Request xmlns=\"urn:ebay:apis:eBLBaseComponents\">")
  71.          x_Params = x_Params.toString().replaceFirst("</root>","</" + v_APICallName + "Request>")
  72.          //info x_Params; 
  73.          // 
  74.          // send the request XML as a string 
  75.          r_ResponseXML = invokeUrl 
  76.          [ 
  77.              url :v_Endpoint 
  78.              type :POST 
  79.              parameters:x_Params 
  80.              headers:m_Headers 
  81.          ]
  82.          info r_ResponseXML; 
  83.      } 
  84.  } 

Success Response
You should get something like the following on a successful subscription:
copyraw
<?xml version="1.0" encoding="UTF-8"?>
<SetNotificationPreferencesResponse
	xmlns="urn:ebay:apis:eBLBaseComponents">
	<Timestamp>2021-09-20T19:50:29.964Z</Timestamp>
	<Ack>Success</Ack>
	<Version>1173</Version>
	<Build>E1173_CORE_APINOTIFY_19146596_R1</Build>
</SetNotificationPreferencesResponse>
  1.  <?xml version="1.0" encoding="UTF-8"?> 
  2.  <SetNotificationPreferencesResponse 
  3.      xmlns="urn:ebay:apis:eBLBaseComponents"> 
  4.      <Timestamp>2021-09-20T19:50:29.964Z</Timestamp> 
  5.      <Ack>Success</Ack> 
  6.      <Version>1173</Version> 
  7.      <Build>E1173_CORE_APINOTIFY_19146596_R1</Build> 
  8.  </SetNotificationPreferencesResponse> 

Re-run GetNotificationPreferences
Just as a double-tap, let's run my GetNotificationPreferences function above specifying the "PreferenceLevel" to "User" to see the user notifications I just created. I get the following response:
copyraw
<?xml version="1.0" encoding="UTF-8"?>
<GetNotificationPreferencesResponse
	xmlns="urn:ebay:apis:eBLBaseComponents">
	<Timestamp>2021-09-20T20:14:17.077Z</Timestamp>
	<Ack>Success</Ack>
	<Version>1173</Version>
	<Build>E1173_CORE_APINOTIFY_19146596_R1</Build>
	<UserDeliveryPreferenceArray>
		<NotificationEnable>
			<EventType>Feedback</EventType>
			<EventEnable>Enable</EventEnable>
		</NotificationEnable>
		<NotificationEnable>
			<EventType>FixedPriceTransaction</EventType>
			<EventEnable>Enable</EventEnable>
		</NotificationEnable>
	</UserDeliveryPreferenceArray>
</GetNotificationPreferencesResponse>
  1.  <?xml version="1.0" encoding="UTF-8"?> 
  2.  <GetNotificationPreferencesResponse 
  3.      xmlns="urn:ebay:apis:eBLBaseComponents"> 
  4.      <Timestamp>2021-09-20T20:14:17.077Z</Timestamp> 
  5.      <Ack>Success</Ack> 
  6.      <Version>1173</Version> 
  7.      <Build>E1173_CORE_APINOTIFY_19146596_R1</Build> 
  8.      <UserDeliveryPreferenceArray> 
  9.          <NotificationEnable> 
  10.              <EventType>Feedback</EventType> 
  11.              <EventEnable>Enable</EventEnable> 
  12.          </NotificationEnable> 
  13.          <NotificationEnable> 
  14.              <EventType>FixedPriceTransaction</EventType> 
  15.              <EventEnable>Enable</EventEnable> 
  16.          </NotificationEnable> 
  17.      </UserDeliveryPreferenceArray> 
  18.  </GetNotificationPreferencesResponse> 


Auth'n'auth (Authentication and Authorization) Process


Not getting notification via the URL but you are getting them via email? Well I read somewhere you need to use Auth'n'auth to enable these notifications if you don't want to sit on a call with eBay. If you use Oauth as above then contact eBay and ask them to enable it once you've run the above function. For me, I didn't have this patience and find it more fun to write another function that will generate the Auth'n'auth token.

Here is a reminder on what my Zoho Creator form looks like for API Integrations and the fields I refer to:
Zoho Creator - API Integration form a la Joel
Note the Dev ID field and the Session ID fields that we didn't use in my previous article but are going to use now. You get the Dev ID from your application keys page:
Zoho Creator Push to eBay Listings API: Application Keys

For the next steps, it's best if you create these 2 functions beforehand, as there isn't much time between getting the Session ID, logging in, agreeing, and then running the second function to get the FetchToken.

So first, I need a function to get me a Session ID. Once I've used this and signed in once, it will last a few seconds, long enough for me to do my Fetch Auth'n'auth token process:
copyraw
string API.fn_eBayConnect_AuthToken_GetSessionUrl()
{
	/*
	Function: fn_eBayConnect_AuthToken_GetSessionUrl()
	Purpose: Gets a SessionID to use the Auth'n'Auth (Authentication and Authorization) method instead of Oauth
	Date Created:   2021-09-22 (Joellipman.com - 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
	- Getting Tokens Documentation: https://developer.ebay.com/devzone/guides/features-guide/default.html#basics/Tokens.html
	- Making a Call Documentation: https://developer.ebay.com/devzone/xml/docs/Concepts/MakingACall.html#auth
	- Get a Session ID Documentation: https://developer.ebay.com/devzone/xml/docs/reference/ebay/getsessionid.html
	*/
	v_SessionURL = "";
	r_Api = API_Integration[Connection_Name == "eBay API (Production)"];
	if(r_Api.count() > 0)
	{	
		v_TradingAPIVersion = r_Api.API_Version;
		v_Endpoint = "https://api.ebay.com/ws/api.dll";
		v_ApiCallName = "GetSessionID";
		//
		// first we need to make a quick call to get a session ID
 		m_Headers = Map();
 		m_Headers.put("X-EBAY-API-SITEID",3);
 		m_Headers.put("X-EBAY-API-CALL-NAME",v_ApiCallName);
 		m_Headers.put("X-EBAY-API-COMPATIBILITY-LEVEL",r_Api.API_Version);
 		m_Headers.put("X-EBAY-API-APP-NAME",r_Api.Client_ID);
 		m_Headers.put("X-EBAY-API-DEV-NAME",r_Api.Dev_ID);
 		m_Headers.put("X-EBAY-API-CERT-NAME",r_Api.Client_Secret);
		m_Params = Map();
		m_Params.put("WarningLevel","High");
		m_Params.put("ErrorLanguage","en_GB");
		m_Params.put("RuName",r_Api.Redirect_URI);
		//
		// 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_ApiCallName+"Request xmlns=\"urn:ebay:apis:eBLBaseComponents\">");
		x_Params = x_Params.toString().replaceFirst("</root>","</"+v_ApiCallName+"Request>");
		//
		// send the request
		r_ResponseXML = invokeurl
		[
			url :v_Endpoint
			type :POST
			parameters:x_Params
			headers: m_Headers
		];
		// parse out the SessionID
		v_SessionID = "";
		if(r_ResponseXML.contains("<Ack>Success</Ack>"))
		{
			// tidy up the response so we can executeXPath
			x_Response = r_ResponseXML.executeXPath("/*/*").toXmlList();
			for each x_Node in x_Response
            {
				if(x_Node.contains("<SessionID"))
				{
					v_SessionID = x_Node.getSuffix(">").getPrefix("<");
				}
            } 
		}
		// info r_ResponseXML;
		if(v_SessionID!="")
		{
			// write back to my field and store it temporarily
			r_Api.Session_ID = v_SessionID;
			// Sandbox link:
			// v_SessionURL = "https://signin.sandbox.ebay.com/ws/eBayISAPI.dll?SignIn&RuName="+r_Api.Redirect_URI+"&SessID="+zoho.encryption.urlEncode(v_SessionID);
			// Production link:
			v_SessionURL = "https://signin.ebay.com/ws/eBayISAPI.dll?SignIn&RuName="+r_Api.Redirect_URI+"&SessID="+zoho.encryption.urlEncode(v_SessionID);
		}
	}
	return v_SessionURL;
}
  1.  string API.fn_eBayConnect_AuthToken_GetSessionUrl() 
  2.  { 
  3.      /* 
  4.      Function: fn_eBayConnect_AuthToken_GetSessionUrl() 
  5.      Purpose: Gets a SessionID to use the Auth'n'Auth (Authentication and Authorization) method instead of Oauth 
  6.      Date Created:   2021-09-22 (Joellipman.com - Joel Lipman) 
  7.                      - Initial release 
  8.   
  9.      More Info: 
  10.      - API Explorer Test Tool: https://developer.ebay.com/DevZone/build-test/test-tool/default.aspx?index=0&env=production&api=trading 
  11.      - Getting Tokens Documentation: https://developer.ebay.com/devzone/guides/features-guide/default.html#basics/Tokens.html 
  12.      - Making a Call Documentation: https://developer.ebay.com/devzone/xml/docs/Concepts/MakingACall.html#auth 
  13.      - Get a Session ID Documentation: https://developer.ebay.com/devzone/xml/docs/reference/ebay/getsessionid.html 
  14.      */ 
  15.      v_SessionURL = ""
  16.      r_Api = API_Integration[Connection_Name == "eBay API (Production)"]
  17.      if(r_Api.count() > 0) 
  18.      { 
  19.          v_TradingAPIVersion = r_Api.API_Version; 
  20.          v_Endpoint = "https://api.ebay.com/ws/api.dll"
  21.          v_ApiCallName = "GetSessionID"
  22.          // 
  23.          // first we need to make a quick call to get a session ID 
  24.           m_Headers = Map()
  25.           m_Headers.put("X-EBAY-API-SITEID",3)
  26.           m_Headers.put("X-EBAY-API-CALL-NAME",v_ApiCallName)
  27.           m_Headers.put("X-EBAY-API-COMPATIBILITY-LEVEL",r_Api.API_Version)
  28.           m_Headers.put("X-EBAY-API-APP-NAME",r_Api.Client_ID)
  29.           m_Headers.put("X-EBAY-API-DEV-NAME",r_Api.Dev_ID)
  30.           m_Headers.put("X-EBAY-API-CERT-NAME",r_Api.Client_Secret)
  31.          m_Params = Map()
  32.          m_Params.put("WarningLevel","High")
  33.          m_Params.put("ErrorLanguage","en_GB")
  34.          m_Params.put("RuName",r_Api.Redirect_URI)
  35.          // 
  36.          // convert to xml and replace root nodes 
  37.          x_Params = m_Params.toXML()
  38.          x_Params = x_Params.toString().replaceFirst("<root>","<?xml version=\"1.0\" encoding=\"utf-8\"?><"+v_ApiCallName+"Request xmlns=\"urn:ebay:apis:eBLBaseComponents\">")
  39.          x_Params = x_Params.toString().replaceFirst("</root>","</"+v_ApiCallName+"Request>")
  40.          // 
  41.          // send the request 
  42.          r_ResponseXML = invokeUrl 
  43.          [ 
  44.              url :v_Endpoint 
  45.              type :POST 
  46.              parameters:x_Params 
  47.              headers: m_Headers 
  48.          ]
  49.          // parse out the SessionID 
  50.          v_SessionID = ""
  51.          if(r_ResponseXML.contains("<Ack>Success</Ack>")) 
  52.          { 
  53.              // tidy up the response so we can executeXPath 
  54.              x_Response = r_ResponseXML.executeXPath("/*/*").toXmlList()
  55.              for each x_Node in x_Response 
  56.              { 
  57.                  if(x_Node.contains("<SessionID")) 
  58.                  { 
  59.                      v_SessionID = x_Node.getSuffix(">").getPrefix("<")
  60.                  } 
  61.              } 
  62.          } 
  63.          // info r_ResponseXML; 
  64.          if(v_SessionID!="") 
  65.          { 
  66.              // write back to my field and store it temporarily 
  67.              r_Api.Session_ID = v_SessionID; 
  68.              // Sandbox link: 
  69.              // v_SessionURL = "https://signin.sandbox.ebay.com/ws/eBayISAPI.dll?SignIn&RuName="+r_Api.Redirect_URI+"&SessID="+zoho.encryption.urlEncode(v_SessionID)
  70.              // Production link: 
  71.              v_SessionURL = "https://signin.ebay.com/ws/eBayISAPI.dll?SignIn&RuName="+r_Api.Redirect_URI+"&SessID="+zoho.encryption.urlEncode(v_SessionID)
  72.          } 
  73.      } 
  74.      return v_SessionURL; 
  75.  } 
Browse to the URL that has been returned when running this function, sign-in and agree. You should land on a "Thank You" page saying "Authorization successfully completed. It's now safe to close the browser window/tab." If you set up a Creator form like I have, then it will store the Session ID in there so you can simply run the next function:
copyraw
string API.fn_eBayConnect_AuthToken_FetchToken()
{
	/*
	Function: fn_eBayConnect_AuthToken_FetchToken()
	Purpose: Gets a token for the Auth'n'Auth (Authentication and Authorization) method instead of Oauth
	Date Created:   2021-09-22 (Joellipman.com - 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
	- FetchToken Documentation: https://developer.ebay.com/Devzone/XML/docs/Reference/eBay/FetchToken.html
	*/
	v_AuthToken = "";
	r_Api = API_Integration[Connection_Name == "eBay API (Production)"];
	if(r_Api.count() > 0)
	{
		v_TradingAPIVersion = r_Api.API_Version;
		v_Endpoint = "https://api.ebay.com/ws/api.dll";
		v_ApiCallName = "FetchToken";
		//
		// first we need to make a quick call to get a session ID
		m_Headers = Map();
		m_Headers.put("X-EBAY-API-SITEID",3);
		m_Headers.put("X-EBAY-API-CALL-NAME",v_ApiCallName);
		m_Headers.put("X-EBAY-API-COMPATIBILITY-LEVEL",r_Api.API_Version);
		m_Headers.put("X-EBAY-API-APP-NAME",r_Api.Client_ID);
		m_Headers.put("X-EBAY-API-DEV-NAME",r_Api.Dev_ID);
		m_Headers.put("X-EBAY-API-CERT-NAME",r_Api.Client_Secret);
		m_Params = Map();
		m_Params.put("WarningLevel","High");
		m_Params.put("ErrorLanguage","en_GB");
		m_Params.put("SessionID",r_Api.Session_ID);
		//
		// 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_ApiCallName + "Request xmlns=\"urn:ebay:apis:eBLBaseComponents\">");
		x_Params = x_Params.toString().replaceFirst("</root>","</" + v_ApiCallName + "Request>");
		//info x_Params;
		//
		// send the request
		r_ResponseXML = invokeurl
		[
			url :v_Endpoint
			type :POST
			parameters:x_Params
			headers:m_Headers
		];
		//
		// parse out the AuthToken
		//info r_ResponseXML;
		v_SessionID = "";
		if(r_ResponseXML.contains("<Ack>Success</Ack>"))
		{
			// tidy up the response so we can executeXPath
			x_Response = r_ResponseXML.executeXPath("/*/*").toXmlList();
			for each  x_Node in x_Response
			{
				if(x_Node.contains("<eBayAuthToken"))
				{
					v_AuthToken = x_Node.getSuffix(">").getPrefix("<");
					r_Api.AuthToken=v_AuthToken;
				}
				if(x_Node.contains("<HardExpirationTime"))
				{
					v_AuthTokenExpiry = x_Node.getSuffix(">").getPrefix("<");
					// yields something like 2023-03-16T22:53:56.000Z
					v_AuthTokenExpiry = v_AuthTokenExpiry.replaceAll("T"," ",true);
					// yields something like 2023-03-16 22:53:56.000Z
					v_AuthTokenExpiry = v_AuthTokenExpiry.getPrefix(".");
					// yields something like 2023-03-16 22:53:56
					// has to match the datetime format of your Creator field
					r_Api.AuthToken_Expiry=v_AuthTokenExpiry;
				}
			}
		}
	}
	return v_AuthToken;
}
  1.  string API.fn_eBayConnect_AuthToken_FetchToken() 
  2.  { 
  3.      /* 
  4.      Function: fn_eBayConnect_AuthToken_FetchToken() 
  5.      Purpose: Gets a token for the Auth'n'Auth (Authentication and Authorization) method instead of Oauth 
  6.      Date Created:   2021-09-22 (Joellipman.com - Joel Lipman) 
  7.                      - Initial release 
  8.   
  9.      More Info: 
  10.      - API Explorer Test Tool: https://developer.ebay.com/DevZone/build-test/test-tool/default.aspx?index=0&env=production&api=trading 
  11.      - FetchToken Documentation: https://developer.ebay.com/Devzone/XML/docs/Reference/eBay/FetchToken.html 
  12.      */ 
  13.      v_AuthToken = ""
  14.      r_Api = API_Integration[Connection_Name == "eBay API (Production)"]
  15.      if(r_Api.count() > 0) 
  16.      { 
  17.          v_TradingAPIVersion = r_Api.API_Version; 
  18.          v_Endpoint = "https://api.ebay.com/ws/api.dll"
  19.          v_ApiCallName = "FetchToken"
  20.          // 
  21.          // first we need to make a quick call to get a session ID 
  22.          m_Headers = Map()
  23.          m_Headers.put("X-EBAY-API-SITEID",3)
  24.          m_Headers.put("X-EBAY-API-CALL-NAME",v_ApiCallName)
  25.          m_Headers.put("X-EBAY-API-COMPATIBILITY-LEVEL",r_Api.API_Version)
  26.          m_Headers.put("X-EBAY-API-APP-NAME",r_Api.Client_ID)
  27.          m_Headers.put("X-EBAY-API-DEV-NAME",r_Api.Dev_ID)
  28.          m_Headers.put("X-EBAY-API-CERT-NAME",r_Api.Client_Secret)
  29.          m_Params = Map()
  30.          m_Params.put("WarningLevel","High")
  31.          m_Params.put("ErrorLanguage","en_GB")
  32.          m_Params.put("SessionID",r_Api.Session_ID)
  33.          // 
  34.          // convert to xml and replace root nodes 
  35.          x_Params = m_Params.toXML()
  36.          x_Params = x_Params.toString().replaceFirst("<root>","<?xml version=\"1.0\" encoding=\"utf-8\"?><" + v_ApiCallName + "Request xmlns=\"urn:ebay:apis:eBLBaseComponents\">")
  37.          x_Params = x_Params.toString().replaceFirst("</root>","</" + v_ApiCallName + "Request>")
  38.          //info x_Params; 
  39.          // 
  40.          // send the request 
  41.          r_ResponseXML = invokeUrl 
  42.          [ 
  43.              url :v_Endpoint 
  44.              type :POST 
  45.              parameters:x_Params 
  46.              headers:m_Headers 
  47.          ]
  48.          // 
  49.          // parse out the AuthToken 
  50.          //info r_ResponseXML; 
  51.          v_SessionID = ""
  52.          if(r_ResponseXML.contains("<Ack>Success</Ack>")) 
  53.          { 
  54.              // tidy up the response so we can executeXPath 
  55.              x_Response = r_ResponseXML.executeXPath("/*/*").toXmlList()
  56.              for each  x_Node in x_Response 
  57.              { 
  58.                  if(x_Node.contains("<eBayAuthToken")) 
  59.                  { 
  60.                      v_AuthToken = x_Node.getSuffix(">").getPrefix("<")
  61.                      r_Api.AuthToken=v_AuthToken; 
  62.                  } 
  63.                  if(x_Node.contains("<HardExpirationTime")) 
  64.                  { 
  65.                      v_AuthTokenExpiry = x_Node.getSuffix(">").getPrefix("<")
  66.                      // yields something like 2023-03-16T22:53:56.000Z 
  67.                      v_AuthTokenExpiry = v_AuthTokenExpiry.replaceAll("T"," ",true)
  68.                      // yields something like 2023-03-16 22:53:56.000Z 
  69.                      v_AuthTokenExpiry = v_AuthTokenExpiry.getPrefix(".")
  70.                      // yields something like 2023-03-16 22:53:56 
  71.                      // has to match the datetime format of your Creator field 
  72.                      r_Api.AuthToken_Expiry=v_AuthTokenExpiry; 
  73.                  } 
  74.              } 
  75.          } 
  76.      } 
  77.      return v_AuthToken; 
  78.  } 

If successful, your API Integration form will now have an AuthToken that lasts pretty much as long as a Refresh Token used in OAuth. So where were we? Ah yes, let's try subscribing to/enabling our notifications with this process instead:
copyraw
void API.fn_eBayQuery_SetNotificationPreferences_AuthNAuth()
{
	/*
    Function: fn_eBayQuery_SetNotificationPreferences_AuthNAuth()
    Purpose: Manage notification and alert preferences for a user or an application using Auth'n'Auth not Oauth
    Date Created:   2021-09-23 (Joellipman.com - 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
    - GetNotificationPreferences Documentation: https://developer.ebay.com/Devzone/XML/docs/Reference/eBay/GetNotificationPreferences.html
    - SetNotificationPreferences Documentation: https://developer.ebay.com/devzone/xml/docs/reference/ebay/SetNotificationPreferences.html
    - Event Types Documentation: https://developer.ebay.com/Devzone/XML/docs/Reference/eBay/extra/stntfctnprfrncs.rqst.evntprprty.evnttyp.html
    */
	r_Api = API_Integration[Connection_Name == "eBay API (Production)"];
	if(r_Api.count() > 0)
	{
		v_AccessToken = thisapp.API.fn_eBayConnect_AccessToken();
		//info v_AccessToken;
		v_TradingAPIVersion = r_Api.API_Version;
		v_Endpoint = "https://api.ebay.com/ws/api.dll";
		v_APICallName = "SetNotificationPreferences";
		//
		// specify the URL of the CRM REST API Function here (can be a mailto:email@address)
		v_CrmRestFunction = "https://www.zohoapis.com/crm/v2/functions/fn_ebay_webhook_ordernotification/actions/execute?auth_type=apikey&zapikey=1003.aaaabbbbccccddddeeeeffff11112222.33334444555566667777888899990000";
		//
		// build header
		m_Headers = Map();
		m_Headers.put("X-EBAY-API-SITEID",3);
		m_Headers.put("X-EBAY-API-CALL-NAME",v_APICallName);
		m_Headers.put("X-EBAY-API-COMPATIBILITY-LEVEL",r_Api.API_Version);
		m_Headers.put("X-EBAY-API-APP-NAME",r_Api.Client_ID);
		m_Headers.put("X-EBAY-API-DEV-NAME",r_Api.Dev_ID);
		m_Headers.put("X-EBAY-API-CERT-NAME",r_Api.Client_Secret);
		//
		// build params
		m_Params = Map();
		m_Params.put("WarningLevel","High");
		m_Params.put("ErrorLanguage","en_GB");
		m_AuthToken=Map();
		m_AuthToken.put("eBayAuthToken",r_Api.AuthToken);
		m_Params.put("RequesterCredentials",m_AuthToken);
		m_AppDeliveryPrefs = Map();
		m_AppDeliveryPrefs.put("AlertEmail","mailto:This email address is being protected from spambots. You need JavaScript enabled to view it.");
		m_AppDeliveryPrefs.put("AlertEnable","Enable");
		m_AppDeliveryPrefs.put("ApplicationEnable","Enable");
		m_AppDeliveryPrefs.put("ApplicationURL",v_CrmRestFunction);
		m_AppDeliveryPrefs.put("DeviceType","Platform");
		m_DeliveryURL = Map();
		m_DeliveryURL.put("DeliveryURL",v_CrmRestFunction);
		m_DeliveryURL.put("DeliveryURLName","eBayToZoho");
		m_AppDeliveryPrefs.put("DeliveryURLDetails",m_DeliveryURL);
		m_Params.put("ApplicationDeliveryPreferences",m_AppDeliveryPrefs);
		// include the User Delivery Preference Array
		l_UserDeliveryPreferenceArray = List();
		m_EventPair = Map();
		m_EventPair.put("EventType","FixedPriceTransaction");
		m_EventPair.put("EventEnable","Enable");
		l_UserDeliveryPreferenceArray.add(m_EventPair);
		m_EventPair = Map();
		m_EventPair.put("EventType","Feedback");
		m_EventPair.put("EventEnable","Enable");
		l_UserDeliveryPreferenceArray.add(m_EventPair);
		m_NotificationEnable = Map();
		m_NotificationEnable.put("NotificationEnable",l_UserDeliveryPreferenceArray);
		m_Params.put("UserDeliveryPreferenceArray",m_NotificationEnable);
		//
		// 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_APICallName + "Request xmlns=\"urn:ebay:apis:eBLBaseComponents\">");
		x_Params = x_Params.toString().replaceFirst("</root>","</" + v_APICallName + "Request>");
		info x_Params;
		//
		// send the request XML as a string
		r_ResponseXML = invokeurl
		[
			url :v_Endpoint
			type :POST
			parameters:x_Params
			headers:m_Headers
		];
		info r_ResponseXML;
	}
}
  1.  void API.fn_eBayQuery_SetNotificationPreferences_AuthNAuth() 
  2.  { 
  3.      /* 
  4.      Function: fn_eBayQuery_SetNotificationPreferences_AuthNAuth() 
  5.      Purpose: Manage notification and alert preferences for a user or an application using Auth'n'Auth not Oauth 
  6.      Date Created:   2021-09-23 (Joellipman.com - Joel Lipman) 
  7.                      - Initial release 
  8.   
  9.      More Info: 
  10.      - API Explorer Test Tool: https://developer.ebay.com/DevZone/build-test/test-tool/default.aspx?index=0&env=production&api=trading 
  11.      - GetNotificationPreferences Documentation: https://developer.ebay.com/Devzone/XML/docs/Reference/eBay/GetNotificationPreferences.html 
  12.      - SetNotificationPreferences Documentation: https://developer.ebay.com/devzone/xml/docs/reference/ebay/SetNotificationPreferences.html 
  13.      - Event Types Documentation: https://developer.ebay.com/Devzone/XML/docs/Reference/eBay/extra/stntfctnprfrncs.rqst.evntprprty.evnttyp.html 
  14.      */ 
  15.      r_Api = API_Integration[Connection_Name == "eBay API (Production)"]
  16.      if(r_Api.count() > 0) 
  17.      { 
  18.          v_AccessToken = thisapp.API.fn_eBayConnect_AccessToken()
  19.          //info v_AccessToken; 
  20.          v_TradingAPIVersion = r_Api.API_Version; 
  21.          v_Endpoint = "https://api.ebay.com/ws/api.dll"
  22.          v_APICallName = "SetNotificationPreferences"
  23.          // 
  24.          // specify the URL of the CRM REST API Function here (can be a mailto:email@address) 
  25.          v_CrmRestFunction = "https://www.zohoapis.com/crm/v2/functions/fn_ebay_webhook_ordernotification/actions/execute?auth_type=apikey&zapikey=1003.aaaabbbbccccddddeeeeffff11112222.33334444555566667777888899990000"
  26.          // 
  27.          // build header 
  28.          m_Headers = Map()
  29.          m_Headers.put("X-EBAY-API-SITEID",3)
  30.          m_Headers.put("X-EBAY-API-CALL-NAME",v_APICallName)
  31.          m_Headers.put("X-EBAY-API-COMPATIBILITY-LEVEL",r_Api.API_Version)
  32.          m_Headers.put("X-EBAY-API-APP-NAME",r_Api.Client_ID)
  33.          m_Headers.put("X-EBAY-API-DEV-NAME",r_Api.Dev_ID)
  34.          m_Headers.put("X-EBAY-API-CERT-NAME",r_Api.Client_Secret)
  35.          // 
  36.          // build params 
  37.          m_Params = Map()
  38.          m_Params.put("WarningLevel","High")
  39.          m_Params.put("ErrorLanguage","en_GB")
  40.          m_AuthToken=Map()
  41.          m_AuthToken.put("eBayAuthToken",r_Api.AuthToken)
  42.          m_Params.put("RequesterCredentials",m_AuthToken)
  43.          m_AppDeliveryPrefs = Map()
  44.          m_AppDeliveryPrefs.put("AlertEmail","mailto:This email address is being protected from spambots. You need JavaScript enabled to view it.")
  45.          m_AppDeliveryPrefs.put("AlertEnable","Enable")
  46.          m_AppDeliveryPrefs.put("ApplicationEnable","Enable")
  47.          m_AppDeliveryPrefs.put("ApplicationURL",v_CrmRestFunction)
  48.          m_AppDeliveryPrefs.put("DeviceType","Platform")
  49.          m_DeliveryURL = Map()
  50.          m_DeliveryURL.put("DeliveryURL",v_CrmRestFunction)
  51.          m_DeliveryURL.put("DeliveryURLName","eBayToZoho")
  52.          m_AppDeliveryPrefs.put("DeliveryURLDetails",m_DeliveryURL)
  53.          m_Params.put("ApplicationDeliveryPreferences",m_AppDeliveryPrefs)
  54.          // include the User Delivery Preference Array 
  55.          l_UserDeliveryPreferenceArray = List()
  56.          m_EventPair = Map()
  57.          m_EventPair.put("EventType","FixedPriceTransaction")
  58.          m_EventPair.put("EventEnable","Enable")
  59.          l_UserDeliveryPreferenceArray.add(m_EventPair)
  60.          m_EventPair = Map()
  61.          m_EventPair.put("EventType","Feedback")
  62.          m_EventPair.put("EventEnable","Enable")
  63.          l_UserDeliveryPreferenceArray.add(m_EventPair)
  64.          m_NotificationEnable = Map()
  65.          m_NotificationEnable.put("NotificationEnable",l_UserDeliveryPreferenceArray)
  66.          m_Params.put("UserDeliveryPreferenceArray",m_NotificationEnable)
  67.          // 
  68.          // convert to xml and replace root nodes 
  69.          x_Params = m_Params.toXML()
  70.          x_Params = x_Params.toString().replaceFirst("<root>","<?xml version=\"1.0\" encoding=\"utf-8\"?><" + v_APICallName + "Request xmlns=\"urn:ebay:apis:eBLBaseComponents\">")
  71.          x_Params = x_Params.toString().replaceFirst("</root>","</" + v_APICallName + "Request>")
  72.          info x_Params; 
  73.          // 
  74.          // send the request XML as a string 
  75.          r_ResponseXML = invokeUrl 
  76.          [ 
  77.              url :v_Endpoint 
  78.              type :POST 
  79.              parameters:x_Params 
  80.              headers:m_Headers 
  81.          ]
  82.          info r_ResponseXML; 
  83.      } 
  84.  } 

Great! Now you should see notifications come in via your email (now comment this out in your CRM before it drives you insane) but also, and if setup correctly, sent through to your Creator app, all without having to speak to someone from eBay. Done!


Error(s) Encountered
  • 22112 - Missing property name or event type: Could have been many things. For me it was because I was submitting an EventType in the EventProperty container and the fix was not to include the EventProperty container at all.
  • Subscription was successful but still no notifications received: If you are using OAuth, you need to tell someone at eBay to enable the notification. Try using the Auth'n'Auth method.
  • Header "X-EBAY-API-APP-NAME" does not exist.: Using an Auth'n'auth instead of Oauth? You will need this in the HTTP Headers.
  • Header "X-EBAY-API-DEV-NAME" does not exist: Using an Auth'n'auth instead of Oauth? You will need this in the HTTP Headers.
  • Header "X-EBAY-API-CERT-NAME" does not exist.: Using an Auth'n'auth instead of Oauth? You will need this in the HTTP Headers.
  • No password and no token: No XML <RequestPassword> or <RequestToken> was found in XML Request.: Forgot to add the container RequesterCredentials in the request body.
  • Unsupported API Call: The API call "GeteBayOfficialTime" is invalid or not supported in this release.: Happened to me when making a GetSessionIDRequest for an Auth'n'auth process. I hadn't included the 3 main headers for auth'n'auth: app-name, dev-name, cert-name.

Source(s):
Category: Zoho :: Article: 770

Credit where Credit is Due:


Feel free to copy, redistribute and share this information. All that we ask is that you attribute credit and possibly even a link back to this website as it really helps in our search engine rankings.

Disclaimer: The information on this website is provided without warranty and any content is merely the opinion of the author. Please try to test in development environments prior to adapting them to your production environments. The articles are written in good faith and, at the time of print, are working examples used in a commercial setting.

Thank you for visiting and, as always, we hope this website was of some use to you!

Kind Regards,

Joel Lipman
www.joellipman.com

Related Articles

Joes Revolver Map

Accreditation

Badge - Certified Zoho Creator Associate
Badge - Certified Zoho Creator Associate

Donate & Support

If you like my content, and would like to support this sharing site, feel free to donate using a method below:

Paypal:
Donate to Joel Lipman via PayPal

Bitcoin:
Donate to Joel Lipman with Bitcoin - Valid till 8 May 2022 3QnhmaBX7LQSRsC9hh6Je9rGQKEGNQNfPb
© 2022 Joel Lipman .com. All Rights Reserved.