SOA Orders Cart Example

 

Hello,

I have a customer that is using an external CMS (not WCM) and wants to access iMIS store functionality.

I want to create some SOA where they can add a product to the cart and checkout when finished their shopping. The checkout is through iMIS and Paypal.

I have searched this site, reviewed some discussions, downloaded a few samples zips people have provided, but can not get the required functionality working.

Has anyone got ideas or sample code that works for the above in SOA 15.1.3 (or 15.2 although this would require an upgrade for the customer that was not planned)?

Any ideas, sugggestions or solid sample code would be appreciated. If no SOA samples, a solid ibo.net would do too.

Thanks NIck

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

IBO.NET Example

 

Hi Nick, when I was looking to create a prototype Order application, I found posts on this site that made me think that SOA is not quite ready for Order processing even in 15.2. I did recently create an Functional Orders iBO .NET checkout process as a test prototype for a client as an iPart. Let me know if that is something you would be interested in.

Thanks

Joe

 

15.2 Soa has more than 15.1.3

Hi Nick,

I'm not sure how much was in 15.1.3 Soa as far as orders and payments.  I think some was there, but 15.2 definietly has more.  When you integrate into the external CMS, can you use .NET?  If so, we have some helper API's that can accomplish this like CartHelper. But I'll assume you don't have access to that and give the long way in the coding example here.  This works in 15.2:

var comboOrder = new ComboOrderData(); // Create the order
OrderData order = comboOrder.Order = new OrderData();
var customer = new CustomerPartyData { PartyId = "MyID" };
order.SoldToCustomerParty = customer; // Set the order customer
order.Lines = new OrderLineDataCollection();
var line = new OrderLineData { Item = new ItemData { ItemId = "ProductCode" }, LineNumber = 1, QuantityOrdered = new QuantityData(1) }; // add the product
order.Lines.Add(line);
order.Delivery = new DeliveryDataCollection();
order.Delivery.Add(new DeliveryData{DeliveryMethod = new DeliveryMethodData { DeliveryMethodId = "UPS" }}); // Set delivery
var payment = new PaymentData // Create payment
{
Amount = new MonetaryAmountData(new decimal(12.50)),
PaymentMethod = new PaymentMethodData { PaymentMethodId = "PaymentMethodId" },
ReferenceNumber = "PaymentReferenceNumber",
CreditCardInformation = new CreditCardInformationData
{
CardNumber = "CreditCardNumber",
SecurityCode = "CreditCardSecurityCode",
Expiration = new YearMonthDateData(YEAR, MO),
HoldersName = "CreditCardHoldersName"
}
};
comboOrder.Payments = new PaymentDataCollection { payment };
ValidateResultsData comboOrderResults = entityService.Add(comboOrder); // Check-out

We hope to document Soa a little better within the coming months.

Hope this helps.

Courtney Robertson
Senior Software Developer
Advanced Solutions International, Inc.

 

SOA Orders

 

Thanks! I will give this a try.

The external CMS is .net based.

I have been testing the CartHelper.

The code looks very similar to what I have been testing. In 15.1.3 the checkout worked fine with CASH, the problem is with CC.

I will give it a try in 15.2 and see how it goes.

I did get an iBO .net version working where checkout worked fine and the CC went through Paypal:-)

Works case, I can make a WCF call from the client (3rd party CMS) to a service running under the iMIS15 apps service that makes the iBO .net transaction.

I will keep you posted - thanks again.

 

SOA Order Update 15.2

 

I went to 15.2 and everything started to work fine.

I could add items to the cart, show items from the cart, delete items from the cart, delete the cart, get product information from orders and submit an order with CC - all worked fine:-)

15.2 is definitely looking a lot better.

After I submitted the order, I went back to place another order with the same ID (362) and am always getting the error below? Is there anything that needs to be done with the cart after the cart is submitted? delete, reload the cart? In debug it looks like the order and payment info is still in the cart after it was submitted.

