For Zoho Services only:


I'm actually part of something bigger at Ascent Business Solutions recognized as the top Zoho Premium Solutions Partner in the United Kingdom.

Ascent Business Solutions offer support for smaller technical fixes and projects for larger developments, such as migrating to a ZohoCRM.  A team rather than a one-man-band is always available to ensure seamless progress and address any concerns. You'll find our competitive support rates with flexible, no-expiration bundles at https://ascentbusiness.co.uk/zoho-services/uk-zoho-support.  For larger projects, talk to our experts and receive dedicated support from our hands-on project consultants at https://ascentbusiness.co.uk/zoho-services/zoho-crm-implementation.

The team I manage specializes in coding API integrations between Zoho and third-party finance/commerce suites such as Xero, Shopify, WooCommerce, and eBay; to name but a few.  Our passion lies in creating innovative solutions where others have fallen short as well as working with new businesses, new sectors, and new ideas.  Our success is measured by the growth and ROI we deliver for clients, such as transforming a garden shed hobby into a 250k monthly turnover operation or generating a +60% return in just three days after launch through online payments and a streamlined e-commerce solution, replacing a paper-based system.

If you're looking for a partner who can help you drive growth and success, we'd love to work with you.  You can reach out to us on 0121 392 8140 (UK) or info@ascentbusiness.co.uk.  You can also visit our website at https://ascentbusiness.co.uk.

Zoho Creator: Receive eBay Notification and Create Shopify Order

What?
This is an article documenting how to parse the notification from eBay and using it to create an order in Shopify.

Why?
Previously, we would receive an eBay notification and create an order record in Zoho Creator. We did the same for when Shopify would process an order. You can see my following articles for more information on these:
This time, the objective is to have an eBay notification be sent to Zoho CRM (can receive webhooks) which forwards it to Zoho Creator, which in turn generates an order in Shopify. This article is primarily for myself as I need to do this for some other clients and I just want to continuously refine and improve my code below.

How?
I'm going to show you the code first of how to parse the eBay Transaction data and then the code to create a Shopify Order:

