Testing API

#1
28/05/2015 - 13:20

Scott D

Member
Hi All,

Newbie to tshirtgang and good to be here.

Okay, I created a custom script to sell shirts. It collects payment via Paypal and that part seems to work.

I just now installed the API. So is there a way I can run a test to make sure my order is getting through properly?

Thanks in advance
#2
28/05/2015 - 13:22
Avatar

Andrew Lyle

Administrator
Hi,

You can just test Create Orders on our live server. You can also create a test user for testing purposes if you require.

Andrew

Developer / Project Manager
Tshirtgang.com
Support Ticket
Twitter: @phpandrew
#3
28/05/2015 - 13:32

Scott D

Member
Thanks Andrew.

How do I do that exactly? This is a custom script on my domain and just installed the API from my account.

Was hoping to place a test order on my website and see what you are receiving, if anything, on your end.

Right now, it processes a payment in Paypal, if I place an order. Do I have to put the script in Paypal Sandbox mode first before running the order through?

Then how would I be able to see the order results on your end in this test?

Sorry, but I'm not a developer and trying to figure this part out.

Thanks
Scott
#4
28/05/2015 - 13:45
Avatar

Andrew Lyle

Administrator
Hi Scott,

Take a look at our CreateOrder API to see how to create an order on tshirtgang:

http://www.tshirtgang.com/cp/api/createorder

I'm not sure what you mean by you "Installed the API", there isn't anything from tshirtgang to install. Did you install a third-party plugin? if so, i would recommend contacting the developer of the project to see how to accomplish what you are trying to do.

Andrew

Developer / Project Manager
Tshirtgang.com
Support Ticket
Twitter: @phpandrew
#5
28/05/2015 - 13:57

Scott D

Member
Thanks Andrew,

I guess I should say I added the API code that is from my TShirtgang Account Dashboard to the script where it asks for it.

I thought by adding the API code and running an order through with Paypal in Sandbox mode, would show an order on my dashboard here on tshirtgang.

I just tried it and it didn't work, I guess, since I'm not seeing any orders in the Orders Tab.

I will look now into that createorder api link you gave me.

Thanks,
Scott
#6
28/05/2015 - 14:21
Avatar

Andrew Lyle

Administrator
I'm not seeing any error messages for your account, so there is likely a bug on your end of the code.

You will receive a response from our API whether it's successful or not.

You will also need to create products under your account. You also haven't explained what code you're using or plugin. Are you using our sample code on our API page?

Developer / Project Manager
Tshirtgang.com
Support Ticket
Twitter: @phpandrew
#7
28/05/2015 - 14:47

Scott D

Member
Okay, I added the product I'm testing with to my account.
You will notice there is a blank spot in the design for a name field. That name field part is generated by the script.

The script's functions.php file has this bit if code in it....

$xml=post_curl($url,$xml_p,"post");
}else{
if($p_id!="" && $p_id>0){
$url="https://www.tshirtgang.com/api/CreateOrder/";
//// print_r($form);
$xml_o='<?xml version="1.0" encoding="utf-8"?>
<OrderForm>
<Auth>
<key>'.$settings['step2'].'</key>
</Auth>
<Order>
<fullname>'.htmlentities($name).'</fullname>
<address1>'.htmlentities($form['address']).'</address1>
<address2></address2>
<city>'.htmlentities($form['city']).'</city>
<postal>'.htmlentities($form['zip code']).'</postal>
<state>'.htmlentities($form['state']).'</state>
<country>'.htmlentities($form['country']).'</country>
<phonenumber></phonenumber>
<sku>'.htmlentities($p_id).'</sku>
<size>'.htmlentities($s[$form['shirt size']]).'</size>
<style>'.htmlentities($sel_style).'</style>
<color>'.htmlentities($sel_color).'</color>
<quantity>1</quantity>
<priorityShipping>0</priorityShipping>
<comments>'.htmlentities($row['comments']).'</comments>
</Order>
</OrderForm>';
$xml=post_curl($url,$xml_o,"post");
}
}
return $xml;

To me, it looks like it's in-line with what the API requirements are.

#8
28/05/2015 - 14:52
Avatar

Andrew Lyle

Administrator
Hi Scott,

While that looks correct at first glance, I do not see your cURL script for actually sending the data.

You may want to look at your post_curl function and determine where the problems are.

I would recommend looking at our sample PHP code here:
http://www.tshirtgang.com/cp/api

Developer / Project Manager
Tshirtgang.com
Support Ticket
Twitter: @phpandrew
#9
28/05/2015 - 15:16

Scott D

Member
Hi Andrew,

There are only two .php files that I can see that contain the api code for CreateOrder, CreateProduct, and CreateSellerCategories. Instead of posting the code here, I've attached the two files.

Maybe you can see something out of place?

Thanks,
Scott
#10
28/05/2015 - 15:19

Scott D

Member
Oops I guess I can't attach a zip file.

You must be signed in to post.