NAV Navbar
Logo
shell php javascript

Introduction

Welcome to the Payla API! You can use our API to access Payla API endpoints.

We have language bindings in Shell, PHP, and Javascript! You can view code examples in the dark area to the right, and you can switch the programming language of the examples with the tabs in the top right.

The API is designed to allow developers to check our products, categories, pricings, user registration and create orders then track updates on that order until completion.

Basics

Payla’s API is fully REST based :

Environments

development environment provides driver bots acting like real couriers (listing and filtering products, user registration, accepting orders, management and etc) so you can test your implementation in “production-like” conditions.

Blow you can find different services in main route:

Blow you can find different services in provider route:

Blow you can find different services in delivery route:

Authentication

To authorize, use this code:

Make sure to replace YOUR_API_KEY with your API key.

<?php
$curl = curl_init();

$token = 'token_id=YOUR_API_KEY';
$route = '/default/global/info';
$version = 'v=0.80';

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://b2csandbox.payla.co'.$route.'?'.$token.'&'.$version,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo 'cURL Error #:' . $err;
} else {
  echo $response;
}
#!/bin/bash
route='/default/global/info'
token='token_id=YOUR_API_KEY'
version='v=0.80'

curl "https://b2csandbox.payla.co${route}?${token}&${version}" \
  -X GET
var data = null;
var token = 'token_id=YOUR_API_KEY';
var route = '/default/global/info';
var version = 'v=0.80';

var xhr = new XMLHttpRequest();

xhr.addEventListener('readystatechange', function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open('GET', 'https://b2csandbox.payla.co'+route+'?'+token+'&'+version);

xhr.send(data);


Every command returns JSON structured like this:

  {
    "data": {
      "auth_required": 0,
      "app_info": {
        "platform_type":"web",
        "newest_version":"0.80",
        "download_link":null
      },
      "new_session_id": "recffmds6c6h516.....",
      ...
    },
    "messages": []
  }

Since you have a valid token you need to add it as a HTTP url request you send to the Payla API.

Response Descriptions:
Every response would include data object and messages array. messages is an array include all system messages like errors and etc. and data object would be the main response to the request:

Parameter type Description
auth_required int If be 1, means this url needs login and user access.
app_info object include data about platform_type, newest version and etc.
new_session_id string jwt session id.
the rest of response parameters are for public dashboard we will explain in the next section

All Payla API endpoints support JWT authentication protocol.

To start sending authenticated HTTP requests (keep your basket and location and other activity before login and keep you login after) you need to use your jwt authorization session_id which is sent to you.

Since you have a valid session_id you need to add it as a HTTP header to every HTTP request you send to the Payla API.

GET https://b2csandbox.payla.co/some_endpoint HTTP/1.1
Authorization: Bearer <SESSION_ID>
Host: b2csandbox.payla.co

Product Listing Services

Global info

Make sure to replace YOUR_API_KEY with your API key. and replace GIVEN_SESSION_ID with the new_session_id and save it for the rest requests til you get a new one.

<?php
$curl = curl_init();

$token = 'token_id=YOUR_API_KEY';
$route = '/default/global/info';
$version = 'v=0.80';
$session = 'GIVEN_SESSION_ID'

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://b2csandbox.payla.co'.$route.'?'.$token.'&'.$version,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer ' . $session,
    'X-Requested-With: XMLHttpRequest',
    'Accept: application/json'
  ]
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo 'cURL Error #:' . $err;
} else {
  echo $response;
}
#!/bin/bash
route='/default/global/info'
token='token_id=YOUR_API_KEY'
session='GIVEN_SESSION_ID'
version='v=0.80'

curl "https://b2csandbox.payla.co${route}?${token}&${version}" \
  -X GET \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer ${session}' \
  -H 'X-Requested-With: XMLHttpRequest'
var data = null;
var token = 'token_id=YOUR_API_KEY';
var route = '/default/global/info';
var session = 'GIVEN_SESSION_ID';
var version = 'v=0.80';

var xhr = new XMLHttpRequest();

xhr.addEventListener('readystatechange', function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open('GET', 'https://b2csandbox.payla.co'+route+'?'+token+'&'+version);
xhr.setRequestHeader('Accept','application/json');
xhr.setRequestHeader('Authorization', 'Bearer ' + session);
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');

xhr.send(data);


The above command returns JSON structured like this:

  [
    ...,
    "min_order_total_price": 40000,
    "min_order_total_price_for_free_delivering": 150000,
    "location_selected": true,
    "basket_count":  2,
    "basket_total_amount": 46963,
    "category_parents":
    [
      {
        "category_id": 368,
        "category_title": "پوشاک",
        "category_order": 1,
        "category_parent_id": 0,
        "first_parent_id": 0,
        "category_image": "https://...",
        "category_icon": "https://...",
      },
      ...
    ],
    "category_parent_children": 
    {
      368: [
        {
          "category_id": 370,
          "category_title": "پوشاک زنانه",
          "category_order": 1,
          "category_parent_id": 368,
          "first_parent_id": 368,
          "category_image": "https://...",
          "category_icon": "https://...",
        },
        ...
      ],
      ...
    },
    "category_sub_children":
    {
      370: [
        {
          "category_id": 371,
          "category_title": "اکسسوری",
          "category_order": 1,
          "category_parent_id": 370,
          "first_parent_id": 368,
          "category_image": "https://...",
          "category_icon": "https://...",
        },
        ...
      ],
      ...
    }
  ]

The global information such as menu, limitations and …

HTTP Request

GET https://b2csandbox.payla.co/default/global/info

Response Descriptions

Parameter type Description
min_order_total_pric int The minimum total price of a basket which can register as an order (basket with less than this price can’t be an order)
min_order_total_price_for_free_delivering int If total price of basket passes this amount customer can have the order with free shipping.
category_parents array of objects The main categories (first level).
category_parent_children object Represent children of the first level categories, the object key points to the first level category’s id.
category_sub_children object Represent childern of the second level of categories, the object key points to the second level category’s id .
location_selected int or false If user select them location. this will show the id of selected location. as the project is LBS this variable specifies the product’s list and prices.
basket_total_amount int If there are products in the basket this variable would be the summation of the products’ prices exist in the list.
basket_count int The count of basket list items.

Basket count info

<?php
$curl = curl_init();

$route = '/default/global/basketinfo';

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://b2csandbox.payla.co'.$route.'?'.$token.'&'.$version,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer ' . $session,
    'X-Requested-With: XMLHttpRequest',
    'Accept: application/json'
  ]
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo 'cURL Error #:' . $err;
} else {
  echo $response;
}
#!/bin/bash
route='/default/global/basketinfo'

curl "https://b2csandbox.payla.co${route}?${token}&${version}" \
  -X GET \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer ${session}' \
  -H 'X-Requested-With: XMLHttpRequest'
var data = null;
var route = '/default/global/basketinfo';

var xhr = new XMLHttpRequest();

xhr.addEventListener('readystatechange', function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open('GET', 'https://b2csandbox.payla.co'+route+'?'+token+'&'+version);
xhr.setRequestHeader('Accept','application/json');
xhr.setRequestHeader('Authorization', 'Bearer ' + session);
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');

xhr.send(data);

The above command returns JSON structured like this:

  [
    ...,
    "location_selected": true,
    "basket_count":  2,
    "basket_total_amount": 46963
  ]

This endpoint returns back location selection status, basket count and total amout info. to update fast if needed.

HTTP Request

GET https://b2csandbox.payla.co/default/global/basketinfo

Public Dashboard Blocks

<?php
$curl = curl_init();

$route = '/default/home/blockslist';

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://b2csandbox.payla.co'.$route.'?'.$token.'&'.$version,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer ' . $session,
    'X-Requested-With: XMLHttpRequest',
    'Accept: application/json'
  ]
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo 'cURL Error #:' . $err;
} else {
  echo $response;
}
#!/bin/bash
route='/default/home/blockslist'

curl "https://b2csandbox.payla.co${route}?${token}&${version}" \
  -X GET \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer ${session}' \
  -H 'X-Requested-With: XMLHttpRequest'
var data = null;
var route = '/default/home/blockslist';

var xhr = new XMLHttpRequest();

