App42 Cloud API

Windows Phone Cloud SDK

Shopping Cart

This is Cloud Persistent Shopping Cart Service. App Developers can use this to create a Shopping Cart. Add Items and Check Out items. It also maintains the transactions and the corresponding Payment Status. The Payment Gateway interface is not provided by the Platform. It is left to the App developer how he wants to do the Payment Integration. This can be used along with Catalogue or used independently. The Cart service can be used along with Catalogue service to create an end to end Shopping feature for a Mobile and Web App

In order to use the various functions available under a particular API, a developer will have to create an instance of ServiceAPI by passing the apiKey and the secretKey which has been received while creating an app.

	ServiceAPI api;
	api = new ServiceAPI("<API_KEY>","<SECRET_KEY>");
                            

After initialization, developer needs to call the BuildXXXService method on ServiceAPI instance to get the instance of the particular API that you wish to build. For example, To build an instance of CartService, BuildCartService() method needs to be called.

CartService cartService = api.BuildCartService();

Once the API instance has been retrieved, You are ready to use the functions available for that particular API.

The Windows Phone API's work in an asynchronous mode that means the response will not be available immediately and all the API methods would not return any value and have return type as void. The response will be returned in callback methods which the caller will provide to the calling method.
As mentioned above that the response will be returned in callback methods, every API method is taking instance of App42Callback (as the last parameter) which will have the implementation of 2 methods: OnSuccess & OnException.(as shown below)

	public class CallBack : App42Callback
	{
		public override void OnSuccess(Object obj)
		{
			Cart cart = (Cart) obj;
			//Do whatever you want with the user object
		}
		public override void OnException(App42Exception e)
		{
			//Do whatever you want with the exception
		}
	}
                            

The callback methods will return the response in the form of Object which will have to be type cast to the object domain object (e.g. App42Response / Cart / IList in this case) The Domain object have the accessor / mutator to access the available properties for that object. You can get the response in the form of JSON as well. We have provided the JSON response with every function detail which can be retrieved by calling the ToString() on the returned object.

public override void OnSuccess(Object obj)
{
       Cart cart = (Cart) obj;
        String cartName = cart.GetUserName(); 
       String cartId = cart.GetCartId(); 
        String jsonResponse = cart.ToString(); /* returns the response in JSON format. */ 
}
                            

The functions available under Shopping Cart API can throw some exceptions in abnormal conditions. Example of the same has been given below.

E.g. If App developer is requesting a cart with id which is not in database, the function will throw the App42Exception (as shown below) with message as "Not Found" and the appErrorCode as "3301" and the details as "Cart with the id '{Id}' does not Exist".

		public override void OnException(App42Exception ex)
		{
			int appErrorCode = ex.GetAppErrorCode();
			int httpErrorCode = ex.GetHttpErrorCode();
			
			String jsonText = ex.GetMessage(); /* returns the Exception text in JSON format. (as shown below)*/	
		}
                            
	{
		"app42Fault": {
			"httpErrorCode": 404,
			"appErrorCode": 3301,
			"message": "Not Found",
			"details": "Cart with the id '1145' does not Exist"
		}
	}							

Below are the HTTP Error Codes and their description, the function under the Shopping Cart API can throw.

/*
1400 - BAD REQUEST - The Request parameters are invalid
1401 - UNAUTHORIZED - Client is not authorized
1500 - INTERNAL SERVER ERROR - Internal Server Error. Please try again		
*/					

Below are the Application Error Codes and their description, the function under the Shopping Cart API can throw.

/*
3300 - NOT FOUND - User by the name '<userName>' does not exist.
3301 - NOT FOUND - Cart with the id '<cartId>' does not exist.
3302 - BAD REQUEST - The request parameters are invalid. The details of the cart with the Id '<cartId>' cannot be fetched since it is in '<cartRow.state>' state. Please use the paymentHistoryXXX methods.
3303 - BAD REQUEST - The request parameters are invalid. Item to the cart with the Id '<cartId>' cannot be added since it is in '<cartState>' state.
3304 - NOT FOUND - Cart with the id '<cartId>' does not have any items.
3305 - BAD REQUEST - The request parameters are invalid. The cart with the Id '<cartId>' cannot be checked out since it is in '<cartState>' state.
3306 - NOT FOUND - Cart with the id '<cartId>' does not have any items.to checkout 
3307 - BAD REQUEST - The request parameters are invalid. Cart with the Id '<cartId>' is already in '<cartState>' state.
3308 - BAD REQUEST - The request parameters are invalid. Cart with the Id '<cartId>' is not in 'CHECKOUT' state. Payment cannot be initiated.
3309 - NOT FOUND - Cart with the id '<cartId>' does not have the item with the Id '<itemId>'.
3310 - NOT FOUND - Cart for the user with the id '<userId>' does not exist.
3311 - NOT FOUND - Payment transactions for the user with the id '<userId>' does not exist. 
3312 - NOT FOUND - Payment transactions for the  Cart with the id '<cartId>' does not exist.
3313 - NOT FOUND - Cart for the user with the id '<userId>' and status '<status>' does not exist. 
3314 - NOT FOUND - Payment transactions for the user with the id '<userId>' and status '<status>' does not exist. 
3315 - NOT FOUND - Payment transactions for the status '<status>' does not exist. 
3316 - NOT FOUND - Cart for the user with the id '<userId>' does not exist in payment history.
3317 - NOT FOUND - Carts with status ('DECLINED', 'PENDING', 'AUTHORIZED') does not exist in payment history. 
3318 - BAD REQUEST - The request parameters are invalid. Item from the cart with the Id '<cartId>' cannot be removed since it is in '<cartState>' state. 
3319 - BAD REQUEST - The request parameters are invalid. Payment for cart with the Id '<cartId>' cannot be initiated since it is already in 'AUTHORIZED' state.      
3320 - BAD REQUEST - Item with the Id '<itemId>' in the cart with the id '<cartId>' already exists. Please use 'increaseQuantity' method to add more quantity.
3321 - BAD REQUEST - The request parameters are invalid. Requested quantity should be less then existing quantity.
3322 - NOT FOUND - Item with the id '<itemId>' in the cart with the id '<cartId>' does not exist.	
*/						

