Skip to main content

Order Registration (Visual Customizer)

Summary

  1. Overview

  2. Register an Order

  3. API REST Call to Obtain Print-Ready Files

  4. Reorder

1. Overview

The Visual Product Customizer generates print-ready files in various formats, provided to the merchant in the "Orders" section of the back-office along with a summary containing purchase information crucial for order fulfillment (learn more here).

These files are generated only when an order, initially received on the e-commerce platform, is subsequently registered on Zakeke. This Zakeke order, sharing the same order number as its e-commerce counterpart, serves as an addition rather than a replacement. It specifically pertains to the customization aspect of the order.

To integrate this workflow effectively, leverage the following API calls:

  • API REST Call to Register an Order:

    Initiate an API REST call to seamlessly register the order on Zakeke after its reception on the e-commerce platform. This step ensures that the Visual Product Customizer generates the necessary print-ready files.

  • API REST Call to Obtain Print-Ready Files:

    Subsequently, utilize another API REST call to obtain a ZIP file containing the print material for each design created. This step is essential for successful order fulfillment.

  • API REST Call for Reorder Information:

    Additionally, leverage an API REST call to retrieve information for a reorder. This functionality streamlines the process, providing access to details related to previous orders and enhancing the efficiency of reorder transactions.

By incorporating these API calls, you ensure that you have the necessary tools to efficiently manage and fulfill orders with personalized products through Zakeke.

2. Register an Order

After processing the order in your e-commerce website, if there are custom products you will need to make an S2S (Server2Server) request POST authenticated at the following endpoint:

https://api.zakeke.com/v1/order

Please refer to the documentation on the ORDER API endpoint on the data to be sent in the request and the returned response.

Example in ASP.NET MVC C# In the example below, the ZakekeCheckoutOrder function should be called up in the Checkout controller (thankyoupage controller of the site):

using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using RestSharp;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Configuration;

// order: order to ckeckout
// userCode: logged user identifier who is ordering on your e-commerce
// sessionID: session ID
public JObject ZakekeCheckoutOrder(OrderEntity order, string userCode,string sessionID)
{
JObject responseJson = null;
// Get Authorization Oauth Token S2S with userCode
string token = getOauthToken(userCode);
if (!string.IsNullOrEmpty(token))
{
// Build body request for ORDER endpoint
var dataToSend = new
{
orderCode = order.ID,
orderDate = order.date,
sessionID = sessionID,
total = order.totalAmount,
details = order.details.Select(detail => new
{
designID = detail.designID,
designUnitPrice = detail.designUnitaryPrice,
modelUnitPrice = detail.productUnitaryPrce,
quantity = detail.Quantita
})
};
// Make request to Order Endpoint API
var urlRequest = "https://api.zakeke.com/v1/order";
var client = new RestClient(urlRequest);
var request = new RestRequest() { Method = Method.POST };
request.AddHeader("Authorization", "Bearer " + token);
request.AddParameter("application/json; charset=utf-8",JsonConvert.SerializeObject(dataToSend), ParameterType.RequestBody);
try
{
var response = client.Execute(request);
if (response != null && response.StatusCode == System.Net.HttpStatusCode.OK)
{
responseJson = JsonConvert.DeserializeObject<JObject>(response.Content);
}
else
{
// Log error that caused request to fail ...
}
}
catch (Exception ex)
{
// Log exception ...
}
return responseJson;
}
}
private string getOauthToken(string usercode)
{
string tokenOauth = string.Empty;;
var client = new RestClient("https://api.zakeke.com/token");
var request = new RestRequest() { Method = Method.POST };
request.AddHeader("Content-Type", "application/json");
request.AddParameter("grant_type", "client_credentials");
request.AddParameter("client_id", "your-api-client-id");
request.AddParameter("client_secret", "your-api-secret-key"]);
request.AddParameter("customercode", usercode);
request.AddParameter("access_type", "S2S");

try
{
var responseToken = client.Execute(request);
if (responseToken != null && responseToken.StatusCode == System.Net.HttpStatusCode.OK)
{
JObject responseJson = JsonConvert.DeserializeObject<JObject>(responseToken.Content);
tokenOauth = responseJson["access_token"].ToString();
}
}
catch(Exception ex)
{
// Handle Exception
}
return tokenOauth;
}

If the order has been successfully registered, you will be able to view the order in the "Orders" section of your back office and download the design printing material for the products ordered.

3. API REST Call to Obtain Print-Ready Files

Tip

Use Products Sync V3 to connecting products, please refer to the documentation on the Products Sync V3

You can download the print files as follows:

  • go to "your orders" page of the back-office, select the reference order and click on "download files for printing". Read the guide on orders and print files for more details.

  • integrate this feature into your back-office via API REST

In order to directly integrate the feature into your back-office via API, you will need to make a GET authenticated S2S request at this endpoint:

https://api.zakeke.com/v1/designs/{designID}/outputfiles/zip

Please refer to the documentation on the DESIGN API endpoint for more details on the data to be sent in the request and the returned response.

Example in ASP.NET MVC C# In the example below, the GetDesignFiles function will give the URL of the ZIP archive with the files for printing a particular design created:

using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using RestSharp;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Configuration;

// designID: unique design ID generated by ZAKEKE
public string GetDesignZIPFile(string designID)
{
string urlZIP = string.Empty;
// Get Authorization Oauth Token S2S
string token = getOauthToken();
if (!string.IsNullOrEmpty(token))
{
// Make request to Design Files Endpoint API
var urlRequest = $"https://api.zakeke.com/v1/designs/{designID}/outputfiles/zip";
var client = new RestClient(urlRequest);
var request = new RestRequest() { Method = Method.GET };
request.AddHeader("Authorization", "Bearer " + token);
try
{
var response = client.Execute(request);
if (response != null && response.StatusCode == System.Net.HttpStatusCode.OK)
{
var responseJson = JsonConvert.DeserializeObject<JObject>(response.Content);
urlZIP = responseJson["url"];
}
else
{
// Log error that caused request to fail ...
}
}
catch (Exception ex)
{
// Log exception ...
}
}

return urlZIP;
}
private string getOauthToken()
{
string tokenOauth = string.Empty;;
var client = new RestClient("https://api.zakeke.com/token");
var request = new RestRequest() { Method = Method.POST };
request.AddHeader("Content-Type", "application/json");
request.AddParameter("grant_type", "client_credentials");
request.AddParameter("client_id", "your-api-client-id");
request.AddParameter("client_secret", "your-api-secret-key"]);
request.AddParameter("access_type", "S2S");

try
{
var responseToken = client.Execute(request);
if (responseToken != null && responseToken.StatusCode == System.Net.HttpStatusCode.OK)
{
JObject responseJson = JsonConvert.DeserializeObject<JObject>(responseToken.Content);
tokenOauth = responseJson["access_token"].ToString();
}
}
catch(Exception ex)
{
// Handle Exception
}
return tokenOauth;
}

4. Reorder

If your platform and commerce gives you the ability to reorder, this API duplicates an item by giving you a different unique identifier.

https://api.zakeke.com/v2/design

Please refer to the documentation on the DESIGN API endpoint on the data to be sent in the request and the returned response