xhr.addEventListener('readystatechange', function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open('GET', 'https://b2csandbox.payla.co'+route+'?'+token+'&'+version);
xhr.setRequestHeader('Accept','application/json');
xhr.setRequestHeader('Authorization', 'Bearer ' + session);
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');

xhr.send(data);

The above command returns JSON structured like this:

  [
    ...,
    "pageblocks":{
      [
        {
          "zone_id": 1,
          "item_title": "Slider one",
          "primary_image": "https://...",
          "secondary_image": "https://...",
          "item_type": "staticLink",
          "link": "#",
          "sort_order": 1
        },
        {
          "zone_id": 1,
          "item_title": "Slider two",
          "primary_image": "https://...",
          "secondary_image": "https://...",
          "item_type": "staticLink",
          "link": "#",
          "sort_order": 2
        }
      ],
      [
        {
          "zone_id": 3,
          "item_title": "محصولات ویژه",
          "primary_image": null,
          "secondary_image": null,
          "item_type": "productPack",
          "sort_order": 1,
          "items":{
            {
              "name": "محصول شماره یک",
              "image": "https://...",
              "link": "https://...",
              "price": 17045,
              "final_price": 15340
              "discount_percent": 10
            },
            {
              "name": "محصول شماره دو",
              "image": "https://...",
              "link": "https://...",
              "price": 19800,
              "final_price": 14851
              "discount_percent": 25
            }
          }
        }
      ]
      [
        {
          "zone_id": 4,
          "item_title": "دسته های پیشنهادی",
          "primary_image": null,
          "secondary_image": null,
          "item_type": "categoryPack",
          "sort_order": 1,
          "items":{
            {
              "name": "دسته شماره یک",
              "image": "https://...",
              "link": "https://...",
            },
            {
              "name": "دسته شماره دو",
              "image": "https://...",
              "link": "https://...",
            }
          }
        }
      ]
    }
  ]

This endpoint returns back all specified boxes in the home page such as sliders, special prices and promotions.

HTTP Request

GET https://b2csandbox.payla.co/default/home/blockslist

Response Descriptions

Parameter type Description
bageblocks object Each key points to an array of zone’s items which is an array of objects. Blow table would descripe an item.

Zone Items’ parameters

Parameter type Description
zone_id int Represent the zone id in database.
item_title string The item title.
primary_image string Uri of the orginal image uploaded for item.
secondary_image string Uri of the thumbnail of the orginal uploaded image.
item_type string The value would be one of the categoryPack, productPack, product, productTag and staticLink. which defines if item has a link or array of items.
link string Url of item if item_type be one of productTag or staticLink.
items object If item_type be one of categoryPack, productPack, product, this object would includes the packs or products details.
sort_order int sort order of zone item

A product or productPack Item’s parameters

Parameter type Description
name string Product name.
image string Uri of image.
link string The product link
price int The product customer price in TOMAN
final_price int The product final price in TOMAN
discount_percent int The product discount

A categoryPack Item’s parameters

Parameter type Description
name string Product name.
image string Uri of image.
link string The product link

Get Categories Children boxes

<?php
$curl = curl_init();

$route = '/default/home/touchcategories';
$token_string = $token.'&'.$version;

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://b2csandbox.payla.co'.$route.'?'.$token_string.'&category_id=<ID>',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer ' . $session,
    'X-Requested-With: XMLHttpRequest',
    'Accept: application/json'
  ]
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo 'cURL Error #:' . $err;
} else {
  echo $response;
}
#!/bin/bash
route='/default/home/touchcategories'
token_string = "${token}&${version}"

curl "https://b2csandbox.payla.co${route}?${token_string}&category_id=<ID>" \
  -X GET \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer ${session}' \
  -H 'X-Requested-With: XMLHttpRequest'
var data = null;
var route = '/default/home/touchcategories';
var token_string = token+'&'+version;

var xhr = new XMLHttpRequest();

xhr.addEventListener('readystatechange', function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open('GET', 'https://b2csandbox.payla.co'+route+'?'+token_string+'&category_id=<ID>');
xhr.setRequestHeader('Accept','application/json');
xhr.setRequestHeader('Authorization', 'Bearer ' + session);
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');

xhr.send(data);

The above command returns JSON structured like this:

  {
    ...,
    "last_child": false,
    "category_info": {
      "category_id": 193,
      "category_title": "آردی، پودری، ماکارونی",
      "category_order": 0,
      "category_parent_id": 170,
      "first_parent_id": 170,
      "category_image": "https://...",
      "category_icon": "https://...",
      "last_child": 0,
      "category_status": 1
    },
    "categories":{
      {
        "category_id": 283,
        "category_title": "ماکارونی",
        "category_order": 0,
        "category_image": "https://...",
        "category_icon": "https://...",
        "last_child": 0,
      },
      {
        "category_id": 284,
        "category_title": "رشته",
        "category_order": 0,
        "category_image": "https://...",
        "category_icon": "https://...",
        "last_child": ture,
      }
    },
    "parents":{
      {
        "category_id": 177,
        "category_title": "مواد غذایی اساسی",
        "category_order": 0,
        "category_parent_id": 0,
        "first_parent_id": 0,
        "category_image": "https://...",
        "category_icon": null,
        "last_child": 0,
        "category_status": 1
      }
    }
  }

This endpoint returns back the category’s detail, subcategoreis in that category in detail and it’s parents.

HTTP Request

GET https://b2csandbox.payla.co/default/home/touchcategories

Response Descriptions

Parameter type Description
last_child boolean if its ture there are no sub-categories in.
category_info object selected cagtegory’s information.
categories array of objects all sub-categories of selectd category
parents array of objects selected category’s parents according to level

Product List

<?php
$curl = curl_init();

$route = '/default/products/list';
$token_string = $token.'&'.$version;
$data = array(
  "category_id"=> 326,
  "limit"=> 20,
  "sort_type"=> "",
  "sort_filter"=> "",
  "after"=> "",
  "product_name"=> "لواشک",
  "filtered_brands"=> array(173, 269),
  "price_range"=> array(
    "minPrice"=> 0,
    "maxPrice"=> 100000
  )
);

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://b2csandbox.payla.co'.$route.'?'.$token_string,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer ' . $session,
    'X-Requested-With: XMLHttpRequest',
    'Content-Type: application/json; charset=utf-8',
    'Accept: application/json'
  ],
  CURLOPT_POSTFIELDS => json_encode($data)
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo 'cURL Error #:' . $err;
} else {
  echo $response;
}
#!/bin/bash
route='/default/products/list'
token_string = "${token}&${version}"

curl "https://b2csandbox.payla.co${route}?${token_string}" \
  -X POST \
  -H "Accept: application/json" \
  -H 'Content-Type: application/json; charset=utf-8' \
  -H 'Authorization: Bearer ${session}' \
  -H 'X-Requested-With: XMLHttpRequest' \
  --DATA '{"category_id":326,"limit":20,"sort_type":"","sort_filter":"","after":"","product_name":"لواشک","filtered_brands":[173,269],"price_range":{"minPrice":0,"maxPrice":100000}}'

var data = JSON.stringify({
    "category_id": 326,
    "limit": 20,
    "sort_type": "",
    "sort_filter": "",
    "after": "",
    "product_name": "لواشک",
    "filtered_brands": [173, 269],
    "price_range": {
        "minPrice": 0,
        "maxPrice": 100000
    }
});
var route = '/default/products/list';
var token_string = token+'&'+version;

var xhr = new XMLHttpRequest();

xhr.addEventListener('readystatechange', function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open('POST', 'https://b2csandbox.payla.co'+route+'?'+token_string);
xhr.setRequestHeader('Accept','application/json');
xhr.setRequestHeader('Authorization', 'Bearer ' + session);
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
xhr.setRequestHeader("Content-Type", "application/json; charset=utf-8");

xhr.send(data);

The above command returns JSON structured like this:

  {
    ...,
    "results_count": 1,
    "after": 20,
    "products":{
      {
        "product_id": 1515,
        "brand_id": 269,
        "packing_type_id": 10,
        "product_name": "لواشک لقمه‌ای خشکپاک",
        "product_sub_name": "چند میوه | 300 گرم",
        "product_status": 1,
        "immediately_status": 1,
        "weight": 300,
        "price": 7200,
        "view_count": 100,
        "barcode": 6260258701515,
        "min_order": 1,
        "deleted": 0,
        "created_on": "یک سال پیش",
        "modified_on": "5 ماه قبل",
        "ptc_id": 24077,
        "category_id": 326,
        "product_status_text": "فعال",
        "product_name_encoded": "%D9%84%D9%88%D...",
        "image_address": "https://...",
        "thumbnail": "https://...",
        "final_price": 0,
        "brand": "خشکپاک",
        "discount_percent": 0,
        "already_in_basket": false,
        "exist_in_area": true,
        "in_fav_list": false
      }
    }
  }

This endpoint returns back a category’s product list, it can be filtered by name, price range, brand id, existing and page number or sort by price, discount, weight (ASC or DESC).

HTTP Request

POST https://b2csandbox.payla.co/default/products/list

Request Parameters

Parameter type Description
category_id int the category id of products.
limit int number of products in a page.
after string products’ number offset (for example if limit is 20 and you want page 5, after should be 80)
sort_type string between (desc and asc)
sort_filter string between (final_price, discount, weight)
product_name string part of product name to filter by name (by default is blank)
price_range[minPrice] string minimum price filter
price_range[maxPrice] string maximum price filter
filtered_brands array brands id to filter by them

Response Descriptions

Parameter type Description
results_count int result number.
after int requested after number + requested limit number.
products array of objects returned products list.

Product Fields Descriptions

Parameter type Description
product_id int the product id
brand_id int the product’s brand id
brand string the product’s brnad name
product_name string product title
product_sub_name string product short describtion
product_status int product’s itself status id
product_status_text string well formated product status
immediately_status int product’s immediately status (uses when a category goes disabled to check if product’s category has been disabled or not in checkout process)
packing_type_id int packing type id
weight int weight in Gram
price int product customer price (the general price of product out side of our store)
view_count int number of visits
barcode string product general barcode
min_order int minimum allowed number of product to add to basket
deleted int 1 means soft delete
created_on string well formated create time.
modified_on string well formated modification time.
ptc_id int product_to_category id
category_id int category id
product_name_encoded string url type encoded name
image_address string product image url
thumbnail string product thumbnail image url
final_price int payla price (0 if location has not been set)
discount_percent int discount percent (0 if location has not been set or discount is 0)
already_in_basket boolean true if customer has already added the product to their basket
exist_in_area boolean true if location has been set and product exits in sepecified location
in_fav_list boolean true if customer has already added product to their wish list

Product

<?php
$curl = curl_init();

$route = '/products/getone';
$token_string = $token.'&'.$version;

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://b2csandbox.payla.co'.$route.'?'.$token_string.'&product_id=<ID>',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer ' . $session,
    'X-Requested-With: XMLHttpRequest',
    'Accept: application/json'
  ]
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo 'cURL Error #:' . $err;
} else {
  echo $response;
}
#!/bin/bash
route='/products/getone'
token_string = "${token}&${version}"

