示例#1
0
        public CheckoutFormParams GetCheckoutFormParams(FormParameters formParams, InvoiceItem[] invoiceLines)
        {
            // normalize target site variable
            string targetSite = formParams["target_site"].EndsWith("/") ? formParams["target_site"]
                                : formParams["target_site"] + "/";

            CheckoutFormParams outputParams = new CheckoutFormParams();

            // setup service url
            outputParams.Action = ServiceUrl;
            outputParams.Method = CheckoutFormParams.POST_METHOD;
            // copy command
            outputParams["cmd"] = CART_COMMAND;
            // workaround to make IPN callbacks work
            outputParams["rm"] = "2";
            // set upload value to indicate a third-party shopping cart
            outputParams["upload"] = "1";
            // set business
            outputParams["business"] = Business;
            // set cancel return url
            outputParams["cancel_return"] = String.Concat(targetSite, "?pid=ecOnlineStore&ContractId=", formParams[FormParameters.CONTRACT]);
            // set return url
            outputParams["return"] = targetSite;
            // set IPN-Endpoint url
            outputParams["notify_url"] = String.Concat(targetSite, IPN_PROCESSOR_ENDPOINT);
            // set invoice number
            outputParams["invoice"] = formParams[FormParameters.INVOICE];
            // set contract number
            outputParams["custom"] = formParams[FormParameters.CONTRACT];
            // set invoice currency
            outputParams["currency_code"] = formParams[FormParameters.CURRENCY];
            // set formatted invoice number
            outputParams["item_name_1"] = String.Format("{0} #{1}", FormParameters.INVOICE, formParams[FormParameters.INVOICE]);
            // set invoice amount
            outputParams["amount_1"] = formParams[FormParameters.AMOUNT];
            // copy first name
            AddParameter(formParams, outputParams, FormParameters.FIRST_NAME, "first_name");
            // copy last name
            AddParameter(formParams, outputParams, FormParameters.LAST_NAME, "last_name");
            // copy address
            AddParameter(formParams, outputParams, FormParameters.ADDRESS, "address1");
            // copy city
            AddParameter(formParams, outputParams, FormParameters.CITY, "city");
            // copy state
            AddParameter(formParams, outputParams, FormParameters.STATE, "state");
            // copy country
            AddParameter(formParams, outputParams, FormParameters.COUNTRY, "country");
            // copy zip
            AddParameter(formParams, outputParams, FormParameters.ZIP, "zip");
            // copty email
            AddParameter(formParams, outputParams, FormParameters.EMAIL, "email");
            // copy phone number
            if (formParams[FormParameters.COUNTRY] != "US" && formParams[FormParameters.COUNTRY] != "CA")
            {
                // phone numbers outside U.S copy as is
                outputParams["night_phone_b"] = formParams[FormParameters.PHONE];
            }
            // return whole set of params
            return(outputParams);
        }
