|
Home > Archive > Commerce Server General > February 2004 > Assign order number before credit card validation and saveasorder
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Assign order number before credit card validation and saveasorder
|
|
| Jennifer 2004-02-07, 9:36 am |
| I am working with Commerce Server 2002 and am needing to assign an
order number to a basket up front and save it to the basket (before a
call to Cybersource and before saving the basket as an order). I
figured out how to generate an id easily by using the OrderTracking
counter currently being used by SaveAsOrder and I thought that if I
set the order_number in the basket prior to saving as an order that
SaveAsOrder would not generate a new order number. Unfortunately,
this doesn't seem to be true OR I am doing something wrong.
The code I setup to test the scenario (set order number and
saveasorder) is as follows:
basket.SetPropertyOnOrderForms("order_number","300");
........
........
basket.SaveAsOrder();
My hope is to replace the "300" number up top with a call to the GenID
OrderTracking to generate new ids. I just used 300 for testing.
After running this I looked at the counters table and verified that
yes a new id was generated (not what I wanted) and found that no order
exists with a '300' number in the OrderGroup table (not what I wanted
either).
Thanks,
Jennifer
| |
| Giles Jerrit 2004-02-07, 9:36 am |
| Jennifer,
At last there seems to be someone else out there that is using Commerce
Server 2002 and Cybersource! I did try to do the same as you are now,
without much success, but that was a while ago and I think I have more of an
idea of what is going on now.
I realise that my case doesn't exactly fit what you are trying to do but
I'll break down what I did and maybe it could be of help. And if anyone else
out there has a better idea then that'd be cool too.....
The requirements for the company I am working for was for each attempt the
user made to authorise the card, the order was stored in the database.
In the event of the order being accepted, the status was updated to accepted
and the basket was cleared.
If, however, the order was not accepted, the order status was set to
declined and a new basket was generated for the user identical to their
original one so they could try and place the order again.
Every time the order attempt is made I set the basket status to
OrderIncomplete (a status we made up so if the system falls over the order
is not be default accepted) and run the basket.SaveAsOrder() method which
returns a purchase order. I then extract the order number from the purchase
order and use this number as the merchant reference number to contact
Cybersource.
In the event of an accepted authorisation, the order status is set to
Accepted and the purchase order is updated with all the cybersource reply
fields.
In the event of a failed authorisation, the order status is set to Declined
and the cybersource reply fields are copied into the purchase order. Then
the
basket.Add((PurchaseOrder)purchaseOrder) is called to refill the basket with
the original data and the user is ready to go again.....
Is this of any help at all?
This is not the exhaustive explanation and there are a few fiddly things
that need to be done in the background, but it shows how I got round the
problem. The only downside of this method (hopefully there is only one) is
that the payment page does take a while with a SaveAsOrder() and multiple
Update() calls.
Giles
"Jennifer" <jdickson@beacontec.com> wrote in message
news:4195d87c.0401070752.5940d00f@posting.google.com...
> I am working with Commerce Server 2002 and am needing to assign an
> order number to a basket up front and save it to the basket (before a
> call to Cybersource and before saving the basket as an order). I
> figured out how to generate an id easily by using the OrderTracking
> counter currently being used by SaveAsOrder and I thought that if I
> set the order_number in the basket prior to saving as an order that
> SaveAsOrder would not generate a new order number. Unfortunately,
> this doesn't seem to be true OR I am doing something wrong.
>
> The code I setup to test the scenario (set order number and
> saveasorder) is as follows:
>
> basket.SetPropertyOnOrderForms("order_number","300");
> .......
> .......
> basket.SaveAsOrder();
>
> My hope is to replace the "300" number up top with a call to the GenID
> OrderTracking to generate new ids. I just used 300 for testing.
> After running this I looked at the counters table and verified that
> yes a new id was generated (not what I wanted) and found that no order
> exists with a '300' number in the OrderGroup table (not what I wanted
> either).
>
> Thanks,
> Jennifer
>
| |
| Erik Mavrinac [MSFT] 2004-02-07, 9:36 am |
| Jennifer, you're not calling a SaveAsBasket() or SaveAsTemplate() in between the SetPropertyOnOrderForms() and SaveAsOrder(), are you? Those
methods clear order_number to DBNull.Value (in VB.NET/C# terms).
Also, generally order_number is intended for use at the order group level, not on order forms. You might try setting basket["order_number"] = "300" instead
and see if the system then recognizes that an order_number was available in the order group and not regenerate it. (You could also copy the value to the
key in the order forms if you like for reference by your own site code, but the system is looking in the order group.)
Erik
--------------------
From: jdickson@beacontec.com (Jennifer)
Subject: Assign order number before credit card validation and saveasorder
Date: 7 Jan 2004 07:52:54 -0800
I am working with Commerce Server 2002 and am needing to assign an
order number to a basket up front and save it to the basket (before a
call to Cybersource and before saving the basket as an order). I
figured out how to generate an id easily by using the OrderTracking
counter currently being used by SaveAsOrder and I thought that if I
set the order_number in the basket prior to saving as an order that
SaveAsOrder would not generate a new order number. Unfortunately,
this doesn't seem to be true OR I am doing something wrong.
The code I setup to test the scenario (set order number and
saveasorder) is as follows:
basket.SetPropertyOnOrderForms("order_number","300");
.......
.......
basket.SaveAsOrder();
My hope is to replace the "300" number up top with a call to the GenID
OrderTracking to generate new ids. I just used 300 for testing.
After running this I looked at the counters table and verified that
yes a new id was generated (not what I wanted) and found that no order
exists with a '300' number in the OrderGroup table (not what I wanted
either).
Thanks,
Jennifer
--
This posting is provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
Note: For the benefit of the community-at-large, all responses to this message are best directed to the newsgroup/thread from which they originated.
|
|
|
|
|