curl "https://b2csandbox.payla.co${route}?${token_string}&product_id=<ID>" \
  -X GET \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer ${session}' \
  -H 'X-Requested-With: XMLHttpRequest'
var data = null;
var route = '/products/getone';
var token_string = token+'&'+version;

var xhr = new XMLHttpRequest();

xhr.addEventListener('readystatechange', function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open('GET', 'https://b2csandbox.payla.co'+route+'?'+token_string+'&product_id=<ID>');
xhr.setRequestHeader('Accept','application/json');
xhr.setRequestHeader('Authorization', 'Bearer ' + session);
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');

xhr.send(data);

The above command returns JSON structured like this:

  {
    ...,
    "result": true,
    "default_location_not_found": true,
    "available_to_buy": true,
    "keywords": "لواشک لقمه ای,خوراکی,تنقلات,لواشک و ترشک,",
    "product_info": {
        "product_id": 1515,
        "brand_id": 269,
        "packing_type_id": 10,
        "product_name": "لواشک لقمه ای خشکپاک",
        "product_sub_name": "چندمیوه | ۳۰۰ گرم",
        "product_status": 1,
        "immediately_status": 1,
        "weight": 300,
        "price": 7200,
        "view_count": 0,
        "barcode": "6260258701515",
        "min_order": 1,
        "deleted": 0,
        "created_on": 1456836744,
        "modified_on": 1481029192,
        "final_price": 0,
        "discount_percent": 0,
        "already_in_basket": false,
        "description": "....",
        "usage_description": "...."
    },
    "product_brand": {
        "brand_id": 269,
        "brand_name": "خشکپاک",
        "brand_english": "khoshkpak",
        "brand_website": "",
        "brand_logo": "https://...",
        "brand_summary": "",
        "brand_description": "",
        "product_count": 42,
        "created_on": 1456218760,
        "modified_on": 1460007186
    },
    "product_images": [
      {
        "product_image_id": 3868,
        "product_id": 1515,
        "image_address": "https://...",
        "is_primary": 1,
        "image_older": 0,
        "created_on": 1460533383,
        "thumbnail": "https://...",
        "large_image_address": "https://..."
      }
    ],
    "product_units": [
      {
        "ptu_id": 22761,
        "unit_id": 8,
        "product_id": 1515,
        "weight": 300,
        "pure_weight": 300,
        "price": 0,
        "number_in_unit": 1,
        "unit_title": "عدد"
      }
    ],
    "attribute_groups": [
      {
        "attribute_value_id": 39225,
        "attribute_id": 76,
        "product_id": 1515,
        "attribute_group_id": 1,
        "attribute_value": "- ایزو ۹۰۰۱\n- ایزو ۲۲۰۰۰\n- استاندارد غذا و دارو",
        "is_important": 0,
        "created_on": 1453276980,
        "group_name": "مشخصات کلی",
        "group_order": 3
      }
    ],
    "product_attributes": {
      "1": [
        {
          "attribute_id": 76,
          "product_id": 1515,
          "attribute_group_id": 1,
          "attribute_value": "...",
          "is_important": 0,
          "attribute_title": "مجوزها و استانداردها"
        }
      ]
    },
    "category_parents":{
      {
        "category_id": 267,
        "category_title": "خوراکی و نوشیدنی",
        "category_order": 2,
        "category_parent_id": 0,
        "first_parent_id": 0,
        "category_image": null,
        "category_icon": null,
        "last_child": 0,
        "category_status": 1,
        "created_on": 1454825486,
        "modified_on": 1465197778
      }, ...
    },
    "close_products":{
      {
        "ptc_id": 24076,
        "product_id": 1593,
        "category_id": 326,
        "brand_id": 269,
        "packing_type_id": 10,
        "product_name": "آلبالو ترش خشکپاک",
        "product_sub_name": "۳۰۰ گرم",
        "product_status": 1,
        "immediately_status": 1,
        "weight": 300,
        "price": 8750,
        "view_count": 0,
        "barcode": "6260258750131",
        "min_order": 1,
        "deleted": 0,
        "created_on": 1456918689,
        "modified_on": 1481029150,
        "product_name_encoded": "%D8%A2%D9%...",
        "image_address": "https://...",
        "final_price": 0,
        "discount_percent": 0
      }, ...
    }
  }

This endpoint returns back the products’s detail, such as category, brand, attributes, images, descriptions and related products.

HTTP Request

GET https://b2csandbox.payla.co/products/getone

Response Descriptions

Parameter type Description
result boolean it’s false if given ID is incorrect or product is not available
default_location_not_found boolean ture if location has been set
available_to_buy boolean if location is set and product exist it would be true
keywords string string of product’s keywords seperated by “,”
product_info object product details
product_brand object product brand details
product_images array of objects product images detials
product_units array of objects product units details
attribute_groups array of objects details of the group of product’s attributes
product_attributes array of objects product’s attributes details (each object has a title and a value)
category_parents array of objects product’s category and parent categories details
close_products array of objects related products to the product

product_info fields Descriptions

Parameter type Description
product_id int the product id
brand_id int the product’s brand id
packing_type_id int packing type id
product_name string product title
product_sub_name string product short describtion
product_status int product’s itself status id
immediately_status int product’s immediately status (uses when a category goes disabled to check if product’s category has been disabled or not in checkout process)
weight int weight in Gram
price int product customer price (the general price of product out side of our store)
view_count int number of visits
barcode string product general barcode
min_order int minimum allowed number of product to add to basket
deleted int 1 means soft delete
created_on int UNIX format create time.
modified_on int UNIX format modification time.
final_price int payla price (0 if location has not been set)
discount_percent int discount percent (0 if location has not been set or discount is 0)
already_in_basket boolean true if customer has already added the product to their basket
description string product complete description
usage_description string product review description

product_units fields Descriptions

Parameter type Description
ptu_id int product unit id
unit_id int unit id
product_id int product id
weight int product weight in the unit
pure_weight int product pure weight in the unit
price int product price in the unit
number_in_unit int number of products the unit contains
unit_title string unit title

Location Services

Get All Locations

<?php
$curl = curl_init();

$route = '/account/signup/locations';
$token_string = $token.'&'.$version;

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://b2csandbox.payla.co'.$route.'?'.$token_string,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer ' . $session,
    'X-Requested-With: XMLHttpRequest',
    'Accept: application/json'
  ]
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo 'cURL Error #:' . $err;
} else {
  echo $response;
}
#!/bin/bash
route='/account/signup/locations'
token_string = "${token}&${version}"

curl "https://b2csandbox.payla.co${route}?${token_string}" \
  -X GET \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer ${session}' \
  -H 'X-Requested-With: XMLHttpRequest'
var data = null;
var route = '/account/signup/locations';
var token_string = token+'&'+version;

var xhr = new XMLHttpRequest();

xhr.addEventListener('readystatechange', function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open('GET', 'https://b2csandbox.payla.co'+route+'?'+token_string);
xhr.setRequestHeader('Accept','application/json');
xhr.setRequestHeader('Authorization', 'Bearer ' + session);
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');

xhr.send(data);

The above command returns JSON structured like this:

  {
    ...,
    "locations": [
      {
        "location_id": 1,
        "location_title": "منطقه 1",
        "location_order": 0,
        "location_parent_id": 23,
        "location_type": 3,
        "last_child": 0,
        "first_parent_id": 627,
        "location_status": 0
      },
      {
        "location_id": 2,
        "location_title": "منطقه 2",
        "location_order": 0,
        "location_parent_id": 23,
        "location_type": 3,
        "last_child": 0,
        "first_parent_id": 627,
        "location_status": 0
      },
      ...
    ]
  }

This endpoint returns back the array of all locations.

HTTP Request

GET https://b2csandbox.payla.co/account/signup/locations

Response Descriptions

Parameter type Description
location_id int location id
location_title string location title
location_order int location order in a same level
location_parent_id int parent id
location_type int location level from 1 to 4
last_child int 1 means it’s the last child
first_parent_id int first level parent’s id
location_status int location status

Set Location

<?php
$curl = curl_init();

$route = '/default/useraddress/setlocation';
$token_string = $token.'&'.$version;
$data = array(
  "selectedArea"=> 131,
  "map_lat" => 35.695071,
  "map_lng" => 51.375053
);

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://b2csandbox.payla.co'.$route.'?'.$token_string,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer ' . $session,
    'X-Requested-With: XMLHttpRequest',
    'Content-Type: application/json; charset=utf-8',
    'Accept: application/json'
  ],
  CURLOPT_POSTFIELDS => json_encode($data)
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo 'cURL Error #:' . $err;
} else {
  echo $response;
}
#!/bin/bash
route='/default/useraddress/setlocation'
token_string = "${token}&${version}"

curl "https://b2csandbox.payla.co${route}?${token_string}" \
  -X POST \
  -H "Accept: application/json" \
  -H 'Content-Type: application/json; charset=utf-8' \
  -H 'Authorization: Bearer ${session}' \
  -H 'X-Requested-With: XMLHttpRequest' \
  --DATA '{"selectedArea":131,"map_lat":35.695071,"map_lng":51.375053}'

var data = JSON.stringify({
    "selectedArea": 131,
    "map_lat": 35.695071,
    "map_lng": 51.375053
});
var route = '/default/useraddress/setlocation';
var token_string = token+'&'+version;

var xhr = new XMLHttpRequest();

