public static void Run(String ApiLoginID, String ApiTransactionKey)
        {
            Console.WriteLine("Charge Customer Profile");

            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
            };

            //create a customer payment profile
            customerProfilePaymentType profileToCharge = new customerProfilePaymentType();

            profileToCharge.customerProfileId = "36731856";
            profileToCharge.paymentProfile    = new paymentProfile {
                paymentProfileId = "33211899"
            };

            var transactionRequest = new transactionRequestType
            {
                transactionType = transactionTypeEnum.authCaptureTransaction.ToString(),    // refund type
                amount          = 2.00m,
                profile         = profileToCharge
            };

            var request = new createTransactionRequest {
                transactionRequest = transactionRequest
            };

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

            controller.Execute();

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

            //validate
            if (response.messages.resultCode == messageTypeEnum.Ok)
            {
                if (response.transactionResponse != null)
                {
                    Console.WriteLine("Success, Auth Code : " + response.transactionResponse.authCode);
                }
            }
            else
            {
                Console.WriteLine("Error: " + response.messages.message[0].code + "  " + response.messages.message[0].text);
                if (response.transactionResponse != null)
                {
                    Console.WriteLine("Transaction Error : " + response.transactionResponse.errors[0].errorCode + " " + response.transactionResponse.errors[0].errorText);
                }
            }
        }
Example #2
0
        public static ANetApiResponse Run(String ApiLoginID, String ApiTransactionKey, string hostedPaymentIFrameCommunicatorUrl, string customerProfileId = null)
        {
            Console.WriteLine("GetAnAcceptPaymentPage Sample");
            ApiOperationBase <ANetApiRequest, ANetApiResponse> .RunEnvironment         = AuthorizeNet.Environment.SANDBOX;
            ApiOperationBase <ANetApiRequest, ANetApiResponse> .MerchantAuthentication = new merchantAuthenticationType()
            {
                name            = ApiLoginID,
                ItemElementName = ItemChoiceType.transactionKey,
                Item            = ApiTransactionKey,
            };

            settingType[] settings = new settingType[5];

            settings[0]              = new settingType();
            settings[0].settingName  = settingNameEnum.hostedPaymentButtonOptions.ToString();
            settings[0].settingValue = "{\"text\": \"Pay\"}";

            settings[1]              = new settingType();
            settings[1].settingName  = settingNameEnum.hostedPaymentOrderOptions.ToString();
            settings[1].settingValue = "{\"show\": false}";


            settings[2]              = new settingType();
            settings[2].settingName  = settingNameEnum.hostedPaymentIFrameCommunicatorUrl.ToString();
            settings[2].settingValue = "{\"url\": \"" + hostedPaymentIFrameCommunicatorUrl + "\"}";

            settings[3]              = new settingType();
            settings[3].settingName  = settingNameEnum.hostedPaymentBillingAddressOptions.ToString();
            settings[3].settingValue = "{\"show\": false}";

            settings[4]              = new settingType();
            settings[4].settingName  = settingNameEnum.hostedPaymentReturnOptions.ToString();
            settings[4].settingValue = "{\"showReceipt\": false,\"url\":\"" + hostedPaymentIFrameCommunicatorUrl + "\",\"urlText\":\"Continue\",\"cancelUrlText\":\"Cancel\"}";


            var custprofile = new customerProfilePaymentType
            {
                customerProfileId = customerProfileId
            };

            var transactionRequest = new transactionRequestType
            {
                transactionType = transactionTypeEnum.authCaptureTransaction.ToString(),    // authorize capture only
                amount          = 99,
                profile         = custprofile
            };

            var request = new getHostedPaymentPageRequest();

            request.transactionRequest    = transactionRequest;
            request.hostedPaymentSettings = settings;

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

            controller.Execute();

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

            //validate
            if (response != null && response.messages.resultCode == messageTypeEnum.Ok)
            {
                Console.WriteLine("Message code : " + response.messages.message[0].code);
                Console.WriteLine("Message text : " + response.messages.message[0].text);
                Console.WriteLine("Token : " + response.token);
            }
            else if (response != null)
            {
                Console.WriteLine("Error: " + response.messages.message[0].code + "  " + response.messages.message[0].text);
                Console.WriteLine("Failed to get hosted payment page");
            }

            return(response);
        }