Various functions available under Shopping Cart/E-Commerce API has been explained below.

public void CreateCart(String user, App42Callback requestCallback)

Creates a Cart Session for the specified User.

Parameters:

user - User for whom Cart Session has to be created returns The Cart Id with Creation Time. The id has to be used in subsequent calls for adding and checking out
requestCallback - Callback instance that will have the implementation of OnSuccess & OnException of App42Callback.

Returns:

Cart Object containing Cart Id with Creation Time. The id has to be used in subsequent calls for adding and checking out

Response: Cart Object

For more details click Exception
String user = "Nick";
						
cartService.CreateCart(user,requestCallback); /* returns the Cart object. */ 
OnSuccess(Object obj){
Cart cart = (Cart) obj;
Console.WriteLine("userName is " + cart.GetUserName());
Console.WriteLine("cartId is " + cart.GetCartId());
String jsonResponse = cart.ToString(); /* returns the response in JSON format. (as shown below)*/
}
                            
{
    "app42": {
        "response": {
            "success": true,
            "carts": {
                "cart": {
                    "userName": "Nick",
                    "cartId": "41c0008e1a90e06271534457ca28a92805ead62296780343794344322b5f3325",
                    "creationTime": "2012-05-10T03:38:14.000Z",
                    "cartSession": "NEW"
                }
            }
        }
    }
}

public void GetCartDetails(String cartId, App42Callback requestCallback)

Fetch Cart details. Can be used by the App developer to display Cart Details i.e. Items in a Cart.

Parameters:

cartId - The Cart Id that has to be fetched
requestCallback - Callback instance that will have the implementation of OnSuccess & OnException of App42Callback.

Returns:

Cart object containing cart details with all the items which are in it. It also tells the state of the Cart

Response: Cart Object

Exception:

This method throws following exception.
/* 
3301 - NOT FOUND - Cart with the id '<cartId>' does not exist.
3302 - BAD REQUEST - The request parameters are invalid. The details of the cart with the Id '<cartId>' cannot be fetched since it is in '<cartRow.state>' state. Please use the paymentHistoryXXX methods.
*/		        
For more details click Exception
String cartId = "0aed1d3b855d01c81bc424e770f6b28105bd7fdf12ae0af09ea35a5bce237ecb";
						
cartService.GetCartDetails(cartId,requestCallback); /* returns the Cart object. */ 
OnSuccess(Object obj){
Cart cart = (Cart) obj;
Console.WriteLine("userName is " + cart.GetUserName());
Console.WriteLine("cartId is " + cart.GetCartId());
Console.WriteLine("state is " + cart.GetState());
String jsonResponse = cart.ToString(); /* returns the response in JSON format. (as shown below)*/
}
                            
{
    "app42": {
        "response": {
            "success": true,
            "carts": {
                "cart": {
                    "userName": "Nick",
                    "cartId": "0aed1d3b855d01c81bc424e770f6b28105bd7fdf12ae0af09ea35a5bce237ecb",
                    "creationTime": "2012-05-10T05:00:36.000Z",
                    "checkOutTime": "2012-05-10T05:00:36.000Z",
                    "state": "CHECKOUT"
                }
            }
        }
    }
}

public void AddItem(String cartID, String itemID, Int64 itemQuantity, Double price, App42Callback requestCallback)

Adds an Item in the Cart with quantity and price. This method does not take currency. Its the onus of the App developer to maintain the currency. It takes only the price.

Parameters:

cartID - The Cart Id into which item has to be added
itemID - The Item id which has to be added in the cart. If the Catalogue Service is used along with the Cart Service then the Item ids should be same.
itemQuantity - Quantity of the Item to be purchased
price - Price of the item
requestCallback - Callback instance that will have the implementation of OnSuccess & OnException of App42Callback.

Returns:

Cart object containing added item.

Response: Cart Object

Exception:

This method throws following exception.
/* 
3301 - NOT FOUND - Cart with the id '<cartId>' does not exist.
3303 - BAD REQUEST - The request parameters are invalid. Item to the cart with the Id '<cartId>' cannot be added since it is in '<cartState>' state.    
3320 - BAD REQUEST - Item with the Id '<itemId>' in the cart with the id '<cartId>' already exists. Please use 'increaseQuantity' method to add more quantity.
*/ 	 	       
For more details click Exception
String cartID = "41c0008e1a90e06271534457ca28a92805ead62296780343794344322b5f3325";
String itemID = "ItemID01";
int itemQuantity = 12;
double price = 1000;

cartService.AddItem(cartID, itemID, itemQuantity, price,requestCallback); /* returns the Cart object. */ 
OnSuccess(Object obj){
Cart cart = (Cart) obj;
String cartId = cart.GetCartId();  
IList<Item> itemList = cart.GetItemList();  
	for (int i = 0; i < itemList.Count; i++)
	{  
	Console.WriteLine("itemId is " + itemList[i].GetItemId());
	Console.WriteLine("quantity is " + itemList[i].GetQuantity());
	Console.WriteLine("price is " + itemList[i].GetPrice());
	Console.WriteLine("totalAmount is " + itemList[i].GetTotalAmount());			
	}  
String jsonResponse = cart.ToString(); /* returns the response in JSON format. (as shown below)*/
}
                            