xhr.addEventListener('readystatechange', function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open('POST', 'https://b2csandbox.payla.co'+route+'?'+token_string);
xhr.setRequestHeader('Accept','application/json');
xhr.setRequestHeader('Authorization', 'Bearer ' + session);
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
xhr.setRequestHeader("Content-Type", "application/json; charset=utf-8");

xhr.send(data);

This endpoint is to set user location. all products’ prices and discount and availability depends to user location.

HTTP Request

POST https://b2csandbox.payla.co/default/useraddress/setlocation

it returns the result of request as true or false in the json array

Basket Services

Add/Update Basket Item

<?php
$curl = curl_init();

$route = '/default/basket/add';
$token_string = $token.'&'.$version;
$data = array(
  "product_id"=> 1480,
  "quantity"=> 1,
  "get_list"=> true,
  "one_by_one"=> true
);

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://b2csandbox.payla.co'.$route.'?'.$token_string,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer ' . $session,
    'X-Requested-With: XMLHttpRequest',
    'Content-Type: application/json; charset=utf-8',
    'Accept: application/json'
  ],
  CURLOPT_POSTFIELDS => json_encode($data)
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo 'cURL Error #:' . $err;
} else {
  echo $response;
}
#!/bin/bash
route='/default/basket/add'
token_string = "${token}&${version}"

curl "https://b2csandbox.payla.co${route}?${token_string}" \
  -X POST \
  -H "Accept: application/json" \
  -H 'Content-Type: application/json; charset=utf-8' \
  -H 'Authorization: Bearer ${session}' \
  -H 'X-Requested-With: XMLHttpRequest' \
  --DATA '{"product_id":1480,"quantity":1,"get_list":true,"one_by_one":true}'
var data = JSON.stringify({
  "product_id": 1480,
  "quantity": 1,
  "get_list": true,
  "one_by_one": true
});
var route = '/default/basket/add';
var token_string = token+'&'+version;

var xhr = new XMLHttpRequest();

xhr.addEventListener('readystatechange', function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open('POST', 'https://b2csandbox.payla.co'+route+'?'+token_string);
xhr.setRequestHeader('Accept','application/json');
xhr.setRequestHeader('Authorization', 'Bearer ' + session);
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
xhr.setRequestHeader("Content-Type", "application/json; charset=utf-8");

xhr.send(data);

This endpoint is to add a product to basket or update quantity of an existing one.

HTTP Request

POST https://b2csandbox.payla.co/default/basket/add

Request Parameters

Parameter type Description
product_id int product id to add or update.
quantity int quantity (new quantity if it’s an update request).
get_list boolean get basket list after? to update basket list in front view.
one_by_one boolean if quantity equels to 1 and it’s true. it would substract existing quantity by one instead of replacing quantity

Response Descriptions

Parameter type Description
result boolean The result of operation.
default_location_not_found boolean If location has not been set it would be true and you can’t add item to basket
basket_error string Show errors related to basket such as product existing
added_quantity int An approval for request quantity to add or update.

Get Basket List

<?php
$curl = curl_init();

$route = '/default/basket/list';
$token_string = $token.'&'.$version;

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://b2csandbox.payla.co'.$route.'?'.$token_string,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer ' . $session,
    'X-Requested-With: XMLHttpRequest',
    'Accept: application/json'
  ]
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo 'cURL Error #:' . $err;
} else {
  echo $response;
}
#!/bin/bash
route='/default/basket/list'
token_string = "${token}&${version}"

curl "https://b2csandbox.payla.co${route}?${token_string}" \
  -X GET \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer ${session}' \
  -H 'X-Requested-With: XMLHttpRequest'
var data = null;
var route = '/default/basket/list';
var token_string = token+'&'+version;

var xhr = new XMLHttpRequest();

xhr.addEventListener('readystatechange', function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open('GET', 'https://b2csandbox.payla.co'+route+'?'+token_string);
xhr.setRequestHeader('Accept','application/json');
xhr.setRequestHeader('Authorization', 'Bearer ' + session);
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');

xhr.send(data);

The above command returns JSON structured like this:

  {
    ...,
    "delivery_cost": 150000,
    "items": [
      {
        "basket_item_id": 634,
        "product_id": 1480,
        "quantity": 1,
        "b_final_price": 120350,
        "product_name": "مایع ظرفشویی گلی",
        "product_sub_name": "۴ لیتر",
        "price": 12035,
        "final_price": 12035,
        "thumbnail": "https://...",
        "category": {
          "category_title": "ظروف",
          "category_id": 264,
          "first_category": "شوینده ،بهداشتی ،سلولزی",
          "first_category_id": 205,
          "second_category": "شوینده و ضدعفونی کننده",
          "second_category_id": 206
        }
      },
      ...
    ]
  }

This endpoint returns back the array of all locations.

HTTP Request

GET https://b2csandbox.payla.co/default/basket/list

Response Descriptions

Parameter type Description
delivery_cost int according to global settings, customer can win a free delivery if their order amout pass the minimum amount of free delivery. it shows the minimum amount to have free delivery.

Items’ fields Descriptions

Parameter type Description
basket_item_id int basket item id
product_id int product id in system
quantity int quantity of product to insert in basket or update previous quantity to it.
b_final_price int base final price in RIAL
product_name string product name
product_sub_name string product short describtion
price int product general customer price
final_price int final price in TOMAN
thumbnail string product thumbnail image url
category[category_title] string category title
category[category_id] int category id
category[first_category] string first level category name (root category)
category[first_category_id] int first level category id
category[second_category] string second level category name
category[second_category_id] int second level category id.

Remove Basket Item

<?php
$curl = curl_init();

$route = '/default/basket/delete';
$token_string = $token.'&'.$version;
$data = array(
  "product_id"=> 1480
);

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://b2csandbox.payla.co'.$route.'?'.$token_string,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer ' . $session,
    'X-Requested-With: XMLHttpRequest',
    'Content-Type: application/json; charset=utf-8',
    'Accept: application/json'
  ],
  CURLOPT_POSTFIELDS => json_encode($data)
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo 'cURL Error #:' . $err;
} else {
  echo $response;
}
#!/bin/bash
route='/default/basket/delete'
token_string = "${token}&${version}"

curl "https://b2csandbox.payla.co${route}?${token_string}" \
  -X POST \
  -H "Accept: application/json" \
  -H 'Content-Type: application/json; charset=utf-8' \
  -H 'Authorization: Bearer ${session}' \
  -H 'X-Requested-With: XMLHttpRequest' \
  --DATA '{"product_id":1480}'

var data = JSON.stringify({
    "product_id": 1480
});
var route = '/default/basket/delete';
var token_string = token+'&'+version;

var xhr = new XMLHttpRequest();

xhr.addEventListener('readystatechange', function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open('POST', 'https://b2csandbox.payla.co'+route+'?'+token_string);
xhr.setRequestHeader('Accept','application/json');
xhr.setRequestHeader('Authorization', 'Bearer ' + session);
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
xhr.setRequestHeader("Content-Type", "application/json; charset=utf-8");

xhr.send(data);

This endpoint is to remove a product from basket.

HTTP Request

POST https://b2csandbox.payla.co/default/basket/delete

it returns the result of request as true or false and basket list in the json array

profile services

Sign Up

<?php
$curl = curl_init();

$route = '/account/signup';
$token_string = $token.'&'.$version;
$data = array(
  "email" => "example@example.com",
  "national_id" => "008xxxxxxx",
  "mobile_number" => "09xxxxxxxxx",
  "password" => "******",
  "first_name" => "احمد",
  "last_name" => "احمدی",
  "inContract" => "true",
  "organization_id" => 2,
  "method_of_introduction" => 1
);

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://b2csandbox.payla.co'.$route.'?'.$token_string,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer ' . $session,
    'X-Requested-With: XMLHttpRequest',
    'Content-Type: application/json; charset=utf-8',
    'Accept: application/json'
  ],
  CURLOPT_POSTFIELDS => json_encode($data)
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo 'cURL Error #:' . $err;
} else {
  echo $response;
}
#!/bin/bash
route='/account/signup'
token_string = "${token}&${version}"

curl "https://b2csandbox.payla.co${route}?${token_string}" \
  -X POST \
  -H "Accept: application/json" \
  -H 'Content-Type: application/json; charset=utf-8' \
  -H 'Authorization: Bearer ${session}' \
  -H 'X-Requested-With: XMLHttpRequest' \
  --DATA '{"email":"example@example.com","national_id":"008xxxxxxx","mobile_number":"09xxxxxxxxx","password":"******","first_name":"احمد","last_name":"احمدی","inContract":"true","organization_id":2,"method_of_introduction":1}'

var data = JSON.stringify({
  "email": "example@example.com",
  "national_id": "008xxxxxxx",
  "mobile_number": "09xxxxxxxxx",
  "password": "******",
  "first_name": "احمد",
  "last_name": "احمدی",
  "inContract": "true",
  "organization_id": 2,
  "method_of_introduction": 1
});
var route = '/account/signup';
var token_string = token+'&'+version;

var xhr = new XMLHttpRequest();

