xWeb Event Registration Free Event
If you have a free event and you want to use the WEBCentralizedShoppingCartInsert and related xWeb web methods to manage the event registration, you can do so with the following case study.
First, let's define a "free event" in NetForum. There is a flag on the Event labeled Free Event. Select that check box and save the event to make the event free; see No_Fee_Event/Session_Registration for more details. When this flag is checked, then NetForum will automatically suppress the creation of invoices/payments etc. when people register for this event in xWeb.
There is one catch: the various CentralizedShoppingCart methods are built around having invoice line items--even for free events which, in the end, will not have any line items. Therefore, in the event setup in iWeb, the event manager will need to create a $0.00 Registration Fee for the event. In your xWeb integration, you'll need to allow the registrant to choose that $0.00 fee just like any other fee and add that Fee to the registrant. If you try to add a registrant to the cart without line items, you'll get a xWebException described in WEBCentralizedShoppingCartAddEventRegistrant#No_line_items_selected.
Add that $0.00 Fee to the EventsRegistrantType the same way as a regular paid fee.
When you submit the order to xWeb in WEBCentralizedShoppingCartInsert, you can pass a blank element for the Payment and Payment_Info elements. You'll need to set certain values in the Invoice element to instruct NetForum to create what's called a "terms" invoice with no payment (although it won't actually create an invoice anyway); see the code below or see Terms_Invoice_With_No_Payment for more.
When the transaction is saved, you will have an event registration but no invoice or payment.
If you do have other line items in the cart that do require payment, then treat the transaction like any other paid order. As long as you have a $0.00 registration fee with the EventsRegistrantType, then everything should work.
Code
The code below is a Visual Studio .NET C# code sample illustrating the case study:
// properties object containing settings for xWeb Username and Password
// this is for illustrative purposes; you might have a different way for storing these settings.
var props = Properties.Settings.Default;
// instantiate web reference
var xWeb = new netForumXML();
// Authenticate
xWeb.Authenticate(props.username, props.pwd);
// Create a new shopping cart object
CentralizedOrderEntryType cart = new CentralizedOrderEntryType();
// Load a blank shopping cart by passing the Customer key of the shopper (typically the registrant):
cart = xWeb.WEBCentralizedShoppingCartGetNew(new Guid("21F1093B-FD6A-4D7F-9DC2-86CDACCE3171"));
EventsRegistrantType reg = new EventsRegistrantType();
// Load the registrant by passing the exising reg_key
reg = xWeb.WEBCentralizedShoppingCartEventRegistrantGet(new Guid("a3ffb9d7-621e-4752-99b6-6365302dca99"));
// Add any new Session Fees. The GUIDs relate are the prc_key for a particular Session Fee
List<Guid> feeGuids = new List<Guid>();
feeGuids.Add(new Guid("922DF215-9448-45F7-82BF-D988999FEC2E")); // first session
feeGuids.Add(new Guid("248EF7EA-CB21-4F07-8E0B-830D27EC946D")); // second session; you could keep adding more...
// Fees Collection
Fee[] fees = new Fee[feeGuids.Count];
for (int i = 0; i < feeGuids.Count; i++)
{
Fee eventFee = new Fee();
eventFee.prc_key = feeGuids[i];
eventFee.action = FeeAction.Add;
eventFee.qty = 1;
eventFee.overrideamount = 0;
fees[i] = eventFee;
}
// Set the line items. Do not worry about what the registrant already paid for in the past,
// you just need the NEW fees for the sessions to be added
reg = xWeb.WEBCentralizedShoppingCartEventRegistrantSetLineItems(reg, fees);
// The next lines illustrate that you need to set the rgs_cancel_qty to "0" for any
// registrant session(s) in your collection.
for (int i = 0; i < reg.Registrant_SessionCollection.Count(); i++)
{
var ses = reg.Registrant_SessionCollection[i];
ses.ev_registration_session.rgs_cancel_qty = "0";
reg.Registrant_SessionCollection[i] = ses;
}
// Add the Registrant object to the Cart
cart = xWeb.WEBCentralizedShoppingCartAddEventRegistrant(cart, reg);
// Set payment information
cart.Payment_Info.pin_cc_cardholder_name = "First M. Last";
cart.Payment_Info.pin_cc_number = "4111111111111111";
cart.Payment_Info.pin_cc_expire = "2011/12"; // Correct format is yyyy/mm
cart.Payment_Info.pin_apm_key = "E3065977-EA16-44B9-9B4F-407150B5C2C1"; // AMEX, Visa, etc.
cart.Payment_Info.pin_check_amount = cart.Invoice.inv_nettotal;
cart.Payment_Info.pin_check_amountSpecified = true;
cart.Invoice.inv_autoapply = 1;
cart.Invoice.inv_autoapplypayment = 1;
// Insert the Cart and payment
cart = xWeb.WEBCentralizedShoppingCartInsert(cart);