Table of Contents
Introduction
The mydealzone REST APIs allows data to be created, read, updated, and deleted using requests in JSON format and using basic authentication or REST API Authentication methods and standard HTTP verbs which are understood by most HTTP clients.
Payments Integration/fund collection Options
Developers have 2 options to integrate collections or payments.
- Integrate Mydealzone’s payment gateway.
- integrate there custom gateway.
Custom gateway integration is allowed for banks only. Mydealzone shall maintain collections account with developer banks where settlements shall be made. A daily settlement schedule shall be required.
For non-bank developers, Mydealzone payment gateway APIs shall be shared. Customer order cycles shall be closed following payment verification. Webhook notifications shall be sent back to the developer partner for reporting and in-app customer notification.
Developer Services
- Create customer account.
- integrate payment/collections system.
- Extract customer interests.
- Pull and display packages based on customer interests.
- process orders on behalf of customer.
- Send in-app transaction notification to customer.
Request/Response Format
The default response format is JSON. Requests with a message-body use plain JSON to set or update resource attributes. Successful requests will return a 200 OK
HTTP status.
Some general information about responses:
- Dates are returned in ISO8601 format:
YYYY-MM-DDTHH:MM:SS
- Resource IDs are returned as integers.
- Any decimal monetary amount, such as prices or totals, will be returned as strings with two decimal places.
- Other amounts, such as item counts, are returned as integers.
- Blank fields are generally included as
null
or emtpy string instead of being omitted.
Errors
Occasionally you might encounter errors when accessing the REST API. There are four possible types:
Error Code | Error Type |
---|---|
400 Bad Request | Invalid request, e.g. using an unsupported HTTP method |
401 Unauthorized | Authentication or permission error, e.g. incorrect API keys |
404 Not Found | Requests to resources that don’t exist or are missing |
500 Internal Server Error | Server error |
Errors return both an appropriate HTTP status code and response object which contains a code
, message
and data
attribute.
WP REST API error example:
{
"code": "rest_no_route",
"message": "No route was found matching the URL and request method",
"data": {
"status": 404
}
}
Pagination
Requests that return multiple items will be paginated to 10 items by default. This default can be changed by the site administrator by changing the posts_per_page
option. Alternatively the items per page can be specified with the ?per_page
parameter:
GET /orders?per_page=15
You can specify further pages with the ?page
parameter:
GET /orders?page=2
You may also specify the offset from the first resource using the ?offset
parameter:
GET /orders?offset=5
Page number is 1-based and omitting the ?page
parameter will return the first page.
The total number of resources and pages are always included in the X-WP-Total
and X-WP-TotalPages
HTTP headers.
API Authentcation
REST API keys
Pre-generated keys can be used to authenticate use of the REST API endpoints. New keys shall be provided to developers by the admin.
Authentication over HTTPS
You may use HTTP Basic Auth by providing the REST API Consumer Key as the username and the REST API Consumer Secret as the password.
Occasionally some servers may not parse the Authorization header correctly (if you see a “Consumer key is missing” error when authenticating over SSL, you have a server issue). In this case, you may provide the consumer key/secret as query string parameters instead.
Endpoints
Customer interests/package categories
The customer interests API allows you to create, view, update, and delete individual, or a batch, of categories.
List all product categories or interest areas
This API lets you retrieve all product categories or customer interest areas.
HTTP request
GET /wp-json/wc/v3/products/categories
JSON response example:
[
{
"id": 15,
"name": "Albums",
"slug": "albums",
"parent": 11,
"description": "",
"display": "default",
"image": [],
"menu_order": 0,
"count": 4,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v3/products/categories/15"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v3/products/categories"
}
],
"up": [
{
"href": "https://example.com/wp-json/wc/v3/products/categories/11"
}
]
}
},
{
"id": 9,
"name": "Clothing",
"slug": "clothing",
"parent": 0,
"description": "",
"display": "default",
"image": {
"id": 730,
"date_created": "2017-03-23T00:01:07",
"date_created_gmt": "2017-03-23T03:01:07",
"date_modified": "2017-03-23T00:01:07",
"date_modified_gmt": "2017-03-23T03:01:07",
"src": "https://example.com/wp-content/uploads/2017/03/T_2_front.jpg",
"name": "",
"alt": ""
},
"menu_order": 0,
"count": 36,
"_links": {
"self": [
{
"href": "https://example/wp-json/wc/v3/products/categories/9"
}
],
"collection": [
{
"href": "https://example/wp-json/wc/v3/products/categories"
}
]
}
},
{
"id": 10,
"name": "Hoodies",
"slug": "hoodies",
"parent": 9,
"description": "",
"display": "default",
"image": [],
"menu_order": 0,
"count": 6,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v3/products/categories/10"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v3/products/categories"
}
],
"up": [
{
"href": "https://example.com/wp-json/wc/v3/products/categories/9"
}
]
}
},
{
"id": 11,
"name": "Music",
"slug": "music",
"parent": 0,
"description": "",
"display": "default",
"image": [],
"menu_order": 0,
"count": 7,
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v3/products/categories/11"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v3/products/categories"
}
]
}
}
]
List interest areas by customer
This API lets you retrieve all customer interest areas based on the customer’s phone number
HTTP request
GET /wp-json/wc/v3/products/categories/msisdn
Packages
The packages API allows you to create, view, update, and delete individual, or a batch, of packages.
List all packages
This API helps you to view all the products.
HTTP request
GET /wp-json/wc/v3/products
Available parameters
Parameter | Type | Description |
---|---|---|
context | string | Scope under which the request is made; determines fields present in response. Options: view and edit . Default is view . |
page | integer | Current page of the collection. Default is 1 . |
per_page | integer | Maximum number of items to be returned in result set. Default is 10 . |
search | string | Limit results to those matching a string. |
after | string | Limit response to resources published after a given ISO8601 compliant date. |
before | string | Limit response to resources published before a given ISO8601 compliant date. |
exclude | array | Ensure result set excludes specific IDs. |
include | array | Limit result set to specific ids. |
offset | integer | Offset the result set by a specific number of items. |
order | string | Order sort attribute ascending or descending. Options: asc and desc . Default is desc . |
orderby | string | Sort collection by object attribute. Options: date , id , include , title , slug , price , popularity and rating . Default is date . |
parent | array | Limit result set to those of particular parent IDs. |
parent_exclude | array | Limit result set to all items except those of a particular parent ID. |
slug | string | Limit result set to products with a specific slug. |
status | string | Limit result set to products assigned a specific status. Options: any , draft , pending , private and publish . Default is any . |
type | string | Limit result set to products assigned a specific type. Options: simple , grouped , external and variable . |
sku | string | Limit result set to products with a specific SKU. |
featured | boolean | Limit result set to featured products. |
category | string | Limit result set to products assigned a specific category ID. |
tag | string | Limit result set to products assigned a specific tag ID. |
shipping_class | string | Limit result set to products assigned a specific shipping class ID. |
attribute | string | Limit result set to products with a specific attribute. |
attribute_term | string | Limit result set to products with a specific attribute term ID (required an assigned attribute). |
tax_class | string | Limit result set to products with a specific tax class. Default options: standard , reduced-rate and zero-rate . |
on_sale | boolean | Limit result set to products on sale. |
min_price | string | Limit result set to products based on a minimum price. |
max_price | string | Limit result set to products based on a maximum price. |
stock_status | string | Limit result set to products with specified stock status. Options: instock , outofstock and onbackorder . |
JSON response example:
{
"id": 794,
"name": "Premium Quality",
"slug": "premium-quality-19",
"permalink": "https://example.com/product/premium-quality-19/",
"date_created": "2017-03-23T17:01:14",
"date_created_gmt": "2017-03-23T20:01:14",
"date_modified": "2017-03-23T17:01:14",
"date_modified_gmt": "2017-03-23T20:01:14",
"type": "simple",
"status": "publish",
"featured": false,
"catalog_visibility": "visible",
"description": "<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>\n",
"short_description": "<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</p>\n",
"sku": "",
"price": "21.99",
"regular_price": "21.99",
"sale_price": "",
"date_on_sale_from": null,
"date_on_sale_from_gmt": null,
"date_on_sale_to": null,
"date_on_sale_to_gmt": null,
"price_html": "<span class=\"woocommerce-Price-amount amount\"><span class=\"woocommerce-Price-currencySymbol\">$</span>21.99</span>",
"on_sale": false,
"purchasable": true,
"total_sales": 0,
"virtual": false,
"downloadable": false,
"downloads": [],
"download_limit": -1,
"download_expiry": -1,
"external_url": "",
"button_text": "",
"tax_status": "taxable",
"tax_class": "",
"manage_stock": false,
"stock_quantity": null,
"stock_status": "instock",
"backorders": "no",
"backorders_allowed": false,
"backordered": false,
"sold_individually": false,
"weight": "",
"dimensions": {
"length": "",
"width": "",
"height": ""
},
"shipping_required": true,
"shipping_taxable": true,
"shipping_class": "",
"shipping_class_id": 0,
"reviews_allowed": true,
"average_rating": "0.00",
"rating_count": 0,
"related_ids": [
53,
40,
56,
479,
99
],
"upsell_ids": [],
"cross_sell_ids": [],
"parent_id": 0,
"purchase_note": "",
"categories": [
{
"id": 9,
"name": "Clothing",
"slug": "clothing"
},
{
"id": 14,
"name": "T-shirts",
"slug": "t-shirts"
}
],
"tags": [],
"images": [
{
"id": 792,
"date_created": "2017-03-23T14:01:13",
"date_created_gmt": "2017-03-23T20:01:13",
"date_modified": "2017-03-23T14:01:13",
"date_modified_gmt": "2017-03-23T20:01:13",
"src": "https://example.com/wp-content/uploads/2017/03/T_2_front-4.jpg",
"name": "",
"alt": ""
},
{
"id": 793,
"date_created": "2017-03-23T14:01:14",
"date_created_gmt": "2017-03-23T20:01:14",
"date_modified": "2017-03-23T14:01:14",
"date_modified_gmt": "2017-03-23T20:01:14",
"src": "https://example.com/wp-content/uploads/2017/03/T_2_back-2.jpg",
"name": "",
"alt": ""
}
],
"attributes": [],
"default_attributes": [],
"variations": [],
"grouped_products": [],
"menu_order": 0,
"meta_data": [],
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v3/products/794"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v3/products"
}
]
}
}
Retrieve a package
This API lets you retrieve and view a specific package by ID.
HTTP request
GET /wp-json/wc/v3/products/<id>
JSON response example:
{
"id": 794,
"name": "Premium Quality",
"slug": "premium-quality-19",
"permalink": "https://example.com/product/premium-quality-19/",
"date_created": "2017-03-23T17:01:14",
"date_created_gmt": "2017-03-23T20:01:14",
"date_modified": "2017-03-23T17:01:14",
"date_modified_gmt": "2017-03-23T20:01:14",
"type": "simple",
"status": "publish",
"featured": false,
"catalog_visibility": "visible",
"description": "<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>\n",
"short_description": "<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</p>\n",
"sku": "",
"price": "21.99",
"regular_price": "21.99",
"sale_price": "",
"date_on_sale_from": null,
"date_on_sale_from_gmt": null,
"date_on_sale_to": null,
"date_on_sale_to_gmt": null,
"price_html": "<span class=\"woocommerce-Price-amount amount\"><span class=\"woocommerce-Price-currencySymbol\">$</span>21.99</span>",
"on_sale": false,
"purchasable": true,
"total_sales": 0,
"virtual": false,
"downloadable": false,
"downloads": [],
"download_limit": -1,
"download_expiry": -1,
"external_url": "",
"button_text": "",
"tax_status": "taxable",
"tax_class": "",
"manage_stock": false,
"stock_quantity": null,
"stock_status": "instock",
"backorders": "no",
"backorders_allowed": false,
"backordered": false,
"sold_individually": false,
"weight": "",
"dimensions": {
"length": "",
"width": "",
"height": ""
},
"shipping_required": true,
"shipping_taxable": true,
"shipping_class": "",
"shipping_class_id": 0,
"reviews_allowed": true,
"average_rating": "0.00",
"rating_count": 0,
"related_ids": [
53,
40,
56,
479,
99
],
"upsell_ids": [],
"cross_sell_ids": [],
"parent_id": 0,
"purchase_note": "",
"categories": [
{
"id": 9,
"name": "Clothing",
"slug": "clothing"
},
{
"id": 14,
"name": "T-shirts",
"slug": "t-shirts"
}
],
"tags": [],
"images": [
{
"id": 792,
"date_created": "2017-03-23T14:01:13",
"date_created_gmt": "2017-03-23T20:01:13",
"date_modified": "2017-03-23T14:01:13",
"date_modified_gmt": "2017-03-23T20:01:13",
"src": "https://example.com/wp-content/uploads/2017/03/T_2_front-4.jpg",
"name": "",
"alt": ""
},
{
"id": 793,
"date_created": "2017-03-23T14:01:14",
"date_created_gmt": "2017-03-23T20:01:14",
"date_modified": "2017-03-23T14:01:14",
"date_modified_gmt": "2017-03-23T20:01:14",
"src": "https://example.com/wp-content/uploads/2017/03/T_2_back-2.jpg",
"name": "",
"alt": ""
}
],
"attributes": [],
"default_attributes": [],
"variations": [],
"grouped_products": [],
"menu_order": 0,
"meta_data": [],
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v3/products/794"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v3/products"
}
]
}
}
Orders
The orders API allows you to create, view, update, and delete individual, or a batch, of orders.
Create an order
This API helps you to create a new order.
HTTP request
POST /wp-json/wc/v3/orders
Example of create a paid order’s:
<?php
$data = [
'payment_method' => 'mydealzone',
'payment_method_title' => 'Mydealzone Pay',
'set_paid' => true,
'billing' => [
'first_name' => 'John',
'last_name' => 'Doe',
'address_1' => '969 Market',
'address_2' => '',
'city' => 'San Francisco',
'state' => 'CA',
'postcode' => '94103',
'country' => 'US',
'email' => 'john.doe@example.com',
'phone' => '(555) 555-5555'
],
'shipping' => [
'first_name' => 'John',
'last_name' => 'Doe',
'address_1' => '969 Market',
'address_2' => '',
'city' => 'San Francisco',
'state' => 'CA',
'postcode' => '94103',
'country' => 'US'
],
'line_items' => [
[
'product_id' => 93,
'quantity' => 2
],
[
'product_id' => 22,
'variation_id' => 23,
'quantity' => 1
]
],
'shipping_lines' => [
[
'method_id' => 'flat_rate',
'method_title' => 'Flat Rate',
'total' => '10.00'
]
]
];
print_r($woocommerce->post('orders', $data));
JSON response example:
{
"id": 727,
"parent_id": 0,
"number": "727",
"order_key": "wc_order_58d2d042d1d",
"created_via": "rest-api",
"version": "3.0.0",
"status": "processing",
"currency": "USD",
"date_created": "2017-03-22T16:28:02",
"date_created_gmt": "2017-03-22T19:28:02",
"date_modified": "2017-03-22T16:28:08",
"date_modified_gmt": "2017-03-22T19:28:08",
"discount_total": "0.00",
"discount_tax": "0.00",
"shipping_total": "10.00",
"shipping_tax": "0.00",
"cart_tax": "1.35",
"total": "29.35",
"total_tax": "1.35",
"prices_include_tax": false,
"customer_id": 0,
"customer_ip_address": "",
"customer_user_agent": "",
"customer_note": "",
"billing": {
"first_name": "John",
"last_name": "Doe",
"company": "",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US",
"email": "john.doe@example.com",
"phone": "(555) 555-5555"
},
"shipping": {
"first_name": "John",
"last_name": "Doe",
"company": "",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US"
},
"payment_method": "bacs",
"payment_method_title": "Direct Bank Transfer",
"transaction_id": "",
"date_paid": "2017-03-22T16:28:08",
"date_paid_gmt": "2017-03-22T19:28:08",
"date_completed": null,
"date_completed_gmt": null,
"cart_hash": "",
"meta_data": [
{
"id": 13106,
"key": "_download_permissions_granted",
"value": "yes"
}
],
"line_items": [
{
"id": 315,
"name": "Woo Single #1",
"product_id": 93,
"variation_id": 0,
"quantity": 2,
"tax_class": "",
"subtotal": "6.00",
"subtotal_tax": "0.45",
"total": "6.00",
"total_tax": "0.45",
"taxes": [
{
"id": 75,
"total": "0.45",
"subtotal": "0.45"
}
],
"meta_data": [],
"sku": "",
"price": 3
},
{
"id": 316,
"name": "Ship Your Idea – Color: Black, Size: M Test",
"product_id": 22,
"variation_id": 23,
"quantity": 1,
"tax_class": "",
"subtotal": "12.00",
"subtotal_tax": "0.90",
"total": "12.00",
"total_tax": "0.90",
"taxes": [
{
"id": 75,
"total": "0.9",
"subtotal": "0.9"
}
],
"meta_data": [
{
"id": 2095,
"key": "pa_color",
"value": "black"
},
{
"id": 2096,
"key": "size",
"value": "M Test"
}
],
"sku": "Bar3",
"price": 12
}
],
"tax_lines": [
{
"id": 318,
"rate_code": "US-CA-STATE TAX",
"rate_id": 75,
"label": "State Tax",
"compound": false,
"tax_total": "1.35",
"shipping_tax_total": "0.00",
"meta_data": []
}
],
"shipping_lines": [
{
"id": 317,
"method_title": "Flat Rate",
"method_id": "flat_rate",
"total": "10.00",
"total_tax": "0.00",
"taxes": [],
"meta_data": []
}
],
"fee_lines": [],
"coupon_lines": [],
"refunds": [],
"_links": {
"self": [
{
"href": "https://example.com/wp-json/wc/v3/orders/727"
}
],
"collection": [
{
"href": "https://example.com/wp-json/wc/v3/orders"
}
]
}
}