xhr.addEventListener('readystatechange', function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open('POST', 'https://b2csandbox.payla.co'+route+'?'+token_string);
xhr.setRequestHeader('Accept','application/json');
xhr.setRequestHeader('Authorization', 'Bearer ' + session);
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
xhr.setRequestHeader("Content-Type", "application/json; charset=utf-8");

xhr.send(data);

The above command returns JSON structured like this:

  {
    ...,
    "user_info": {
        "id": 3190,
        "email": "example@example.com",
        "email_verified": 0,
        "user_type": "user",
        "role_name": "common_user",
        "auth_status": 1,
        "first_name": "علی",
        "last_name": "احمدی"
    }
  }

This endpoint is to sign up as a new user or customer.

HTTP Request

POST https://b2csandbox.payla.co/account/signup

Request Parameters

Parameter type Description
email string email address.
national_id string national id
mobile_number string mobile number to notify and verify account
password string password
first_name string user first name
last_name string user last name
inContract string if user is member of organizations have contract with payla set it “true”
organization_id int set it if user is inContract you can get id from organizations list. this item would verify with national id. so national_id would be required in this case.
reagentCode string if user has a reagent_code set it “true”
reagent_code string generated code from Payla’s members to introduce new members to the payla club
method_of_introduction int 1. outside adv, 2.tv 3.google 4.internet 5.other
remember_me boolean to set a long token life for user

Get in Contract Organizations list

<?php
$curl = curl_init();

$route = '/account/signup/getlistorganization';
$token_string = $token.'&'.$version;

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://b2csandbox.payla.co'.$route.'?'.$token_string,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer ' . $session,
    'X-Requested-With: XMLHttpRequest',
    'Accept: application/json'
  ]
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo 'cURL Error #:' . $err;
} else {
  echo $response;
}
#!/bin/bash
route='/account/signup/getlistorganization'
token_string = "${token}&${version}"

curl "https://b2csandbox.payla.co${route}?${token_string}" \
  -X GET \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer ${session}' \
  -H 'X-Requested-With: XMLHttpRequest'
var data = null;
var route = '/account/signup/getlistorganization';
var token_string = token+'&'+version;

var xhr = new XMLHttpRequest();

xhr.addEventListener('readystatechange', function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open('GET', 'https://b2csandbox.payla.co'+route+'?'+token_string);
xhr.setRequestHeader('Accept','application/json');
xhr.setRequestHeader('Authorization', 'Bearer ' + session);
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');

xhr.send(data);

The above command returns JSON structured like this:

  {
    ...,
    "list": [
      {
        "id": 1,
        "name_organize": "مترو تهران"
      },
      ...
    ]
  }

This endpoint returns back the organizations list.

HTTP Request

GET https://b2csandbox.payla.co/account/signup/getlistorganization

Login

<?php
$curl = curl_init();

$route = '/account/auth';
$token_string = $token.'&'.$version;
$data = array(
  "email" => "example@example.com",
  "password" => "*****",
  "remember_me" => true
);

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://b2csandbox.payla.co'.$route.'?'.$token_string,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer ' . $session,
    'X-Requested-With: XMLHttpRequest',
    'Content-Type: application/json; charset=utf-8',
    'Accept: application/json'
  ],
  CURLOPT_POSTFIELDS => json_encode($data)
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo 'cURL Error #:' . $err;
} else {
  echo $response;
}
#!/bin/bash
route='/account/auth'
token_string = "${token}&${version}"

curl "https://b2csandbox.payla.co${route}?${token_string}" \
  -X POST \
  -H "Accept: application/json" \
  -H 'Content-Type: application/json; charset=utf-8' \
  -H 'Authorization: Bearer ${session}' \
  -H 'X-Requested-With: XMLHttpRequest' \
  --DATA '{"email":"example@example.com","password":"*****","remember_me":true}'
var data = JSON.stringify({
    "email": "example@example.com",
    "password": "*****",
    "remember_me": true
});
var route = '/account/auth';
var token_string = token+'&'+version;

var xhr = new XMLHttpRequest();

xhr.addEventListener('readystatechange', function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open('POST', 'https://b2csandbox.payla.co'+route+'?'+token_string);
xhr.setRequestHeader('Accept','application/json');
xhr.setRequestHeader('Authorization', 'Bearer ' + session);
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
xhr.setRequestHeader("Content-Type", "application/json; charset=utf-8");

xhr.send(data);

The above command returns JSON structured like this:

  {
    ...,
    "user_info": {
        "id": 3190,
        "email": "example@example.com",
        "email_verified": 1,
        "user_type": "user",
        "role_name": "common_user",
        "auth_status": 1,
        "first_name": "علی",
        "last_name": "احمدی"
    },
    "result": true,
    "need_to_merge_basket": false
  }

This endpoint is to Login to profile or system admin.

HTTP Request

POST https://b2csandbox.payla.co/account/auth

Response Descriptions

Parameter type Description
new_session_id string In an unsuccessful try gives you a new session Id and you should replace it with an old one.
result boolean result of login
need_to_merge_basket boolean true if user had already a basket in his profile and now has a new one before login. so system should merge or replace basket.
user_info[id] int user id
user_info[email] string user email address
user_info[email_verified] int If be 0, means the user’s email is not verified yet.
user_info[user_type] string user type: user, admin, provider, deliverer
user_info[role_name] string user role name: admin, common_user, sales_support, product_entity, accounter, provider, deliverer
user_info[auth_status] int If be 1, means the user has logged in
user_info[first_name] string User first name
user_info[last_name] string User family name

Forget Password / Get Verfiy Code

<?php
$curl = curl_init();

$route = '/account/auth/recovery';
$token_string = $token.'&'.$version;
$data = array(
  "email" => "example@example.com"
);

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://b2csandbox.payla.co'.$route.'?'.$token_string,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer ' . $session,
    'X-Requested-With: XMLHttpRequest',
    'Content-Type: application/json; charset=utf-8',
    'Accept: application/json'
  ],
  CURLOPT_POSTFIELDS => json_encode($data)
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo 'cURL Error #:' . $err;
} else {
  echo $response;
}
#!/bin/bash
route='/account/auth/recovery'
token_string = "${token}&${version}"

curl "https://b2csandbox.payla.co${route}?${token_string}" \
  -X POST \
  -H "Accept: application/json" \
  -H 'Content-Type: application/json; charset=utf-8' \
  -H 'Authorization: Bearer ${session}' \
  -H 'X-Requested-With: XMLHttpRequest' \
  --DATA '{"email":"example@example.com"}'

var data = JSON.stringify({
    "email": "example@example.com"
});
var route = '/account/auth/recovery';
var token_string = token+'&'+version;

var xhr = new XMLHttpRequest();

xhr.addEventListener('readystatechange', function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open('POST', 'https://b2csandbox.payla.co'+route+'?'+token_string);
xhr.setRequestHeader('Accept','application/json');
xhr.setRequestHeader('Authorization', 'Bearer ' + session);
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
xhr.setRequestHeader("Content-Type", "application/json; charset=utf-8");

xhr.send(data);

This endpoint is to get a new verification code to change your password and uses in cases the customer has forgatten their password.

HTTP Request

POST https://b2csandbox.payla.co/account/auth/recovery

Response Descriptions

Parameter type Description
type string email or mobile wich indicates the link has been sent as SMS or Email.
result boolean result of operation.

Get Profile Information

<?php
$curl = curl_init();

$route = '/default/profile/info';
$token_string = $token.'&'.$version;

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://b2csandbox.payla.co'.$route.'?'.$token_string,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer ' . $session,
    'X-Requested-With: XMLHttpRequest',
    'Accept: application/json'
  ]
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo 'cURL Error #:' . $err;
} else {
  echo $response;
}
#!/bin/bash
route='/default/profile/info'
token_string = "${token}&${version}"

curl "https://b2csandbox.payla.co${route}?${token_string}" \
  -X GET \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer ${session}' \
  -H 'X-Requested-With: XMLHttpRequest'
var data = null;
var route = '/default/profile/info';
var token_string = token+'&'+version;

var xhr = new XMLHttpRequest();

xhr.addEventListener('readystatechange', function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open('GET', 'https://b2csandbox.payla.co'+route+'?'+token_string);
xhr.setRequestHeader('Accept','application/json');
xhr.setRequestHeader('Authorization', 'Bearer ' + session);
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');

xhr.send(data);

The above command returns JSON structured like this:

  {
    ...,
    "user_info": {
        "user_id": 1,
        "email": "example@example.com",
        "mobile_number": "09xxxxxxxxx",
        "national_id": "008xxxxxxx",
        "first_name": "احمد",
        "last_name": "احمدی",
        "avatar": "http://...",
        "last_access_time": "یک ساعت پیش",
        "created_on": "یک سال پیش",
        "email_verified": 1
    }
  }

This endpoint returns back the user profile information.

HTTP Request

GET https://b2csandbox.payla.co/default/profile/info

Change Password

<?php
$curl = curl_init();

$route = '/profile/changepassword';
$token_string = $token.'&'.$version;
$data = array(
  "old_password" => "oldpassword",
  "new_password" => "newpass",
  "retype_new_password" => "newpass"
);

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://b2csandbox.payla.co'.$route.'?'.$token_string,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer ' . $session,
    'X-Requested-With: XMLHttpRequest',
    'Content-Type: application/json; charset=utf-8',
    'Accept: application/json'
  ],
  CURLOPT_POSTFIELDS => json_encode($data)
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo 'cURL Error #:' . $err;
} else {
  echo $response;
}
#!/bin/bash
route='/profile/changepassword'
token_string = "${token}&${version}"

curl "https://b2csandbox.payla.co${route}?${token_string}" \
  -X POST \
  -H "Accept: application/json" \
  -H 'Content-Type: application/json; charset=utf-8' \
  -H 'Authorization: Bearer ${session}' \
  -H 'X-Requested-With: XMLHttpRequest' \
  --DATA '{"old_password":"oldpassword","new_password":"newpass","retype_new_password":"newpass"}'

var data = JSON.stringify({
  "old_password": "oldpassword",
  "new_password": "newpass",
  "retype_new_password": "newpass"
});
var route = '/profile/changepassword';
var token_string = token+'&'+version;

var xhr = new XMLHttpRequest();

