public string GetCustomerProfile()
        {
            ApiOperationBase <ANetApiRequest, ANetApiResponse> .RunEnvironment         = AuthorizeNet.Environment.SANDBOX;
            ApiOperationBase <ANetApiRequest, ANetApiResponse> .MerchantAuthentication = new merchantAuthenticationType()
            {
                name            = "35WkY7AsU",
                ItemElementName = ItemChoiceType.transactionKey,
                Item            = "85T8Hsv4JMu76P5b"
            };

            customerProfileType customerProfile = new customerProfileType();

            //customerProfile.merchantCustomerId = "Test CustomerID";
            customerProfile.email       = "*****@*****.**";
            customerProfile.description = "abc";


            var request = new createCustomerProfileRequest {
                profile = customerProfile, validationMode = validationModeEnum.none
            };

            // instantiate the controller that will call the service
            var controller = new createCustomerProfileController(request);

            controller.Execute();

            // get the response from the service (errors contained if any)
            createCustomerProfileResponse response = controller.GetApiResponse();

            // validate response
            if (response != null)
            {
                if (response.messages.resultCode == messageTypeEnum.Ok)
                {
                    return(response.customerProfileId);
                }
                else
                {
                    return($"{response.messages.message[0].code}+ and {response.messages.message[0].text}");
                }
            }
            else
            {
                if (controller.GetErrorResponse().messages.message.Length > 0)
                {
                    return($"{response.messages.message[0].code}+ and {response.messages.message[0].text}");
                }
                else
                {
                    return($"Profile created failed");
                }
            }
        }
        public static ANetApiResponse Run(string ApiLoginID, string ApiTransactionKey, string emailId)
        {
            Console.WriteLine("Create Customer Profile Sample");

            // set whether to use the sandbox environment, or production enviornment
            ApiOperationBase <ANetApiRequest, ANetApiResponse> .RunEnvironment = AuthorizeNet.Environment.SANDBOX;

            // define the merchant information (authentication / transaction id)
            ApiOperationBase <ANetApiRequest, ANetApiResponse> .MerchantAuthentication = new merchantAuthenticationType()
            {
                name            = ApiLoginID,
                ItemElementName = ItemChoiceType.transactionKey,
                Item            = ApiTransactionKey,
            };

            var creditCard = new creditCardType
            {
                cardNumber     = "4111111111111111",
                expirationDate = "1018"
            };

            var bankAccount = new bankAccountType
            {
                accountNumber = "231323342",
                routingNumber = "000000224",
                accountType   = bankAccountTypeEnum.checking,
                echeckType    = echeckTypeEnum.WEB,
                nameOnAccount = "test",
                bankName      = "Bank Of America"
            };

            // standard api call to retrieve response
            paymentType cc = new paymentType {
                Item = creditCard
            };
            paymentType echeck = new paymentType {
                Item = bankAccount
            };

            List <customerPaymentProfileType> paymentProfileList = new List <customerPaymentProfileType>();
            customerPaymentProfileType        ccPaymentProfile   = new customerPaymentProfileType();

            ccPaymentProfile.payment = cc;

            customerPaymentProfileType echeckPaymentProfile = new customerPaymentProfileType();

            echeckPaymentProfile.payment = echeck;

            paymentProfileList.Add(ccPaymentProfile);
            paymentProfileList.Add(echeckPaymentProfile);

            List <customerAddressType> addressInfoList = new List <customerAddressType>();
            customerAddressType        homeAddress     = new customerAddressType();

            homeAddress.address = "10900 NE 8th St";
            homeAddress.city    = "Seattle";
            homeAddress.zip     = "98006";


            customerAddressType officeAddress = new customerAddressType();

            officeAddress.address = "1200 148th AVE NE";
            officeAddress.city    = "NorthBend";
            officeAddress.zip     = "92101";

            addressInfoList.Add(homeAddress);
            addressInfoList.Add(officeAddress);


            customerProfileType customerProfile = new customerProfileType();

            customerProfile.merchantCustomerId = "Test CustomerID";
            customerProfile.email           = emailId;
            customerProfile.paymentProfiles = paymentProfileList.ToArray();
            customerProfile.shipToList      = addressInfoList.ToArray();

            var request = new createCustomerProfileRequest {
                profile = customerProfile, validationMode = validationModeEnum.none
            };

            // instantiate the controller that will call the service
            var controller = new createCustomerProfileController(request);

            controller.Execute();

            // get the response from the service (errors contained if any)
            createCustomerProfileResponse response = controller.GetApiResponse();

            // validate response
            if (response != null)
            {
                if (response.messages.resultCode == messageTypeEnum.Ok)
                {
                    if (response.messages.message != null)
                    {
                        Console.WriteLine("Success!");
                        Console.WriteLine("Customer Profile ID: " + response.customerProfileId);
                        Console.WriteLine("Payment Profile ID: " + response.customerPaymentProfileIdList[0]);
                        Console.WriteLine("Shipping Profile ID: " + response.customerShippingAddressIdList[0]);
                    }
                }
                else
                {
                    Console.WriteLine("Customer Profile Creation Failed.");
                    Console.WriteLine("Error Code: " + response.messages.message[0].code);
                    Console.WriteLine("Error message: " + response.messages.message[0].text);
                }
            }
            else
            {
                if (controller.GetErrorResponse().messages.message.Length > 0)
                {
                    Console.WriteLine("Customer Profile Creation Failed.");
                    Console.WriteLine("Error Code: " + response.messages.message[0].code);
                    Console.WriteLine("Error message: " + response.messages.message[0].text);
                }
                else
                {
                    Console.WriteLine("Null Response.");
                }
            }

            return(response);
        }
