Esempio n. 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);
        }
Esempio n. 2
0
        private void AddParameter(FormParameters inputParams, CheckoutFormParams outputParams, string inputKey, string outputKey)
        {
            string formParameter = inputParams[inputKey];

            if (formParameter != null)
            {
                outputParams[outputKey] = formParameter;
            }
        }
        public static CheckoutFormParams GetCheckoutFormParams(string contractId, int invoiceId,
                                                               string methodName, KeyValueBunch options)
        {
            Contract contractInfo = ContractSystem.ContractController.GetContract(contractId);

            // Impersonate
            ContractSystem.ContractController.ImpersonateAsContractReseller(contractInfo);
            //
            SupportedPlugin pmPlugin = GetResellerPMPlugin(contractInfo.ResellerId, methodName);

            //
            if (pmPlugin == null)
            {
                throw new Exception("Incorrect payment method has been specified");
            }
            // create instance of plugin
            IInteractivePaymentGatewayProvider provider = (IInteractivePaymentGatewayProvider)
                                                          SystemPluginController.GetSystemPluginInstance(contractInfo, pmPlugin, true);
            //
            Invoice userInvoice = InvoiceController.GetCustomerInvoiceInternally(invoiceId);
            //
            List <InvoiceItem> invoiceLines = InvoiceController.GetCustomerInvoiceItems(invoiceId);
            // load contract account
            ContractAccount account = ContractSystem.ContractController.GetContractAccountSettings(contractId);

            // build form parameters
            FormParameters formParams = new FormParameters();

            // copy reseller id
            formParams[FormParameters.CONTRACT] = userInvoice.ContractId;
            // copy invoice number
            formParams[FormParameters.INVOICE] = userInvoice.InvoiceId.ToString();
            // copy invoice amount
            formParams[FormParameters.AMOUNT] = userInvoice.Total.ToString("0.00");
            // copy invoice tax amount
            formParams[FormParameters.TAX_AMOUNT] = userInvoice.TaxAmount.ToString("0.00");
            // copy invoice currency
            formParams[FormParameters.CURRENCY] = userInvoice.Currency;

            // copy first name
            formParams[FormParameters.FIRST_NAME] = account[ContractAccount.FIRST_NAME];
            // copy last name
            formParams[FormParameters.LAST_NAME] = account[ContractAccount.LAST_NAME];
            // copy email
            formParams[FormParameters.EMAIL] = account[ContractAccount.EMAIL];
            // copy address
            formParams[FormParameters.ADDRESS] = account[ContractAccount.ADDRESS];
            // copy country
            formParams[FormParameters.COUNTRY] = account[ContractAccount.COUNTRY];
            // copy phone number
            formParams[FormParameters.PHONE] = account[ContractAccount.PHONE_NUMBER];
            // copy city
            formParams[FormParameters.CITY] = account[ContractAccount.CITY];
            // copy state
            formParams[FormParameters.STATE] = account[ContractAccount.STATE];
            // copy zip
            formParams[FormParameters.ZIP] = account[ContractAccount.ZIP];
            // copy options if any
            if (options != null)
            {
                foreach (string keyName in options.GetAllKeys())
                {
                    formParams[keyName] = options[keyName];
                }
            }

            // return result
            return(provider.GetCheckoutFormParams(formParams, invoiceLines.ToArray()));
        }
		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;
		}
Esempio n. 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;
        }
Esempio n. 7
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);
        }