• Toll-free  888-665-8637
  • International  +1 717-220-0012
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

2 Pages12>
tappedtech
#1 Posted : Monday, December 8, 2014 5:52:49 PM(UTC)
tappedtech

Rank: Member

Joined: 11/21/2014(UTC)
Posts: 66

What is the correct process for creating an order using the Webservices3?

There are two ways I can think of this working:
1) Create a WebServices3.Order object and call Orders_Order_Insert(). Update order information as each step of the checkout process is completed (products added, addresses added, etc).

2) Create the WebServices3.Order object and call Orders_Order_Insert() once (after all required information is available).

I attempted the first way but I can't find a way to get the order number through the web service (why isn't an order number returned when inserting an order?). I can see the order in the database if I search by username.This appears to be because Orders_Order_FindByUser is looking for orders that have been placed (isPlaced == 1). Which leads me to think that the second way is correct.

Is there a set process for creating an order through the web service? What default information is required by the WebServices3.Order object?

This is the code (simplified) I used so far:
WebServices3.WebServices3SoapClient ws = new WebServices3.WebServices3SoapClient();

WebServices3.Product product = ws.Catalog_InternalProduct_FindByBvin(ref token, pid);

WebServices3.UserAccount userAcct = ws.Membership_UserAccount_FindByUserName(ref token, u);

WebServices3.Order order = new WebServices3.Order();
order.User = userAcct;
order.UserEmail = userAcct.Email;
order.TimeOfOrder = DateTime.Now;
order.FraudScore = -1;
order.GrandTotal = product.SitePrice * itemQuantity;
order.SubTotal = order.GrandTotal;
order.PaymentStatus = WebServices3.OrderPaymentStatus.Unpaid;
order.ShippingStatus = WebServices3.OrderShippingStatus.Unshipped;

WebServices3.LineItem lItem = new WebServices3.LineItem();
lItem.Quantity = itemQuantity;
lItem.Bvin = product.Bvin;
lItem.BasePrice = product.SitePrice;
lItem.ProductSku = product.Sku;

WebServices3.LineItem[] items = {lItem};
order.Items = items;

if(ws.Orders_Order_Insert(ref token, order))
{
//Success
}
Aaron
#2 Posted : Tuesday, December 9, 2014 10:36:41 AM(UTC)
Aaron

Rank: Administration

Joined: 4/2/2004(UTC)
Posts: 2,381
United States
Location: Hummelstown, PA

Thanks: 6 times
Was thanked: 163 time(s) in 158 post(s)
Orders are a little more complicated. One point of clarity is that a cart and an order are the same thing; the only difference is the value of IsPlaced as well as the order status (StatusCode and StatusName). While you can create an order through inserts and updates to the Order object (and its supporting objects), it's best to use the "Process New Order" workflow to handle converting the cart to an order as well as everything that goes along with processing a new order (e.g. payment processing and sending order confirmation emails).

Before you run the workflow you will want to make sure that all of your data has been saved to the database (i.e. user, order, line item, and payment data). Note that you do not need to calculate the order subtotal, tax, grand total, etc; this should be handled automatically when you call Orders_Order_FindByBvin. So, once you're done saving all of your data you'll want to get a fresh copy of the Order object from the API which will then have everything calculated.

You can run the "Process New Order" workflow by either calling BusinessRules_Workflow_RunByName and passing the workflow name or by calling BusinessRules_Workflow_RunByBvin and passing the workflow bvin (eac003c6-a354-489f-ba2c-029f4311851a). This function takes an OrderTaskContext object which you can instantiate and then set the UserId and Order properties.
Aaron Sherrick
BV Commerce
Toll-free 888-665-8637 - Int'l +1 717-220-0012
tappedtech
#3 Posted : Tuesday, December 9, 2014 11:47:16 AM(UTC)
tappedtech

Rank: Member

Joined: 11/21/2014(UTC)
Posts: 66

I'm not writing this for use on the website; it's for a mobile application. So the order isn't a cart (order) when I'm starting the process.