Example #3
0
        public static ANetApiResponse Run(String ApiLoginID, String ApiTransactionKey, string customerProfileId,
                                          string customerPaymentProfileId, decimal Amount)
        {
            //Console.WriteLine("Charge Customer Profile");

            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
            };

            //create a customer payment profile
            customerProfilePaymentType profileToCharge = new customerProfilePaymentType();

            profileToCharge.customerProfileId = customerProfileId;
            profileToCharge.paymentProfile    = new paymentProfile {
                paymentProfileId = customerPaymentProfileId
            };

            var transactionRequest = new transactionRequestType
            {
                transactionType = transactionTypeEnum.authCaptureTransaction.ToString(),    // refund type
                amount          = Amount,
                profile         = profileToCharge
            };

            var request = new createTransactionRequest {
                transactionRequest = transactionRequest
            };

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

            controller.Execute();

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

            //validate
            if (response != null)
            {
                if (response.messages.resultCode == messageTypeEnum.Ok)
                {
                    if (response.transactionResponse.messages != null)
                    {
                        //Console.WriteLine("Successfully created transaction with Transaction ID: " + response.transactionResponse.transId);
                        //Console.WriteLine("Response Code: " + response.transactionResponse.responseCode);
                        //Console.WriteLine("Message Code: " + response.transactionResponse.messages[0].code);
                        //Console.WriteLine("Description: " + response.transactionResponse.messages[0].description);
                        //Console.WriteLine("Success, Auth Code : " + response.transactionResponse.authCode);
                        //EventPay.EventMakePayment.sOutput = "Successfully created transaction with Transaction ID: " + response.transactionResponse.transId;
                        //EventPay.EventMakePayment.sOutput = EventPay.EventMakePayment.sOutput + "<p>Description: " + response.transactionResponse.messages[0].description + "</p>";
                        //LouACH.Main.theOutput = LouACH.Main.theOutput + "<p>Transaction ID: " + response.transactionResponse.transId + "</p>";
                        //var result = "";
                        //result = LouACH.DataBaseTransactions.DataBase.WriteTransactionData(response.transactionResponse.transId, Amount, customerPaymentProfileId);
                    }
                    else
                    {
                        //Console.WriteLine("Failed Transaction.");
                        LouACH.Main.theOutput = "Failed Transaction.";
                        if (response.transactionResponse.errors != null)
                        {
                            //Console.WriteLine("Error Code: " + response.transactionResponse.errors[0].errorCode);
                            //Console.WriteLine("Error message: " + response.transactionResponse.errors[0].errorText);
                            LouACH.Main.theOutput = "Error message: " + response.transactionResponse.errors[0].errorText;
                        }
                    }
                }
                else
                {
                    //Console.WriteLine("Failed Transaction.");
                    LouACH.Main.theOutput = "Failed Transaction.";
                    if (response.transactionResponse != null && response.transactionResponse.errors != null)
                    {
                        //Console.WriteLine("Error Code: " + response.transactionResponse.errors[0].errorCode);
                        //Console.WriteLine("Error message: " + response.transactionResponse.errors[0].errorText);
                        LouACH.Main.theOutput = "Error message: " + response.transactionResponse.errors[0].errorText;
                    }
                    else
                    {
                        //Console.WriteLine("Error Code: " + response.messages.message[0].code);
                        //Console.WriteLine("Error message: " + response.messages.message[0].text);
                        LouACH.Main.theOutput = "Error message: " + response.transactionResponse.errors[0].errorText;
                    }
                }
            }
            else
            {
                //Console.WriteLine("Null Response.");
                LouACH.Main.theOutput = "Null Response.";
            }

            return(response);
        }
 public createProfileController(customerProfilePaymentType apiRequest)// : base(apiRequest)
 {
 }
Example #5
0
 public static void customerProfilePaymentType(customerProfilePaymentType request)
 {
 }