xhr.addEventListener('readystatechange', function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open('POST', 'https://b2csandbox.payla.co'+route+'?'+token_string);
xhr.setRequestHeader('Accept','application/json');
xhr.setRequestHeader('Authorization', 'Bearer ' + session);
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
xhr.setRequestHeader("Content-Type", "application/json; charset=utf-8");

xhr.send(data);

This endpoint is to change your password after login.

HTTP Request

POST https://b2csandbox.payla.co/profile/changepassword

it returns the result of request as true or false in the json array

Resend Activation Code

<?php
$curl = curl_init();

$route = '/default/profile/resendactivation';
$token_string = $token.'&'.$version;

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://b2csandbox.payla.co'.$route.'?'.$token_string,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer ' . $session,
    'X-Requested-With: XMLHttpRequest',
    'Accept: application/json'
  ]
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo 'cURL Error #:' . $err;
} else {
  echo $response;
}
#!/bin/bash
route='/default/profile/resendactivation'
token_string = "${token}&${version}"

curl "https://b2csandbox.payla.co${route}?${token_string}" \
  -X GET \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer ${session}' \
  -H 'X-Requested-With: XMLHttpRequest'
var data = null;
var route = '/default/profile/resendactivation';
var token_string = token+'&'+version;

var xhr = new XMLHttpRequest();

xhr.addEventListener('readystatechange', function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open('GET', 'https://b2csandbox.payla.co'+route+'?'+token_string);
xhr.setRequestHeader('Accept','application/json');
xhr.setRequestHeader('Authorization', 'Bearer ' + session);
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');

xhr.send(data);

This endpoint resend acctivation code to user.

HTTP Request

GET https://b2csandbox.payla.co/default/profile/resendactivation

it returns the result of request as true or false in the json array

Edit Profile

<?php
$curl = curl_init();

$route = '/default/profile/edit';
$token_string = $token.'&'.$version;
$data = array(
  "user_id"=> 1,
  "email"=> "example@example.com",
  "mobile_number"=> "09xxxxxxxxx",
  "national_id"=> "008xxxxxxx",
  "first_name"=> "احمد",
  "last_name"=> "احمدی"
);

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://b2csandbox.payla.co'.$route.'?'.$token_string,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer ' . $session,
    'X-Requested-With: XMLHttpRequest',
    'Content-Type: application/json; charset=utf-8',
    'Accept: application/json'
  ],
  CURLOPT_POSTFIELDS => json_encode($data)
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo 'cURL Error #:' . $err;
} else {
  echo $response;
}
#!/bin/bash
route='/default/profile/edit'
token_string = "${token}&${version}"

curl "https://b2csandbox.payla.co${route}?${token_string}" \
  -X POST \
  -H "Accept: application/json" \
  -H 'Content-Type: application/json; charset=utf-8' \
  -H 'Authorization: Bearer ${session}' \
  -H 'X-Requested-With: XMLHttpRequest' \
  --DATA '{"user_id":1,"email":"example@example.com","mobile_number":"09xxxxxxxxx","national_id":"008xxxxxxx","first_name":"احمد","last_name":"احمدی"}'
var data = JSON.stringify({
  "user_id": 1,
  "email": "example@example.com",
  "mobile_number": "09xxxxxxxxx",
  "national_id": "008xxxxxxx",
  "first_name": "احمد",
  "last_name": "احمدی"
});
var route = '/default/profile/edit';
var token_string = token+'&'+version;

var xhr = new XMLHttpRequest();

xhr.addEventListener('readystatechange', function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open('POST', 'https://b2csandbox.payla.co'+route+'?'+token_string);
xhr.setRequestHeader('Accept','application/json');
xhr.setRequestHeader('Authorization', 'Bearer ' + session);
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
xhr.setRequestHeader("Content-Type", "application/json; charset=utf-8");

xhr.send(data);

This endpoint is to change profile information.

HTTP Request

POST https://b2csandbox.payla.co/default/profile/edit

it returns the result of request as true or false and user information in the json array

Change Avatar

<?php
$curl = curl_init();

$route = '/default/profile/changeavatar';
$token_string = $token.'&'.$version;
$data = array(
  "avatar"=> "@FILE_DATA"
);

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://b2csandbox.payla.co'.$route.'?'.$token_string,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer ' . $session,
    'X-Requested-With: XMLHttpRequest',
    'Content-Type: multipart/form-data',
    'Accept: application/json'
  ],
  CURLOPT_POSTFIELDS => $data
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo 'cURL Error #:' . $err;
} else {
  echo $response;
}
#!/bin/bash
route='/default/profile/changeavatar'
token_string = "${token}&${version}"

curl "https://b2csandbox.payla.co${route}?${token_string}" \
  -X POST \
  -H "Accept: application/json" \
  -H 'Authorization: Bearer ${session}' \
  -H 'X-Requested-With: XMLHttpRequest' \
  -H "Content-Type: multipart/form-data" \
  -F 'avatar=@FILE_PATH'
var data = new FormData();
data.append('avatar', @FILE_DATA);

var route = '/default/profile/changeavatar';
var token_string = token+'&'+version;

var xhr = new XMLHttpRequest();

xhr.addEventListener('readystatechange', function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open('POST', 'https://b2csandbox.payla.co'+route+'?'+token_string);
xhr.setRequestHeader('Accept','application/json');
xhr.setRequestHeader('Authorization', 'Bearer ' + session);
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
xhr.setRequestHeader('Content-Type','multipart/form-data');

xhr.send(data);

This endpoint is to change profile information.

HTTP Request

POST https://b2csandbox.payla.co/default/profile/changeavatar

it returns the result of request as true or false and new_avatar url in the json array

Logout

<?php
$curl = curl_init();

$route = '/account/auth/logout';
$token_string = $token.'&'.$version;

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://b2csandbox.payla.co'.$route.'?'.$token_string,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer ' . $session,
    'X-Requested-With: XMLHttpRequest',
    'Accept: application/json'
  ]
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo 'cURL Error #:' . $err;
} else {
  echo $response;
}
#!/bin/bash
route='/account/auth/logout'
token_string = "${token}&${version}"

curl "https://b2csandbox.payla.co${route}?${token_string}" \
  -X GET \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer ${session}' \
  -H 'X-Requested-With: XMLHttpRequest'
var data = null;
var route = '/account/auth/logout';
var token_string = token+'&'+version;

var xhr = new XMLHttpRequest();

xhr.addEventListener('readystatechange', function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open('GET', 'https://b2csandbox.payla.co'+route+'?'+token_string);
xhr.setRequestHeader('Accept','application/json');
xhr.setRequestHeader('Authorization', 'Bearer ' + session);
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');

xhr.send(data);

This endpoint is to logout from your profile account.

HTTP Request

GET https://b2csandbox.payla.co/account/auth/logout

it returns the result of request as true or false in the json array

Add/Remove favorite products

<?php
$curl = curl_init();

$route = '/default/favorites/add';
$token_string = $token.'&'.$version;
$data = array(
  "product_id"=> 2038
);

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://b2csandbox.payla.co'.$route.'?'.$token_string,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer ' . $session,
    'X-Requested-With: XMLHttpRequest',
    'Content-Type: application/json; charset=utf-8',
    'Accept: application/json'
  ],
  CURLOPT_POSTFIELDS => json_encode($data)
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo 'cURL Error #:' . $err;
} else {
  echo $response;
}
#!/bin/bash
route='/default/favorites/add'
token_string = "${token}&${version}"

curl "https://b2csandbox.payla.co${route}?${token_string}" \
  -X POST \
  -H "Accept: application/json" \
  -H 'Content-Type: application/json; charset=utf-8' \
  -H 'Authorization: Bearer ${session}' \
  -H 'X-Requested-With: XMLHttpRequest' \
  --DATA '{"product_id":2038}'
var data = JSON.stringify({
  "product_id": 2038
});
var route = '/default/favorites/add';
var token_string = token+'&'+version;

var xhr = new XMLHttpRequest();

xhr.addEventListener('readystatechange', function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open('POST', 'https://b2csandbox.payla.co'+route+'?'+token_string);
xhr.setRequestHeader('Accept','application/json');
xhr.setRequestHeader('Authorization', 'Bearer ' + session);
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
xhr.setRequestHeader("Content-Type", "application/json; charset=utf-8");

xhr.send(data);

This endpoint is to add a product to profile favorite list.

HTTP Request

POST https://b2csandbox.payla.co/default/favorites/add

Same endpoint to delete a product from profile favorite list.

HTTP Request

POST https://b2csandbox.payla.co/default/favorites/delete

both return the result of request as true or false in the json array

List Favorite Products

<?php
$curl = curl_init();

$route = '/default/favorites/list';
$token_string = $token.'&'.$version;

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://b2csandbox.payla.co'.$route.'?'.$token_string.'&after=<OFFSET>',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer ' . $session,
    'X-Requested-With: XMLHttpRequest',
    'Accept: application/json'
  ]
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo 'cURL Error #:' . $err;
} else {
  echo $response;
}
#!/bin/bash
route='/default/favorites/list'
token_string = "${token}&${version}"

curl "https://b2csandbox.payla.co${route}?${token_string}&after=<OFFSET>" \
  -X GET \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer ${session}' \
  -H 'X-Requested-With: XMLHttpRequest'
var data = null;
var route = '/default/favorites/list';
var token_string = token+'&'+version;

var xhr = new XMLHttpRequest();