Is this the correct process?
Retrieve all necessary information (products, user, payment, etc)
Create and fill the Order object once
Insert the Order
Call Orders_Order_FindByBvin so that all totals are calculated
(how do I get the order bvin? insert order only returns a boolean. I can't get the order by user because isPlaced == 0)
Create a TaskContext for the order
(what is the userId?, bvin, username)
(what order properties need to be provided?)

Run the Process New Order Workflow and pass the order context

Thanks, Aaron.
tappedtech
#4 Posted : Tuesday, December 9, 2014 2:00:36 PM(UTC)
tappedtech

Rank: Member

Joined: 11/21/2014(UTC)
Posts: 66

Additional related question: What is the best way to get a list of the available shipping rates/methods?

I called Orders_Order_FindAvailableShippingRates and it returned the same rate $ amount I saw on the website (with the same item added to cart) but all other parameters of the shipping rate were null. No shipping method names were available.
Aaron
#5 Posted : Wednesday, December 10, 2014 10:50:54 AM(UTC)
Aaron

Rank: Administration

Joined: 4/2/2004(UTC)
Posts: 2,381
United States
Location: Hummelstown, PA

Thanks: 6 times
Was thanked: 163 time(s) in 158 post(s)
Originally Posted by: tappedtech Go to Quoted Post
I'm not writing this for use on the website; it's for a mobile application. So the order isn't a cart (order) when I'm starting the process.

We're talking semantics. Until a cart/order is fully created (data-wise) and run through the Process New Order workflow, it's not a real/complete order.

Originally Posted by: tappedtech Go to Quoted Post
Is this the correct process?
Retrieve all necessary information (products, user, payment, etc)
Create and fill the Order object once
Insert the Order

When you insert the Order object it won't insert all of the child object collections (e.g. line items, payments, etc). You will need to insert these with separate API calls (e.g. Orders_Order_AddItem, Orders_Order_AddPayment, etc---alternately you can use the insert calls for each object).

Originally Posted by: tappedtech Go to Quoted Post
Call Orders_Order_FindByBvin so that all totals are calculated
(how do I get the order bvin? insert order only returns a boolean. I can't get the order by user because isPlaced == 0)

Set the bvin value (use a GUID string) before you perform the insert.

Originally Posted by: tappedtech Go to Quoted Post
Create a TaskContext for the order
(what is the userId?, bvin, username)
(what order properties need to be provided?)

The userId property should be the same one that you set for the Order object---it's the bvin value of the UserAccount object. If you're not using user accounts for customers than this string can be empty.
Aaron Sherrick
BV Commerce
Toll-free 888-665-8637 - Int'l +1 717-220-0012
Aaron
#6 Posted : Wednesday, December 10, 2014 11:03:43 AM(UTC)
Aaron

Rank: Administration

Joined: 4/2/2004(UTC)
Posts: 2,381
United States
Location: Hummelstown, PA

Thanks: 6 times
Was thanked: 163 time(s) in 158 post(s)
Originally Posted by: tappedtech Go to Quoted Post
Additional related question: What is the best way to get a list of the available shipping rates/methods?

I called Orders_Order_FindAvailableShippingRates and it returned the same rate $ amount I saw on the website (with the same item added to cart) but all other parameters of the shipping rate were null. No shipping method names were available.

That is the correct API call. I just tested this and saw the shipping method name in the DisplayName property. Some of the other properties are null, though.

Aaron Sherrick
BV Commerce
Toll-free 888-665-8637 - Int'l +1 717-220-0012
tappedtech
#7 Posted : Wednesday, December 10, 2014 6:59:24 PM(UTC)
tappedtech

Rank: Member

Joined: 11/21/2014(UTC)
Posts: 66

Thanks Aaron.

Creating the order, adding items and getting shipping rates are all working. The shipping rates call must not have liked how the order was previously formatted. I haven't tested running the process new order workflow yet.

I'm using Orders_Order_AddItem_ByBvin to add products.

I tried using Orders_Order_UpdateItemQuantity and Orders_Order_RemoveItem but they aren't working. I tried passing the product bvin and the productId straight from the order object. Orders_Order_UpdateItemQuantity returns true and Orders_Order_RemoveItem return false.

Any suggestions?
Aaron
#8 Posted : Thursday, December 11, 2014 1:39:36 PM(UTC)
Aaron

Rank: Administration

Joined: 4/2/2004(UTC)
Posts: 2,381
United States
Location: Hummelstown, PA

Thanks: 6 times
Was thanked: 163 time(s) in 158 post(s)
Originally Posted by: tappedtech Go to Quoted Post
I tried using Orders_Order_UpdateItemQuantity and Orders_Order_RemoveItem but they aren't working. I tried passing the product bvin and the productId straight from the order object. Orders_Order_UpdateItemQuantity returns true and Orders_Order_RemoveItem return false.

The itemId parameter that these functions take should be the bvin of the LineItem, not the product.
Aaron Sherrick
BV Commerce
Toll-free 888-665-8637 - Int'l +1 717-220-0012
tappedtech
#9 Posted : Friday, December 12, 2014 4:24:21 PM(UTC)
tappedtech

Rank: Member

Joined: 11/21/2014(UTC)
Posts: 66

That does it. Thanks, Aaron.
tappedtech
#10 Posted : Sunday, January 11, 2015 3:00:39 PM(UTC)
tappedtech

Rank: Member

Joined: 11/21/2014(UTC)
Posts: 66

Hi Arron,

I'm still getting bad results from Orders_Order_FindAvailableShippingRates sometimes. The rates will be provided but everything else will be null (including the display name).

Any suggestions?
Aaron
#11 Posted : Monday, January 12, 2015 11:34:30 AM(UTC)
Aaron

Rank: Administration

Joined: 4/2/2004(UTC)
Posts: 2,381
United States
Location: Hummelstown, PA

Thanks: 6 times
Was thanked: 163 time(s) in 158 post(s)
No, I'm not sure what would cause this. Are you saying that it's only happening in some cases? Have you been able to identify any pattern to the behavior?
Aaron Sherrick
BV Commerce
Toll-free 888-665-8637 - Int'l +1 717-220-0012
tappedtech
#12 Posted : Monday, January 12, 2015 4:22:53 PM(UTC)
tappedtech

Rank: Member

Joined: 11/21/2014(UTC)
Posts: 66

It doesn't fail every time but I can't detect a pattern. It fails more often than it works.

This is how I'm creating the order and pulling the shipping methods:

//Create the order
WebServices3.Order order = new WebServices3.Order();
order.Bvin = orderGuid.ToString();
order.User = userAcct;
order.UserID = userAcct.Bvin;
order.UserEmail = userAcct.Email;
order.ShippingAddress = userAcct.ShippingAddress;
order.TimeOfOrder = DateTime.Now;
order.FraudScore = -1;
order.PaymentStatus = WebServices3.OrderPaymentStatus.Unpaid;
order.ShippingStatus = WebServices3.OrderShippingStatus.Unshipped;

//Insert the order
Orders_Order_Insert()

//Refresh the local order
Orders_Order_FindByBvin()

//Add product(s)
Orders_Order_AddItem_ByBvin()

//Refresh the local order
Orders_Order_FindByBvin()

//Get shipping methods
Orders_Order_FindAvailableShippingRates()
Aaron
#13 Posted : Monday, January 12, 2015 6:00:43 PM(UTC)
Aaron

Rank: Administration

Joined: 4/2/2004(UTC)
Posts: 2,381
United States
Location: Hummelstown, PA

Thanks: 6 times
Was thanked: 163 time(s) in 158 post(s)
Originally Posted by: tappedtech Go to Quoted Post
It doesn't fail every time but I can't detect a pattern. It fails more often than it works.

Can you make the same API request multiple times and get different results?

I could offer some suggestions if you weren't getting any shipping rates, but it sounds like you're getting rates back with incomplete/null properties. I know when I tested some of the properties were null, but not the DisplayName property.
Aaron Sherrick
BV Commerce
Toll-free 888-665-8637 - Int'l +1 717-220-0012
tappedtech
#14 Posted : Wednesday, January 14, 2015 4:52:58 PM(UTC)
tappedtech

Rank: Member

Joined: 11/21/2014(UTC)
Posts: 66

I just tried to pull the shipping methods for the orders created when I was testing this a few days ago and it worked correctly.

I haven't altered the orders in any way and I haven't made any changes in how I'm requesting the shipping methods.

I also tested it with a completely new order and it worked correctly.

So the issue isn't consistent. I find it very odd that when it fails, I still get the correct rates but everything else is null.

Is there anything else you can look into?
tappedtech
#15 Posted : Thursday, January 15, 2015 5:44:14 PM(UTC)
tappedtech

Rank: Member

Joined: 11/21/2014(UTC)
Posts: 66

I have a few more Order.

For gift certificates and cards, I'm creating a OrderPayment and adding it to the order via Orders_Order_AddPayment().

What needs to be filled in for the OrderPayment for each type? What are the payment types?

You set the OrderID and AuditDate when responding to my PayPal question so I assume these are required fields.

For cards I'm setting:
CreditCardType - what is stored for type?
CreditCardHolder
CreditCardNumber
CreditCardSecurityCode
CreditCardExpYear
CreditCardExpMonth

For gift certificates:
GiftCertificateNumber
Ryan Groene
#16 Posted : Friday, January 16, 2015 10:48:00 AM(UTC)
Ryan Groene

Rank: Member

Joined: 10/28/2014(UTC)
Posts: 11
United States
Location: Hummelstown, PA

Was thanked: 2 time(s) in 2 post(s)
For credit cards, you'll probably need the following fields:

AmountAuthorized
AmountCharged
AmountRefunded (if it's not 0, which it usually is)

In BV, you can have it set to authorize payments when the user first places the order and capture them later. The only case where AmountAuthorized and AmountCharged will be different is when an order was placed, but not fully processed in BV.

You'll also need all of the CreditCard fields that you mentioned above. The CreditCardType field keeps track of what type of credit card was used (Visa, MasterCard, etc.) It uses a one-character code as follows (M=MasterCard, V=Visa, D=Discover, A=American Express). There are also some other options like JCB, Diner's Club, etc., but I don't remember those ones off the top of my head. Let me know if you need codes for anything other than the 4 major credit cards mentioned above. CreditCardExpMonth is simply an integer between 1 and 12, while creditCardExpYear is the entire year (i.e. 2014, not just 14). Credit card numbers that are stored in BV are automatically encrypted.

OrderID is necessary to connect the payment to a specific order. The PaymentMethodId field also must be filled in--this determines the payment type. There are a number of payment types built into BV, though it is also possible to add custom ones. You can retrieve all of the ID's for available payment methods by calling either Payment_AvailablePayments_EnabledMethods or Payment_AvailablePayments_CollectibleMethods. The difference is that the latter only returns payment methods that are collectible via BV (so, for instance, not purchase orders or phone payments).

AuditDate is automatically initialized to the current date, so you don't need to fill that in.

Here are some of the built in ID's for reference:

7FCC4B3F-6E67-4f58-86B0-25BCCC035A0E Cash
494A61C8-D7E7-457f-B293-4838EF010C32 Check
4A807645-4B9D-43f1-BC07-9F233B4E713C Credit Card
4B0A1BD7-1EE1-4BE0-87B4-E635F96442BF Offline
33eeba60-e5b7-4864-9b57-3f8d614f8301 Paypal Express
26C948F3-22EF-4bcb-9AE9-DEB9839BF4A7 Purchase Order
9FD35C50-CDCB-42ac-9549-14119BECBD0C Telephone
91a205f1-8c1c-4267-bed0-c8e410e7e680 Gift Certificate

For purchase orders, you'll also need to fill in purchaseOrderNumber
For gift certificates, you'll also need to fill in giftCertificateNumber

Edited by user Friday, January 16, 2015 10:55:37 AM(UTC)  | Reason: Not specified

Ryan Groene
BV Commerce
Toll-free 888-665-8637 - Int'l +1 717-220-0012
tappedtech
#17 Posted : Saturday, January 17, 2015 3:03:40 PM(UTC)
tappedtech

Rank: Member

Joined: 11/21/2014(UTC)
Posts: 66

Originally Posted by: Ryan Groene Go to Quoted Post
For credit cards, you'll probably need the following fields:

AmountAuthorized
AmountCharged
AmountRefunded (if it's not 0, which it usually is)

In BV, you can have it set to authorize payments when the user first places the order and capture them later. The only case where AmountAuthorized and AmountCharged will be different is when an order was placed, but not fully processed in BV.


Wouldn't the AmountAuthorized and AmountCharged be 0 when adding the payment information to the order since the order and payment information hasn't been processed yet?

Depending on your answer to my question above, are these fields only required for credit cards? What about PayPal?

Originally Posted by: Ryan Groene Go to Quoted Post

OrderID is necessary to connect the payment to a specific order. The PaymentMethodId field also must be filled in--this determines the payment type. There are a number of payment types built into BV, though it is also possible to add custom ones. You can retrieve all of the ID's for available payment methods by calling either Payment_AvailablePayments_EnabledMethods or Payment_AvailablePayments_CollectibleMethods. The difference is that the latter only returns payment methods that are collectible via BV (so, for instance, not purchase orders or phone payments).


Does the PaymentMethodName need to be filled in too or is the PaymentMethodId enough?
tappedtech
#18 Posted : Saturday, January 17, 2015 5:27:50 PM(UTC)
tappedtech

Rank: Member

Joined: 11/21/2014(UTC)
Posts: 66

In addition to the questions I posted above a few hours ago, I have another order issue.

I'm trying to add a shipping method to the order. The result comes back true when I add it but when I look at the order it has no shipping method associated with it.

This is how I'm adding the shipping method to the order:
WebServices3.ShippingRate[] shippingRates = ws.Orders_Order_FindAvailableShippingRates(ref token, order);
WebServices3.ShippingRate selectedShippingRate = shippingRates[0]; //Not really 0
bool shippingMethodAdded = ws.Orders_Order_ApplyShippingRate(ref token, order, selectedShippingRate);
tappedtech
#19 Posted : Monday, January 19, 2015 1:31:11 PM(UTC)
tappedtech

Rank: Member

Joined: 11/21/2014(UTC)
Posts: 66

I have an additional order question. I noticed the order's tax amount isn't changing.

Do I need to call Taxes_Tax_CalculateTaxForOrder to have the tax amount calculated and applied?
Ryan Groene
#20 Posted : Monday, January 19, 2015 6:18:07 PM(UTC)
Ryan Groene

Rank: Member

Joined: 10/28/2014(UTC)
Posts: 11
United States
Location: Hummelstown, PA

Was thanked: 2 time(s) in 2 post(s)
Originally Posted by: tappedtech Go to Quoted Post
Wouldn't the AmountAuthorized and AmountCharged be 0 when adding the payment information to the order since the order and payment information hasn't been processed yet?


Actually, you are correct. These fields will be populated automatically when you call the workflow.

Originally Posted by: tappedtech Go to Quoted Post
Does the PaymentMethodName need to be filled in too or is the PaymentMethodId enough?


I believe the order will still go through without PaymentMethodName as the code always uses the PaymentMethodId for lookup. However, not specifying the PaymentMethodName may affect what is displayed at certain places in the BV admin, so I'd say it's probably best to include it. The name you should specify

I'll respond to your other posts tomorrow as I have to go now.
Ryan Groene
BV Commerce
Toll-free 888-665-8637 - Int'l +1 717-220-0012
2 Pages12>
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

©2024 Develisys. All rights reserved.
  • Toll-free  888-665-8637
  • International  +1 717-220-0012