示例#2
0
        private void AddParameter(FormParameters inputParams, CheckoutFormParams outputParams, string inputKey, string outputKey)
        {
            string formParameter = inputParams[inputKey];

            if (formParameter != null)
            {
                outputParams[outputKey] = formParameter;
            }
        }
		private void AddParameter(FormParameters inputParams, CheckoutFormParams outputParams, string inputKey, string outputKey)
		{
			string formParameter = inputParams[inputKey];
			if (formParameter != null)
			{
				outputParams[outputKey] = formParameter;
			}
		}
		public CheckoutFormParams GetCheckoutFormParams(FormParameters formParams, InvoiceItem[] invoiceLines)
		{
			// normalize target site variable
			string targetSite = formParams["target_site"].EndsWith("/") ? formParams["target_site"] 
				: formParams["target_site"] + "/";

			CheckoutFormParams outputParams = new CheckoutFormParams();
			// setup service url
			outputParams.Action = ServiceUrl;
			outputParams.Method = CheckoutFormParams.POST_METHOD;
			// copy command
			outputParams["cmd"] = CART_COMMAND;
			// workaround to make IPN callbacks work
			outputParams["rm"] = "2";
			// set upload value to indicate a third-party shopping cart
			outputParams["upload"] = "1";
			// set business
			outputParams["business"] = Business;
			// set cancel return url
			outputParams["cancel_return"] = String.Concat(targetSite, "?pid=ecOnlineStore&ContractId=", formParams[FormParameters.CONTRACT]);
			// set return url
			outputParams["return"] = targetSite;
			// set IPN-Endpoint url
			outputParams["notify_url"] = String.Concat(targetSite, IPN_PROCESSOR_ENDPOINT);
			// set invoice number
			outputParams["invoice"] = formParams[FormParameters.INVOICE];
			// set contract number
			outputParams["custom"] = formParams[FormParameters.CONTRACT];
			// set invoice currency
			outputParams["currency_code"] = formParams[FormParameters.CURRENCY];
			// set formatted invoice number
			outputParams["item_name_1"] = String.Format("{0} #{1}", FormParameters.INVOICE, formParams[FormParameters.INVOICE]);
			// set invoice amount
			outputParams["amount_1"] = formParams[FormParameters.AMOUNT];
			// copy first name
			AddParameter(formParams, outputParams, FormParameters.FIRST_NAME, "first_name");
			// copy last name
			AddParameter(formParams, outputParams, FormParameters.LAST_NAME, "last_name");
			// copy address
			AddParameter(formParams, outputParams, FormParameters.ADDRESS, "address1");
			// copy city
			AddParameter(formParams, outputParams, FormParameters.CITY, "city");
			// copy state
			AddParameter(formParams, outputParams, FormParameters.STATE, "state");
			// copy country
			AddParameter(formParams, outputParams, FormParameters.COUNTRY, "country");
			// copy zip
			AddParameter(formParams, outputParams, FormParameters.ZIP, "zip");
			// copty email
			AddParameter(formParams, outputParams, FormParameters.EMAIL, "email");
			// copy phone number
			if (formParams[FormParameters.COUNTRY] != "US" && formParams[FormParameters.COUNTRY] != "CA")
			{
				// phone numbers outside U.S copy as is
				outputParams["night_phone_b"] = formParams[FormParameters.PHONE];
			}
			// return whole set of params
			return outputParams;
		}
示例#5
0
        public CheckoutFormParams GetCheckoutFormParams(FormParameters inputParams, InvoiceItem[] invoiceLines)
        {
			// check invoice currency against 2CO settings
			if (!CI_ValuesEqual(TCO_Currency, inputParams[FormParameters.CURRENCY]))
				throw new Exception(CURRENCY_NOT_MATCH_MSG);

			// fill checkout params
			CheckoutFormParams outputParams = new CheckoutFormParams();
			// sets serviced props
			outputParams.Action = PAYMENT_ROUTINE;
			outputParams.Method = CheckoutFormParams.POST_METHOD;
			// copy target_site variable
			outputParams["target_site"] = inputParams["target_site"];
			// copy invoice amount
			outputParams["sid"] = AccountSID;
            // copy contract number
            outputParams["contract_id"] = inputParams[FormParameters.CONTRACT];
			// copy invoice number
			outputParams["merchant_order_id"] = inputParams[FormParameters.INVOICE];
			// copy invoice currency
			outputParams["tco_currency"] = inputParams[FormParameters.CURRENCY];
			// copy continue shopping button url
			// outputParams["return_url"] = ContinueShoppingUrl + "&ContractId=" + inputParams[FormParameters.CONTRACT];
			// copy fixed cart option
			if (FixedCart)
				outputParams["fixed"] = "Y";
			// copy pay method (credit card)
			outputParams["pay_method"] = "CC";
			// copy live mode flag
			if (!LiveMode)
				outputParams["demo"] = "Y";
			// copy card holder name
			outputParams["card_holder_name"] = inputParams[FormParameters.FIRST_NAME] + " " + inputParams[FormParameters.LAST_NAME];
			// copy email
			outputParams["email"] = inputParams[FormParameters.EMAIL];
			// copy street address
			outputParams["street_address"] = inputParams[FormParameters.ADDRESS];
			// copy country
			outputParams["country"] = inputParams[FormParameters.COUNTRY];
			// copy city
			outputParams["city"] = inputParams[FormParameters.CITY];
			// copy state & phone
			if (!CI_ValuesEqual(inputParams[FormParameters.COUNTRY], "US") &&
				!CI_ValuesEqual(inputParams[FormParameters.COUNTRY], "CA"))
			{
				// state is outside US & CA
				outputParams["state"] = OUTSIDE_US_CA;
				// copy outside US phone as is 
				outputParams["phone"] = inputParams[FormParameters.PHONE];
			}
			else
			{
				// copy state
				outputParams["state"] = inputParams[FormParameters.STATE];
				// convert phone to US format
				outputParams["phone"] = ConvertPhone2US(inputParams[FormParameters.PHONE]);
			}
			// copy zip
			outputParams["zip"] = inputParams[FormParameters.ZIP];
			// copy invoice amount
			outputParams["total"] = inputParams[FormParameters.AMOUNT];
			// copy invoice number
			outputParams["cart_order_id"] = inputParams[FormParameters.INVOICE];

			return outputParams;
        }