xhr.addEventListener('readystatechange', function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open('GET', 'https://b2csandbox.payla.co'+route+'?'+token_string+'&after=<OFFSET>');
xhr.setRequestHeader('Accept','application/json');
xhr.setRequestHeader('Authorization', 'Bearer ' + session);
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');

xhr.send(data);

The above command returns JSON structured like this:

  {
    ...,
    "after": 32,
    "favorites": [
      {
        "fav_id": 120,
        "user_id": 1,
        "product_id": 1423,
        "created_on": 1468997475,
        "product_name": "کره پاستوریزه کاله",
        "product_name_encoded": "%DA%A9%D8...",
        "image_address": "https://...",
        "thumbnail": "https://...",
        "price": 2400,
        "final_price": 2385
      }
      ,...
    ]
  }

This endpoint is to get favorite products’ list with an ofset (by default use 0).

HTTP Request

GET https://b2csandbox.payla.co/default/favorites/list

Response Descriptions

Parameter type Description
after int the next offset to get the rest of list
favorites array of objects favorited products’ list

List Orders History

<?php
$curl = curl_init();

$route = '/default/orders/list';
$token_string = $token.'&'.$version;

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://b2csandbox.payla.co'.$route.'?'.$token_string.'&after=<OFFSET>',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer ' . $session,
    'X-Requested-With: XMLHttpRequest',
    'Accept: application/json'
  ]
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo 'cURL Error #:' . $err;
} else {
  echo $response;
}
#!/bin/bash
route='/default/orders/list'
token_string = "${token}&${version}"

curl "https://b2csandbox.payla.co${route}?${token_string}&after=<OFFSET>" \
  -X GET \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer ${session}' \
  -H 'X-Requested-With: XMLHttpRequest'
var data = null;
var route = '/default/orders/list';
var token_string = token+'&'+version;

var xhr = new XMLHttpRequest();

xhr.addEventListener('readystatechange', function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open('GET', 'https://b2csandbox.payla.co'+route+'?'+token_string+'&after=<OFFSET>');
xhr.setRequestHeader('Accept','application/json');
xhr.setRequestHeader('Authorization', 'Bearer ' + session);
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');

xhr.send(data);

The above command returns JSON structured like this:

  {
    ...,
    "after": 32,
    "orders": [
      {
        "order_id": 26672,
        "service_time_hours": "11,13",
        "delivery_day": "1396/01/16",
        "total_price": 138056
        "final_total_price": 123084,
        "final_price": 123084,
        "delivery_cost": 45000,
        "payment_method": "cod",
        "created_on": "یک ماه پیش",
        "modified_on": "20 روز پیش",
        "receiver_fullname": "احمد احمدی",
        "order_status_text": "تکمیل شده",
        "payment_status_text": "پرداخت شده"
      }
      ,...
    ]
  }

This endpoint is to get user orders list with an ofset (by default use 0).

HTTP Request

GET https://b2csandbox.payla.co/default/orders/list

Response Descriptions

Parameter type Description
order_id int the order refrence number
service_time_hours string selected receiving hours seperated by a ,
delivery_day string selected deliver date in Jalali format calandar
total_price int order total price without discounts
final_total_price int order total price after deducting discounts
final_price int order final amount to pay after deducting credits.
delivery_cost int delivery cost
payment_method string payment method
created_on string well formated created on date in persian
modified_on string well formated modified on date in persian
receiver_fullname string receiver name
order_status_text string well formated order status
payment_status_text string well formated payment status

An Order Details

<?php
$curl = curl_init();

$route = '/default/orders/getone';
$token_string = $token.'&'.$version;

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://b2csandbox.payla.co'.$route.'?'.$token_string.'&order_id=<ID>',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer ' . $session,
    'X-Requested-With: XMLHttpRequest',
    'Accept: application/json'
  ]
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo 'cURL Error #:' . $err;
} else {
  echo $response;
}
#!/bin/bash
route='/default/orders/getone'
token_string = "${token}&${version}"

curl "https://b2csandbox.payla.co${route}?${token_string}&order_id=<ID>" \
  -X GET \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer ${session}' \
  -H 'X-Requested-With: XMLHttpRequest'
var data = null;
var route = '/default/orders/getone';
var token_string = token+'&'+version;

var xhr = new XMLHttpRequest();

xhr.addEventListener('readystatechange', function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open('GET', 'https://b2csandbox.payla.co'+route+'?'+token_string+'&order_id=<ID>');
xhr.setRequestHeader('Accept','application/json');
xhr.setRequestHeader('Authorization', 'Bearer ' + session);
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');

xhr.send(data);

The above command returns JSON structured like this:

  {
    ...,
    "order": {
      "order_id": 26672,
      "service_time_hours": "11,13",
      "delivery_day": "1396/01/16",
      "total_price": 42595
      "final_total_price": 45091,
      "final_price": 2836,
      "delivery_cost": 4500,
      "order_status": 1,
      "payment_status": 1,
      "payment_method": "cod",
      "created_on": "یک ماه پیش",
      "modified_on": "20 روز پیش",
      "order_status_text": "تکمیل شده",
      "payment_status_text": "پرداخت شده"
    },
    "order_discount": [
      {
        "id": 183,
        "sub_type": "credit",
        "discount": 40000,
      },
      {
        "id": 182,
        "sub_type": "discount",
        "discount": 2255,
        "discount_code": "p-5stf-test",
      }
    ],
    "user": {
      "receiver_fullname": "احمد احمدی",
      "full_address": "سردار جنگل جنبو، ... ، پلاک ...",
      "location_id": 501,
      "map_lat": 35.70041455580,
      "map_lng": 51.39184028045,
      "postal_code": "12xxxxxxxx",
      "phone_number": "66xxxxxx",
      "mobile_number": "09xxxxxxxxx",
      "location_long_title": "تهران > تهران > منطقه 5 > شهران شمالی"
    },
    "payment_transaction": {
      "transaction_id": 521,
      "order_id": 26672,
      "payment_method": "cod",
      "bank_transaction_id": null,
      "bank_ref_id": null,
      "bank_result_status_id": 0,
      "bank_result_status_message": "pending",
      "transaction_status": "تایید نهایی",
      "created_on": "1395/10/28 16:10:31"
    },
    "order_list": [
      {
        "order_list_id": 1337,
        "order_id": 26672,
        "product_id": 936,
        "price": 12450,
        "quantity": 1,
        "final_price": 1337,
        "product_name": "قلم گوساله آلایش",
        "product_sub_name": "یک و نیم کیلوگرم",
        "barcode": "6262301300256",
        "product_image": "https://..."
      }
      ,...
    ],

  }

This endpoint is to get user order details by order id.

HTTP Request

GET https://b2csandbox.payla.co/default/orders/getone

Get User Credit and Credit list

<?php
$curl = curl_init();

$route = '/default/profile/getcreditlist';
$token_string = $token.'&'.$version;

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://b2csandbox.payla.co'.$route.'?'.$token_string,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer ' . $session,
    'X-Requested-With: XMLHttpRequest',
    'Accept: application/json'
  ]
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo 'cURL Error #:' . $err;
} else {
  echo $response;
}
#!/bin/bash
route='/default/profile/getcreditlist'
token_string = "${token}&${version}"

curl "https://b2csandbox.payla.co${route}?${token_string}" \
  -X GET \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer ${session}' \
  -H 'X-Requested-With: XMLHttpRequest'
var data = null;
var route = '/default/profile/getcreditlist';
var token_string = token+'&'+version;

var xhr = new XMLHttpRequest();

xhr.addEventListener('readystatechange', function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open('GET', 'https://b2csandbox.payla.co'+route+'?'+token_string);
xhr.setRequestHeader('Accept','application/json');
xhr.setRequestHeader('Authorization', 'Bearer ' + session);
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');

xhr.send(data);

The above command returns JSON structured like this:

  {
    ...,
    "result": [
      {
        "id": 1,
        "type": "nounrefundable",
        "description": "100 هزارتومانی ویژه کارکنان",
        "debtor": 400000,
        "creditor": 1000000,
        "source_type": "coupon",
        "title_source_type": "کارت اعتباری",
        "source_id": 1005,
        "created_on": "1395-10-25"
      },
      ...
    ]
  }

This endpoint returns back the user profile information.

HTTP Request

GET https://b2csandbox.payla.co/default/profile/getcreditlist

Response Descriptions

Parameter type Description
debtor int the amount that user has used from credit
creditor int the amount of added credit

HTTP Request

GET https://b2csandbox.payla.co/default/profile/getcredit

Response Descriptions

Parameter type Description
total int The remaining amount of credit
total_toman int The remaining amount of credit in Toman

Add Credits

<?php
$curl = curl_init();

$route = '/default/profile/setcredit';
$token_string = $token.'&'.$version;
$data = array(
  "coupon_code"=> "org-xxxxxxxx",
  "source_type"=> "coupon"
);

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://b2csandbox.payla.co'.$route.'?'.$token_string,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer ' . $session,
    'X-Requested-With: XMLHttpRequest',
    'Content-Type: application/json; charset=utf-8',
    'Accept: application/json'
  ],
  CURLOPT_POSTFIELDS => json_encode($data)
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo 'cURL Error #:' . $err;
} else {
  echo $response;
}
#!/bin/bash
route='/default/profile/setcredit'
token_string = "${token}&${version}"

curl "https://b2csandbox.payla.co${route}?${token_string}" \
  -X POST \
  -H "Accept: application/json" \
  -H 'Content-Type: application/json; charset=utf-8' \
  -H 'Authorization: Bearer ${session}' \
  -H 'X-Requested-With: XMLHttpRequest' \
  --DATA '{"coupon_code":"org-xxxxxxxx","source_type":"coupon"}'
var data = JSON.stringify({
  "coupon_code": "org-xxxxxxxx",
  "source_type": "coupon"
});
var route = '/default/profile/setcredit';
var token_string = token+'&'+version;

var xhr = new XMLHttpRequest();