{
    "app42": {
        "response": {
            "success": true,
            "carts": {
                "cart": {
                    "cartId": "41c0008e1a90e06271534457ca28a92805ead62296780343794344322b5f3325",
                    "items": {
                        "item": {
                            "itemId": "ItemID01",
                            "quantity": 12,
                            "price": 1000,
                            "totalAmount": 12000
                        }
                    }
                }
            }
        }
    }
}



public void GetItems(String cartId, App42Callback requestCallback)

Fetches the Items from the specified Cart.

Parameters:

cartId - The cart id from which items have to be fetched
requestCallback - Callback instance that will have the implementation of OnSuccess & OnException of App42Callback.

Returns:

Cart object which contains all items in the cart

Response: Cart Object

Exception:

This method throws following exception.
/* 
3301 - NOT FOUND - Cart with the id '<cartId>' does not exist.
3302 - BAD REQUEST - The request parameters are invalid. The details of the cart with the Id '<cartId>' cannot be fetched since it is in '<cartRow.state>' state. Please use the paymentHistoryXXX methods.
3304 - NOT FOUND - Cart with the id '<cartId>' does not have any items.
*/ 	       
For more details click Exception
cartService.GetItems(cartId,requestCallback); /* returns the Cart object. */ 
OnSuccess(Object obj){
Cart cart = (Cart) obj;
String cartId = cart.GetCartId();  
IList<Item> itemList = cart.GetItemList();  
	for (int i = 0; i < itemList.Count; i++) 
	{  
			Console.WriteLine("itemId is " + itemList[i].GetItemId());
			Console.WriteLine("quantity is " + itemList[i].GetQuantity());
			Console.WriteLine("price is " + itemList[i].GetPrice());
			Console.WriteLine("totalAmount is " + itemList[i].GetTotalAmount());	  
	}  
String jsonResponse = cart.ToString(); /* returns the response in JSON format. (as shown below)*/
}
                            
{
    "app42": {
        "response": {
            "success": true,
            "carts": {
                "cart": {
                    "cartId": "41c0008e1a90e06271534457ca28a92805ead62296780343794344322b5f3325",
                    "items": {
                        "item": [
                            {
                                "itemId": "ItemID",
                                "quantity": 2,
                                "price": 100,
                                "totalAmount": 200
                            },
                            {
                                "itemId": "ItemID01",
                                "quantity": 12,
                                "price": 1000,
                                "totalAmount": 12000
                            }
                        ]
                    }
                }
            }
        }
    }
}

public void GetItem(String cartId, String itemId, App42Callback requestCallback)

Fetches the specified Item from the specified Cart.

Parameters:

cartId - The cart id from which item has to be fetched
itemId - The item for which the information has to be fetched
requestCallback - Callback instance that will have the implementation of OnSuccess & OnException of App42Callback.

Returns:

Cart Object

Response: Cart Object

Exception:

This method throws following exception.
/* 
3301 - NOT FOUND - Cart with the id '<cartId>' does not exist.
3302 - BAD REQUEST - The request parameters are invalid. The details of the cart with the Id '<cartId>' cannot be fetched since it is in '<cartRow.state>' state. Please use the paymentHistoryXXX methods.  
3309 - NOT FOUND - Cart with the id '<cartId>' does not have the item with the Id '<itemId>'. 
*/ 	       
For more details click Exception
String cartId = "41c0008e1a90e06271534457ca28a92805ead62296780343794344322b5f3325";
String itemId = "ItemID01";

cartService.GetItem(cartId, itemId,requestCallback); /* returns the Cart object. */ 
OnSuccess(Object obj){
Cart cart = (Cart) obj;
String cartId = cart.GetCartId();  
IList<Item> itemList = cart.GetItemList();  
	for (int i = 0; i < itemList.Count; i++) 
	{  
			Console.WriteLine("itemId is " + itemList[i].GetItemId());
			Console.WriteLine("quantity is " + itemList[i].GetQuantity());
			Console.WriteLine("price is " + itemList[i].GetPrice());
			Console.WriteLine("totalAmount is " + itemList[i].GetTotalAmount());
	}  
String jsonResponse = cart.ToString(); /* returns the response in JSON format. (as shown below)*/
}
                            
{
    "app42": {
        "response": {
            "success": true,
            "carts": {
                "cart": {
                    "cartId": "41c0008e1a90e06271534457ca28a92805ead62296780343794344322b5f3325",
                    "items": {
                        "item": {
                            "itemId": "ItemID01",
                            "quantity": 12,
                            "price": 1000,
                            "totalAmount": 12000
                        }
                    }
                }
            }
        }
    }
}

public void RemoveItem(String cartId, String itemId, App42Callback requestCallback)

Removes the specified item from the specified Cart.

Parameters:

cartId - The cart id from which the item has to be removed
itemId - Id of the Item which has to be removed
requestCallback - Callback instance that will have the implementation of OnSuccess & OnException of App42Callback.

Returns:

App42Response if removed successfully

Response: App42Response Object

Exception:

This method throws following exception.
/* 
3301 - NOT FOUND - Cart with the id '<cartId>' does not exist. 
3309 - NOT FOUND - Cart with the id '<cartId>' does not have the item with the Id '<itemId>'.
3318 - BAD REQUEST - The request parameters are invalid. Item from the cart with the Id '<cartId>' cannot be removed since it is in '<cartState>' state.
*/ 	       
For more details click Exception
String cartId = "7452d7ad3d3c86197d95b7060662533e05bd1995313b8aa4ac675728044b205e";
String itemId =	"itemID";

