Zakeke uses cookies to provide necessary site functionality and improve your experience. By using our website, you agree to our privacy policy and our cookie policy.   

Integrazione con le API

Register an order on Zakeke

An order with customized products using the ZAKEKE IFRAME must be registered in the system. This will allow you to download the print material of designs created for custom products.

Basically, this phase is divided into two steps:

1. Register an order

After processing the order in your e-commerce website, if there are custom products you will need to make a 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.

2. API Integration to download files for custom products

You can download the files for printing of the ordered custom product as follows:

In order to directly integrate the feature into your backoffice via API, you will need to make an 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;
    }