xhr.addEventListener('readystatechange', function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open('POST', 'https://b2csandbox.payla.co'+route+'?'+token_string);
xhr.setRequestHeader('Accept','application/json');
xhr.setRequestHeader('Authorization', 'Bearer ' + session);
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
xhr.setRequestHeader("Content-Type", "application/json; charset=utf-8");

xhr.send(data);

This endpoint is to add a valid credit to profile.

HTTP Request

POST https://b2csandbox.payla.co/default/profile/setcredit

Account/Session Basket or Merge them

<?php
$curl = curl_init();

$route = '/default/basket/operation';
$token_string = $token.'&'.$version;
$data = array(
  "action_name"=> "merge"
);

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://b2csandbox.payla.co'.$route.'?'.$token_string,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer ' . $session,
    'X-Requested-With: XMLHttpRequest',
    'Content-Type: application/json; charset=utf-8',
    'Accept: application/json'
  ],
  CURLOPT_POSTFIELDS => json_encode($data)
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo 'cURL Error #:' . $err;
} else {
  echo $response;
}
#!/bin/bash
route='/default/basket/operation'
token_string = "${token}&${version}"

curl "https://b2csandbox.payla.co${route}?${token_string}" \
  -X POST \
  -H "Accept: application/json" \
  -H 'Content-Type: application/json; charset=utf-8' \
  -H 'Authorization: Bearer ${session}' \
  -H 'X-Requested-With: XMLHttpRequest' \
  --DATA '{"action_name":"merge"}'
var data = JSON.stringify({
  "action_name": "merge"
});
var route = '/default/basket/operation';
var token_string = token+'&'+version;

var xhr = new XMLHttpRequest();

xhr.addEventListener('readystatechange', function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open('POST', 'https://b2csandbox.payla.co'+route+'?'+token_string);
xhr.setRequestHeader('Accept','application/json');
xhr.setRequestHeader('Authorization', 'Bearer ' + session);
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
xhr.setRequestHeader("Content-Type", "application/json; charset=utf-8");

xhr.send(data);

Befor login basket saves in Session and after login it saves in Account. This endpoint help user to choose between session or account basket or merge them after login.

HTTP Request

POST https://b2csandbox.payla.co/default/basket/operation

it returns the result of request as true or false in the json array

Request Parameters

Parameter type Description
action_name string a string between (merge, session, account).

Get User Address list

<?php
$curl = curl_init();

$route = '/default/useraddress/list';
$token_string = $token.'&'.$version;

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://b2csandbox.payla.co'.$route.'?'.$token_string,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer ' . $session,
    'X-Requested-With: XMLHttpRequest',
    'Accept: application/json'
  ]
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo 'cURL Error #:' . $err;
} else {
  echo $response;
}
#!/bin/bash
route='/default/useraddress/list'
token_string = "${token}&${version}"

curl "https://b2csandbox.payla.co${route}?${token_string}" \
  -X GET \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer ${session}' \
  -H 'X-Requested-With: XMLHttpRequest'
var data = null;
var route = '/default/useraddress/list';
var token_string = token+'&'+version;

var xhr = new XMLHttpRequest();

xhr.addEventListener('readystatechange', function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open('GET', 'https://b2csandbox.payla.co'+route+'?'+token_string);
xhr.setRequestHeader('Accept','application/json');
xhr.setRequestHeader('Authorization', 'Bearer ' + session);
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');

xhr.send(data);

The above command returns JSON structured like this:

  {
    ...,
    "addresses": [
      {
        "utl_id": 1,
        "location_id": 501,
        "last_selected": 1,
        "full_address": "خیبان گلستان، ...",
        "postal_code": "12xxxxxxx",
        "receiver_fullname": "احمد احمدی",
        "phone_number": "66xxxxxx",
        "mobile_number": "09xxxxxxxxx",
        "location_title": "شهران شمالی",
        "location_long_title": "استان تهران > تهران > منطقه 5 > شهران شمالی"
      },
      ...
    ]
  }

This endpoint returns back the user selected addresses. last_selected for primary selected address is 1.

HTTP Request

GET https://b2csandbox.payla.co/default/useraddress/list

Set As Primary/Delete an Address

<?php
$curl = curl_init();

$route = '/default/useraddress/setprimarylocation';
$token_string = $token.'&'.$version;
$data = array(
  "utl_id"=> 5
);

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://b2csandbox.payla.co'.$route.'?'.$token_string,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer ' . $session,
    'X-Requested-With: XMLHttpRequest',
    'Content-Type: application/json; charset=utf-8',
    'Accept: application/json'
  ],
  CURLOPT_POSTFIELDS => json_encode($data)
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo 'cURL Error #:' . $err;
} else {
  echo $response;
}
#!/bin/bash
route='/default/useraddress/setprimarylocation'
token_string = "${token}&${version}"

curl "https://b2csandbox.payla.co${route}?${token_string}" \
  -X POST \
  -H "Accept: application/json" \
  -H 'Content-Type: application/json; charset=utf-8' \
  -H 'Authorization: Bearer ${session}' \
  -H 'X-Requested-With: XMLHttpRequest' \
  --DATA '{"utl_id":5}'
var data = JSON.stringify({
  "utl_id": 5
});
var route = '/default/useraddress/setprimarylocation';
var token_string = token+'&'+version;

var xhr = new XMLHttpRequest();

xhr.addEventListener('readystatechange', function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open('POST', 'https://b2csandbox.payla.co'+route+'?'+token_string);
xhr.setRequestHeader('Accept','application/json');
xhr.setRequestHeader('Authorization', 'Bearer ' + session);
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
xhr.setRequestHeader("Content-Type", "application/json; charset=utf-8");

xhr.send(data);

these endpoints are for select an address as user primary address and delete an address according to given utl_id.

HTTP Request

POST https://b2csandbox.payla.co/default/useraddress/setprimarylocation

it returns the result of request as true or false in the json array

HTTP Request

POST https://b2csandbox.payla.co/default/useraddress/delete

it returns the result of request as true or false in the json array

Add/Edit Address

<?php
$curl = curl_init();

$route = '/default/useraddress/edit';
$token_string = $token.'&'.$version;
$data = array(
  "utl_id"=> 5, //unset if you are adding an address
  "selectedArea" => 310,
  "get_user_locations" => true,
  "map_lat" => "35.70041455580",
  "map_lng" => "51.39184028045",
  "receiver_fullname"=> "احمد احمدی",
  "postal_code"=> "12xxxxxxx",
  "phone_number"=> "66xxxxxx",
  "mobile_number"=> "09xxxxxxxxx",
  "full_address"=> "خیبان گلستان، ..."
);

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://b2csandbox.payla.co'.$route.'?'.$token_string,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer ' . $session,
    'X-Requested-With: XMLHttpRequest',
    'Content-Type: application/json; charset=utf-8',
    'Accept: application/json'
  ],
  CURLOPT_POSTFIELDS => json_encode($data)
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo 'cURL Error #:' . $err;
} else {
  echo $response;
}
#!/bin/bash
route='/default/useraddress/edit'
token_string = "${token}&${version}"

curl "https://b2csandbox.payla.co${route}?${token_string}" \
  -X POST \
  -H "Accept: application/json" \
  -H 'Content-Type: application/json; charset=utf-8' \
  -H 'Authorization: Bearer ${session}' \
  -H 'X-Requested-With: XMLHttpRequest' \
  --DATA '{"utl_id":5,"selectedArea":310,"get_user_locations":true,"map_lat":"35.70041455580","map_lng":"51.39184028045","receiver_fullname":"احمد احمدی","postal_code":"12xxxxxxx","phone_number":"66xxxxxx","mobile_number":"09xxxxxxxxx","full_address":"خیبان گلستان، ..."}'
var data = JSON.stringify({
  "utl_id": 5, //unset if you are adding an address
  "selectedArea": 310,
  "get_user_locations": true,
  "map_lat": "35.70041455580",
  "map_lng": "51.39184028045",
  "receiver_fullname": "احمد احمدی",
  "postal_code": "12xxxxxxx",
  "phone_number": "66xxxxxx",
  "mobile_number": "09xxxxxxxxx",
  "full_address": "خیبان گلستان، ..."
});
var route = '/default/useraddress/edit';
var token_string = token+'&'+version;

var xhr = new XMLHttpRequest();

xhr.addEventListener('readystatechange', function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open('POST', 'https://b2csandbox.payla.co'+route+'?'+token_string);
xhr.setRequestHeader('Accept','application/json');
xhr.setRequestHeader('Authorization', 'Bearer ' + session);
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
xhr.setRequestHeader("Content-Type", "application/json; charset=utf-8");

xhr.send(data);

This endpoint is to add or edit an address. to edit send utl_id as parameters.

HTTP Request

POST https://b2csandbox.payla.co/default/useraddress/edit

it returns the result of request as true or false and user addresses list in the json array

Request Parameters

Parameter type Description
utl_id int user_to_location id wich you can get from user addersses if already have one and you want to edit the address. leave it blank if it’s a new address to save
selectedArea int location id (get from location list)
map_lat float map point lat
map_lng float map point lng
receiver_fullname sting receiver full name
postal_code string receive address postal code
phone_number numeric receiver phone number
mobile_number numeric receiver mobile number
full_address string receive full address
get_user_locations boolean set it true to get user address list after edit an address

Errors

The API uses the following error codes:

Error Code Meaning
400 Bad Request – Your request sucks
401 Unauthorized – Your API key is wrong
403 Forbidden – The kitten requested is hidden for administrators only
404 Not Found – The specified kitten could not be found
405 Method Not Allowed – You tried to access a kitten with an invalid method
406 Not Acceptable – You requested a format that isn’t json
410 Gone – The kitten requested has been removed from our servers
418 I’m a teapot
429 Too Many Requests – You’re requesting too many kittens! Slow down!
500 Internal Server Error – We had a problem with our server. Try again later.
503 Service Unavailable – We’re temporarily offline for maintenance. Please try again later.