示例#6
0
        public CheckoutFormParams GetCheckoutFormParams(FormParameters inputParams, InvoiceItem[] invoiceLines)
        {
            // check invoice currency against 2CO settings
            if (!CI_ValuesEqual(TCO_Currency, inputParams[FormParameters.CURRENCY]))
            {
                throw new Exception(CURRENCY_NOT_MATCH_MSG);
            }

            // fill checkout params
            CheckoutFormParams outputParams = new CheckoutFormParams();

            // sets serviced props
            outputParams.Action = PAYMENT_ROUTINE;
            outputParams.Method = CheckoutFormParams.POST_METHOD;
            // copy target_site variable
            outputParams["target_site"] = inputParams["target_site"];
            // copy invoice amount
            outputParams["sid"] = AccountSID;
            // copy contract number
            outputParams["contract_id"] = inputParams[FormParameters.CONTRACT];
            // copy invoice number
            outputParams["merchant_order_id"] = inputParams[FormParameters.INVOICE];
            // copy invoice currency
            outputParams["tco_currency"] = inputParams[FormParameters.CURRENCY];
            // copy continue shopping button url
            // outputParams["return_url"] = ContinueShoppingUrl + "&ContractId=" + inputParams[FormParameters.CONTRACT];
            // copy fixed cart option
            if (FixedCart)
            {
                outputParams["fixed"] = "Y";
            }
            // copy pay method (credit card)
            outputParams["pay_method"] = "CC";
            // copy live mode flag
            if (!LiveMode)
            {
                outputParams["demo"] = "Y";
            }
            // copy card holder name
            outputParams["card_holder_name"] = inputParams[FormParameters.FIRST_NAME] + " " + inputParams[FormParameters.LAST_NAME];
            // copy email
            outputParams["email"] = inputParams[FormParameters.EMAIL];
            // copy street address
            outputParams["street_address"] = inputParams[FormParameters.ADDRESS];
            // copy country
            outputParams["country"] = inputParams[FormParameters.COUNTRY];
            // copy city
            outputParams["city"] = inputParams[FormParameters.CITY];
            // copy state & phone
            if (!CI_ValuesEqual(inputParams[FormParameters.COUNTRY], "US") &&
                !CI_ValuesEqual(inputParams[FormParameters.COUNTRY], "CA"))
            {
                // state is outside US & CA
                outputParams["state"] = OUTSIDE_US_CA;
                // copy outside US phone as is
                outputParams["phone"] = inputParams[FormParameters.PHONE];
            }
            else
            {
                // copy state
                outputParams["state"] = inputParams[FormParameters.STATE];
                // convert phone to US format
                outputParams["phone"] = ConvertPhone2US(inputParams[FormParameters.PHONE]);
            }
            // copy zip
            outputParams["zip"] = inputParams[FormParameters.ZIP];
            // copy invoice amount
            outputParams["total"] = inputParams[FormParameters.AMOUNT];
            // copy invoice number
            outputParams["cart_order_id"] = inputParams[FormParameters.INVOICE];

            return(outputParams);
        }