Credit Card Number -CPAYMENT

Hi,

I am getting an exception :The type initializer for 'Asi.Security.AppPrincipal' threw an exception

  var payment = new CPayment(CStaffUser.GetDefaultStaffUser())
            {
                CashAccountCode = "VISA",
                CreditCardNumber = "4007000000027"
            };

 

I have tried this as well:

 

                IiMISUser user1 = CContactUser.LoginByWebLogin("33232");  OR IiMISUser user1 = CStaffUser.Login("Manager", "ddsd432");

then
                Payment = new CPayment(user1);
                Payment.Amount = 120;
                Payment.PaymentType = EnumPaymentType.CreditCard;
                Payment.CreditDebitCardAuthorizationCode = "123";
                Payment.CreditCardSecurityCode = "123";
                Payment.CreditCardExpiration = "12/50";
                Payment.CreditDebitCardHoldersName = "Name";
                Payment.CreditCardNumber = "41111111111111111";
                Payment.CashAccountCode = "VISA";
                Payment.Validate();

 

the exception happesn at credit card number line,

 

is there some process i need to follow when creating user, and insert payment for that product?

 

or

is there any IMIS setup I need to do in IMIS Desktop ??

 

Thanks

 

 

 

Comment viewing options

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

card number length?

4007000000027 is a 13-digit VISA number; I'm not sure if that's a valid test number for that length or not.

41111111111111111 from your code sample is 17 digits long.

Try "4111111111111111" - 4 followed by 15 1s - in both code snippets, to see if you get better results.

Didnt Work!!

Didn't Work,

is there something related to how imis was setup, or is there any configuration need to be in web.config?

is there any DLLs other than ASI's need to be referenced, for example gateway DLLs?

i tried many many test numbers - AMEX,VISA and others

none worked

I was able to get past the AppPrincipal error...

 by this code (Sorry it is VB.NET):

you need to eventually get a iIMISUser object (apparently)....

Dim User As CContactUser = CContactUser.LoginByWebLogin("testee", "testee")
        Dim PUser As CWebUser = CWebUser.LoginByPrincipal(User)

 Dim user1 As IiMISUser = DirectCast(Puser, IiMISUser)

Then continue on using the user1 as the user variable.

Here is what I cannot get past: I am pointing to my Test Paypal merchant account and when I use any old CC # it hits the merchant account with an Invalid CC error returned.

but when I use the Visa 411... test card I get an Object Reference not set to instance of object error...(wierd)

Hope the code above helps somewhat..

-Paul

Didnt Work!!

I used what u suggested and thanks for that, but didnt work?

                            CContactUser userNew = CContactUser.LoginByWebLogin(ConfigurationManager.AppSettings["LoginKey"], ConfigurationManager.AppSettings["LoginPW"]);
                            CWebUser pUser = CWebUser.LoginByPrincipal(userNew);
                            IiMISUser Iuser = (IiMISUser)pUser;
                            CPayment Payment = new CPayment(Iuser);
                            Payment.Amount = 120;
                            Payment.PaymentType = EnumPaymentType.CreditCard;
                            Payment.CreditDebitCardAuthorizationCode = "123";
                            Payment.CreditCardSecurityCode = "123";
                            Payment.CreditCardExpiration = "12/50";
                            Payment.CreditDebitCardHoldersName = "Name";
                            Payment.CreditCardNumber = "4111111111111111";
                            Payment.CashAccountCode = "VISA";
                            Payment.Validate();

 

the exception if happening at :                            Payment.CreditCardNumber = "4111111111111111";

 

Thanks

Try this (one more time w/feeling....)

Update that first line of code to :

CContactUser userNew = CContactUser.LoginByWebLogin(ConfigurationManager.AppSettings["LoginKey"], true);

That will at least force AppPrincipal to be the User ID of whatever [ "LoginKey"] is.

That should, "for all that is good and holy" , work !!