Order NewLineItem doesn't work

"

 

Hi!

We are using simple code to add new line item to order and it doesn’t' work:

protected void Button1_Click(object sender, EventArgs e)
        {
             IiMISUser user = (IiMISUser)CStaffUser.Login(ConfigurationManager.AppSettings["System.WebLogin"], ConfigurationManager.AppSettings["System.Password"]);

            CStandardOrder myOrder = new CStandardOrder(user);
           
            CStandardOrderLine myNewItem =  myOrder.NewLineItem("EDU_XXXXXX", 1);
        }

First 2 line work but 

myNewItem is allways NULL.

Please help.

Thank you!

 

Comment viewing options

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

After calling the below

After calling the below line

CStandardOrderLine myNewItem =  myOrder.NewLineItem("EDU_XXXXXX", 1);

Please check

 if  (orderline != null)

{

        // make changes to order line

}

otherwise check whether there are any errors added  into myOrder object.

something like

if  (myOrder.ErrorCount > 0)

{

    Console.WriteLine(myOrder.Errors.PrimaryErrorMessage);

}

 

 

 

  Hi! Thanks for reply. We

 

Hi!
Thanks for reply.
We checked our code and it came out with 2 errors.
 
1# The supplied value, '0' is not defined in the Financial Terms reference table and is invalid.
2# The system setting for Order_Control.WebOrderType is missing.  It must be set before performing this operation.
 
 
We did everything according example on your site. Which property and values we have to set  correspond to above errors.
Thank you!

I am not sure about

I am not sure about Financial Terms supplied value '0' error but you can insert these 2 records and restart your IIS or restart your development server could solve the problem

INSERT INTO System_Params (ParameterName, ShortValue)
VALUES ('Order_Control.WebOrderType','WEB')

INSERT INTO System_Params (ParameterName, ShortValue)
VALUES ('AR_Control.TermsCode','30')
 

If you still get the Fin. Terms error after inserting these records, try changing '30' to '0' for Terms code entry

Thanks

Hi! Thank you for promt

Hi!

Thank you for promt reply.

We run all querie as you said and received below errors:

"COrder.TermsCode" The supplied value, '0' is not defined in the Financial Terms reference table and is invalid.
"COrder.OrderTypeCode" "The supplied value, 'WEB' is not defined in the Set up Order Types window and is invalid."
The system setting for Order_Control.WebOrderType is missing.  It must be set before performing this operation.
What is your suggestions?

Thank you!

  Ok, Looks like you don't

 

Ok,

Looks like you don't have an entry in TERMS, Order type tables

You can inser those records using below sql statements

INSERT INTO Terms

 

           ([TERMS_CODE]
           ,[DESCRIPTION]
           ,[DISC_DAYS]
           ,[DISC_PERCENT]
           ,[DUE_DAYS])
     VALUES (0,'T0' ,0,0 ,0)
  
INSERT INTO Order_Type([CODE],[DESCRIPTION],[INVOICE_DESCRIPTION],[TYPE_OF_ORDER],[AFFECT_INVENTORY],[SHIPPING_PAPER_ACTION],[INVOICE_ACTION]
           ,[CONVERSION_CODE],[PRINTQUOTE_STAGE],[PICKLIST_STAGE],[SHIPPAPER_STAGE]
           ,[INVOICE_STAGE])
VALUES
           ('WEB','WEB ORDER','INVOICE',3,0,0,0,'REG',0,0 ,0,0)

 

 

Hi! Looks good now. Only

Hi!

Looks good now.

Only thing is a message related to product property I guess:

Err Num: 20 - CStandardOrder.NewLineItem: The product 'ED_XXX/XXX' is not available for sale on the web.

Which product attribute we have to set so it works.

Many thanks!

 

You need to set this product

You need to set this product to 'Sell on Web' 

You can set this Option from

iMIS Desktop client

1. Select Orders tab from Top navigation

2. From Left navigation menu select 'Manage Inventory'

3. select 'Manage Products'

4. Now you will see list of products

5. Select the product you want to make sell on the web

6. Click 'Web' button or [Alt + W]  

7. There will be 3 options you need to select the last option and click Save

Thanks

  We don’t

 

We don’t “Sell” inventory. The products we are using are function codes for Events. The product is really an Event code and function code.
  
What the order schema works for Events code?
Or how mark event available for sell on Web?
 

You need to use CEvent and

You need to use CEvent and CRegistration objects for event registrations

Please look at this sample code.

http://www.imiscommunity.com/event_function_with_negative_fees

I get  access denied when I

I get  access denied when I try accessing the link above

I don't know why you can't

I don't know why you can't access this link, but this is the sample code for creating a new registration

2043 - Registrant Id

