Skip to content

FameThemes/teesight-api-docs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 

Repository files navigation

API end point

LIVE: https://seller.teesight.com/wp-json/ts/v1/order

TEST: https://server.teesight.com/wp-json/ts/v1/order

To get app token, login to your account then go to Orders -> Webhook URL copy value in field App Token. See https://cl.ly/8261633d0669

Submit new order

$url = 'https://server.teesight.com/wp-json/ts/v1/order';
$token =  'a1befc42-d425-46fe-a001-d255553f2d31';
$order_data = array();


$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode( $order_data ) );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );

$headers = [
	'Content-Type: application/json; charset=utf-8',
	'access-token: '.$token,
];
curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers );
$server_output = curl_exec( $ch );
curl_close( $ch );

// Dump respond
var_dump( json_decode(  $server_output, true ) );
    

Example order data here https://github.com/FameThemes/teesight-api-docs/blob/master/example-order.json

Example response data success

{
	"code" : "success",
	"status" : 200,
}

Example response data error

{
	"code" : "error",
	"error_code" : "error_code",
	"message" : "Error message",
	"status" : 200,
}

Example webhook reciever

When an order item tracking code is changed, we will send a webhook to your site.

First, go to Orders -> Webhook URL to add your Webhook, see: https://cl.ly/5c8f48e18696

To receive the data, you can follow this code:

if ( isset( $_SERVER['HTTP_X_TS_WEBHOOK_SOURCE'] ) && false !== strpos( $_SERVER['HTTP_X_TS_WEBHOOK_SOURCE'], 'teesight' ) ) {
	$input = @file_get_contents( 'php://input' );
	$data = wp_parse_args(
		json_decode( $input, true ), 
		array(
			'order_id'      => '',
			'line_item_id'  => '',
			'tracking_code' => '',
			'sent_from'     => '',
			'action'        => '',
		) 
	);

	if ( $data['order_id'] && $data['tracking_code'] ) {
		// Do your stuff.
	}
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published