cartService.RemoveItem(cartId, itemId,requestCallback); /* returns the App42Response object. */
OnSuccess(Object obj){
App42Response response = (App42Response) obj;
Boolean success = response.IsResponseSuccess();
String jsonResponse = response.ToString(); /* returns the response in JSON format. (as shown below)*/
}
                            
{
    "app42": {
        "response": {
            "success": true,
            "carts": {
                "cart": {
                    "cartId": "7452d7ad3d3c86197d95b7060662533e05bd1995313b8aa4ac675728044b205e",
                    "items": {
                        "item": {
                            "itemId": "itemID",
                            "quantity": 2,
                            "price": 100,
                            "totalAmount": 200
                        }
                    }
                }
            }
        }
    }
}
public void RemoveAllItems(String cartId, App42Callback requestCallback)

Removes all Items from the specified Cart.

Parameters:

cartId - The cart id from which items have to be removed
requestCallback - Callback instance that will have the implementation of OnSuccess & OnException of App42Callback.

Returns:

App42Response if removed successfully

Response: App42Response Object

Exception:

This method throws following exception.
/* 
3301 - NOT FOUND - Cart with the id '<cartId>' does not exist.
3304 - NOT FOUND - Cart with the id '<cartId>' does not have any items.
3318 - BAD REQUEST - The request parameters are invalid. Item from the cart with the Id '<cartId>' cannot be removed since it is in '<cartState>' state. 
*/ 	       
For more details click Exception
cartService.RemoveAllItems(cartId,requestCallback); /* returns the App42Response object. */
OnSuccess(Object obj){
App42Response response = (App42Response) obj;
Boolean success = response.IsResponseSuccess();
String jsonResponse = response.ToString(); /* returns the response in JSON format. (as shown below)*/
}
                            
{
    "app42": {
        "response": {
            "success": true,
            "carts": {
                "cart": {
                    "cartId": "665bd3b621b83ff09a6b3a08604ac01148751b5e21438f64c6de4b0256aaa584",
                    "items": {
                        "item": [
                            {
                                "itemId": "itemID",
                                "quantity": 12,
                                "price": 1030,
                                "totalAmount": 12360
                            },
                            {
                                "itemId": "itemID09",
                                "quantity": 22,
                                "price": 1060,
                                "totalAmount": 23320
                            }
                        ]
                    }
                }
            }
        }
    }
}
public void IsEmpty(String cartId, App42Callback requestCallback)

Checks whether the Cart is Empty or not.

Parameters:

cartId - The cart id to check for empty
requestCallback - Callback instance that will have the implementation of OnSuccess & OnException of App42Callback.

Returns:

Cart object (isEmpty method on Cart object can be used to check status)

Response: Cart Object

Exception:

This method throws following exception.
/* 
3301 - NOT FOUND - Cart with the id '<cartId>' does not exist. 
3302 - BAD REQUEST - The request parameters are invalid. The details of the cart with the Id '<cartId>' cannot be fetched since it is in '<cartRow.state>' state. Please use the paymentHistoryXXX methods. 
*/ 	   
For more details click Exception
String cartId = "5527cc1eb516ffeaf8c927782f196757ef2feb4ad43efbe8b6bf37e52d83f4af";
						
cartService.IsEmpty(cartId,requestCallback); /* returns the Cart object. */ 
OnSuccess(Object obj){
Cart cart = (Cart) obj;
String cartId =  cart.GetCartId();
String jsonResponse = cart.ToString(); /* returns the response in JSON format. (as shown below)*/
}
                            
{
    "app42": {
        "response": {
            "success": true,
            "carts": {
                "cart": {
                    "cartId": "5527cc1eb516ffeaf8c927782f196757ef2feb4ad43efbe8b6bf37e52d83f4af",
                    "isEmpty": true
                }
            }
        }
    }
}

public void CheckOut(String cartID, App42Callback requestCallback)

Checks out the Cart and put it in CheckOut Stage and returns the Transaction Id The transaction id has to be used in future to update the Payment Status.

Parameters:

cartID - The cart id that has to be checkedout
requestCallback - Callback instance that will have the implementation of OnSuccess & OnException of App42Callback.

Returns:

Cart object containing Checked Out Cart Information with the Transaction Id

Response: Cart Object

Exception:

This method throws following exception.
/* 
3301 - NOT FOUND - Cart with the id '<cartId>' does not exist.
3305 - BAD REQUEST - The request parameters are invalid. The cart with the Id '<cartId>' cannot be checked out since it is in '<cartState>' state.
3306 - NOT FOUND - Cart with the id '<cartId>' does not have any items to checkout.
*/ 		     
For more details click Exception
String cartID = "5b16be7ac5a46dc1524251b6724183d3ba42702dc10309e5d5db1728c3c5fd30";
						
cartService.CheckOut(cartID,requestCallback); /* returns the Cart object. */ 
OnSuccess(Object obj){
Cart cart = (Cart) obj;
Console.WriteLine("userName is " + cart.GetUserName());
Console.WriteLine("cartId is " + cart.GetCartId());
Console.WriteLine("state is " + cart.GetState());
String jsonResponse = cart.ToString(); /* returns the response in JSON format. (as shown below)*/
}
                            