Example #3
0
        public ActionResult CreateCustProfile(Card c)
        {
            string cardnumber = c.cardnumber;
            string expirydate = c.expirydate;
            string cvv        = c.cvv;


            Console.WriteLine("Create Customer Profile Sample");

            // set whether to use the sandbox environment, or production enviornment
            ApiOperationBase <ANetApiRequest, ANetApiResponse> .RunEnvironment = AuthorizeNet.Environment.SANDBOX;

            // define the merchant information (authentication / transaction id)
            ApiOperationBase <ANetApiRequest, ANetApiResponse> .MerchantAuthentication = new merchantAuthenticationType()
            {
                name            = ApiLoginID,
                ItemElementName = ItemChoiceType.transactionKey,
                Item            = ApiTransactionKey,
            };

            var creditCard = new creditCardType
            {
                cardNumber     = "4111111111111111",
                expirationDate = "0725"
            };

            //var bankAccount = new bankAccountType
            //{
            //    accountNumber = "231323342",
            //    routingNumber = "000000224",
            //    accountType = bankAccountTypeEnum.checking,
            //    echeckType = echeckTypeEnum.WEB,
            //    nameOnAccount = "test",
            //    bankName = "Bank Of America"
            //};

            // standard api call to retrieve response
            paymentType cc = new paymentType {
                Item = creditCard
            };
            //paymentType echeck = new paymentType { Item = bankAccount };

            List <customerPaymentProfileType> paymentProfileList = new List <customerPaymentProfileType>();
            customerPaymentProfileType        ccPaymentProfile   = new customerPaymentProfileType();

            ccPaymentProfile.payment = cc;
            //ccPaymentProfile.defaultPaymentProfile = true;

            //customerPaymentProfileType echeckPaymentProfile = new customerPaymentProfileType();
            //echeckPaymentProfile.payment = echeck;

            paymentProfileList.Add(ccPaymentProfile);

            //paymentProfileList.Add(echeckPaymentProfile);

            List <customerAddressType> addressInfoList = new List <customerAddressType>();
            customerAddressType        homeAddress     = new customerAddressType();

            homeAddress.address = "10900 NE 8th St";
            homeAddress.city    = "Seattle";
            homeAddress.zip     = "98006";


            customerAddressType officeAddress = new customerAddressType();

            officeAddress.address = "1200 148th AVE NE";
            officeAddress.city    = "NorthBend";
            officeAddress.zip     = "92101";

            addressInfoList.Add(homeAddress);
            addressInfoList.Add(officeAddress);


            customerProfileType customerProfile = new customerProfileType();

            customerProfile.merchantCustomerId = "Test parthlathiya";
            customerProfile.email           = Session["Email"].ToString();
            customerProfile.paymentProfiles = paymentProfileList.ToArray();
            customerProfile.shipToList      = addressInfoList.ToArray();

            var request = new createCustomerProfileRequest {
                profile = customerProfile, validationMode = validationModeEnum.none
            };

            // instantiate the controller that will call the service
            var controller = new createCustomerProfileController(request);

            controller.Execute();

            // get the response from the service (errors contained if any)
            createCustomerProfileResponse response = controller.GetApiResponse();

            DAL dal = new DAL();

            // validate response
            if (response != null)
            {
                if (response.messages.resultCode == messageTypeEnum.Ok)
                {
                    if (response.messages.message != null)
                    {
                        ViewBag.Message = "We have stored your card details. Now you can subscribe to any channel/pack with single click.";
                        ViewBag.Type    = "success";

                        dal.UpdateCustProfileId(Session["Email"].ToString(), response.customerProfileId, response.customerPaymentProfileIdList[0]);

                        //Console.WriteLine("Success!");
                        //Console.WriteLine("Customer Profile ID: " + response.customerProfileId);
                        Console.WriteLine("Payment Profile ID: " + response.customerPaymentProfileIdList[0]);
                        Console.WriteLine("Shipping Profile ID: " + response.customerShippingAddressIdList[0]);
                    }
                }
                else
                {
                    ViewBag.Message = "Customer Profile Creation Failed.";
                    ViewBag.Type    = "danger";
                    Console.WriteLine("Error Code: " + response.messages.message[0].code);
                    Console.WriteLine("Error message: " + response.messages.message[0].text);
                }
            }
            else
            {
                if (controller.GetErrorResponse().messages.message.Length > 0)
                {
                    ViewBag.Message = "Customer Profile Creation Failed.";
                    ViewBag.Type    = "danger";
                    Console.WriteLine("Error Code: " + response.messages.message[0].code);
                    Console.WriteLine("Error message: " + response.messages.message[0].text);
                }
                else
                {
                    Console.WriteLine("Null Response.");
                }
            }

            List <Channel> channelsList = dal.AllChannels();
            List <Pack>    packsList    = dal.AllPacks();

            ViewData["AllChannels"] = channelsList;
            ViewData["AllPacks"]    = packsList;
            List <int> chids = new List <int>();

            foreach (var ch1 in channelsList)
            {
                chids.Add(ch1.ChannelId);
            }
            List <bool> subornot = dal.issubornot(chids, Session["Email"].ToString());

            ViewData["SuborNot"] = subornot;
            Customer c1 = dal.FetchCustomer(Session["email"].ToString());

            List <int> packids = new List <int>();

            foreach (var pack in packsList)
            {
                packids.Add(pack.PackId);
            }
            List <bool> subornot1 = dal.issubornot1(packids, Session["Email"].ToString());

            ViewData["SuborNot1"] = subornot1;

            List <bool> subornot2 = dal.issubornotinanypack(chids, packids, Session["Email"].ToString());

            ViewData["SuborNot2"] = subornot2;

            ViewData["ProfileId"] = c1.ProfileId;

            return(View("../Home/Welcome"));
        }
