The loyalty program awards points for purchases. When an order is returned, the points should be deducted from the user's account.

The Returns Tracking API passes the data for each return to Zinrelo. These returns are correlated against an earlier corresponding purchase. This Returns Tracking API enables Zinrelo to deduct points for returned purchases. This API is typically called from the server side when the return transaction is created.

Returns API

The API call is a HTTP POST request to this URL:

POST https://api.zinrelo.com/v1/loyalty/transaction/return

Click here for detailed documentation regarding this API.

API Authentication

All API calls have to be authenticated with your API key and partner ID. The API key and partner ID are automatically generated for you when your Zinrelo account is created. These can be found in your Zinrelo admin console under the General >> Settings section.

For authenticating an API call, you have to send your Partner ID, and an API Key in the HTTP header of each API request.

Send the keys in the HTTP header of each API request as given below :

'api-key': '<your-api-key'
'partner-id' : '<your-partner-id>'

Calling the Returns API

Shown below is a sample Python script to call the Zinrelo Returns API. 

import requests
import json

headers = {'partner-id': 'cad458dc4e',
           'api-key': 'c921e097e6679d21c0cad26a45bfec20'}

payload = {
       "order_id=75a2726d13artibb10",
       "returned_amount = 26.95",
       "returned_product_id = 1234df",
       "quantity = 1"}

response = requests.post(url = "https://api.zinrelo.com/v1/loyalty/transaction/return",
                        headers = headers, data = payload)

Here is a description of the query parameters used in the payload of the Returns API call.

JSON Response

Here is the sample sample JSON structured response that you will receive from Zinrelo. 

{
  "data":{
          "user_email": "bob@gmail.com",
          "last_name": "Baker",
          "first_name": "Bob",
          "points": 270,
          "points_status": "pending_deduction",
          "returned_for_order_id": "75a2726d13artibb10",
          "reason": "Order Fully Returned",
          "created_time": "30-Mar-16 19:20:22"
    },
  "success":true
}

Expected Result

Zinrelo will respond with standard HTTP success or failure codes. In case of a success response, the return transaction will reflect in the customer's account in the Zinrelo admin console.

Error Handling

For failures, Zinrelo will also include extra information about what went wrong, encoded in the response as JSON. The various HTTP and API status codes that Zinrelo returns are listed below.

Standard HTTP status codes:

Zinrelo API Status Codes:

The error handling code should log the error response. If you need to look into why a return transaction was not processed, the logs will provide that information easily.

Did this answer your question?