{
    "app42": {
        "response": {
            "success": true,
            "carts": {
                "cart": {
                    "cartId": "5b16be7ac5a46dc1524251b6724183d3ba42702dc10309e5d5db1728c3c5fd30",
                    "totalAmount": 1000,
                    "state": "CHECKOUT",
                    "checkOutDate": "2012-05-10T04:07:21.000Z"
                }
            }
        }
    }
}
public void Payment(String cartID, String transactionID, String paymentStatus, App42Callback requestCallback)

Update Payment Status of the Cart. When a Cart is checkout, It is in Checkout state. The payment status has to be updated based on the Payment Gateway interaction.

Parameters:

cartID - The cart id for which the payment status has to be updated
transactionID - Transaction id for which the payment status has to be updated
paymentStatus - Payment Status to be updated. The probable values are PaymentStatus.DECLINED, PaymentStatus.AUTHORIZED, PaymentStatus.PENDING
requestCallback - Callback instance that will have the implementation of OnSuccess & OnException of App42Callback.

Returns:

Cart object which contains Payment Status

Response: Cart Object

Exception:

This method throws following exception.
/* 
3301 - NOT FOUND - Cart with the id '<cartId>' does not exist.
3307 - BAD REQUEST - The request parameters are invalid. Cart with the Id '<cartId>' is already in '<cartState>' state.
3308 - BAD REQUEST - The request parameters are invalid. Cart with the Id '<cartId>' is not in 'CHECKOUT' state. Payment cannot be initiated.
3319 - BAD REQUEST - The request parameters are invalid. Payment for cart with the Id '<cartId>' cannot be initiated since it is already in 'AUTHORIZED' state.
*/ 	      
For more details click Exception
String cartID = "5b16be7ac5a46dc1524251b6724183d3ba42702dc10309e5d5db1728c3c5fd30";
String transactionID = "transactionID";
PaymentStatus paymentStatus	= AUTHORIZED;

cartService.Payment(cartID, transactionID, paymentStatus,requestCallback); /* returns the Cart object. */ 
OnSuccess(Object obj){
Cart cart = (Cart) obj;
String cartId =  cart.GetCartId(); 
Cart.Payment payment = cart.GetPayment();  
Console.WriteLine("transactionId is " + payment.GetTransactionId());
Console.WriteLine("totalAmount is " + payment.GetTotalAmount());
Console.WriteLine("state is " + payment.GetStatus());
String jsonResponse = cart.ToString(); /* returns the response in JSON format. (as shown below)*/
}
                            

    "app42": {
        "response": {
            "success": true,
            "carts": {
                "cart": {
                    "cartId": "5b16be7ac5a46dc1524251b6724183d3ba42702dc10309e5d5db1728c3c5fd30",
                    "payments": {
                        "payment": {
                            "transactionId": "transactionID",
                            "totalAmount": 1000,
                            "status": "AUTHORIZED",
                            "date": "2012-05-10T04:07:22.000Z"
                        }
                    }
                }
            }
        }
    }
}
public void GetPaymentsByUser(String userId, App42Callback requestCallback)

Fetches Payment information for a User. This can be used to display Order and Payment History.

Parameters:

userId - User Id for whom payment information has to be fetched
requestCallback - Callback instance that will have the implementation of OnSuccess & OnException of App42Callback.

Returns:

IList containing Cart objects. Payment history can be retrieved from individual Cart object.

Response: IList<Cart> Object

Exception:

This method throws following exception.
/* 
3310 - NOT FOUND - Cart for the user with the id '<userId>' does not exist.
3311 - NOT FOUND - Payment transactions for the user with the id '<userId>' does not exist. 
*/ 		       
For more details click Exception
cartService.GetPaymentsByUser(userId,requestCallback); /* returns the list of Cart object. */ 
OnSuccess(Object obj){
IList<Cart> cartList = (IList<Cart>) obj;
for(int i = 0; i < cartList.Count; i++)
{
	Console.WriteLine("cartId is " + cartList[i].GetCartId());
	Console.WriteLine("payments is " + cartList[i].GetPayment());
	Cart.Payment payment = cartList[i].GetPayment();  
	Console.WriteLine("transactionId is " + payment.GetTransactionId());
	Console.WriteLine("status is " +  payment.GetStatus());
	Console.WriteLine("totalAmount is " +  payment.GetTotalAmount());
}
String jsonResponse = cartList.ToString(); /* returns the response in JSON format. (as shown below)*/
}
                            
			
{
    "app42": {
        "response": {
            "success": true,
            "carts": {
                "cart": {
                    "cartId": "5b16be7ac5a46dc1524251b6724183d3ba42702dc10309e5d5db1728c3c5fd30",
                    "payments": {
                        "payment": {
                            "transactionId": "transactionID",
                            "totalAmount": 1000,
                            "status": "AUTHORIZED",
                            "date": "2012-05-10T04:07:22.000Z"
                        }
                    }
                }
            }
        }
    }
}

public void GetPaymentByCart(String cartId, App42Callback requestCallback)

Fetches Payment information for the specified Cart Id

Parameters:

cartId - Cart Id for which the payment information has to be fetched
requestCallback - Callback instance that will have the implementation of OnSuccess & OnException of App42Callback.

Returns:

Cart object which contains Payment History for the specified Cart

Response: Cart Object

Exception:

This method throws following exception.
/* 
3301 - NOT FOUND - Cart with the id '<cartId>' does not exist.
3312 - NOT FOUND - Payment transactions for the cart with the id '<cartId>' does not exist. 
*/ 		       
For more details click Exception
String cartId = "5b16be7ac5a46dc1524251b6724183d3ba42702dc10309e5d5db1728c3c5fd30";
						