AM09TEST - Event Code

CContact testContact = new CContact(ManagerUser, "2043");
CEvent testEvent = new CEvent(ManagerUser, "AM09TEST");
CRegistration testRegistration = new CRegistration(ManagerUser, "AM09TEST", testContact.ContactId, false, false);

testRegistration.FirstName = testContact.FirstName;
testRegistration.LastName = testContact.LastName;

testRegistration.RegistrantClass = "M";
testRegistration.BatchNumber = "TESTBATCH";

testRegistration.NewLineItem("REGISTER", 1);
testRegistration.NewLineItem("LCD", 1);

CPayment testPayment = testRegistration.Payment;
testPayment.PaymentType = EnumPaymentType.CreditCard;
testPayment.Amount = testRegistration.TotalCharges;
testPayment.CashAccountCode = "VISA";
testPayment.CreditCardNumber = "4111111111111111";
testPayment.CreditCardSecurityCode = "123";
testPayment.CreditDebitCardHoldersName = "John Doe";
testPayment.CreditCardExpiration = "1209";

if (!testPayment.Validate())
{
	foreach (CError err in testPayment.Errors)
		LblStatus.Text += err.Message + "
"; return; } if (!testRegistration.Validate()) { foreach (CError err in testRegistration.Errors) LblStatus.Text += err.Message + "
"; return; } if (!testRegistration.Save()) foreach (CError err in testRegistration.Errors) LblStatus.Text += err.Message + "
"; LblStatus.Text += "Registration successful.";

Thank you so mach! Looks

Thank you so mach!

Looks good now except we getting error:

Err Num: 12 - CPayment.CreditCardNumber: The supplied card number is not valid.

I did test even real AMEX

I did test even real AMEX credit card and got error:

Object reference to set.

I think you don't have cash

I think you don't have cash account code called 'AMEX', also make sure that cash account type must be ticked as credit/debit card .

Always check Error collection to get the exact error details.

 

 

We check our setting and 

We check our setting and  we have all CashAccounts set. So When I use bellow code snippet  Im getting  diferent error messages:

--- On Payment Validation

The supplied card number is not valid .

--- Registration Validation

This functionality is not supported by iBO at this time.

For this version full payment must be made for the registration.

 

 

             CContact testContact = new CContact(user, "276354");
                CEvent testEvent = new CEvent(user, "XXX_1008");
                CRegistration testRegistration = new CRegistration(user, "XXXX_1008", testContact.ContactId, false, false);
                CRegistrationLineItem lineItem = testRegistration.NewLineItem(testEvent.Functions[0].FunctionCode, 1, true);

                testRegistration.FirstName = testContact.FirstName;
                testRegistration.LastName = testContact.LastName;

                testRegistration.RegistrantClass = "M";
                testRegistration.BatchNumber = CreateBatch(contact, user);
             

                CPayment testPayment = testRegistration.Payment;
                testPayment.PaymentType = EnumPaymentType.CreditCard;
                testPayment.Amount = testRegistration.TotalCharges;
               
                testPayment.CashAccountCode = "AMEX";
                testPayment.CreditCardNumber = "4111111111111111"; 
                testPayment.CreditCardSecurityCode = "6737";
                testPayment.CreditDebitCardHoldersName = "User Name";
                testPayment.CreditCardExpiration = "1113";
               

                if (!testPayment.Validate())
                {
                    foreach (Asi.iBO.Errors.CError err in testPayment.Errors)
                        _err += err.Message + "";
                   // return;
                }
                
                
                
 

Please use valid credit card

Please use valid credit card number for AMEX, the number you are using is valid only for VISA

http://www.crazysquirrel.com/finance/test-cc.jspx

Second error could be a side effect from the first error. since no valid card number defined.

Payment much match balance due

For the second error, I don't see where you have indicated the amount of the payment. You need to set that and it needs to equal the total amount of the registration.

Thanks,

Randy

I can see there is line

I can see there is line which does set the payment amount?

Is it not enough?

testPayment.Amount = testRegistration.TotalCharges;

didn't see that

Sorry,

 

I didn't catch that total_charges item. that is enough. I would step through and make sure that value is non 0.

thanks,

Randy

Hi, Randy!  Thank you for

Hi, Randy!

 Thank you for you promt help. We did everything as you said.
 Below is a complete function code
 
 The line :
 testPayment.CreditCardNumber = "37xxxxxxxxxxxxxxx";//real card number cause  NullReferenceException - "Object reference not set to an instance of an object."
 
 
 protected void CreateImisEvent(CContact testContact, IiMISUser user)
        {
            if (user == null)
                user = CStaffUser.Login(ConfigurationManager.AppSettings["System.WebLogin"], ConfigurationManager.AppSettings["System.Password"]);
            if (user == null)
                throw new Exception("System login faild in CreateImisOrderBTContact");
  

            String _err = String.Empty;
            try
            {
    
                CEvent testEvent = new CEvent(user, "EDUC_1008");
                CRegistration testRegistration = new CRegistration(user, "EDUC_1008", testContact.ContactId, false, false);
                CRegistrationLineItem lineItem = testRegistration.NewLineItem(testEvent.Functions[0].FunctionCode, 1, true);
                lineItem.UnitPrice = 100M;
                testRegistration.FirstName = testContact.FirstName;
                testRegistration.LastName = testContact.LastName;

                testRegistration.RegistrantClass = "M";
                testRegistration.BatchNumber = CreateBatch(testContact, user);
             

                CPayment testPayment = testRegistration.Payment;
                testPayment.PaymentType = EnumPaymentType.CreditCard;
              
                testPayment.Amount = testRegistration.TotalCharges; // TotalCharges = 100M
                testPayment.CashAccountCode = "AMEX";
                testPayment.CreditCardNumber = "37xxxxxxxxxxxxxxx"; //real card number
                testPayment.CreditCardSecurityCode = "6737"; // real security code
                testPayment.CreditDebitCardHoldersName = "User Name"; //real user first last name
                testPayment.CreditCardExpiration = "1113"; //real expiration date
               

                if (!testPayment.Validate())
                {
                    foreach (Asi.iBO.Errors.CError err in testPayment.Errors)
                        _err += err.Message + "";
                   // return;
                }

                if (!testRegistration.Validate())
                {
                    foreach (Asi.iBO.Errors.CError err in testRegistration.Errors)
                        _err += err.Message + "";
                    //return;
                }

                if (!testRegistration.Save())
                    foreach (Asi.iBO.Errors.CError err in testRegistration.Errors)
                        _err += err.Message + "";

                _err += "Registration successful.";

            }catch(Exception){
            }
        }

One more questions, does the

One more questions, does the credit card getting charged. What actually card processing work flow? 

Credit card does not get

Credit card does not get charged, Credit card process called when you call "ProcessPayment" method from payment object otherwise no.

About Object no found error: Have you tested using VISA card 41111... was it saving correctly?

 

 

 

Hi!Thank you for prompt

Hi!

Thank you for prompt response.

 We did test with VISA.

Code line

testPayment.CreditCardNumber = "4111111111111111";  - Generates exception: Object reference not set to an instance of an object.

Below full code snippet. What is your idea guys?

 protected void CreateImisEvent(CContact testContact, IiMISUser user)
        {
            if (user == null)
                user = CStaffUser.Login(ConfigurationManager.AppSettings["System.WebLogin"], ConfigurationManager.AppSettings["System.Password"]);
            if (user == null)
                throw new Exception("System login faild in CreateImisOrderBTContact");
  

 

            String _err = String.Empty;
            try
            {
    
                CEvent testEvent = new CEvent(user, "EDUC_1008");
                CRegistration testRegistration = new CRegistration(user, "EDUC_1008", testContact.ContactId, false, false); 
                testRegistration.FirstName = testContact.FirstName;
                testRegistration.LastName = testContact.LastName;
                testRegistration.RegistrantClass = "M";
  
               
                CRegistrationLineItem lineItem = testRegistration.NewLineItem(testEvent.Functions[0].FunctionCode, 1, true);
               
              
                CPayment testPayment = testRegistration.Payment;
                testPayment.PaymentType = EnumPaymentType.CreditCard;
                testPayment.Amount = testRegistration.TotalCharges;

                #region VISA
                 testPayment.CashAccountCode = "VISA";
                 testPayment.CreditCardNumber = "4111111111111111"; // Exception: Object reference not set to an instance of an object.
                 testPayment.CreditCardSecurityCode = "123";
                 testPayment.CreditDebitCardHoldersName = testContact.FullName;
                 testPayment.CreditCardExpiration = "1113";
                #endregion

 

                 testRegistration.BatchNumber = CreateBatch(testContact, user);
                if (!testPayment.Validate())
                {
                    foreach (Asi.iBO.Errors.CError err in testPayment.Errors)
                        _err += err.Message + "";
                   // return;
                }

                if (!testRegistration.Validate())
                {
                    foreach (Asi.iBO.Errors.CError err in testRegistration.Errors)
                        _err += err.Message + "";
                    //return;
                }

                if (!testRegistration.Save())
                    foreach (Asi.iBO.Errors.CError err in testRegistration.Errors)
                        _err += err.Message + "";

                _err += "Registration successful.";

            }catch(Exception){
            }
        }