Example #6
0
        public void SampleCodeCreateTransactionUsingProfile()
        {
            LogHelper.info(Logger, "Sample createTransaction using Profile");

            ApiOperationBase <ANetApiRequest, ANetApiResponse> .MerchantAuthentication = CustomMerchantAuthenticationType;
            ApiOperationBase <ANetApiRequest, ANetApiResponse> .RunEnvironment         = TestEnvironment;

            // Use CIM to create the profile we're going to charge
            var customerProfileId = "0";
            var paymentProfileId  = "0";

            Assert.IsTrue(createProfile(out customerProfileId, out paymentProfileId));

            //create a customer payment profile
            customerProfilePaymentType profileToCharge = new customerProfilePaymentType();

            profileToCharge.customerProfileId = customerProfileId;
            profileToCharge.paymentProfile    = new paymentProfile {
                paymentProfileId = paymentProfileId
            };

            var transactionRequestType = new transactionRequestType
            {
                transactionType = transactionTypeEnum.authCaptureTransaction.ToString(),
                amount          = SetValidTransactionAmount(Counter),
                profile         = profileToCharge
            };
            var createRequest = new createTransactionRequest
            {
                refId = RefId,
                transactionRequest = transactionRequestType,
            };
            //create controller, execute and get response
            var createController = new createTransactionController(createRequest);

            createController.Execute();
            var createResponse = createController.GetApiResponse();

            //test response
            Assert.IsNotNull(createResponse.transactionResponse);
            LogHelper.info(Logger, "Response: {0}", createResponse);
            DisplayResponse(createResponse, "Create Transaction Response");
            LogHelper.info(Logger, "Created Transaction: {0}", createResponse.transactionResponse);
            Assert.IsNotNull(createResponse.transactionResponse.transId);
            long transId;

            Assert.IsTrue(long.TryParse(createResponse.transactionResponse.transId, out transId));
            if (0 == transId)
            {
                ValidateFailure <createTransactionRequest, createTransactionResponse, createTransactionController>(createController, createResponse);
                Assert.IsNotNull(createResponse.transactionResponse.errors);
                foreach (var error in createResponse.transactionResponse.errors)
                {
                    LogHelper.info(Logger, "Error-> Code:{0}, Text:{1}", error.errorCode, error.errorText);
                }
            }
            else
            {
                Assert.AreNotEqual(0, transId);
                ValidateSuccess <createTransactionRequest, createTransactionResponse, createTransactionController>(createController, createResponse);
            }
        }
        //  public static ANetApiResponse Run(String ApiLoginID, String ApiTransactionKey, string customerProfileId,
        //      string customerPaymentProfileId, decimal Amount)
        //  {
        //      Console.WriteLine("Charge Customer Profile");

        //      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
        //      };

        //      //create a customer payment profile
        //      customerProfilePaymentType profileToCharge = new customerProfilePaymentType();
        //      profileToCharge.customerProfileId = customerProfileId;
        //      profileToCharge.paymentProfile = new paymentProfile { paymentProfileId = customerPaymentProfileId };

        //      var transactionRequest = new transactionRequestType
        //      {
        //          transactionType = transactionTypeEnum.authCaptureTransaction.ToString(),    // refund type
        //          amount = Amount,
        //          profile = profileToCharge
        //      };

        //      var request = new createTransactionRequest { transactionRequest = transactionRequest };

        //      // instantiate the collector that will call the service
        //      var controller = new createTransactionController(request);
        //      controller.Execute();

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

        //      //validate
        //      if (response != null)
        //      {
        //          if (response.messages.resultCode == messageTypeEnum.Ok)
        //          {
        //              if(response.transactionResponse.messages != null)
        //              {
        //                  Console.WriteLine("Successfully created transaction with Transaction ID: " + response.transactionResponse.transId);
        //                  Console.WriteLine("Response Code: " + response.transactionResponse.responseCode);
        //                  Console.WriteLine("Message Code: " + response.transactionResponse.messages[0].code);
        //                  Console.WriteLine("Description: " + response.transactionResponse.messages[0].description);
        //Console.WriteLine("Success, Auth Code : " + response.transactionResponse.authCode);
        //              }
        //              else
        //              {
        //                  Console.WriteLine("Failed Transaction.");
        //                  if (response.transactionResponse.errors != null)
        //                  {
        //                      Console.WriteLine("Error Code: " + response.transactionResponse.errors[0].errorCode);
        //                      Console.WriteLine("Error message: " + response.transactionResponse.errors[0].errorText);
        //                  }
        //              }
        //          }
        //          else
        //          {
        //              Console.WriteLine("Failed Transaction.");
        //              if (response.transactionResponse != null && response.transactionResponse.errors != null)
        //              {
        //                  Console.WriteLine("Error Code: " + response.transactionResponse.errors[0].errorCode);
        //                  Console.WriteLine("Error message: " + response.transactionResponse.errors[0].errorText);
        //              }
        //              else
        //              {
        //                  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;
        //  }

        public static void ChargeCustomerProfileExec(String ApiLoginID, String ApiTransactionKey)
        {
            using (CsvReader csv = new CsvReader(new StreamReader(new FileStream(@"../../../CSV_DATA/ChargeCustomerProfile.csv", FileMode.Open)), true))
            {
                Console.WriteLine("Charge Customer Profile");

                int      flag       = 0;
                int      fieldCount = csv.FieldCount;
                string[] headers    = csv.GetFieldHeaders();
                //Append data
                var item1 = DataAppend.ReadPrevData();
                using (CsvFileWriter writer = new CsvFileWriter(new FileStream(@"../../../CSV_DATA/Outputfile.csv", FileMode.Open)))
                {
                    while (csv.ReadNextRecord())
                    {
                        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
                        };
                        string amount     = null;
                        string TestCaseId = null;
                        string customerPaymentProfileId = null;
                        string customerProfileId        = null;
                        for (int i = 0; i < fieldCount; i++)
                        {
                            switch (headers[i])
                            {
                            case "TestCaseId":
                                TestCaseId = csv[i];
                                break;

                            case "customerProfileId":
                                customerProfileId = csv[i];
                                break;

                            case "customerPaymentProfileId":
                                customerPaymentProfileId = csv[i];
                                break;

                            case "amount":
                                amount = csv[i];
                                break;

                            default:
                                break;
                            }
                        }
                        CsvRow row = new CsvRow();
                        try
                        {
                            if (flag == 0)
                            {
                                row.Add("TestCaseId");
                                row.Add("APIName");
                                row.Add("Status");
                                row.Add("TimeStamp");
                                writer.WriteRow(row);
                                flag = flag + 1;
                                //Append Results
                                foreach (var item in item1)
                                {
                                    writer.WriteRow(item);
                                }
                            }


                            //create a customer payment profile
                            customerProfilePaymentType profileToCharge = new customerProfilePaymentType();
                            profileToCharge.customerProfileId = customerProfileId;
                            profileToCharge.paymentProfile    = new paymentProfile {
                                paymentProfileId = customerPaymentProfileId
                            };

                            var transactionRequest = new transactionRequestType
                            {
                                transactionType = transactionTypeEnum.authCaptureTransaction.ToString(),    // refund type
                                amount          = Convert.ToDecimal(amount),
                                profile         = profileToCharge
                            };

                            var request = new createTransactionRequest {
                                transactionRequest = transactionRequest
                            };

                            // instantiate the collector that will call the service
                            var controller = new createTransactionController(request);
                            controller.Execute();

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

                            //validate
                            if ((response != null) && (response.messages.resultCode == messageTypeEnum.Ok) &&
                                (response.transactionResponse.messages != null))
                            {
                                //if (response.messages.resultCode == messageTypeEnum.Ok)
                                //{

                                //if (response.transactionResponse.messages != null)
                                //{
                                /*****************************/
                                try
                                {
                                    //Assert.AreEqual(response.Id, customerProfileId);
                                    //Console.WriteLine("Assertion Succeed! Valid customerProfileId fetched.");
                                    CsvRow row1 = new CsvRow();
                                    row1.Add("CCP_00" + flag.ToString());
                                    row1.Add("ChargeCustomerProfile");
                                    row1.Add("Pass");
                                    row1.Add(DateTime.Now.ToString("yyyy/MM/dd" + "::" + "HH:mm:ss:fff"));
                                    writer.WriteRow(row1);
                                    //  Console.WriteLine("Success " + TestcaseID + " CustomerID : " + response.Id);
                                    flag = flag + 1;

                                    Console.WriteLine("Successfully created transaction with Transaction ID: " + response.transactionResponse.transId);
                                    Console.WriteLine("Response Code: " + response.transactionResponse.responseCode);
                                    Console.WriteLine("Message Code: " + response.transactionResponse.messages[0].code);
                                    Console.WriteLine("Description: " + response.transactionResponse.messages[0].description);
                                    Console.WriteLine("Success, Auth Code : " + response.transactionResponse.authCode);
                                }
                                catch
                                {
                                    CsvRow row1 = new CsvRow();
                                    row1.Add("CCP_00" + flag.ToString());
                                    row1.Add("ChargeCustomerProfile");
                                    row1.Add("Assertion Failed!");
                                    row1.Add(DateTime.Now.ToString("yyyy/MM/dd" + "::" + "HH:mm:ss:fff"));
                                    writer.WriteRow(row1);
                                    //Console.WriteLine("Assertion Failed! Invalid CustomerPaymentProfile fetched.");
                                    flag = flag + 1;
                                }
                                /*******************/

                                // }
                                //else
                                //{
                                //    Console.WriteLine("Failed Transaction.");
                                //    CsvRow row1 = new CsvRow();
                                //    row1.Add("CCP_00" + flag.ToString());
                                //    row1.Add("ChargeCustomerProfile");
                                //    row1.Add("Assertion Failed!");
                                //    row1.Add(DateTime.Now.ToString("yyyy/MM/dd" + "::" + "HH:mm:ss:fff"));
                                //    writer.WriteRow(row1);
                                //    //Console.WriteLine("Assertion Failed! Invalid CustomerPaymentProfile fetched.");
                                //    flag = flag + 1;

                                //    if (response.transactionResponse.errors != null)
                                //    {
                                //        Console.WriteLine("Error Code: " + response.transactionResponse.errors[0].errorCode);
                                //        Console.WriteLine("Error message: " + response.transactionResponse.errors[0].errorText);
                                //    }
                                //}
                                //  }
                                //else
                                //{
                                //    Console.WriteLine("Failed Transaction.");
                                //    CsvRow row2 = new CsvRow();
                                //    row2.Add("CCP_00" + flag.ToString());
                                //    row2.Add("ChargeCustomerProfile");
                                //    row2.Add("Fail");
                                //    row2.Add(DateTime.Now.ToString("yyyy/MM/dd" + "::" + "HH:mm:ss:fff"));
                                //    writer.WriteRow(row2);
                                //    flag = flag + 1;
                                //    //if (response.transactionResponse != null && response.transactionResponse.errors != null)
                                //    //{
                                //    //    Console.WriteLine("Error Code: " + response.transactionResponse.errors[0].errorCode);
                                //    //    Console.WriteLine("Error message: " + response.transactionResponse.errors[0].errorText);
                                //    //}
                                //    //else
                                //    //{
                                //    //    Console.WriteLine("Error Code: " + response.messages.message[0].code);
                                //    //    Console.WriteLine("Error message: " + response.messages.message[0].text);
                                //    //}
                                //}
                            }
                            else
                            {
                                CsvRow row2 = new CsvRow();
                                row2.Add("CCP_00" + flag.ToString());
                                row2.Add("ChargeCustomerProfile");
                                row2.Add("Fail");
                                row2.Add(DateTime.Now.ToString("yyyy/MM/dd" + "::" + "HH:mm:ss:fff"));
                                writer.WriteRow(row2);
                                flag = flag + 1;
                                if (response == null)
                                {
                                    Console.WriteLine("Null Response.");
                                }
                                else
                                {
                                    Console.WriteLine("WAP");
                                }
                                ;
                            }
                        }

                        //return response;
                        catch (Exception e)
                        {
                            CsvRow row2 = new CsvRow();
                            row2.Add("CCP_00" + flag.ToString());
                            row2.Add("ChargeCustomerProfile");
                            row2.Add("Fail");
                            row2.Add(DateTime.Now.ToString("yyyy/MM/dd" + "::" + "HH:mm:ss:fff"));
                            writer.WriteRow(row2);
                            flag = flag + 1;
                            //Console.WriteLine(TestCaseId + " Error Message " + e.Message);
                        }
                    }
                }
            }
        }