Everything was working great to this point. If I can get past this I'm very confident 15.2 will deliver the solution the customer wants. Once I get past this I will recommend that the customer upgrade to 15.2 so we can integrate the 3rd party CMS into iMIS.

A few other point:

--- Cart Helper - I did not see the carthelper anywher in the namespaces, assemblies - it was not where the documentation says and I could not find it searching the various assemblies with the object browser.

--- Item Properties - I did not see a status or category property for items? I want to show only active items and the customer wants to group items into catgories for display/purchase pages. I can get this through direct SQL to the product tables but would rather do through the entities. 

Besided the error things are looking:-)

Thanks Nick

 

System.ServiceModel.FaultException`1 was unhandled by user code
  Message=ArgumentFault: Format Exception occurred. object: '362' destinationType: 'System.Guid'
  Source=Asi.Soa.ClientServices
  StackTrace:
    Server stack trace:
       at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
       at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
       at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
    Exception rethrown at [0]:
       at Asi.Soa.ClientServices.ExceptionHandlingProxyBase`1.Invoke[TResult](MethodInfo methodInfo, Object[] parameters) in c:\Builds\42\ScrumV3\15.2.0_MainFoundation_Commit\Sources\imis.net\Packages\Soa\Asi.Soa\Asi.Soa.ClientServices\EntityManager\ExceptionHandlingProxyBase.cs:line 680
       at Asi.Soa.ClientServices.ExceptionHandlingProxyBase`1.Invoke[TResult](String operationName, Object[] parameters) in c:\Builds\42\ScrumV3\15.2.0_MainFoundation_Commit\Sources\imis.net\Packages\Soa\Asi.Soa\Asi.Soa.ClientServices\EntityManager\ExceptionHandlingProxyBase.cs:line 643
       at Asi.Soa.ClientServices.EntityServiceProxy.Update(Object entity) in c:\Builds\42\ScrumV3\15.2.0_MainFoundation_Commit\Sources\imis.net\Packages\Soa\Asi.Soa\Asi.Soa.ClientServices\EntityManager\EntityServiceProxy.cs:line 406
       at Asi.Soa.ClientServices.EntityManager.Update[T](T entity) in c:\Builds\42\ScrumV3\15.2.0_MainFoundation_Commit\Sources\imis.net\Packages\Soa\Asi.Soa\Asi.Soa.ClientServices\EntityManager\EntityManager.cs:line 1047
       at Asi.Soa.ClientServices.CartManager.SaveCart(CartData cart) in c:\Builds\42\ScrumV3\15.2.0_MainFoundation_Commit\Sources\imis.net\Packages\Soa\Asi.Soa\Asi.Soa.ClientServices\CommerceManager\CartManager.cs:line 744
       at Asi.Soa.ClientServices.CartManager.SaveCart() in c:\Builds\42\ScrumV3\15.2.0_MainFoundation_Commit\Sources\imis.net\Packages\Soa\Asi.Soa\Asi.Soa.ClientServices\CommerceManager\CartManager.cs:line 484
       at Asi.Soa.ClientServices.CartManager.AddLine(OrderLineData line, Uri websiteEditUrl) in c:\Builds\42\ScrumV3\15.2.0_MainFoundation_Commit\Sources\imis.net\Packages\Soa\Asi.Soa\Asi.Soa.ClientServices\CommerceManager\CartManager.cs:line 366
       at Asi.Soa.ClientServices.CartManager.AddItem(String itemId, Decimal qty, Uri websiteEditUrl) in c:\Builds\42\ScrumV3\15.2.0_MainFoundation_Commit\Sources\imis.net\Packages\Soa\Asi.Soa\Asi.Soa.ClientServices\CommerceManager\CartManager.cs:line 316
       at Asi.Soa.ClientServices.CartManager.AddItem(String itemId, Decimal qty) in c:\Builds\42\ScrumV3\15.2.0_MainFoundation_Commit\Sources\imis.net\Packages\Soa\Asi.Soa\Asi.Soa.ClientServices\CommerceManager\CartManager.cs:line 329
       at _Default.btnAddToCart_Click(Object sender, EventArgs e) in c:\Users\Nick\Documents\Visual Studio 2010\WebSites\SOA152\Default.aspx.cs:line 166
       at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
       at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
       at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
       at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
       at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
  InnerException:
 

Sorry, I meant CartManager,

Sorry, I meant CartManager, not CartHelper.  I think of all the managers as helper or wrappers to let you do more in fewer steps.  And no, there's no way to group product by categories in Soa that I know of yet.  This is a great idea for a future enhancement though, and it might be worth entering an RSE.

As for the cart error - this is strange, I wouldn't expect you would have to clear the cart.  How did you instantiate your cart?  The cart ID is always a guid and does not correlate to an iMIS ID.  If you don't mind sharing your code, I'd be happy to try it out myself and see if I can find a "missing step."

NP about CartManager

 

The managers are definitely helpful!

Thanks for confirming the category - definitely would be a nice feature - I would think most people group their products and want to display by grouping like this customer. Is this the same for the product status that I have not seen browsing the dlls? I only want to display active products that does not appear to be in the objects either.

I have not seen this error again in my testing? :-) It may have been something with the earlier testing when I tried some variations that caused an inconsistency that cleared up? Anyway, problem is gone. If it reappears I will open update again.

Thanks Again.

 

 

 

Need Help in PHP - SOA integration for orders and payments

Hi Courtney,

We are using latest version of iMIS 15.2.5, but still not been able to use SOA in PHP for Orders and Payments effectively. We are following PHP toolkits exmaples but there is no exmaple for How to place a successful order and payments in PHP ? This is really an important part of my application and we are stuck up at Orders and Payments section.

Can you please provide any help or any guidance on this.  Any help will be appreciated.

Thanks,

Jaco.

 

 

SOA Orders Cart Example in PHP

I was trying the following code:

try {
$comboOrder = new OrderComboData();
$order = new OrderData();
$customer = new CustomerPartyData ("220542");
$order->SoldToCustomerParty = $customer;
$line = new OrderLineData();
$line->LineNumber = 1;
$line->Item = new ItemData();
$line->Item->ItemId = '101';
$line->Item->Name = 'TITLE OF THE PRODUCT';
$line->QuantityOrdered = new QuantityData();
$line->QuantityOrdered->Amount = 1;

$order->Lines->OrderLine[] = $line;

I can retrieve following data based on partyid
$delivery = new DeliveryData();
$delivery->CustomerParty = $customer;
$delivery->AddressId = '88147';
$delivery->Address = new FullAddressData();
$delivery->Address->Phone = '(555) 555-5555';
$delivery->Address->Fax = '(212) 111-1111';
$delivery->Address->Email = 'email@email.com';
$addr = new AddressData();
$addr->AddressLines->AddressLine[] = 'Street Address';
$addr->AddressLines->AddressLine[] = 'Office Address';
$addr->CityName = "New York";
$addr->PostalCode = '10000';
$addr->CountrySubEntityName = 'New York';
$addr->CountrySubEntityCode = 'NY';
$delivery->Address->Address = $addr;
$delivery->Address->AddressPurpose = 'office';

$order->Delivery = $delivery;

$comboOrder->Order = $order;

$result = $client->Add($comboOrder);
if ($result->IsValid) {
echo "Added an order: $comboOrder\n";
}
else {
echo "Error adding order: " . $result->getErrorSummary() . "\n";
}
}
catch (Exception $e) {
echo "Exception: " . $e->getMessage() . "\n";
exit();
}

However I was getting an error that tosoapvariable function is not defined. What am I doing wrong?
Thanks

We are facing the same problem

Hi All,

We are facing the same problem as mentioned above by lradin

We are trying to create Commerce data like orders using PHP but we get same error of tosoapvariable function is not defined. If anyone has fixed it pleaes let us know.

-Jaco