cartService.GetPaymentByCart(cartId,requestCallback); /* returns the list of Cart object. */ 
OnSuccess(Object obj){
IList<Cart> cartList = (IList<Cart>) obj;
for(int i = 0; i < cartList.Count; i++)
{
	Console.WriteLine("cartId is " + cartList[i].GetCartId());
	Console.WriteLine("payments is " + cartList[i].GetPayment());
	Cart.Payment payment = cartList[i].GetPayment();  
	Console.WriteLine("transactionId is " + payment.GetTransactionId());
	Console.WriteLine("status is " +  payment.GetStatus());
	Console.WriteLine("totalAmount is " +  payment.GetTotalAmount());
}
String jsonResponse = cart.ToString(); /* returns the response in JSON format. (as shown below)*/
}
                            
{
    "app42": {
        "response": {
            "success": true,
            "carts": {
                "cart": {
                    "cartId": "5b16be7ac5a46dc1524251b6724183d3ba42702dc10309e5d5db1728c3c5fd30",
                    "payments": {
                        "payment": {
                            "transactionId": "transactionID",
                            "totalAmount": 1000,
                            "status": "AUTHORIZED",
                            "date": "2012-05-10T04:07:22.000Z"
                        }
                    }
                }
            }
        }
    }
}
public void GetPaymentsByUserAndStatus(String userId, String paymentStatus, App42Callback requestCallback)

Fetches Payment information based on User Id and Status

Parameters:

userId - User Id for whom payment information has to be fetched
paymentStatus - Status of type which payment information has to be fetched
requestCallback - Callback instance that will have the implementation of OnSuccess & OnException of App42Callback.

Returns:

containing Cart objects. Payment history can be retrieved from individual Cart object.
Payment History

Response: IList<Cart> Object

Exception:

This method throws following exception.
/* 
3313 - NOT FOUND - Cart for the user with the id '<userId>' and status '<status>' does not exist.
3314 - NOT FOUND - Payment transactions for the user with the id '<userId>' and status '<status>' does not exist.
*/ 	     
For more details click Exception
String userId = "mike@123";
PaymentStatus paymentStatus = PaymentStatus.AUTHORIZED ;

cartService.GetPaymentsByUserAndStatus(userId, paymentStatus,requestCallback); /* returns the list of Cart object. */ 
OnSuccess(Object obj){
IList<Cart> cartList = (IList<Cart>) obj;
for(int i = 0; i < cartList.Count; i++)
{
	Console.WriteLine("cartId is " + cartList[i].GetCartId());
	Console.WriteLine("payments is " + cartList[i].GetPayment());
	Cart.Payment payment = cartList[i].GetPayment();  
	Console.WriteLine("transactionId is " + payment.GetTransactionId());
	Console.WriteLine("status is " +  payment.GetStatus());
	Console.WriteLine("totalAmount is " +  payment.GetTotalAmount()); 
}
String jsonResponse = cartList.ToString(); /* returns the response in JSON format. (as shown below)*/
}
                            
{
    "app42": {
        "response": {
            "success": true,
            "carts": {
                "cart": {
                    "cartId": "5b16be7ac5a46dc1524251b6724183d3ba42702dc10309e5d5db1728c3c5fd30",
                    "payments": {
                        "payment": {
                            "transactionId": "transactionID",
                            "totalAmount": 1000,
                            "status": "AUTHORIZED",
                            "date": "2012-05-10T04:07:22.000Z"
                        }
                    }
                }
            }
        }
    }
}
public void GetPaymentsByStatus(String paymentStatus, App42Callback requestCallback)

Fetches Payment information based on Status.

Parameters:

paymentStatus - Status of type which payment information has to be fetched
requestCallback - Callback instance that will have the implementation of OnSuccess & OnException of App42Callback.

Returns:

IList containing Cart objects. Payment history can be retrieved from individual Cart object.

Response: IList<Cart> Object

Exception:

This method throws following exception.
/* 
3315 - NOT FOUND - Payment transactions for the status '' does not exist.
*/ 		      
For more details click Exception
String paymentStatus = PaymentStatus.AUTHORIZED;
						
IList<Cart> cartList = cartService.GetPaymentsByStatus(paymentStatus,requestCallback); /* returns the list of Cart object. */ 
OnSuccess(Object obj){
IList<Cart> cartList = (IList<Cart>) obj;
	for(int i = 0; i < cartList.Count; i++)
	{
		Console.WriteLine("cartId is " + cartList[i].GetCartId());
		Console.WriteLine("payments is " + cartList[i].GetPayment());
		Cart.Payment payment = cartList[i].GetPayment();  
		Console.WriteLine("transactionId is " + payment.GetTransactionId());
		Console.WriteLine("status is " +  payment.GetStatus());
		Console.WriteLine("totalAmount is " +  payment.GetTotalAmount()); 
	}
String jsonResponse = cartList.ToString(); /* returns the response in JSON format. (as shown below)*/
}
                            
{
    "app42": {
        "response": {
            "success": true,
            "carts": {
                "cart": {
                    "cartId": "154a1ec1af463eaf0780fc580f19e853613518fde415eacebde89993ef633b92",
                    "payments": {
                        "payment": {
                            "transactionId": "transactionID",
                            "totalAmount": 5050,
                            "status": "AUTHORIZED",
                            "date": "2012-06-01T03:11:41.000Z"
                        }
                    }
                }
            }
        }
    }
}
public void GetPaymentHistoryByUser(String userId, App42Callback requestCallback)

History of Carts and Payments for a User. It gives all the carts which are in AUTHORIZED, DECLINED, PENDING state.

Parameters:

userId - User Id for whom payment history has to be fetched
requestCallback - Callback instance that will have the implementation of OnSuccess & OnException of App42Callback.