Example #8
0
        public ActionResult ChargeChannel(Channel ch)
        {
            if (ch.month > 1)
            {
                // LAKSHMI //                autorec call
            }
            Console.WriteLine("Charge Customer Profile");

            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
            };

            DAL dal = new DAL();
            //create a customer payment profile
            customerProfilePaymentType profileToCharge = new customerProfilePaymentType();

            profileToCharge.customerProfileId = dal.getCustomerProfileId(Session["Email"].ToString());
            profileToCharge.paymentProfile    = new paymentProfile {
                paymentProfileId = dal.getPaymentProfileId(Session["Email"].ToString())
            };


            var transactionRequest = new transactionRequestType
            {
                transactionType = transactionTypeEnum.authCaptureTransaction.ToString(),    // refund type
                //amount = 12,
                amount  = Convert.ToDecimal(ch.ChannelCost),
                profile = profileToCharge
            };

            var request = new createTransactionRequest {
                transactionRequest = transactionRequest
            };

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

            controller.Execute();

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

            // validate response
            if (response != null)
            {
                if (response.messages.resultCode == messageTypeEnum.Ok)
                {
                    if (response.transactionResponse.messages != null)
                    {
                        int sid = dal.AddChannelSubscriptionMaster(Session["Email"].ToString(), ch, response.transactionResponse.transId); // as of now no validation here

                        //here 1stparametr is sid from above function.. as of now hardcoded.
                        dal.AddSubscriptionChannel(sid, ch); // as of now no validation here

                        //sid = dal.AddChannelSubscriptionMaster(useremail, InvoiceDetails); // as of now no validation here

                        //here 1stparametr is sid from above function.. as of now hardcoded.
                        //success_insertion_channel = dal.AddSubscriptionChannel(sid, InvoiceDetails); // as of now no validation here

                        //DateTime theDate = DateTime.Now;
                        //DateTime expdate = theDate.AddMonths(1).Date;
                        ViewBag.Message = "Successfully completed payment of " + ch.ChannelCost + ". Transaction ID: " + response.transactionResponse.transId + ". \n Subscribed Channel: " + ch.ChannelName + ". \n We will charge you " + ch.ChannelCost + " on " + DateTime.Now.Day + "th of every month for next " + (ch.month - 1) + " months.";
                        ViewBag.Type    = "success";


                        Console.WriteLine("Successfully created transaction with Transaction ID: " + response.transactionResponse.transId);
                        Console.WriteLine("Response Code: " + response.transactionResponse.responseCode);
                        Console.WriteLine("Message Code: " + response.transactionResponse.messages[0].code);
                        Console.WriteLine("Description: " + response.transactionResponse.messages[0].description);
                        Console.WriteLine("Success, Auth Code : " + response.transactionResponse.authCode);
                    }
                    else
                    {
                        ViewBag.Message = "Transaction Failed.";
                        ViewBag.Type    = "danger";
                        Console.WriteLine("Failed Transaction.");
                        if (response.transactionResponse.errors != null)
                        {
                            Console.WriteLine("Error Code: " + response.transactionResponse.errors[0].errorCode);
                            Console.WriteLine("Error message: " + response.transactionResponse.errors[0].errorText);
                        }
                    }
                }
                else
                {
                    ViewBag.Message = "Transaction Failed.";
                    ViewBag.Type    = "danger";

                    Console.WriteLine("Failed Transaction.");
                    if (response.transactionResponse != null && response.transactionResponse.errors != null)
                    {
                        Console.WriteLine("Error Code: " + response.transactionResponse.errors[0].errorCode);
                        Console.WriteLine("Error message: " + response.transactionResponse.errors[0].errorText);
                    }
                    else
                    {
                        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 #9
0
        public string RefundChannels(List <Channel> chs)
        {
            string reply = "";

            foreach (Channel ch in chs)
            {
                // LAKSHMI    //            delsubscription from auto rec if its there


                //fetchexpiry and calculate transamount;
                DAL dal = new DAL();

                DateTime d = dal.getexpirydate(ch.ChannelId, Session["Email"].ToString());
                decimal  TransactionAmount = Convert.ToDecimal((ch.ChannelCost * (d - DateTime.Now).TotalDays) / 30.0);

                Console.WriteLine("Refund Transaction");

                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
                };


                customerProfilePaymentType profileToCharge = new customerProfilePaymentType();
                profileToCharge.customerProfileId = dal.getCustomerProfileId(Session["Email"].ToString());
                profileToCharge.paymentProfile    = new paymentProfile {
                    paymentProfileId = dal.getPaymentProfileId(Session["Email"].ToString())
                };



                //var creditCard = new creditCardType
                //{
                //    cardNumber = "1111",
                //    expirationDate = "XXXX"
                //};

                ////standard api call to retrieve response
                //var paymentType = new paymentType { Item = creditCard };

                var transactionRequest = new transactionRequestType
                {
                    transactionType = transactionTypeEnum.refundTransaction.ToString(),    // refund type
                                                                                           //payment = paymentType,
                    profile = profileToCharge,
                    amount  = TransactionAmount
                              //refTransId = TransactionID
                };

                var request = new createTransactionRequest {
                    transactionRequest = transactionRequest
                };

                // instantiate the controller that will call the service
                var controller = new createTransactionController(request);
                controller.Execute();

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

                // validate response
                if (response != null)
                {
                    if (response.messages.resultCode == messageTypeEnum.Ok)
                    {
                        if (response.transactionResponse.messages != null)
                        {
                            // get sid from subch
                            // del sid wala row from submaster and subch

                            int sid = dal.getSid(ch.ChannelId, Session["Email"].ToString());
                            dal.deleteChannelSubscr(sid);

                            reply += "\n Successfully refunded amount of " + ch.ChannelCost + " for channel " + ch.ChannelName + ". Transaction ID: " + response.transactionResponse.transId;

                            //ViewBag.Type = "success";

                            Console.WriteLine("Successfully created transaction with Transaction ID: " + response.transactionResponse.transId);
                            Console.WriteLine("Response Code: " + response.transactionResponse.responseCode);
                            Console.WriteLine("Message Code: " + response.transactionResponse.messages[0].code);
                            Console.WriteLine("Description: " + response.transactionResponse.messages[0].description);
                            Console.WriteLine("Success, Auth Code : " + response.transactionResponse.authCode);
                        }
                        else
                        {
                            reply += "\n Refund transaction failed for channel " + ch.ChannelName;
                            //ViewBag.Type = "danger";
                            Console.WriteLine("Failed Transaction.");
                            if (response.transactionResponse.errors != null)
                            {
                                Console.WriteLine("Error Code: " + response.transactionResponse.errors[0].errorCode);
                                Console.WriteLine("Error message: " + response.transactionResponse.errors[0].errorText);
                            }
                        }
                    }
                    else
                    {
                        reply += "\n Refund transaction failed for channel " + ch.ChannelName;
                        //ViewBag.Type = "danger";
                        Console.WriteLine("Failed Transaction.");

                        if (response.transactionResponse != null && response.transactionResponse.errors != null)
                        {
                            Console.WriteLine("Error Code: " + response.transactionResponse.errors[0].errorCode);
                            Console.WriteLine("Error message: " + response.transactionResponse.errors[0].errorText);
                        }
                        else
                        {
                            Console.WriteLine("Error Code: " + response.messages.message[0].code);
                            Console.WriteLine("Error message: " + response.messages.message[0].text);
                        }
                    }
                }
                else
                {
                    Console.WriteLine("Null Response.");
                }
            }

            return(reply);
        }
Example #10
0
        public ActionResult RefundPack(Pack p)
        {
            // LAKSHMI    //            delsubscription from auto rec if its there


            //fetchexpiry and calculate transamount;
            DAL dal = new DAL();

            DateTime d = dal.getexpirydatepack(p.PackId, Session["Email"].ToString());
            decimal  TransactionAmount = Convert.ToDecimal((p.PackCost * (d - DateTime.Now).TotalDays) / 30.0);

            Console.WriteLine("Refund Transaction");

            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
            };


            customerProfilePaymentType profileToCharge = new customerProfilePaymentType();

            profileToCharge.customerProfileId = dal.getCustomerProfileId(Session["Email"].ToString());
            profileToCharge.paymentProfile    = new paymentProfile {
                paymentProfileId = dal.getPaymentProfileId(Session["Email"].ToString())
            };



            //var creditCard = new creditCardType
            //{
            //    cardNumber = "1111",
            //    expirationDate = "XXXX"
            //};

            ////standard api call to retrieve response
            //var paymentType = new paymentType { Item = creditCard };

            var transactionRequest = new transactionRequestType
            {
                transactionType = transactionTypeEnum.refundTransaction.ToString(),    // refund type
                //payment = paymentType,
                profile = profileToCharge,
                amount  = TransactionAmount
                          //refTransId = TransactionID
            };

            var request = new createTransactionRequest {
                transactionRequest = transactionRequest
            };

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

            controller.Execute();

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

            // validate response
            if (response != null)
            {
                if (response.messages.resultCode == messageTypeEnum.Ok)
                {
                    if (response.transactionResponse.messages != null)
                    {
                        // get sid from subch
                        // del sid wala row from submaster and subch

                        int sid = dal.getSidPack(p.PackId, Session["Email"].ToString());
                        dal.deletePackSubscr(sid);

                        ViewBag.Message = "Successfully refunded amount of " + p.PackCost + ". Transaction ID: " + response.transactionResponse.transId + ". You have successfully unsubscribed to the pack " + p.PackName + ".";
                        ViewBag.Type    = "success";

                        Console.WriteLine("Successfully created transaction with Transaction ID: " + response.transactionResponse.transId);
                        Console.WriteLine("Response Code: " + response.transactionResponse.responseCode);
                        Console.WriteLine("Message Code: " + response.transactionResponse.messages[0].code);
                        Console.WriteLine("Description: " + response.transactionResponse.messages[0].description);
                        Console.WriteLine("Success, Auth Code : " + response.transactionResponse.authCode);
                    }
                    else
                    {
                        ViewBag.Message = "Transaction Failed.";
                        ViewBag.Type    = "danger";
                        Console.WriteLine("Failed Transaction.");
                        if (response.transactionResponse.errors != null)
                        {
                            Console.WriteLine("Error Code: " + response.transactionResponse.errors[0].errorCode);
                            Console.WriteLine("Error message: " + response.transactionResponse.errors[0].errorText);
                        }
                    }
                }
                else
                {
                    ViewBag.Message = "Transaction Failed.";
                    ViewBag.Type    = "danger";
                    Console.WriteLine("Failed Transaction.");

                    if (response.transactionResponse != null && response.transactionResponse.errors != null)
                    {
                        Console.WriteLine("Error Code: " + response.transactionResponse.errors[0].errorCode);
                        Console.WriteLine("Error message: " + response.transactionResponse.errors[0].errorText);
                    }
                    else
                    {
                        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 #11
0
        public async Task <ITransactionResponse> ChargeCustomerProfile(ICustomerPayment customerPayment)
        {
            var transactionResponse = new TransactionResponse();

            var task = Task.Run(() =>
            {
                if (Convert.ToBoolean(string.IsNullOrEmpty(ConfigurationManager.AppSettings["AuthNetIsProduction"]) ? "false" : ConfigurationManager.AppSettings["AuthNetIsProduction"]))
                {
                    ApiOperationBase <ANetApiRequest, ANetApiResponse> .RunEnvironment = AuthorizeNet.Environment.PRODUCTION;
                }
                else
                {
                    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,
                };

                customerProfilePaymentType profileToCharge = new customerProfilePaymentType();
                profileToCharge.customerProfileId          = customerPayment.CustomerProfileId;
                profileToCharge.paymentProfile             = new paymentProfile {
                    paymentProfileId = customerPayment.CustomerPaymentProfileId
                };

                var transactionRequest = new transactionRequestType
                {
                    transactionType = transactionTypeEnum.authCaptureTransaction.ToString(),    // refund type
                    amount          = customerPayment.Amount,
                    profile         = profileToCharge
                };

                var request = new createTransactionRequest {
                    transactionRequest = transactionRequest
                };

                // instantiate the collector that will call the service
                var controller = new createTransactionController(request);
                controller.Execute();

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

                if (response != null && response.messages.resultCode == messageTypeEnum.Ok)
                {
                    if (response.transactionResponse != null)
                    {
                        transactionResponse.AuthCode  = response.transactionResponse.authCode;
                        transactionResponse.Errors    = null;
                        transactionResponse.IsSuccess = true;
                        transactionResponse.Messages  = null;
                        transactionResponse.TransId   = response.transactionResponse.transId;

                        System.Diagnostics.Debug.WriteLine("Success, Auth Code : " + response.transactionResponse.authCode);
                    }
                }
                else if (response != null && response.messages.message != null)
                {
                    transactionResponse.IsSuccess = false;

                    System.Diagnostics.Debug.WriteLine("Error: " + response.messages.message[0].code + "  " + response.messages.message[0].text);

                    transactionResponse.Messages = new TransactionResponseMessage[] { new TransactionResponseMessage()
                                                                                      {
                                                                                          Code = response.messages.message[0].code, Description = response.messages.message[0].text
                                                                                      } };

                    if (response.transactionResponse != null)
                    {
                        transactionResponse.AuthCode = response.transactionResponse.authCode;
                        transactionResponse.Errors   = new TransactionResponseError[] { new TransactionResponseError()
                                                                                        {
                                                                                            ErrorCode = response.transactionResponse.errors[0].errorCode, ErrorText = response.transactionResponse.errors[0].errorText
                                                                                        } };
                        transactionResponse.RawResponseCode = response.transactionResponse.rawResponseCode;
                        transactionResponse.TransId         = response.transactionResponse.transId;

                        System.Diagnostics.Debug.WriteLine("Transaction Error : " + response.transactionResponse.errors[0].errorCode + " " + response.transactionResponse.errors[0].errorText);
                    }
                }

                return(response);
            });

            await task;

            return(transactionResponse);
        }
Example #12
0
        public PaymentResponse CustTransection(CardInfoViewModel data, string customerPaymentProfileId)
        {
            PaymentResponse objPaymentRes = new PaymentResponse();

            try
            {
                //String ApiLoginID = "5z2fSW5G"; String ApiTransactionKey = "66JWg8eyL2Z78Sfs";
                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,
                };
                objPaymentRes.cutomerProfileId = data.customerProfile_Id;
                objPaymentRes.transAmount      = data.Amount;

                // Use CIM to create the profile we're going to charge
                var customerProfileId = data.customerProfile_Id;  //"1960337182";
                var paymentProfileId  = customerPaymentProfileId; // "1976458349";

                //create a customer payment profile
                customerProfilePaymentType profileToCharge = new customerProfilePaymentType();
                profileToCharge.customerProfileId = customerProfileId;
                profileToCharge.paymentProfile    = new paymentProfile {
                    paymentProfileId = paymentProfileId
                };


                var transactionRequestType = new transactionRequestType
                {
                    transactionType = transactionTypeEnum.authCaptureTransaction.ToString(),
                    amount          = Convert.ToDecimal(data.Amount),
                    profile         = profileToCharge,
                    poNumber        = data.InvoiceNumber,
                    //transactionSettings = itemArr.ToArray(),
                    shipTo = new nameAndAddressType
                    {
                        firstName = data.shippingFName,
                        lastName  = data.shippingLName,
                        address   = data.shippingAddrLine1 + ' ' + data.shippingAddressLine2,
                        city      = data.shippingCity,
                        company   = data.shippingCompany,
                        state     = data.shippingState,
                        country   = data.shippingCountry,
                        zip       = data.shippingZipCode
                    },
                    //billTo = new customerAddressType
                    //{
                    //    firstName = data.billingFName,
                    //    lastName = data.billingLName,
                    //    address = $"{data.billingAddrLine1} {data.billingAddressLine2}",
                    //    city = data.billingCity,
                    //    company = data.billingCompany,
                    //    state = data.billingState,
                    //    country = data.billingCountry,
                    //    zip = data.billingZipCode,
                    //    email = data.email,
                    //    faxNumber = !string.IsNullOrEmpty(data.billingFax) ? data.billingFax : string.Empty,
                    //    phoneNumber = data.billingPhno

                    //},
                    tax = new extendedAmountType
                    {
                        amount      = Convert.ToDecimal(data.taxAmount),
                        name        = "",
                        description = ""
                    }
                    ,

                    shipping = new extendedAmountType
                    {
                        amount      = Convert.ToDecimal(data.shipping),
                        name        = "",
                        description = ""
                    },
                };
                var createRequest = new createTransactionRequest
                {
                    //refId = RefId,
                    transactionRequest = transactionRequestType,
                };
                //create controller, execute and get response
                var createController = new createTransactionController(createRequest);
                createController.Execute();
                var response = createController.GetApiResponse();

                if (response != null)
                {
                    if (response.messages.resultCode == messageTypeEnum.Ok)
                    {
                        if (response.transactionResponse.messages != null)
                        {
                            //Console.WriteLine("Successfully created transaction with Transaction ID: " + response.transactionResponse.transId);
                            //Console.WriteLine("Response Code: " + response.transactionResponse.responseCode);
                            //Console.WriteLine("Message Code: " + response.transactionResponse.messages[0].code);
                            //Console.WriteLine("Description: " + response.transactionResponse.messages[0].description);
                            //Console.WriteLine("Success, Auth Code : " + response.transactionResponse.authCode);

                            objPaymentRes.statusCode          = "200";
                            objPaymentRes.message             = response.transactionResponse.messages[0].description;
                            objPaymentRes.transId             = response.transactionResponse.transId;
                            objPaymentRes.transactionResponse = response.transactionResponse;
                        }
                        else
                        {
                            //Console.WriteLine("Failed Transaction.");
                            if (response.transactionResponse.errors != null)
                            {
                                //Console.WriteLine("Error Code: " + response.transactionResponse.errors[0].errorCode);
                                //Console.WriteLine("Error message: " + response.transactionResponse.errors[0].errorText);


                                objPaymentRes.statusCode          = "400";
                                objPaymentRes.message             = response.transactionResponse.errors[0].errorText;
                                objPaymentRes.transId             = response.transactionResponse.transId;
                                objPaymentRes.transactionResponse = response.transactionResponse;
                            }
                        }
                    }
                    else
                    {
                        // Console.WriteLine("Failed Transaction.");
                        if (response.transactionResponse != null && response.transactionResponse.errors != null)
                        {
                            //Console.WriteLine("Error Code: " + response.transactionResponse.errors[0].errorCode);
                            //Console.WriteLine("Error message: " + response.transactionResponse.errors[0].errorText);

                            objPaymentRes.statusCode = "400";
                            objPaymentRes.message    = response.transactionResponse.errors[0].errorText;
                            objPaymentRes.transId    = response.transactionResponse.transId;

                            objPaymentRes.transactionResponse = response.transactionResponse;
                        }
                        else
                        {
                            //Console.WriteLine("Error Code: " + response.messages.message[0].code);
                            //Console.WriteLine("Error message: " + response.messages.message[0].text);

                            objPaymentRes.statusCode          = "400";
                            objPaymentRes.message             = response.messages.message[0].text;
                            objPaymentRes.transId             = string.Empty;
                            objPaymentRes.transactionResponse = new transactionResponse();
                        }
                    }
                }
                else
                {
                    // Console.WriteLine("Null Response.");


                    objPaymentRes.statusCode = "400";
                    objPaymentRes.message    = "Null Response";
                    objPaymentRes.transId    = string.Empty;

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

            var customerProfile = new customerProfilePaymentType();

            customerProfile.customerProfileId = "1927580170";
            customerProfile.createProfile     = true;

            var settings = new List <settingType>();

            settings.Add(new settingType()
            {
                settingName  = settingNameEnum.hostedProfileSaveButtonText.ToString(),
                settingValue = "Save"
            });

            settings.Add(new settingType()
            {
                settingName  = settingNameEnum.hostedProfileIFrameCommunicatorUrl.ToString(),
                settingValue = "http://localhost:4201/IFrameCommunicator.html"
            });

            settings.Add(new settingType()
            {
                settingName  = settingNameEnum.hostedProfileManageOptions.ToString(),
                settingValue = "showPayment"
            });

            settings.Add(new settingType()
            {
                settingName  = settingNameEnum.hostedProfilePaymentOptions.ToString(),
                settingValue = "showCreditCard"
            });

            settings.Add(new settingType()
            {
                settingName  = settingNameEnum.hostedProfileCardCodeRequired.ToString(),
                settingValue = "true"
            });

            settings.Add(new settingType()
            {
                settingName  = settingNameEnum.hostedProfileBillingAddressOptions.ToString(),
                settingValue = "showNone"
            });



            var request = new getHostedProfilePageRequest();

            request.customerProfileId     = "1927580170";
            request.hostedProfileSettings = settings.ToArray();

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

            controller.Execute();

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


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

            var customerProfile = new customerProfilePaymentType();

            customerProfile.customerProfileId = "1927580170";
            customerProfile.createProfile     = true;

            var transactionRequest = new transactionRequestType
            {
                transactionType = transactionTypeEnum.authCaptureTransaction.ToString(),    // authorize capture only
                amount          = amount,
                profile         = customerProfile
                ,
                billTo = new customerAddressType
                {
                    firstName = "firstname",
                    lastName  = "lastname",
                    address   = "address",
                    city      = "city",
                    state     = "state",
                    zip       = "zip"
                }
                //order = new orderType
                //{
                //    invoiceNumber = "INV-123456",
                //    description = "TEST INVOICE",
                //    purchaseOrderDateUTC= DateTime.Now.ToUniversalTime()
                //}
            };

            var settings = new List <settingType>();

            settings.Add(new settingType()
            {
                settingName  = settingNameEnum.hostedPaymentButtonOptions.ToString(),
                settingValue = @"{""text"": ""Pay""}"
            });

            settings.Add(new settingType()
            {
                settingName  = settingNameEnum.hostedPaymentPaymentOptions.ToString(),
                settingValue = @"{""cardCodeRequired"": true, ""showCreditCard"": true, ""showBankAccount"": true}"
            });

            settings.Add(new settingType()
            {
                settingName  = settingNameEnum.hostedPaymentReturnOptions.ToString(),
                settingValue = @"{""showReceipt"": false }"
            });

            //settings.Add(new settingType()
            //{
            //    settingName = settingNameEnum.hostedPaymentCustomerOptions.ToString(),
            //    settingValue = @"{""addPaymentProfile"": true }"
            //});

            //settings.Add(new settingType()
            //{
            //    settingName = settingNameEnum.hostedPaymentReturnOptions.ToString(),
            //    settingValue = @"{""showReceipt"": true, ""url"": ""http://*****:*****@"{""show"": true}"
            });
            //settings.Add(new settingType()
            //{
            //    settingName = settingNameEnum.hostedPaymentShippingAddressOptions.ToString(),
            //    settingValue = @"{""show"" : false }"
            //});
            settings.Add(new settingType()
            {
                settingName  = settingNameEnum.hostedPaymentBillingAddressOptions.ToString(),
                settingValue = @"{""show"" : false, ""required"" : false }"
            });

            settings.Add(new settingType()
            {
                settingName  = settingNameEnum.hostedPaymentStyleOptions.ToString(),
                settingValue = @"{""bgColor"" : ""green""}"
            });

            //settings.Add(new settingType()
            //{
            //    settingName = settingNameEnum.hostedProfileHeadingBgColor.ToString(),
            //    settingValue =  @"{""green"" }"
            //});

            //settings.Add(new settingType()
            //{
            //    settingName = settingNameEnum.hostedProfilePageBorderVisible.ToString(),
            //    settingValue = @"{false}"
            //});
            //string Url= ""http://*****:*****@"{ ""url"" : ""http://localhost:4201/IFrameCommunicator.html"" }"
            });


            var request = new getHostedPaymentPageRequest();

            request.transactionRequest    = transactionRequest;
            request.hostedPaymentSettings = settings.ToArray();

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

            controller.Execute();

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


            return(response.token);
        }