Parse an eBay Transaction Notification (XML)
copyraw
x_ResponseBody = input.Payload.getJSON("body");
v_MainNodeName = "GetItemTransactionsResponse";
x_MainNode = x_ResponseBody.subString(x_ResponseBody.indexOf("<" + v_MainNodeName),x_ResponseBody.lastIndexOf(v_MainNodeName) + v_MainNodeName.length() + 1);
x_Item = x_MainNode.subString(x_MainNode.indexOf("<Item>"),x_MainNode.indexOf("</Item>") + 7);
x_Transaction = x_MainNode.subString(x_MainNode.indexOf("<Transaction>"),x_MainNode.indexOf("</Transaction>") + 14);
//
// item details
v_Item_ID = x_Item.executeXPath("/Item/ItemID/text()").replaceAll("[^0-9]","");
v_Item_ID = if(!isnull(v_Item_ID),v_Item_ID.toLong(),null);
v_Item_CategoryID = x_Item.executeXPath("/Item/PrimaryCategory/CategoryID/text()").replaceAll("[^0-9]","");
v_Item_Listing_Start = x_Item.executeXPath("/Item/ListingDetails/StartTime/text()");
v_Item_Listing_End = x_Item.executeXPath("/Item/ListingDetails/EndTime/text()");
v_Item_Selling_Price = x_Item.executeXPath("/Item/SellingStatus/CurrentPrice/text()");
v_Item_Selling_Currency = x_Item.executeXPath("/Item/SellingStatus/CurrentPrice/@currencyID").executeXPath("/currencyID/text()");
v_Item_Selling_Currency = ifnull(v_Item_Selling_Currency,"GBP");
v_Item_Selling_Quantity = x_Item.executeXPath("/Item/SellingStatus/QuantitySold/text()");
v_Item_Title = x_Item.executeXPath("/Item/Title/text()");
v_Item_SKU = x_Item.executeXPath("/Item/SKU/text()");
//
// transaction details
v_Transaction_ID = x_Transaction.executeXPath("/Transaction/TransactionID/text()").replaceAll("[^0-9]","");
v_Transaction_OrderID = x_Transaction.executeXPath("/Transaction/ExtendedOrderID/text()").replaceAll("[^0-9]","");
v_Transaction_OrderRef = x_Transaction.executeXPath("/Transaction/ExtendedOrderID/text()");
v_Transaction_OrderName = x_Transaction.executeXPath("/Transaction/Buyer/UserID/text()") + " " + zoho.currenttime.toString("dd-MMM-yyyy HH:mm");
v_Transaction_LineItem_ID = x_Transaction.executeXPath("/Transaction/OrderLineItemID/text()");
v_Transaction_Amount = x_Transaction.executeXPath("/Transaction/TransactionPrice/text()");
v_Transaction_Paid = x_Transaction.executeXPath("/Transaction/AmountPaid/text()");
v_Transaction_Currency = x_Transaction.executeXPath("/Transaction/AmountPaid/@currencyID").executeXPath("/currencyID/text()");
v_Transaction_Quantity = x_Transaction.executeXPath("/Transaction/QuantityPurchased/text()");
v_Transaction_Status = x_Transaction.executeXPath("/Transaction/Status/CompleteStatus/text()");
v_Transaction_Method = x_Transaction.executeXPath("/Transaction/Status/PaymentInstrument/text()");
v_Transaction_Adjustment = x_Transaction.executeXPath("/Transaction/ConvertedAdjustmentAmount/text()");
v_Transaction_DateCreated = x_Transaction.executeXPath("/Transaction/CreatedDate/text()");
v_Transaction_DateCreated = if(!isnull(v_Transaction_DateCreated),v_Transaction_DateCreated.getPrefix(".").replaceFirst("T"," ",true).toTime(),zoho.currenttime);
v_Transaction_DateModified = x_Transaction.executeXPath("/Transaction/Status/LastTimeModified/text()");
v_Transaction_DateModified = if(!isnull(v_Transaction_DateModified),v_Transaction_DateModified.getPrefix(".").replaceFirst("T"," ",true).toTime(),zoho.currenttime);
v_Transaction_DatePaid = x_Transaction.executeXPath("/Transaction/PaidTime/text()");
v_Transaction_DatePaid = if(!isnull(v_Transaction_DatePaid),v_Transaction_DatePaid.getPrefix(".").replaceFirst("T"," ",true).toTime(),zoho.currenttime);
//
// buyer details
v_Transaction_UserID = x_Transaction.executeXPath("/Transaction/Buyer/UserID/text()");
v_Transaction_FeedbackScore = x_Transaction.executeXPath("/Transaction/Buyer/FeedbackScore/text()");
v_Transaction_UserID = x_Transaction.executeXPath("/Transaction/Buyer/UserID/text()");
v_Transaction_Buyer_Email = x_Transaction.executeXPath("/Transaction/Buyer/Email/text()");
v_Transaction_Buyer_FName = x_Transaction.executeXPath("/Transaction/Buyer/UserFirstName/text()");
v_Transaction_Buyer_SName = x_Transaction.executeXPath("/Transaction/Buyer/UserLastName/text()");
v_Transaction_Buyer_StaticEmail = x_Transaction.executeXPath("/Transaction/Buyer/StaticAlias/text()");
v_Transaction_Buyer_MemberSince = x_Transaction.executeXPath("/Transaction/Buyer/RegistrationDate/text()");
v_Transaction_Buyer_MemberSince = if(!isnull(v_Transaction_Buyer_MemberSince),v_Transaction_Buyer_MemberSince.getPrefix(".").replaceFirst("T"," ",true).toTime(),zoho.currenttime);
//
// shipping details
x_Transaction_Shipping_Address = x_Transaction.executeXPath("/Transaction/Buyer/BuyerInfo/ShippingAddress");
v_Transaction_Shipping_Name = x_Transaction_Shipping_Address.executeXPath("/ShippingAddress/Name/text()");
v_Transaction_Shipping_Phone = x_Transaction_Shipping_Address.executeXPath("/ShippingAddress/Phone/text()");
v_Transaction_Shipping_Address_Street1 = x_Transaction_Shipping_Address.executeXPath("/ShippingAddress/Street1/text()");
v_Transaction_Shipping_Address_Street2 = x_Transaction_Shipping_Address.executeXPath("/ShippingAddress/Street2/text()");
v_Transaction_Shipping_Address_City = x_Transaction_Shipping_Address.executeXPath("/ShippingAddress/CityName/text()");
v_Transaction_Shipping_Address_State = x_Transaction_Shipping_Address.executeXPath("/ShippingAddress/StateOrProvince/text()");
v_Transaction_Shipping_Address_Country = x_Transaction_Shipping_Address.executeXPath("/ShippingAddress/CountryName/text()");
v_Transaction_Shipping_Address_Zip = x_Transaction_Shipping_Address.executeXPath("/ShippingAddress/PostalCode/text()");
v_Transaction_Shipping_Address_CountryCode = x_Transaction_Shipping_Address.executeXPath("/ShippingAddress/Country/text()");
v_Transaction_Shipping_Tax = x_Transaction.executeXPath("/Transaction/ShippingDetails/SalesTax/SalesTaxAmount/text()");
v_Transaction_Shipping_Service = x_Transaction.executeXPath("/Transaction/ShippingServiceSelected/ShippingService/text()");
v_Transaction_Shipping_ServiceCost = x_Transaction.executeXPath("/Transaction/ShippingServiceSelected/ShippingServiceCost/text()");
v_Transaction_Shipping_ServiceSelected = x_Transaction.executeXPath("/Transaction/ShippingServiceSelected/ShippingService/text()");
v_Transaction_Shipping_ExpectedDeliveryMin = x_Transaction.executeXPath("/Transaction/ShippingServiceSelected/ShippingPackageInfo/EstimatedDeliveryTimeMin/text()");
v_Transaction_Shipping_ExpectedDeliveryMax = x_Transaction.executeXPath("/Transaction/ShippingServiceSelected/ShippingPackageInfo/EstimatedDeliveryTimeMax/text()");
//
// payment details
v_Transaction_EbayPaymentStatus = x_Transaction.executeXPath("/Transaction/Status/eBayPaymentStatus/text()");
v_Transaction_PaymentStatus = x_Transaction.executeXPath("/Transaction/MonetaryDetails/Payments/Payment/PaymentStatus/text()");
v_Transaction_Status_Payment = x_Transaction.executeXPath("/Transaction/Status/eBayPaymentStatus/text()");
v_Transaction_Status_Checkout = x_Transaction.executeXPath("/Transaction/Status/CheckoutStatus/text()");
v_Transaction_Payments_Status = x_Transaction.executeXPath("/Transaction/MonetaryDetails/Payments/Payment/PaymentStatus/text()");
v_Transaction_Payments_ebayUser = x_Transaction.executeXPath("/Transaction/MonetaryDetails/Payments/Payment/Payer/text()");
v_Transaction_Payments_Amount = x_Transaction.executeXPath("/Transaction/MonetaryDetails/Payments/Payment/PaymentAmount/text()");
//
// multi-leg (International Deliveries)
v_Transaction_Shipping_Address_IsMultiLeg = x_Transaction.executeXPath("/Transaction/IsMultiLegShipping/text()");
if(v_Transaction_Shipping_Address_IsMultiLeg == "true")
{
    x_Transaction_ShipTo_Address = x_Transaction.executeXPath("/Transaction/MultiLegShippingDetails/SellerShipmentToLogisticsProvider/ShipToAddress");
    v_Transaction_Shipping_Name = x_Transaction_ShipTo_Address.executeXPath("/ShipToAddress/Name/text()");
    v_Transaction_ShipTo_Address_Street1 = x_Transaction_ShipTo_Address.executeXPath("/ShipToAddress/Street1/text()");
    v_Transaction_ShipTo_Address_Street2 = x_Transaction_ShipTo_Address.executeXPath("/ShipToAddress/Street2/text()");
    v_Transaction_ShipTo_Address_Street2 = if(v_Transaction_ShipTo_Address_Street2.contains("ebay"),v_Transaction_ShipTo_Address_Street2.getPrefix("ebay").trim(),v_Transaction_ShipTo_Address_Street2);
    v_Transaction_ShipTo_Address_City = x_Transaction_ShipTo_Address.executeXPath("/ShipToAddress/CityName/text()");
    v_Transaction_ShipTo_Address_State = x_Transaction_ShipTo_Address.executeXPath("/ShipToAddress/StateOrProvince/text()");
    v_Transaction_ShipTo_Address_Country = x_Transaction_ShipTo_Address.executeXPath("/ShipToAddress/CountryName/text()");
    v_Transaction_ShipTo_Address_Zip = x_Transaction_ShipTo_Address.executeXPath("/ShipToAddress/PostalCode/text()");
    //
    // domestic shipping free but international shipping has service cost and import charge (is it possible to add line in Shopify Order? Tax Lines?)
    v_Transaction_Shipping_ImportCharge = x_Transaction.executeXPath("/Transaction/ShippingServiceSelected/ImportCharge/text()");
    if(isNumber(v_Transaction_Shipping_ServiceCost) && isNumber(v_Transaction_Shipping_ImportCharge))
    {
        v_Transaction_Shipping_ServiceCost = v_Transaction_Shipping_ImportCharge.toDecimal() + v_Transaction_Shipping_ServiceCost.toDecimal();
    }
    //
    // client would like middleman reference in the address
    v_Transaction_ShipTo_Address_GSPRef = x_Transaction_ShipTo_Address.executeXPath("/ShipToAddress/ReferenceID/text()");
    if(v_Transaction_ShipTo_Address_GSPRef != "")
    {
        v_Transaction_ShipTo_Address_Street2 = "Ref# " + v_Transaction_ShipTo_Address_GSPRef;
    }
}
else
{
    v_Transaction_ShipTo_Address_Street1 = v_Transaction_Shipping_Address_Street1;
    v_Transaction_Shipping_Address_Street2 = if(v_Transaction_Shipping_Address_Street2.containsIgnoreCase(" eCP:"),v_Transaction_Shipping_Address_Street2.getPrefixIgnoreCase(" eCP:"),v_Transaction_Shipping_Address_Street2);
    v_Transaction_Shipping_Address_Street2 = if(v_Transaction_Shipping_Address_Street2.containsIgnoreCase("ebay"),v_Transaction_Shipping_Address_Street2.getPrefixIgnoreCase("ebay"),v_Transaction_Shipping_Address_Street2);
    v_Transaction_ShipTo_Address_Street2 = v_Transaction_Shipping_Address_Street2;
    v_Transaction_ShipTo_Address_City = v_Transaction_Shipping_Address_City;
    v_Transaction_ShipTo_Address_State = v_Transaction_Shipping_Address_State;
    v_Transaction_ShipTo_Address_Country = v_Transaction_Shipping_Address_Country;
    v_Transaction_ShipTo_Address_Zip = v_Transaction_Shipping_Address_Zip;
}
//
// transforms
v_Transaction_Buyer_Email = ifnull(v_Transaction_Buyer_Email,"").toLowerCase();
v_Transaction_Buyer_FName = ifnull(v_Transaction_Buyer_FName,"").proper();
v_Transaction_Buyer_SName = ifnull(v_Transaction_Buyer_SName,"").proper();
v_CreatorFinancialStatus = if(v_Transaction_PaymentStatus.containsIgnoreCase("Succeeded"),"paid",v_Transaction_PaymentStatus.toLowerCase());
v_Transaction_DateCreated = if(!isnull(v_Transaction_DateCreated),v_Transaction_DateCreated.getPrefix(".").replaceFirst("T"," ",true).toTime(),zoho.currenttime);
v_Transaction_DateModified = if(!isnull(v_Transaction_DateModified),v_Transaction_DateModified.getPrefix(".").replaceFirst("T"," ",true).toTime(),zoho.currenttime);
v_Transaction_DatePaid = if(!isnull(v_Transaction_DatePaid),v_Transaction_DatePaid.getPrefix(".").replaceFirst("T"," ",true).toTime(),zoho.currenttime);
v_CreatorFinancialStatus = if(v_Transaction_PaymentStatus.containsIgnoreCase("Succeeded"),"paid",v_Transaction_PaymentStatus.toLowerCase());
v_Transaction_Shipping_ExpectedDelivery = if(!isnull(v_Transaction_Shipping_ExpectedDeliveryMin),v_Transaction_Shipping_ExpectedDeliveryMin.getPrefix("T").toDate(),zoho.currentdate.addBusinessday(1));
v_Transaction_Shipping_ExpectedDelivery = v_Transaction_Shipping_ExpectedDelivery.toString("E, d MMM yyyy");
  1.  x_ResponseBody = input.Payload.getJSON("body")
  2.  v_MainNodeName = "GetItemTransactionsResponse"
  3.  x_MainNode = x_ResponseBody.subString(x_ResponseBody.indexOf("<" + v_MainNodeName),x_ResponseBody.lastIndexOf(v_MainNodeName) + v_MainNodeName.length() + 1)
  4.  x_Item = x_MainNode.subString(x_MainNode.indexOf("<Item>"),x_MainNode.indexOf("</Item>") + 7)
  5.  x_Transaction = x_MainNode.subString(x_MainNode.indexOf("<Transaction>"),x_MainNode.indexOf("</Transaction>") + 14)
  6.  // 
  7.  // item details 
  8.  v_Item_ID = x_Item.executeXPath("/Item/ItemID/text()").replaceAll("[^0-9]","")
  9.  v_Item_ID = if(!isnull(v_Item_ID),v_Item_ID.toLong(),null)
  10.  v_Item_CategoryID = x_Item.executeXPath("/Item/PrimaryCategory/CategoryID/text()").replaceAll("[^0-9]","")
  11.  v_Item_Listing_Start = x_Item.executeXPath("/Item/ListingDetails/StartTime/text()")
  12.  v_Item_Listing_End = x_Item.executeXPath("/Item/ListingDetails/EndTime/text()")
  13.  v_Item_Selling_Price = x_Item.executeXPath("/Item/SellingStatus/CurrentPrice/text()")
  14.  v_Item_Selling_Currency = x_Item.executeXPath("/Item/SellingStatus/CurrentPrice/@currencyID").executeXPath("/currencyID/text()")
  15.  v_Item_Selling_Currency = ifnull(v_Item_Selling_Currency,"GBP")
  16.  v_Item_Selling_Quantity = x_Item.executeXPath("/Item/SellingStatus/QuantitySold/text()")
  17.  v_Item_Title = x_Item.executeXPath("/Item/Title/text()")
  18.  v_Item_SKU = x_Item.executeXPath("/Item/SKU/text()")
  19.  // 
  20.  // transaction details 
  21.  v_Transaction_ID = x_Transaction.executeXPath("/Transaction/TransactionID/text()").replaceAll("[^0-9]","")
  22.  v_Transaction_OrderID = x_Transaction.executeXPath("/Transaction/ExtendedOrderID/text()").replaceAll("[^0-9]","")
  23.  v_Transaction_OrderRef = x_Transaction.executeXPath("/Transaction/ExtendedOrderID/text()")
  24.  v_Transaction_OrderName = x_Transaction.executeXPath("/Transaction/Buyer/UserID/text()") + " " + zoho.currenttime.toString("dd-MMM-yyyy HH:mm")
  25.  v_Transaction_LineItem_ID = x_Transaction.executeXPath("/Transaction/OrderLineItemID/text()")
  26.  v_Transaction_Amount = x_Transaction.executeXPath("/Transaction/TransactionPrice/text()")
  27.  v_Transaction_Paid = x_Transaction.executeXPath("/Transaction/AmountPaid/text()")
  28.  v_Transaction_Currency = x_Transaction.executeXPath("/Transaction/AmountPaid/@currencyID").executeXPath("/currencyID/text()")
  29.  v_Transaction_Quantity = x_Transaction.executeXPath("/Transaction/QuantityPurchased/text()")
  30.  v_Transaction_Status = x_Transaction.executeXPath("/Transaction/Status/CompleteStatus/text()")
  31.  v_Transaction_Method = x_Transaction.executeXPath("/Transaction/Status/PaymentInstrument/text()")
  32.  v_Transaction_Adjustment = x_Transaction.executeXPath("/Transaction/ConvertedAdjustmentAmount/text()")
  33.  v_Transaction_DateCreated = x_Transaction.executeXPath("/Transaction/CreatedDate/text()")
  34.  v_Transaction_DateCreated = if(!isnull(v_Transaction_DateCreated),v_Transaction_DateCreated.getPrefix(".").replaceFirst("T"," ",true).toTime(),zoho.currenttime)
  35.  v_Transaction_DateModified = x_Transaction.executeXPath("/Transaction/Status/LastTimeModified/text()")
  36.  v_Transaction_DateModified = if(!isnull(v_Transaction_DateModified),v_Transaction_DateModified.getPrefix(".").replaceFirst("T"," ",true).toTime(),zoho.currenttime)
  37.  v_Transaction_DatePaid = x_Transaction.executeXPath("/Transaction/PaidTime/text()")
  38.  v_Transaction_DatePaid = if(!isnull(v_Transaction_DatePaid),v_Transaction_DatePaid.getPrefix(".").replaceFirst("T"," ",true).toTime(),zoho.currenttime)
  39.  // 
  40.  // buyer details 
  41.  v_Transaction_UserID = x_Transaction.executeXPath("/Transaction/Buyer/UserID/text()")
  42.  v_Transaction_FeedbackScore = x_Transaction.executeXPath("/Transaction/Buyer/FeedbackScore/text()")
  43.  v_Transaction_UserID = x_Transaction.executeXPath("/Transaction/Buyer/UserID/text()")
  44.  v_Transaction_Buyer_Email = x_Transaction.executeXPath("/Transaction/Buyer/Email/text()")
  45.  v_Transaction_Buyer_FName = x_Transaction.executeXPath("/Transaction/Buyer/UserFirstName/text()")
  46.  v_Transaction_Buyer_SName = x_Transaction.executeXPath("/Transaction/Buyer/UserLastName/text()")
  47.  v_Transaction_Buyer_StaticEmail = x_Transaction.executeXPath("/Transaction/Buyer/StaticAlias/text()")
  48.  v_Transaction_Buyer_MemberSince = x_Transaction.executeXPath("/Transaction/Buyer/RegistrationDate/text()")
  49.  v_Transaction_Buyer_MemberSince = if(!isnull(v_Transaction_Buyer_MemberSince),v_Transaction_Buyer_MemberSince.getPrefix(".").replaceFirst("T"," ",true).toTime(),zoho.currenttime)
  50.  // 
  51.  // shipping details 
  52.  x_Transaction_Shipping_Address = x_Transaction.executeXPath("/Transaction/Buyer/BuyerInfo/ShippingAddress")
  53.  v_Transaction_Shipping_Name = x_Transaction_Shipping_Address.executeXPath("/ShippingAddress/Name/text()")
  54.  v_Transaction_Shipping_Phone = x_Transaction_Shipping_Address.executeXPath("/ShippingAddress/Phone/text()")
  55.  v_Transaction_Shipping_Address_Street1 = x_Transaction_Shipping_Address.executeXPath("/ShippingAddress/Street1/text()")
  56.  v_Transaction_Shipping_Address_Street2 = x_Transaction_Shipping_Address.executeXPath("/ShippingAddress/Street2/text()")
  57.  v_Transaction_Shipping_Address_City = x_Transaction_Shipping_Address.executeXPath("/ShippingAddress/CityName/text()")
  58.  v_Transaction_Shipping_Address_State = x_Transaction_Shipping_Address.executeXPath("/ShippingAddress/StateOrProvince/text()")
  59.  v_Transaction_Shipping_Address_Country = x_Transaction_Shipping_Address.executeXPath("/ShippingAddress/CountryName/text()")
  60.  v_Transaction_Shipping_Address_Zip = x_Transaction_Shipping_Address.executeXPath("/ShippingAddress/PostalCode/text()")
  61.  v_Transaction_Shipping_Address_CountryCode = x_Transaction_Shipping_Address.executeXPath("/ShippingAddress/Country/text()")
  62.  v_Transaction_Shipping_Tax = x_Transaction.executeXPath("/Transaction/ShippingDetails/SalesTax/SalesTaxAmount/text()")
  63.  v_Transaction_Shipping_Service = x_Transaction.executeXPath("/Transaction/ShippingServiceSelected/ShippingService/text()")
  64.  v_Transaction_Shipping_ServiceCost = x_Transaction.executeXPath("/Transaction/ShippingServiceSelected/ShippingServiceCost/text()")
  65.  v_Transaction_Shipping_ServiceSelected = x_Transaction.executeXPath("/Transaction/ShippingServiceSelected/ShippingService/text()")
  66.  v_Transaction_Shipping_ExpectedDeliveryMin = x_Transaction.executeXPath("/Transaction/ShippingServiceSelected/ShippingPackageInfo/EstimatedDeliveryTimeMin/text()")
  67.  v_Transaction_Shipping_ExpectedDeliveryMax = x_Transaction.executeXPath("/Transaction/ShippingServiceSelected/ShippingPackageInfo/EstimatedDeliveryTimeMax/text()")
  68.  // 
  69.  // payment details 
  70.  v_Transaction_EbayPaymentStatus = x_Transaction.executeXPath("/Transaction/Status/eBayPaymentStatus/text()")
  71.  v_Transaction_PaymentStatus = x_Transaction.executeXPath("/Transaction/MonetaryDetails/Payments/Payment/PaymentStatus/text()")
  72.  v_Transaction_Status_Payment = x_Transaction.executeXPath("/Transaction/Status/eBayPaymentStatus/text()")
  73.  v_Transaction_Status_Checkout = x_Transaction.executeXPath("/Transaction/Status/CheckoutStatus/text()")
  74.  v_Transaction_Payments_Status = x_Transaction.executeXPath("/Transaction/MonetaryDetails/Payments/Payment/PaymentStatus/text()")
  75.  v_Transaction_Payments_ebayUser = x_Transaction.executeXPath("/Transaction/MonetaryDetails/Payments/Payment/Payer/text()")
  76.  v_Transaction_Payments_Amount = x_Transaction.executeXPath("/Transaction/MonetaryDetails/Payments/Payment/PaymentAmount/text()")
  77.  // 
  78.  // multi-leg (International Deliveries) 
  79.  v_Transaction_Shipping_Address_IsMultiLeg = x_Transaction.executeXPath("/Transaction/IsMultiLegShipping/text()")
  80.  if(v_Transaction_Shipping_Address_IsMultiLeg == "true") 
  81.  { 
  82.      x_Transaction_ShipTo_Address = x_Transaction.executeXPath("/Transaction/MultiLegShippingDetails/SellerShipmentToLogisticsProvider/ShipToAddress")
  83.      v_Transaction_Shipping_Name = x_Transaction_ShipTo_Address.executeXPath("/ShipToAddress/Name/text()")
  84.      v_Transaction_ShipTo_Address_Street1 = x_Transaction_ShipTo_Address.executeXPath("/ShipToAddress/Street1/text()")
  85.      v_Transaction_ShipTo_Address_Street2 = x_Transaction_ShipTo_Address.executeXPath("/ShipToAddress/Street2/text()")
  86.      v_Transaction_ShipTo_Address_Street2 = if(v_Transaction_ShipTo_Address_Street2.contains("ebay"),v_Transaction_ShipTo_Address_Street2.getPrefix("ebay").trim(),v_Transaction_ShipTo_Address_Street2)
  87.      v_Transaction_ShipTo_Address_City = x_Transaction_ShipTo_Address.executeXPath("/ShipToAddress/CityName/text()")
  88.      v_Transaction_ShipTo_Address_State = x_Transaction_ShipTo_Address.executeXPath("/ShipToAddress/StateOrProvince/text()")
  89.      v_Transaction_ShipTo_Address_Country = x_Transaction_ShipTo_Address.executeXPath("/ShipToAddress/CountryName/text()")
  90.      v_Transaction_ShipTo_Address_Zip = x_Transaction_ShipTo_Address.executeXPath("/ShipToAddress/PostalCode/text()")
  91.      // 
  92.      // domestic shipping free but international shipping has service cost and import charge (is it possible to add line in Shopify Order? Tax Lines?) 
  93.      v_Transaction_Shipping_ImportCharge = x_Transaction.executeXPath("/Transaction/ShippingServiceSelected/ImportCharge/text()")
  94.      if(isNumber(v_Transaction_Shipping_ServiceCost) && isNumber(v_Transaction_Shipping_ImportCharge)) 
  95.      { 
  96.          v_Transaction_Shipping_ServiceCost = v_Transaction_Shipping_ImportCharge.toDecimal() + v_Transaction_Shipping_ServiceCost.toDecimal()
  97.      } 
  98.      // 
  99.      // client would like middleman reference in the address 
  100.      v_Transaction_ShipTo_Address_GSPRef = x_Transaction_ShipTo_Address.executeXPath("/ShipToAddress/ReferenceID/text()")
  101.      if(v_Transaction_ShipTo_Address_GSPRef != "") 
  102.      { 
  103.          v_Transaction_ShipTo_Address_Street2 = "Ref# " + v_Transaction_ShipTo_Address_GSPRef; 
  104.      } 
  105.  } 
  106.  else 
  107.  { 
  108.      v_Transaction_ShipTo_Address_Street1 = v_Transaction_Shipping_Address_Street1; 
  109.      v_Transaction_Shipping_Address_Street2 = if(v_Transaction_Shipping_Address_Street2.containsIgnoreCase(" eCP:"),v_Transaction_Shipping_Address_Street2.getPrefixIgnoreCase(" eCP:"),v_Transaction_Shipping_Address_Street2)
  110.      v_Transaction_Shipping_Address_Street2 = if(v_Transaction_Shipping_Address_Street2.containsIgnoreCase("ebay"),v_Transaction_Shipping_Address_Street2.getPrefixIgnoreCase("ebay"),v_Transaction_Shipping_Address_Street2)
  111.      v_Transaction_ShipTo_Address_Street2 = v_Transaction_Shipping_Address_Street2; 
  112.      v_Transaction_ShipTo_Address_City = v_Transaction_Shipping_Address_City; 
  113.      v_Transaction_ShipTo_Address_State = v_Transaction_Shipping_Address_State; 
  114.      v_Transaction_ShipTo_Address_Country = v_Transaction_Shipping_Address_Country; 
  115.      v_Transaction_ShipTo_Address_Zip = v_Transaction_Shipping_Address_Zip; 
  116.  } 
  117.  // 
  118.  // transforms 
  119.  v_Transaction_Buyer_Email = ifnull(v_Transaction_Buyer_Email,"").toLowerCase()
  120.  v_Transaction_Buyer_FName = ifnull(v_Transaction_Buyer_FName,"").proper()
  121.  v_Transaction_Buyer_SName = ifnull(v_Transaction_Buyer_SName,"").proper()
  122.  v_CreatorFinancialStatus = if(v_Transaction_PaymentStatus.containsIgnoreCase("Succeeded"),"paid",v_Transaction_PaymentStatus.toLowerCase())
  123.  v_Transaction_DateCreated = if(!isnull(v_Transaction_DateCreated),v_Transaction_DateCreated.getPrefix(".").replaceFirst("T"," ",true).toTime(),zoho.currenttime)
  124.  v_Transaction_DateModified = if(!isnull(v_Transaction_DateModified),v_Transaction_DateModified.getPrefix(".").replaceFirst("T"," ",true).toTime(),zoho.currenttime)
  125.  v_Transaction_DatePaid = if(!isnull(v_Transaction_DatePaid),v_Transaction_DatePaid.getPrefix(".").replaceFirst("T"," ",true).toTime(),zoho.currenttime)
  126.  v_CreatorFinancialStatus = if(v_Transaction_PaymentStatus.containsIgnoreCase("Succeeded"),"paid",v_Transaction_PaymentStatus.toLowerCase())
  127.  v_Transaction_Shipping_ExpectedDelivery = if(!isnull(v_Transaction_Shipping_ExpectedDeliveryMin),v_Transaction_Shipping_ExpectedDeliveryMin.getPrefix("T").toDate(),zoho.currentdate.addBusinessday(1))
  128.  v_Transaction_Shipping_ExpectedDelivery = v_Transaction_Shipping_ExpectedDelivery.toString("E, d MMM yyyy")