Returns:

IList containing Cart objects. Payment history can be retrieved from individual Cart object.

Response: IList<Cart> Object

Exception:

This method throws following exception.
/*
3316 - NOT FOUND - Cart for the user with the id '<userId>' does not exist in payment history.
*/ 		       
For more details click Exception
String userId = "mike@123";
						
cartService.GetPaymentHistoryByUser(userId,requestCallback); /* returns the list of Cart object. */ 
OnSuccess(Object obj){
IList<Cart> cartList = (IList<Cart>) obj;
	for(int i = 0; i < cartList.Count; i++)
	{
		Console.WriteLine("userName is " + cartList[i].GetCartId()); 
		Console.WriteLine("cartId is " + cartList[i].GetUserName()); 
		Console.WriteLine("state is " + cartList[i].getState()); 	
		Cart.Payment payment = cartList[i].GetPayment();		
		IList<Item> itemList = cart.GetItemList();  
			for(int j=0;j < itemList.Count;j++)
			{   
				Console.WriteLine("itemId is " + itemList[i].GetItemId()); 
				Console.WriteLine("quantity is " + itemList[i].GetQuantity());
				Console.WriteLine("totalAmount is " +itemList[i].GetTotalAmount());
			}  
		Console.WriteLine("transactionId is " + payment.GetTransactionId()); 
		Console.WriteLine("totalAmount is " + payment.GetTotalAmount());    
	}
}	
String jsonResponse = cartList.ToString(); /* returns the response in JSON format. (as shown below)*/
}
                            
{
    "app42": {
        "response": {
            "success": true,
            "carts": {
                "cart": {
                    "userName": "Nick",
                    "cartId": "5b16be7ac5a46dc1524251b6724183d3ba42702dc10309e5d5db1728c3c5fd30",
                    "creationTime": "2012-05-10T04:06:18.000Z",
                    "checkOutTime": "2012-05-10T04:07:21.000Z",
                    "state": "AUTHORIZED",
                    "items": {
                        "item": {
                            "itemId": "ItemID01",
                            "quantity": 122,
                            "totalAmount": 1000
                        }
                    },
                    "payments": {
                        "payment": {
                            "transactionId": "transactionID",
                            "totalAmount": 1000,
                            "status": "AUTHORIZED",
                            "date": "2012-05-10T04:07:22.000Z"
                        }
                    }
                }
            }
        }
    }
}

public void GetPaymentHistoryAll(App42Callback requestCallback)

History of all carts. It gives all the carts which are in AUTHORIZED, DECLINED, PENDING state.

Parameters:

requestCallback - Callback instance that will have the implementation of OnSuccess & OnException of App42Callback.

Returns:

IList containing Cart objects. Payment history can be retrieved from individual Cart object.

Response: IList<Cart> Object

Exception:

This method throws following exception.
/* 
3317 - NOT FOUND - Carts with status ('DECLINED', 'PENDING', 'AUTHORIZED') does not exist in payment history.
*/ 		  
For more details click Exception
cartService.GetPaymentHistoryAll(requestCallback); /* returns the list of Cart object. */ 
OnSuccess(Object obj){
IList<Cart> cartList = (IList<Cart>) obj;
	for(int i = 0; i < cartList.Count; i++)
	{
		Console.WriteLine("userName is " + cartList[i].GetCartId()); 
		Console.WriteLine("cartId is " + cartList[i].GetUserName()); 
		Console.WriteLine("state is " + cartList[i].GetState()); 
		Cart.Payment payment = cartList[i].GetPayment();		
		IList<Item> itemList = cart.GetItemList();  
			for(int j=0;j < itemList.Count;j++)
			{   
				Console.WriteLine("itemId is " + itemList[i].GetItemId()); 
				Console.WriteLine("quantity is " + itemList[i].GetQuantity());
				Console.WriteLine("totalAmount is " +itemList[i].GetTotalAmount());
			}  
		Console.WriteLine("transactionId is " + payment.GetTransactionId()); 
		Console.WriteLine("totalAmount is " + payment.GetTotalAmount());     
	}
}	
String jsonResponse = cartList.ToString(); /* returns the response in JSON format. (as shown below)*/
}
                            
{
    "app42": {
        "response": {
            "success": true,
            "carts": {
                "cart": [
                    {
                        "userName": "Nick",
                        "cartId": "bff030558be32e9225e33b75a825d822a9f30c3c940ebf7be73fdd9680e0ea28",
                        "creationTime": "2012-05-12T07:19:32.000Z",
                        "checkOutTime": "2012-05-12T07:19:33.000Z",
                        "state": "AUTHORIZED",
                        "items": {
                            "item": {
                                "itemId": "itemID",
                                "quantity": 5,
                                "totalAmount": 5050
                            }
                        },
                        "payments": {
                            "payment": {
                                "transactionId": "transactionID",
                                "totalAmount": 5050,
                                "status": "AUTHORIZED",
                                "date": "2012-05-12T07:19:33.000Z"
                            }
                        }
                    },
                    {
                        "userName": "Nick",
                        "cartId": "1f37c7045c18455f5dc9aea5877ed5f469e18436d32fbf0922699d951ec09263",
                        "creationTime": "2012-05-12T07:23:52.000Z",
                        "checkOutTime": "2012-05-12T07:23:53.000Z",
                        "state": "AUTHORIZED",
                        "items": {
                            "item": {
                                "itemId": "itemID",
                                "quantity": 5,
                                "totalAmount": 5050
                            }
                        },
                        "payments": {
                            "payment": {
                                "transactionId": "transactionID",
                                "totalAmount": 5050,
                                "status": "AUTHORIZED",
                                "date": "2012-05-12T07:23:53.000Z"
                            }
                        }
                    },
                    {
                        "userName": "userName": "Nick",
                        "cartId": "e0ad6792876b5682bf57de10dd1076787212accbda5e2270778862e5c81c9aba",
                        "creationTime": "2012-05-13T00:17:55.000Z",
                        "checkOutTime": "2012-05-13T00:17:55.000Z",
                        "state": "AUTHORIZED",
                        "items": {
                            "item": {
                                "itemId": "itemID",
                                "quantity": 5,
                                "totalAmount": 5050
                            }
                        },
                        "payments": {
                            "payment": {
                                "transactionId": "transactionID",
                                "totalAmount": 5050,
                                "status": "AUTHORIZED",
                                "date": "2012-05-13T00:17:55.000Z"
                            }
                        }
                    }
                ]
            }
        }
    }
}