Example #4
0
        public string CreateCust(CardInfoViewModel data)
        {
            //Console.WriteLine("Create Customer Profile Sample");

            // set whether to use the sandbox environment, or production enviornment
            ApiOperationBase <ANetApiRequest, ANetApiResponse> .RunEnvironment = AuthorizeNet.Environment.PRODUCTION;

            // define the merchant information (authentication / transaction id)
            ApiOperationBase <ANetApiRequest, ANetApiResponse> .MerchantAuthentication = new merchantAuthenticationType()
            {
                name            = data.ANET_ApiLoginID,
                ItemElementName = ItemChoiceType.transactionKey,
                Item            = data.ANET_ApiTransactionKey,
            };

            customerProfileType customerProfile = new customerProfileType();

            customerProfile.merchantCustomerId = data.CustomerId;
            customerProfile.email = data.email;

            var request = new createCustomerProfileRequest {
                profile = customerProfile, validationMode = validationModeEnum.none
            };

            // instantiate the controller that will call the service
            var controller = new createCustomerProfileController(request);

            controller.Execute();

            // get the response from the service (errors contained if any)
            createCustomerProfileResponse response = controller.GetApiResponse();

            // validate response
            if (response != null)
            {
                if (response.messages.resultCode == messageTypeEnum.Ok)
                {
                    if (response.messages.message != null)
                    {
                        //Console.WriteLine("Success!");
                        //Console.WriteLine("Customer Profile ID: " + );
                        return(response.customerProfileId);
                    }
                }
                else
                {
                    Console.WriteLine("Customer Profile Creation Failed.");
                    Console.WriteLine("Error Code: " + response.messages.message[0].code);
                    Console.WriteLine("Error message: " + response.messages.message[0].text);
                }
            }
            else
            {
                if (controller.GetErrorResponse().messages.message.Length > 0)
                {
                    Console.WriteLine("Customer Profile Creation Failed.");
                    Console.WriteLine("Error Code: " + response.messages.message[0].code);
                    Console.WriteLine("Error message: " + response.messages.message[0].text);
                }
                else
                {
                    Console.WriteLine("Null Response.");
                }
            }

            return(string.Empty);
        }