Create Shopify Order (JSON)
And here's my code so far for creating an order in Shopify. You will need to amend the connection details and also the value of your Shopify Product ID and Shopify Variant ID. This works so far but it's a little plain and I'm still addressing an issue that the inventory level isn't being automatically updated when an order is processed. I'm told this happens on fulfillment but we need it to remove it from Shopify as soon as the item is sold on eBay:
copyraw
// 
// *************************************
// shopify connection
// 
m_Header = Map();
m_Header.put("Content-Type","application/json");
//
// app specific
r_ShopifyAPI = API_Integration[Connection_Name == "Shopify API"];
v_ClientID = r_ShopifyAPI.Client_ID;
v_ClientSecret = r_ShopifyAPI.Client_Secret;
v_ShopID = r_ShopifyAPI.Shop_ID;
v_ShopifyApiVersion = r_ShopifyAPI.API_Version;
v_ShopifyURL = "https://" + v_ClientID + ":" + v_ClientSecret + "@" + v_ShopID;
v_ShopifyLocationID = r_ShopifyAPI.Location_ID;
v_ShopifyLocationCountryCode = r_ShopifyAPI.Location_Code_Origin;
//
// set these to the Shopify Product ID and Shopify Variant ID
v_ShopifyProductID = 0;
v_ShopifyVariantID = 0;
// 
// I have a Creator table/form called Portal Listing storing both the SKU, ebay Item #, Shopify Product ID, Shopify Variant ID, and Shopify Inventory ID 
// double-check these are stored as 64-bit signed integers having a possible length of 19 digits. 
// determine Shopify product ID by SKU 
r_Listing = Portal_Listing[Product_SKU.equalsIgnoreCase(v_Item_SKU)];
if(r_Listing.count() > 0)
{
	v_ShopifyProductID = ifnull(r_Listing.Shopify_Product_ID,0).toLong();
	v_ShopifyVariantID = ifnull(r_Listing.Shopify_Product_Variant_ID,0).toLong();
}
// 
// initialize Shopify Order JSON
m_CreateShopifyOrder = Map();
m_CreateShopifyOrder.put("fulfillable_quantity",v_Transaction_Quantity.toLong());
m_CreateShopifyOrder.put("financial_status","paid");
m_CreateShopifyOrder.put("currency","GBP");
m_CreateShopifyOrder.put("fulfillment_status",null);
m_CreateShopifyOrder.put("send_receipt",false);
m_CreateShopifyOrder.put("send_fulfillment_receipt",false);
m_CreateShopifyOrder.put("inventory_behaviour","decrement_ignoring_policy");
m_CreateShopifyOrder.put("tags","eBay, Zoho");
m_CreateShopifyOrder.put("gateway","manual");
//
// customer
m_Customer = Map();
m_Customer.put("email",v_Transaction_Buyer_Email);
m_Customer.put("first_name",v_Transaction_Buyer_FName);
m_Customer.put("last_name",v_Transaction_Buyer_SName);
m_Customer.put("note","ebay User: " + v_Transaction_UserID + " (" + v_Transaction_FeedbackScore + ") Since " + v_Transaction_Buyer_MemberSince.toString("MMM-yyyy"));
m_CreateShopifyOrder.put("customer",m_Customer);
//
// billing address
v_BillingName = trim(v_Transaction_Buyer_FName + " " + v_Transaction_Buyer_SName);
m_BillingAddress = Map();
m_BillingAddress.put("first_name",v_Transaction_Buyer_FName);
m_BillingAddress.put("last_name",v_Transaction_Buyer_SName);
m_BillingAddress.put("address1",v_Transaction_Shipping_Address_Street1);
m_BillingAddress.put("address2",v_Transaction_Shipping_Address_Street2);
m_BillingAddress.put("city",v_Transaction_Shipping_Address_City);
m_BillingAddress.put("zip",v_Transaction_Shipping_Address_Zip);
m_BillingAddress.put("province",v_Transaction_Shipping_Address_State);
m_BillingAddress.put("country",v_Transaction_Shipping_Address_Country);
m_CreateShopifyOrder.put("billing_address",m_BillingAddress);
//
// shipping address
v_ShippingName = trim(v_Transaction_Buyer_FName + " " + v_Transaction_Buyer_SName);
m_ShippingAddress = Map();
m_ShippingAddress.put("name",v_Transaction_Shipping_Name);
m_ShippingAddress.put("phone",v_Transaction_Shipping_Phone);
m_ShippingAddress.put("address1",v_Transaction_ShipTo_Address_Street1);
m_ShippingAddress.put("address2",v_Transaction_ShipTo_Address_Street2);
m_ShippingAddress.put("city",v_Transaction_ShipTo_Address_City);
m_ShippingAddress.put("zip",v_Transaction_ShipTo_Address_Zip);
m_ShippingAddress.put("province",v_Transaction_ShipTo_Address_State);
m_ShippingAddress.put("country",v_Transaction_ShipTo_Address_Country);
m_CreateShopifyOrder.put("shipping_address",m_ShippingAddress);
//
// shipping line
l_ShippingLines = List();
m_ShippingLine = Map();
m_ShippingLine.put("price",ifnull(v_Transaction_Shipping_ServiceCost,0));
m_ShippingLine.put("source","eBay");
m_ShippingLine.put("code",v_Transaction_Shipping_ServiceSelected);
m_ShippingLine.put("title",v_Transaction_Shipping_ServiceSelected);
l_ShippingLines.add(m_ShippingLine);
m_CreateShopifyOrder.put("shipping_lines",l_ShippingLines);
//
// line items
l_LineItems = List();
m_LineItem = Map();
m_LineItem.put("name",v_Item_Title);
m_LineItem.put("title",v_Item_Title);
//m_LineItem.put("variant_title",v_Item_Title);
m_LineItem.put("price",v_Item_Selling_Price.toDecimal());
m_LineItem.put("sku",v_Item_SKU);
m_LineItem.put("product_id",v_ShopifyProductID);
m_LineItem.put("variant_id",v_ShopifyVariantID);
m_LineItem.put("quantity",v_Transaction_Quantity.toLong());
l_TaxLines = List();
m_TaxLine = Map();
m_TaxLine.put("rate",0);
m_TaxLine.put("price",0);
m_TaxLine.put("title","No VAT");
l_TaxLines.add(m_TaxLine);
m_LineItem.put("tax_lines",l_TaxLines);
l_LineItems.add(m_LineItem);
m_CreateShopifyOrder.put("line_items",l_LineItems);
//
// transactions
l_Transactions = List();
m_Transaction = Map();
m_Transaction.put("kind","sale");
m_Transaction.put("status","success");
m_Transaction.put("gateway","manual");
m_Transaction.put("amount",v_Transaction_Paid);
m_Transaction.put("currency",v_Transaction_Currency);
l_Transactions.add(m_Transaction);
m_CreateShopifyOrder.put("transactions",l_Transactions);
//
// note attributes
l_NoteAttributes = List();
m_NoteAttribute = Map();
m_NoteAttribute.put("name","Source");
m_NoteAttribute.put("value","Zoho Creator");
l_NoteAttributes.add(m_NoteAttribute);
m_NoteAttribute = Map();
m_NoteAttribute.put("name","eBay Order ID");
m_NoteAttribute.put("value",v_Transaction_OrderRef);
l_NoteAttributes.add(m_NoteAttribute);
m_NoteAttribute = Map();
m_NoteAttribute.put("name","eBay Item #");
m_NoteAttribute.put("value",v_Item_ID);
l_NoteAttributes.add(m_NoteAttribute);
m_NoteAttribute = Map();
m_NoteAttribute.put("name","eBay Deliver By Date");
m_NoteAttribute.put("value",v_Transaction_Shipping_ExpectedDelivery);
l_NoteAttributes.add(m_NoteAttribute);
m_CreateShopifyOrder.put("note_attributes",l_NoteAttributes);
//
// package for request to Shopify
m_ShopifyParams = Map();
//
// check if already exists
v_ShopifyOrderID = 0;
l_eBayOrders = Portal_Listing[eBay_Order_ID == v_Transaction_OrderRef];
if(l_eBayOrders.count() > 0)
{
    for each  r_eBayOrder in l_eBayOrders
    {
        if(!isnull(r_eBayOrder.Shopify_Order_ID))
        {
            v_ShopifyOrderID = r_eBayOrder.Shopify_Order_ID.toLong();
        }
    }
}
// if not 0 then update the Shopify Order ID
b_ShopifyOrderSuccessful = true;
v_ShopifyMode = "created";
if(v_ShopifyOrderID != 0)
{
    m_CreateShopifyOrder.put("id",v_ShopifyOrderID);
    m_ShopifyParams.put("order",m_CreateShopifyOrder);
    v_Endpoint = v_ShopifyURL + "/admin/api/" + v_ShopifyApiVersion.toString() + "/orders/" + v_ShopifyOrderID + ".json";
    r_CreateOrder = invokeurl
    [
        url :v_Endpoint
        type :PUT
        parameters:m_ShopifyParams.toString()
        headers:m_Header
    ];
    if(r_CreateOrder.get("order") != null)
    {
        if(!isnull(r_CreateOrder.get("order").get("id")))
        {
            v_ShopifyOrderID = r_CreateOrder.get("order").get("id");
            b_ShopifyOrderSuccessful = true;
            v_ShopifyMode = "updated";
        }
    }
}
// else then create the Shopify Order
else
{
    m_ShopifyParams.put("order",m_CreateShopifyOrder);
    v_Endpoint = v_ShopifyURL + "/admin/api/" + v_ShopifyApiVersion.toString() + "/orders.json";
    r_CreateOrder = invokeurl
    [
        url :v_Endpoint
        type :POST
        parameters:m_ShopifyParams.toString()
        headers:m_Header
    ];
    if(!isnull(r_CreateOrder.get("order")) != null)
    {
        if(!isnull(r_CreateOrder.get("order").get("id")))
        {
            v_ShopifyOrderID = r_CreateOrder.get("order").get("id");
            b_ShopifyOrderSuccessful = true;
        }
    }
}
info r_CreateOrder;
  1.  // 
  2.  // ************************************* 
  3.  // shopify connection 
  4.  // 
  5.  m_Header = Map()
  6.  m_Header.put("Content-Type","application/json")
  7.  // 
  8.  // app specific 
  9.  r_ShopifyAPI = API_Integration[Connection_Name == "Shopify API"]
  10.  v_ClientID = r_ShopifyAPI.Client_ID; 
  11.  v_ClientSecret = r_ShopifyAPI.Client_Secret; 
  12.  v_ShopID = r_ShopifyAPI.Shop_ID; 
  13.  v_ShopifyApiVersion = r_ShopifyAPI.API_Version; 
  14.  v_ShopifyURL = "https://" + v_ClientID + ":" + v_ClientSecret + "@" + v_ShopID; 
  15.  v_ShopifyLocationID = r_ShopifyAPI.Location_ID; 
  16.  v_ShopifyLocationCountryCode = r_ShopifyAPI.Location_Code_Origin; 
  17.  // 
  18.  // set these to the Shopify Product ID and Shopify Variant ID 
  19.  v_ShopifyProductID = 0
  20.  v_ShopifyVariantID = 0
  21.  // 
  22.  // I have a Creator table/form called Portal Listing storing both the SKU, ebay Item #, Shopify Product ID, Shopify Variant ID, and Shopify Inventory ID 
  23.  // double-check these are stored as 64-bit signed integers having a possible length of 19 digits. 
  24.  // determine Shopify product ID by SKU 
  25.  r_Listing = Portal_Listing[Product_SKU.equalsIgnoreCase(v_Item_SKU)]
  26.  if(r_Listing.count() > 0) 
  27.  { 
  28.      v_ShopifyProductID = ifnull(r_Listing.Shopify_Product_ID,0).toLong()
  29.      v_ShopifyVariantID = ifnull(r_Listing.Shopify_Product_Variant_ID,0).toLong()
  30.  } 
  31.  // 
  32.  // initialize Shopify Order JSON 
  33.  m_CreateShopifyOrder = Map()
  34.  m_CreateShopifyOrder.put("fulfillable_quantity",v_Transaction_Quantity.toLong())
  35.  m_CreateShopifyOrder.put("financial_status","paid")
  36.  m_CreateShopifyOrder.put("currency","GBP")
  37.  m_CreateShopifyOrder.put("fulfillment_status",null)
  38.  m_CreateShopifyOrder.put("send_receipt",false)
  39.  m_CreateShopifyOrder.put("send_fulfillment_receipt",false)
  40.  m_CreateShopifyOrder.put("inventory_behaviour","decrement_ignoring_policy")
  41.  m_CreateShopifyOrder.put("tags","eBay, Zoho")
  42.  m_CreateShopifyOrder.put("gateway","manual")
  43.  // 
  44.  // customer 
  45.  m_Customer = Map()
  46.  m_Customer.put("email",v_Transaction_Buyer_Email)
  47.  m_Customer.put("first_name",v_Transaction_Buyer_FName)
  48.  m_Customer.put("last_name",v_Transaction_Buyer_SName)
  49.  m_Customer.put("note","ebay User: " + v_Transaction_UserID + (" + v_Transaction_FeedbackScore + ") Since " + v_Transaction_Buyer_MemberSince.toString("MMM-yyyy"))
  50.  m_CreateShopifyOrder.put("customer",m_Customer)
  51.  // 
  52.  // billing address 
  53.  v_BillingName = trim(v_Transaction_Buyer_FName + " " + v_Transaction_Buyer_SName)
  54.  m_BillingAddress = Map()
  55.  m_BillingAddress.put("first_name",v_Transaction_Buyer_FName)
  56.  m_BillingAddress.put("last_name",v_Transaction_Buyer_SName)
  57.  m_BillingAddress.put("address1",v_Transaction_Shipping_Address_Street1)
  58.  m_BillingAddress.put("address2",v_Transaction_Shipping_Address_Street2)
  59.  m_BillingAddress.put("city",v_Transaction_Shipping_Address_City)
  60.  m_BillingAddress.put("zip",v_Transaction_Shipping_Address_Zip)
  61.  m_BillingAddress.put("province",v_Transaction_Shipping_Address_State)
  62.  m_BillingAddress.put("country",v_Transaction_Shipping_Address_Country)
  63.  m_CreateShopifyOrder.put("billing_address",m_BillingAddress)
  64.  // 
  65.  // shipping address 
  66.  v_ShippingName = trim(v_Transaction_Buyer_FName + " " + v_Transaction_Buyer_SName)
  67.  m_ShippingAddress = Map()
  68.  m_ShippingAddress.put("name",v_Transaction_Shipping_Name)
  69.  m_ShippingAddress.put("phone",v_Transaction_Shipping_Phone)
  70.  m_ShippingAddress.put("address1",v_Transaction_ShipTo_Address_Street1)
  71.  m_ShippingAddress.put("address2",v_Transaction_ShipTo_Address_Street2)
  72.  m_ShippingAddress.put("city",v_Transaction_ShipTo_Address_City)
  73.  m_ShippingAddress.put("zip",v_Transaction_ShipTo_Address_Zip)
  74.  m_ShippingAddress.put("province",v_Transaction_ShipTo_Address_State)
  75.  m_ShippingAddress.put("country",v_Transaction_ShipTo_Address_Country)
  76.  m_CreateShopifyOrder.put("shipping_address",m_ShippingAddress)
  77.  // 
  78.  // shipping line 
  79.  l_ShippingLines = List()
  80.  m_ShippingLine = Map()
  81.  m_ShippingLine.put("price",ifnull(v_Transaction_Shipping_ServiceCost,0))
  82.  m_ShippingLine.put("source","eBay")
  83.  m_ShippingLine.put("code",v_Transaction_Shipping_ServiceSelected)
  84.  m_ShippingLine.put("title",v_Transaction_Shipping_ServiceSelected)
  85.  l_ShippingLines.add(m_ShippingLine)
  86.  m_CreateShopifyOrder.put("shipping_lines",l_ShippingLines)
  87.  // 
  88.  // line items 
  89.  l_LineItems = List()
  90.  m_LineItem = Map()
  91.  m_LineItem.put("name",v_Item_Title)
  92.  m_LineItem.put("title",v_Item_Title)
  93.  //m_LineItem.put("variant_title",v_Item_Title)
  94.  m_LineItem.put("price",v_Item_Selling_Price.toDecimal())
  95.  m_LineItem.put("sku",v_Item_SKU)
  96.  m_LineItem.put("product_id",v_ShopifyProductID)
  97.  m_LineItem.put("variant_id",v_ShopifyVariantID)
  98.  m_LineItem.put("quantity",v_Transaction_Quantity.toLong())
  99.  l_TaxLines = List()
  100.  m_TaxLine = Map()
  101.  m_TaxLine.put("rate",0)
  102.  m_TaxLine.put("price",0)
  103.  m_TaxLine.put("title","No VAT")
  104.  l_TaxLines.add(m_TaxLine)
  105.  m_LineItem.put("tax_lines",l_TaxLines)
  106.  l_LineItems.add(m_LineItem)
  107.  m_CreateShopifyOrder.put("line_items",l_LineItems)
  108.  // 
  109.  // transactions 
  110.  l_Transactions = List()
  111.  m_Transaction = Map()
  112.  m_Transaction.put("kind","sale")
  113.  m_Transaction.put("status","success")
  114.  m_Transaction.put("gateway","manual")
  115.  m_Transaction.put("amount",v_Transaction_Paid)
  116.  m_Transaction.put("currency",v_Transaction_Currency)
  117.  l_Transactions.add(m_Transaction)
  118.  m_CreateShopifyOrder.put("transactions",l_Transactions)
  119.  // 
  120.  // note attributes 
  121.  l_NoteAttributes = List()
  122.  m_NoteAttribute = Map()
  123.  m_NoteAttribute.put("name","Source")
  124.  m_NoteAttribute.put("value","Zoho Creator")
  125.  l_NoteAttributes.add(m_NoteAttribute)
  126.  m_NoteAttribute = Map()
  127.  m_NoteAttribute.put("name","eBay Order ID")
  128.  m_NoteAttribute.put("value",v_Transaction_OrderRef)
  129.  l_NoteAttributes.add(m_NoteAttribute)
  130.  m_NoteAttribute = Map()
  131.  m_NoteAttribute.put("name","eBay Item #")
  132.  m_NoteAttribute.put("value",v_Item_ID)
  133.  l_NoteAttributes.add(m_NoteAttribute)
  134.  m_NoteAttribute = Map()
  135.  m_NoteAttribute.put("name","eBay Deliver By Date")
  136.  m_NoteAttribute.put("value",v_Transaction_Shipping_ExpectedDelivery)
  137.  l_NoteAttributes.add(m_NoteAttribute)
  138.  m_CreateShopifyOrder.put("note_attributes",l_NoteAttributes)
  139.  // 
  140.  // package for request to Shopify 
  141.  m_ShopifyParams = Map()
  142.  // 
  143.  // check if already exists 
  144.  v_ShopifyOrderID = 0
  145.  l_eBayOrders = Portal_Listing[eBay_Order_ID == v_Transaction_OrderRef]
  146.  if(l_eBayOrders.count() > 0) 
  147.  { 
  148.      for each  r_eBayOrder in l_eBayOrders 
  149.      { 
  150.          if(!isnull(r_eBayOrder.Shopify_Order_ID)) 
  151.          { 
  152.              v_ShopifyOrderID = r_eBayOrder.Shopify_Order_ID.toLong()
  153.          } 
  154.      } 
  155.  } 
  156.  // if not 0 then update the Shopify Order ID 
  157.  b_ShopifyOrderSuccessful = true
  158.  v_ShopifyMode = "created"
  159.  if(v_ShopifyOrderID != 0) 
  160.  { 
  161.      m_CreateShopifyOrder.put("id",v_ShopifyOrderID)
  162.      m_ShopifyParams.put("order",m_CreateShopifyOrder)
  163.      v_Endpoint = v_ShopifyURL + "/admin/api/" + v_ShopifyApiVersion.toString() + "/orders/" + v_ShopifyOrderID + ".json"
  164.      r_CreateOrder = invokeUrl 
  165.      [ 
  166.          url :v_Endpoint 
  167.          type :PUT 
  168.          parameters:m_ShopifyParams.toString() 
  169.          headers:m_Header 
  170.      ]
  171.      if(r_CreateOrder.get("order") != null) 
  172.      { 
  173.          if(!isnull(r_CreateOrder.get("order").get("id"))) 
  174.          { 
  175.              v_ShopifyOrderID = r_CreateOrder.get("order").get("id")
  176.              b_ShopifyOrderSuccessful = true
  177.              v_ShopifyMode = "updated"
  178.          } 
  179.      } 
  180.  } 
  181.  // else then create the Shopify Order 
  182.  else 
  183.  { 
  184.      m_ShopifyParams.put("order",m_CreateShopifyOrder)
  185.      v_Endpoint = v_ShopifyURL + "/admin/api/" + v_ShopifyApiVersion.toString() + "/orders.json"
  186.      r_CreateOrder = invokeUrl 
  187.      [ 
  188.          url :v_Endpoint 
  189.          type :POST 
  190.          parameters:m_ShopifyParams.toString() 
  191.          headers:m_Header 
  192.      ]
  193.      if(!isnull(r_CreateOrder.get("order")) != null) 
  194.      { 
  195.          if(!isnull(r_CreateOrder.get("order").get("id"))) 
  196.          { 
  197.              v_ShopifyOrderID = r_CreateOrder.get("order").get("id")
  198.              b_ShopifyOrderSuccessful = true
  199.          } 
  200.      } 
  201.  } 
  202.  info r_CreateOrder; 

Additional Note(s):
  • ShipTo: Note my variables of Ship To address as opposed to Shipping Address. If the customer was in the UK, the ShipTo address is the same as the eBay Shipping address. If it is an international order, then my client is using a middleman in the UK who then ships it to the overseas destination and so the ShipTo address would be the middleman's address.
  • eBay GetItemTransactions vs eBay GetOrderTransactions I'm using GetItemTransactions as these are line item orders. As eBay supports baskets now, I will use and add GetOrderTransactions if there is any information I couldn't get from the line item.

GetItemTransaction
I also changed the code above our first snippet (parsing the eBay transaction) to run a function which gets the line item order from eBay:
copyraw
string API.fn_eBayQuery_GetItemTransaction(int p_ItemID)
{
	/*
    Function: fn_eBayQuery_GetItemTransaction()
    Input: int p_ItemID (ebay number of the item)
    Purpose: Fetches a line item transaction per item ID
    Date Created:   2022-01-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
    - 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_ResponseXML = "";
	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;
	}
	return r_ResponseXML;
}
  1.  string API.fn_eBayQuery_GetItemTransaction(int p_ItemID) 
  2.  { 
  3.      /* 
  4.      Function: fn_eBayQuery_GetItemTransaction() 
  5.      Input: int p_ItemID (ebay number of the item) 
  6.      Purpose: Fetches a line item transaction per item ID 
  7.      Date Created:   2022-01-22 (Joellipman.com - 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_ResponseXML = ""
  20.      r_Api = API_Integration[Connection_Name == "eBay API (Production)"]
  21.      if(r_Api.count() > 0) 
  22.      { 
  23.          v_AccessToken = thisapp.API.fn_eBayConnect_AccessToken()
  24.          v_TradingAPIVersion = r_Api.API_Version; 
  25.          v_Endpoint = "https://api.ebay.com/ws/api.dll"
  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.          v_ApiCall = "GetItemTransactions"
  32.          m_Headers.put("X-EBAY-API-CALL-NAME",v_ApiCall)
  33.          m_Headers.put("X-EBAY-API-IAF-TOKEN",v_AccessToken)
  34.          // 
  35.          // build params 
  36.          m_Params = Map()
  37.          m_Params.put("WarningLevel","High")
  38.          m_Params.put("ErrorLanguage","en_GB")
  39.          m_Params.put("DetailLevel","ItemReturnCategories")
  40.          // 
  41.          // include fixed price items 
  42.          m_Pagination = Map()
  43.          m_Pagination.put("PageNumber",v_Page)
  44.          m_Pagination.put("EntriesPerPage",v_PerPage)
  45.          m_Params.put("Pagination",m_Pagination)
  46.          //m_ActiveList.put("Sort","ItemID")
  47.          m_Params.put("ItemID",p_ItemID)
  48.          // 
  49.          // convert to xml and replace root nodes 
  50.          x_Params = m_Params.toXML()
  51.          x_Params = x_Params.toString().replaceFirst("<root>","<?xml version=\"1.0\" encoding=\"utf-8\"?><" + v_ApiCall + "Request xmlns=\"urn:ebay:apis:eBLBaseComponents\">")
  52.          x_Params = x_Params.toString().replaceFirst("</root>","</" + v_ApiCall + "Request>")
  53.          // 
  54.          // send the request XML as a string 
  55.          r_ResponseXML = invokeUrl 
  56.          [ 
  57.              url :v_Endpoint 
  58.              type :POST 
  59.              parameters:x_Params 
  60.              headers:m_Headers 
  61.          ]
  62.          // 
  63.          // output response 
  64.          info r_ResponseXML; 
  65.      } 
  66.      return r_ResponseXML; 
  67.  } 

Usage:
copyraw
// expects eBay Item number
x_ResponseBody = thisapp.API.fn_eBayQuery_GetItemTransaction(p_ItemID);
  1.  // expects eBay Item number 
  2.  x_ResponseBody = thisapp.API.fn_eBayQuery_GetItemTransaction(p_ItemID)

Source(s) / Issue(s):
  • Bad Request: This could be a number of things. The obvious one that eluded me for ages however was that when sending the request, I had forgotten to put .toString() to send the JSON. I think the response is mostly due to invalid JSON being sent as a request.
  • Product doesn't display photo and is not clickable in Shopify Order: Product ID and Variant ID aren't being correctly populated in the Shopify Order Line Item. The line item order gets created but there was no link to an existing Variant ID. Check that both Creator fields storing these allow 19 digits (64-bit signed integers). I had an inventory field in the process that was limited to 10 digits causing the wrong variant ID to be submitted in the order.
  • Paid by Customer is 0.00: Check transactions is being submitted with kind as "sale" instead of "authorization". There will be an event on the timeline saying something like: "myApp manually marked this order as paid".
  • Third-Party Courier ID: (reference ID for when a delivery by third-party is made to update the Shopify order). - to be tested.
  • Inventory does NOT get updated: inventory_behaviour is defaulted to "bypass". Consider sending this as "decrement_ignoring_policy".
  • Enhance Timeline Entry eg. "My App (with icon) manually marked this order as paid": - I think app has to be a registered app and not a private app

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

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: Please note that the information provided on this website is intended for informational purposes only and does not represent a warranty. The opinions expressed are those of the author only. We recommend testing any solutions in a development environment before implementing them in production. The articles are based on our good faith efforts and were current at the time of writing, reflecting our practical experience 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 bc1qf6elrdxc968h0k673l2djc9wrpazhqtxw8qqp4

Ethereum:
Donate to Joel Lipman with Ethereum 0xb038962F3809b425D661EF5D22294Cf45E02FebF
© 2024 Joel Lipman .com. All Rights Reserved.