public void IncreaseQuantity(String cartID, String itemID, Int64 itemQuantity, App42Callback requestCallback)

Increase the quantity of specified Item to the specified Cart

Parameters:

cartID - The cart id for which item has to be increased
itemID - The item id that has to be increased
itemQuantity - The quantity of the item that has to be increased
requestCallback - Callback instance that will have the implementation of OnSuccess & OnException of App42Callback.

Returns:

Cart object containing updated item.

Response: Cart Object

Exception:

This method throws following exception.
/*
3301 - NOT FOUND - Cart with the id '<cartId>' does not exist.
3303 - BAD REQUEST - The request parameters are invalid. Item to the cart with the Id '<cartId>' cannot be added since it is in '<cartState>' state. 
3322 - NOT FOUND - Item with the id '<itemId>' in the cart with the id '<cartId>' does not exist.	
*/ 		   
For more details click Exception
String cartID = "735eef8a7745cd4c16ca30356d0cfd784736aa695f0200f73980dd154ba8f7fb";
String itemID = "ItemID090";
int itemQuantity = 5;

cartService.IncreaseQuantity(cartID, itemID, itemQuantity,requestCallback); /* returns the Cart object. */ 
OnSuccess(Object obj){
Cart cart = (Cart) obj;
String cartId = cart.GetCartId();  
IList<Item> itemList = cart.GetItemList();  
	for (int i = 0; i < itemList.Count; i++) 
	{  
			Console.WriteLine("itemId is " + itemList[i].GetItemId()); 
			Console.WriteLine("quantity is " + itemList[i].GetQuantity());
			Console.WriteLine("price is " + itemList[i].GetPrice());
			Console.WriteLine("totalAmount is " + itemList[i].GetTotalAmount()); 
    }  
String jsonResponse = cart.ToString(); /* returns the response in JSON format. (as shown below)*/
}
                            
{
    "app42": {
        "response": {
            "success": true,
            "carts": {
                "cart": {
                    "cartId": "735eef8a7745cd4c16ca30356d0cfd784736aa695f0200f73980dd154ba8f7fb",
                    "items": {
                        "item": {
                            "itemId": "ItemID090",
                            "quantity": 5,
                            "price": 5050,
                            "totalAmount": 25250
                        }
                    }
                }
            }
        }
    }
}

public void DecreaseQuantity(String cartID, String itemID, Int64 itemQuantity, App42Callback requestCallback)

Decrease the quantity of specified Item from the specified Cart

Parameters:

cartID - The cart id for which item has to be decreased
itemID - The item id that has to be decreased
itemQuantity - The quantity of the item that has to be decreased
requestCallback - Callback instance that will have the implementation of OnSuccess & OnException of App42Callback.

Returns:

Cart object containing updated item.

Response: Cart Object

Exception:

This method throws following exception.
/*
3301 - NOT FOUND - Cart with the id '<cartId>' does not exist.
3303 - BAD REQUEST - The request parameters are invalid. Item to the cart with the Id '<cartId>' cannot be added since it is in '<cartState>' state.
3321 - BAD REQUEST - The request parameters are invalid. Requested quantity should be less then existing quantity.
3322 - NOT FOUND - Item with the id '<itemId>' in the cart with the id '<cartId>' does not exist.
*/ 		 
For more details click Exception
String cartID = "735eef8a7745cd4c16ca30356d0cfd784736aa695f0200f73980dd154ba8f7fb";
String itemID = "ItemID090";
int itemQuantity = 3;

cartService.DecreaseQuantity(cartID, itemID, itemQuantity,requestCallback); /* returns the Cart object. */ 
OnSuccess(Object obj){
Cart cart = (Cart) obj;
String cartId = cart.GetCartId();  
IList<Item> itemList = cart.GetItemList();  
	for (int i = 0; i < itemList.Count; i++) 
	{  
			Console.WriteLine("itemId is " + itemList[i].GetItemId()); 
			Console.WriteLine("quantity is " + itemList[i].GetQuantity());
			Console.WriteLine("price is " + itemList[i].GetPrice());
			Console.WriteLine("totalAmount is " + itemList[i].GetTotalAmount()); 
    }  
String jsonResponse = cart.ToString(); /* returns the response in JSON format. (as shown below)*/
}
                            
{
    "app42": {
        "response": {
            "success": true,
            "carts": {
                "cart": {
                    "cartId": "735eef8a7745cd4c16ca30356d0cfd784736aa695f0200f73980dd154ba8f7fb",
                    "items": {
                        "item": {
                            "itemId": "ItemID090",
                            "quantity": 3,
                            "price": 5050,
                            "totalAmount": 15150
                        }
                    }
                }
            }
        }
    }
}