Example #1
0
        public override PaymentHtmlForm GenerateHtmlForm(Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary <string, string> settings)
        {
            order.MustNotBeNull("order");
            settings.MustNotBeNull("settings");
            settings.MustContainKey("form_url", "settings");

            PaymentHtmlForm htmlForm = new PaymentHtmlForm
            {
                Action = settings["form_url"]
            };

            htmlForm.InputFields["form_url"] = settings.ContainsKey("mode") && settings["mode"] == "live" ? LiveTransactionEndpoint : TestTransactionEndpoint;

            htmlForm.InputFields["cancel_url"]        = teaCommerceCancelUrl;
            htmlForm.InputFields["communication_url"] = teaCommerceCommunicationUrl;
            order.Properties.AddOrUpdate(new CustomProperty("teaCommerceContinueUrl", teaCommerceContinueUrl)
            {
                ServerSideOnly = true
            });
            order.Properties.AddOrUpdate(new CustomProperty("teaCommerceCallBackUrl", teaCommerceCallBackUrl)
            {
                ServerSideOnly = true
            });
            order.Save();

            return(htmlForm);
        }
Example #2
0
        public override PaymentHtmlForm GenerateHtmlForm(Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary <string, string> settings)
        {
            order.MustNotBeNull("order");
            settings.MustNotBeNull("settings");
            settings.MustContainKey("paymentFormUrl", "settings");

            PaymentHtmlForm htmlForm = new PaymentHtmlForm {
                Action = settings["paymentFormUrl"]
            };

            order.Properties.AddOrUpdate(new CustomProperty("teaCommerceCommunicationUrl", teaCommerceCommunicationUrl)
            {
                ServerSideOnly = true
            });
            order.Properties.AddOrUpdate(new CustomProperty("teaCommerceContinueUrl", teaCommerceContinueUrl)
            {
                ServerSideOnly = true
            });
            order.Properties.AddOrUpdate(new CustomProperty("teaCommerceCallbackUrl", teaCommerceCallBackUrl)
            {
                ServerSideOnly = true
            });

            return(htmlForm);
        }
Example #3
0
        public override PaymentHtmlForm GenerateHtmlForm(Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary <string, string> settings)
        {
            order.MustNotBeNull("order");
            settings.MustNotBeNull("settings");
            settings.MustContainKey("form_url", "settings");
            settings.MustContainKey("mode", "settings");
            settings.MustContainKey(settings["mode"] + "_public_key", "settings");

            var htmlForm = new PaymentHtmlForm
            {
                Action = settings["form_url"]
            };

            // Copy all settings except those in default settings list
            // as all default settings are handled explicitly below
            htmlForm.InputFields = settings.Where(i => !DefaultSettings.ContainsKey(i.Key)).ToDictionary(i => i.Key, i => i.Value);

            htmlForm.InputFields["api_key"]      = settings[settings["mode"] + "_public_key"];
            htmlForm.InputFields["continue_url"] = teaCommerceContinueUrl;
            htmlForm.InputFields["cancel_url"]   = teaCommerceCancelUrl;

            if (settings.ContainsKey("billing_address_line1_property_alias") && !string.IsNullOrWhiteSpace(settings["billing_address_line1_property_alias"]))
            {
                htmlForm.InputFields["billing_address_line1"] = order.Properties.First(x => x.Alias == settings["billing_address_line1_property_alias"]).Value;
            }

            if (settings.ContainsKey("billing_address_line2_property_alias") && !string.IsNullOrWhiteSpace(settings["billing_address_line2_property_alias"]))
            {
                htmlForm.InputFields["billing_address_line2"] = order.Properties.First(x => x.Alias == settings["billing_address_line2_property_alias"]).Value;
            }

            if (settings.ContainsKey("billing_city_property_alias") && !string.IsNullOrWhiteSpace(settings["billing_city_property_alias"]))
            {
                htmlForm.InputFields["billing_city"] = order.Properties.First(x => x.Alias == settings["billing_city_property_alias"]).Value;
            }

            if (settings.ContainsKey("billing_state_property_alias") && !string.IsNullOrWhiteSpace(settings["billing_state_property_alias"]))
            {
                htmlForm.InputFields["billing_state"] = order.Properties.First(x => x.Alias == settings["billing_state_property_alias"]).Value;
            }

            if (settings.ContainsKey("billing_zip_code_property_alias") && !string.IsNullOrWhiteSpace(settings["billing_zip_code_property_alias"]))
            {
                htmlForm.InputFields["billing_zip_code"] = order.Properties.First(x => x.Alias == settings["billing_zip_code_property_alias"]).Value;
            }

            if (order.PaymentInformation != null && order.PaymentInformation.CountryId > 0)
            {
                var country = CountryService.Instance.Get(order.StoreId, order.PaymentInformation.CountryId);
                htmlForm.InputFields["billing_country"] = country.RegionCode.ToLowerInvariant();
            }

            return(htmlForm);
        }
Example #4
0
        public override PaymentHtmlForm GenerateHtmlForm( Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary<string, string> settings )
        {
            order.MustNotBeNull( "order" );
              settings.MustNotBeNull( "settings" );
              settings.MustContainKey( "paymentFormUrl", "settings" );

              PaymentHtmlForm htmlForm = new PaymentHtmlForm {
            Action = settings[ "paymentFormUrl" ]
              };

              order.Properties.AddOrUpdate( new CustomProperty( "teaCommerceCommunicationUrl", teaCommerceCommunicationUrl ) { ServerSideOnly = true } );
              order.Properties.AddOrUpdate( new CustomProperty( "teaCommerceContinueUrl", teaCommerceContinueUrl ) { ServerSideOnly = true } );
              order.Properties.AddOrUpdate( new CustomProperty( "teaCommerceCallbackUrl", teaCommerceCallBackUrl ) { ServerSideOnly = true } );

              return htmlForm;
        }
Example #5
0
        public override PaymentHtmlForm GenerateHtmlForm(Api.Models.Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary <string, string> settings)
        {
            try
            {
                settings.MustNotBeNull("settings");
                settings.MustContainKey("PartnerId", "settings");
                settings.MustContainKey("ProfileKey", "settings");
                settings.MustContainKey("SecretKey", "settings");
                settings.MustContainKey("ReturnUrl", "settings");
                settings.MustContainKey("mollieiDealBanksPropertyAlias", "settings");
                settings.MustContainKey("OrderDescriptionField", "settings");

                string bankId = order.Properties[settings["mollieiDealBanksPropertyAlias"]];
                string amount = order.TotalPrice.Value.WithVatFormattedWithoutSymbol.Replace(".", "");

                //var hash = GenerateHMACMD5Hash(settings["SecretKey"], string.Format("{0}{1}{2}", settings["PartnerId"], settings["ProfileKey"], order.CartNumber));
                var hash = new HMACSHA256(Encoding.UTF8.GetBytes(settings["SecretKey"])).ComputeHash(Encoding.UTF8.GetBytes(string.Format("{0}{1}{2}", settings["PartnerId"], settings["ProfileKey"], order.CartNumber))).ToBase64();

                var    qs                    = (settings["ReportUrl"].Contains('?')) ? "&" : "?";
                string reporturl             = string.Format("{0}{1}cartNumber={2}&hash={3}", settings["ReportUrl"], qs, order.CartNumber, hash);
                string orderDescriptionField = settings["OrderDescriptionField"];
                string description           = string.Format("{0} {1}", orderDescriptionField, order.CartNumber);
                qs = (settings["ReturnUrl"].Contains('?')) ? "&" : "?";
                string returnurl   = string.Format("{0}{1}orderId={2}", settings["ReturnUrl"], qs, order.Id);
                string profile_key = settings["ProfileKey"];
                string partner_id  = settings["PartnerId"];

                Dictionary <string, string> transactionSettings = getTransactionURL(settings, order);
                Dictionary <string, string> inputFields         = new Dictionary <string, string>();
                inputFields.Add("paymentUrl", transactionSettings["transactionUrl"]);
                // The next line is here because Mollie does not accept POST requests, only GET requests
                PaymentHtmlForm htmlForm = new PaymentHtmlForm
                {
                    Action      = "/pages/redirecttopayment.aspx",
                    InputFields = inputFields
                };
                return(htmlForm);
            }
            catch (Exception ex)
            {
                LoggingService.Instance.Error <MollieiDeal>("GenerateHtmlForm exception", ex);
                throw ex;
            }
        }
Example #6
0
        public override PaymentHtmlForm GenerateHtmlForm(Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary <string, string> settings)
        {
            order.MustNotBeNull("order");
            settings.MustNotBeNull("settings");
            settings.MustContainKey("x_login", "settings");
            settings.MustContainKey("x_type", "settings");
            settings.MustContainKey("transactionKey", "settings");

            PaymentHtmlForm htmlForm = new PaymentHtmlForm {
                Action = settings.ContainsKey("testing") && settings["testing"] == "1" ? "https://test.authorize.net/gateway/transact.dll" : "https://secure.authorize.net/gateway/transact.dll"
            };

            string[] settingsToExclude = new[] { "transactionKey", "md5HashKey", "testing" };
            htmlForm.InputFields = settings.Where(i => !settingsToExclude.Contains(i.Key)).ToDictionary(i => i.Key, i => i.Value);

            //Future: Would be cool to support item lines for this one - you have to return a List<Tuple<string, string>> for it to work with this provider
            htmlForm.InputFields["x_version"]             = "3.1";
            htmlForm.InputFields["x_show_form"]           = "PAYMENT_FORM";
            htmlForm.InputFields["x_relay_always"]        = "false";
            htmlForm.InputFields["x_relay_response"]      = "TRUE";
            htmlForm.InputFields["x_receipt_link_method"] = "LINK";

            htmlForm.InputFields["x_invoice_num"] = order.CartNumber;

            string amount = order.TotalPrice.Value.WithVat.ToString("0.00", CultureInfo.InvariantCulture);

            htmlForm.InputFields["x_amount"] = amount;

            htmlForm.InputFields["x_receipt_link_url"] = teaCommerceContinueUrl;
            htmlForm.InputFields["x_cancel_url"]       = teaCommerceCancelUrl;

            string sequenceNumber = new Random().Next(0, 1000).ToString(CultureInfo.InvariantCulture);

            htmlForm.InputFields["x_fp_sequence"] = sequenceNumber;

            string timestamp = (DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds.ToString("0", CultureInfo.InvariantCulture);

            htmlForm.InputFields["x_fp_timestamp"] = timestamp;
            htmlForm.InputFields["x_fp_hash"]      = new HMACMD5(Encoding.UTF8.GetBytes(settings["transactionKey"])).ComputeHash(Encoding.UTF8.GetBytes(settings["x_login"] + "^" + sequenceNumber + "^" + timestamp + "^" + amount + "^")).ToHex();

            return(htmlForm);
        }
Example #7
0
        public override PaymentHtmlForm GenerateHtmlForm( Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary<string, string> settings )
        {
            order.MustNotBeNull( "order" );
              settings.MustNotBeNull( "settings" );
              settings.MustContainKey( "form_url", "settings" );

              PaymentHtmlForm htmlForm = new PaymentHtmlForm {
            Action = settings[ "form_url" ]
              };

              htmlForm.InputFields[ "form_url" ] = settings.ContainsKey( "mode" ) && settings[ "mode" ] == "live" ? LiveTransactionEndpoint : TestTransactionEndpoint;

              htmlForm.InputFields[ "cancel_url" ] = teaCommerceCancelUrl;
              htmlForm.InputFields[ "communication_url" ] = teaCommerceCommunicationUrl;
              order.Properties.AddOrUpdate( new CustomProperty( "teaCommerceContinueUrl", teaCommerceContinueUrl ) { ServerSideOnly = true } );
              order.Properties.AddOrUpdate( new CustomProperty( "teaCommerceCallBackUrl", teaCommerceCallBackUrl ) { ServerSideOnly = true } );
              order.Save();

              return htmlForm;
        }
        public override PaymentHtmlForm GenerateHtmlForm(Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary <string, string> settings)
        {
            order.MustNotBeNull("order");
            settings.MustNotBeNull("settings");
            settings.MustContainKey("SHAINPASSPHRASE", "settings");

            PaymentHtmlForm htmlForm = new PaymentHtmlForm
            {
                Action = GetMethodUrl("GENERATEFORM", settings)
            };

            string[] settingsToExclude = new[] { "SHAINPASSPHRASE", "SHAOUTPASSPHRASE", "APIUSERID", "APIPASSWORD", "TESTMODE" };
            htmlForm.InputFields = settings.Where(i => !settingsToExclude.Contains(i.Key) && !string.IsNullOrEmpty(i.Value)).ToDictionary(i => i.Key.ToUpperInvariant(), i => i.Value);

            htmlForm.InputFields["ORDERID"] = order.CartNumber;
            htmlForm.InputFields["AMOUNT"]  = (order.TotalPrice.Value.WithVat * 100M).ToString("0", CultureInfo.InvariantCulture);

            //Check that the Iso code exists
            Currency currency = CurrencyService.Instance.Get(order.StoreId, order.CurrencyId);

            if (!Iso4217CurrencyCodes.ContainsKey(currency.IsoCode))
            {
                throw new Exception("You must specify an ISO 4217 currency code for the " + currency.Name + " currency");
            }
            htmlForm.InputFields["CURRENCY"] = currency.IsoCode;

            htmlForm.InputFields["CN"]           = order.PaymentInformation.FirstName + " " + order.PaymentInformation.LastName;
            htmlForm.InputFields["EMAIL"]        = order.PaymentInformation.Email;
            htmlForm.InputFields["ACCEPTURL"]    = teaCommerceContinueUrl;
            htmlForm.InputFields["DECLINEURL"]   = teaCommerceCancelUrl;
            htmlForm.InputFields["EXCEPTIONURL"] = teaCommerceCancelUrl;
            htmlForm.InputFields["CANCELURL"]    = teaCommerceCancelUrl;

            //Ogone dont support to show order line information to the shopper

            string strToHash = string.Join("", htmlForm.InputFields.OrderBy(i => i.Key).Select(i => i.Key + "=" + i.Value + settings["SHAINPASSPHRASE"]));

            htmlForm.InputFields["SHASIGN"] = new SHA512Managed().ComputeHash(Encoding.UTF8.GetBytes(strToHash)).ToHex();

            return(htmlForm);
        }
Example #9
0
        public override PaymentHtmlForm GenerateHtmlForm(Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl,
                                                         string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary <string, string> settings)
        {
            var htmlForm = new PaymentHtmlForm();

            htmlForm.InputFields["return"]        = teaCommerceContinueUrl;
            htmlForm.InputFields["cancel_return"] = teaCommerceCancelUrl;
            htmlForm.InputFields["notify_url"]    = teaCommerceCallBackUrl;

            htmlForm.InputFields["env"] = settings["env"];

            htmlForm.InputFields["button_style_label"] = settings["button_style_label"];
            htmlForm.InputFields["button_style_size"]  = settings["button_style_size"];
            htmlForm.InputFields["button_style_shape"] = settings["button_style_shape"];
            htmlForm.InputFields["button_style_color"] = settings["button_style_color"];

            htmlForm.InputFields["client_sandbox_id"]    = settings["client_sandbox_id"];
            htmlForm.InputFields["client_production_id"] = settings["client_production_id"];

            return(htmlForm);
        }
Example #10
0
        public override PaymentHtmlForm GenerateHtmlForm(Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary <string, string> settings)
        {
            order.MustNotBeNull("order");
            settings.MustNotBeNull("settings");
            settings.MustContainKey("form_url", "settings");
            settings.MustContainKey("mode", "settings");
            settings.MustContainKey(settings["mode"] + "_public_key", "settings");

            PaymentHtmlForm htmlForm = new PaymentHtmlForm {
                Action = settings["form_url"]
            };

            string[] settingsToExclude = new[] { "form_url", "capture", "test_secret_key", "test_public_key", "live_secret_key", "live_public_key", "mode" };
            htmlForm.InputFields = settings.Where(i => !settingsToExclude.Contains(i.Key)).ToDictionary(i => i.Key, i => i.Value);

            htmlForm.InputFields["api_key"]      = settings[settings["mode"] + "_public_key"];
            htmlForm.InputFields["continue_url"] = teaCommerceContinueUrl;
            htmlForm.InputFields["cancel_url"]   = teaCommerceCancelUrl;

            return(htmlForm);
        }
Example #11
0
        public override PaymentHtmlForm GenerateHtmlForm( Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary<string, string> settings )
        {
            order.MustNotBeNull( "order" );
              settings.MustNotBeNull( "settings" );
              settings.MustContainKey( "x_login", "settings" );
              settings.MustContainKey( "x_type", "settings" );
              settings.MustContainKey( "transactionKey", "settings" );

              PaymentHtmlForm htmlForm = new PaymentHtmlForm {
            Action = settings.ContainsKey( "testing" ) && settings[ "testing" ] == "1" ? "https://test.authorize.net/gateway/transact.dll" : "https://secure.authorize.net/gateway/transact.dll"
              };

              string[] settingsToExclude = new[] { "transactionKey", "md5HashKey", "testing" };
              htmlForm.InputFields = settings.Where( i => !settingsToExclude.Contains( i.Key ) ).ToDictionary( i => i.Key, i => i.Value );

              //Future: Would be cool to support item lines for this one - you have to return a List<Tuple<string, string>> for it to work with this provider
              htmlForm.InputFields[ "x_version" ] = "3.1";
              htmlForm.InputFields[ "x_show_form" ] = "PAYMENT_FORM";
              htmlForm.InputFields[ "x_relay_always" ] = "false";
              htmlForm.InputFields[ "x_relay_response" ] = "TRUE";
              htmlForm.InputFields[ "x_receipt_link_method" ] = "LINK";

              htmlForm.InputFields[ "x_invoice_num" ] = order.CartNumber;

              string amount = order.TotalPrice.Value.WithVat.ToString( "0.00", CultureInfo.InvariantCulture );
              htmlForm.InputFields[ "x_amount" ] = amount;

              htmlForm.InputFields[ "x_receipt_link_url" ] = teaCommerceContinueUrl;
              htmlForm.InputFields[ "x_cancel_url" ] = teaCommerceCancelUrl;

              string sequenceNumber = new Random().Next( 0, 1000 ).ToString( CultureInfo.InvariantCulture );
              htmlForm.InputFields[ "x_fp_sequence" ] = sequenceNumber;

              string timestamp = ( DateTime.UtcNow - new DateTime( 1970, 1, 1 ) ).TotalSeconds.ToString( "0", CultureInfo.InvariantCulture );
              htmlForm.InputFields[ "x_fp_timestamp" ] = timestamp;
              htmlForm.InputFields[ "x_fp_hash" ] = new HMACMD5( Encoding.UTF8.GetBytes( settings[ "transactionKey" ] ) ).ComputeHash( Encoding.UTF8.GetBytes( settings[ "x_login" ] + "^" + sequenceNumber + "^" + timestamp + "^" + amount + "^" ) ).ToHex();

              return htmlForm;
        }
        public override PaymentHtmlForm GenerateHtmlForm(Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary <string, string> settings)
        {
            order.MustNotBeNull("order");
            settings.MustNotBeNull("settings");

            PaymentHtmlForm htmlForm = new PaymentHtmlForm {
                Action = settings.ContainsKey("isSandbox") && settings["isSandbox"] == "1" ? "https://www.sandbox.paypal.com/cgi-bin/webscr" : "https://www.paypal.com/cgi-bin/webscr"
            };

            string[] settingsToExclude = new[] { "USER", "PWD", "SIGNATURE", "isSandbox" };
            htmlForm.InputFields = settings.Where(i => !settingsToExclude.Contains(i.Key)).ToDictionary(i => i.Key, i => i.Value);

            htmlForm.InputFields["cmd"]    = "_cart";
            htmlForm.InputFields["upload"] = "1";

            //Check that the Iso code exists
            Currency currency = CurrencyService.Instance.Get(order.StoreId, order.CurrencyId);

            if (!Iso4217CurrencyCodes.ContainsKey(currency.IsoCode))
            {
                throw new Exception("You must specify an ISO 4217 currency code for the " + currency.Name + " currency");
            }
            htmlForm.InputFields["currency_code"] = currency.IsoCode;

            htmlForm.InputFields["invoice"] = order.CartNumber;

            htmlForm.InputFields["return"]        = teaCommerceContinueUrl;
            htmlForm.InputFields["rm"]            = "2";
            htmlForm.InputFields["cancel_return"] = teaCommerceCancelUrl;
            htmlForm.InputFields["notify_url"]    = teaCommerceCallBackUrl;

            htmlForm.InputFields["item_name_1"]   = settings.ContainsKey("totalName") ? settings["totalName"] : "Total";
            htmlForm.InputFields["item_number_1"] = settings.ContainsKey("totalSku") ? settings["totalSku"] : "0001";
            htmlForm.InputFields["amount_1"]      = order.TotalPrice.Value.WithVat.ToString("0.00", CultureInfo.InvariantCulture);
            htmlForm.InputFields["quantity_1"]    = 1M.ToString("0", CultureInfo.InvariantCulture);

            return(htmlForm);
        }
Example #13
0
        public override PaymentHtmlForm GenerateHtmlForm(Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary <string, string> settings)
        {
            order.MustNotBeNull("order");
            settings.MustNotBeNull("settings");
            settings.MustContainKey("md5Secret", "settings");
            settings.MustContainKey("instId", "settings");
            settings.MustContainKey("streetAddressPropertyAlias", "settings");
            settings.MustContainKey("cityPropertyAlias", "settings");
            settings.MustContainKey("zipCodePropertyAlias", "settings");
            order.Properties[settings["streetAddressPropertyAlias"]].MustNotBeNullOrEmpty("street address");
            order.Properties[settings["cityPropertyAlias"]].MustNotBeNullOrEmpty("city");
            order.Properties[settings["zipCodePropertyAlias"]].MustNotBeNullOrEmpty("zip code");

            PaymentHtmlForm htmlForm = new PaymentHtmlForm {
                Action = settings.ContainsKey("testMode") && settings["testMode"] == "100" ? "https://secure-test.worldpay.com/wcc/purchase" : "https://secure.worldpay.com/wcc/purchase"
            };

            string[] settingsToExclude = new[] { "md5Secret", "callbackPW", "streetAddressPropertyAlias", "cityPropertyAlias", "zipCodePropertyAlias" };
            htmlForm.InputFields = settings.Where(i => !settingsToExclude.Contains(i.Key)).ToDictionary(i => i.Key, i => i.Value);

            //cartId
            htmlForm.InputFields["cartId"] = order.CartNumber;

            //currency
            Currency currency = CurrencyService.Instance.Get(order.StoreId, order.CurrencyId);

            if (!Iso4217CurrencyCodes.ContainsKey(currency.IsoCode))
            {
                throw new Exception("You must specify an ISO 4217 currency code for the " + currency.Name + " currency");
            }
            htmlForm.InputFields["currency"] = currency.IsoCode;

            //amount
            string amount = order.TotalPrice.Value.WithVat.ToString("0.00", CultureInfo.InvariantCulture);

            htmlForm.InputFields["amount"] = amount;

            htmlForm.InputFields["successURL"] = teaCommerceContinueUrl;
            htmlForm.InputFields["cancelURL"]  = teaCommerceCancelUrl;

            //name
            htmlForm.InputFields["name"] = order.PaymentInformation.FirstName + " " + order.PaymentInformation.LastName;

            //email
            htmlForm.InputFields["email"] = order.PaymentInformation.Email;

            //country
            Country country = CountryService.Instance.Get(order.StoreId, order.PaymentInformation.CountryId);

            htmlForm.InputFields["country"] = country.RegionCode;

            //country region
            if (order.PaymentInformation.CountryRegionId != null)
            {
                CountryRegion countryRegion = CountryRegionService.Instance.Get(order.StoreId, order.PaymentInformation.CountryRegionId.Value);
                htmlForm.InputFields["region"] = countryRegion.RegionCode;
            }

            //address1
            htmlForm.InputFields["address1"] = order.Properties[settings["streetAddressPropertyAlias"]];

            //town
            htmlForm.InputFields["town"] = order.Properties[settings["cityPropertyAlias"]];

            //postcode
            htmlForm.InputFields["postcode"] = order.Properties[settings["zipCodePropertyAlias"]];

            //UI settings
            htmlForm.InputFields["noLanguageMenu"] = string.Empty;
            htmlForm.InputFields["hideCurrency"]   = string.Empty;
            htmlForm.InputFields["fixContact"]     = string.Empty;
            htmlForm.InputFields["hideContact"]    = string.Empty;

            htmlForm.InputFields["signatureFields"] = "amount:currency:instId:cartId";
            htmlForm.InputFields["signature"]       = GenerateMD5Hash(settings["md5Secret"] + ":" + amount + ":" + currency.IsoCode + ":" + settings["instId"] + ":" + order.CartNumber);

            //WorldPay dont support to show order line information to the shopper

            return(htmlForm);
        }
Example #14
0
        public override PaymentHtmlForm GenerateHtmlForm(Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary <string, string> settings)
        {
            order.MustNotBeNull("order");
            settings.MustNotBeNull("settings");
            settings.MustContainKey("merchant_id", "settings");
            settings.MustContainKey("agreement_id", "settings");
            settings.MustContainKey("autocapture", "settings");
            settings.MustContainKey("language", "settings");
            settings.MustContainKey("windowApiKey", "settings");

            PaymentHtmlForm htmlForm = new PaymentHtmlForm {
                Action = "https://payment.quickpay.net"
            };

            htmlForm.InputFields["version"]         = "v10";
            htmlForm.InputFields["merchant_id"]     = settings["merchant_id"];
            htmlForm.InputFields["agreement_id"]    = settings["agreement_id"];
            htmlForm.InputFields["autocapture"]     = settings["autocapture"];
            htmlForm.InputFields["payment_methods"] = settings["payment_methods"];

            //Order name must be between 4 or 20 chars
            string orderName = order.CartNumber;

            while (orderName.Length < 4)
            {
                orderName = "0" + orderName;
            }
            if (orderName.Length > 20)
            {
                throw new Exception("Cart number of the order can not exceed 20 characters.");
            }
            htmlForm.InputFields["order_id"] = orderName;

            htmlForm.InputFields["amount"] = (order.TotalPrice.Value.WithVat * 100M).ToString("0", CultureInfo.InvariantCulture);

            //Check that the Iso code exists
            Currency currency = CurrencyService.Instance.Get(order.StoreId, order.CurrencyId);

            if (!Iso4217CurrencyCodes.ContainsKey(currency.IsoCode))
            {
                throw new Exception("You must specify an ISO 4217 currency code for the " + currency.Name + " currency");
            }
            htmlForm.InputFields["currency"] = currency.IsoCode;

            htmlForm.InputFields["continueurl"] = teaCommerceContinueUrl;
            htmlForm.InputFields["cancelurl"]   = teaCommerceCancelUrl;
            htmlForm.InputFields["callbackurl"] = teaCommerceCallBackUrl;

            htmlForm.InputFields["language"] = settings["language"];

            if (settings.ContainsKey("branding_id"))
            {
                htmlForm.InputFields["branding_id"] = settings["branding_id"];
            }

            if (settings.ContainsKey("google_analytics_tracking_id"))
            {
                htmlForm.InputFields["google_analytics_tracking_id"] = settings["google_analytics_tracking_id"];
            }

            if (settings.ContainsKey("google_analytics_client_id"))
            {
                htmlForm.InputFields["google_analytics_client_id"] = settings["google_analytics_client_id"];
            }

            htmlForm.InputFields["checksum"] = GetChecksum(htmlForm.InputFields, settings["windowApiKey"]);

            return(htmlForm);
        }
Example #15
0
        public override PaymentHtmlForm GenerateHtmlForm( Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary<string, string> settings )
        {
            order.MustNotBeNull( "order" );
              settings.MustNotBeNull( "settings" );
              settings.MustContainKey( "merchant", "settings" );
              settings.MustContainKey( "md5k1", "settings" );
              settings.MustContainKey( "md5k2", "settings" );

              PaymentHtmlForm htmlForm = new PaymentHtmlForm {
            Action = "https://payment.architrade.com/paymentweb/start.action"
              };

              string[] settingsToExclude = new[] { "md5k1", "md5k2", "apiusername", "apipassword" };
              htmlForm.InputFields = settings.Where( i => !settingsToExclude.Contains( i.Key ) ).ToDictionary( i => i.Key, i => i.Value );

              htmlForm.InputFields[ "orderid" ] = order.CartNumber;

              string strAmount = ( order.TotalPrice.Value.WithVat * 100M ).ToString( "0", CultureInfo.InvariantCulture );
              htmlForm.InputFields[ "amount" ] = strAmount;

              Currency currency = CurrencyService.Instance.Get( order.StoreId, order.CurrencyId );
              if ( !Iso4217CurrencyCodes.ContainsKey( currency.IsoCode ) ) {
            throw new Exception( "You must specify an ISO 4217 currency code for the " + currency.Name + " currency" );
              }
              string currencyStr = Iso4217CurrencyCodes[ currency.IsoCode ];
              htmlForm.InputFields[ "currency" ] = currencyStr;

              htmlForm.InputFields[ "accepturl" ] = teaCommerceContinueUrl;
              htmlForm.InputFields[ "cancelurl" ] = teaCommerceCancelUrl;
              htmlForm.InputFields[ "callbackurl" ] = teaCommerceCallBackUrl;

              if ( htmlForm.InputFields.ContainsKey( "capturenow" ) && htmlForm.InputFields[ "capturenow" ] != "1" )
            htmlForm.InputFields.Remove( "capturenow" );

              if ( htmlForm.InputFields.ContainsKey( "calcfee" ) && htmlForm.InputFields[ "calcfee" ] != "1" )
            htmlForm.InputFields.Remove( "calcfee" );

              htmlForm.InputFields[ "uniqueoid" ] = string.Empty;

              if ( htmlForm.InputFields.ContainsKey( "test" ) && htmlForm.InputFields[ "test" ] != "1" )
            htmlForm.InputFields.Remove( "test" );

              //DIBS dont support to show order line information to the shopper

              //MD5(key2 + MD5(key1 + “merchant=<merchant>&orderid=<orderid> &currency=<cur>&amount=<amount>))
              string md5CheckValue = string.Empty;
              md5CheckValue += settings[ "md5k1" ];
              md5CheckValue += "merchant=" + settings[ "merchant" ];
              md5CheckValue += "&orderid=" + order.CartNumber;
              md5CheckValue += "&currency=" + currencyStr;
              md5CheckValue += "&amount=" + strAmount;

              htmlForm.InputFields[ "md5key" ] = GenerateMD5Hash( settings[ "md5k2" ] + GenerateMD5Hash( md5CheckValue ) );

              return htmlForm;
        }
        public override PaymentHtmlForm GenerateHtmlForm(Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary <string, string> settings)
        {
            order.MustNotBeNull("order");
            settings.MustNotBeNull("settings");
            settings.MustContainKey("streetAddressPropertyAlias", "settings");
            settings.MustContainKey("cityPropertyAlias", "settings");
            settings.MustContainKey("zipCodePropertyAlias", "settings");
            settings.MustContainKey("Description", "settings");

            PaymentHtmlForm htmlForm = new PaymentHtmlForm();

            string[] settingsToExclude = new[] { "streetAddressPropertyAlias", "cityPropertyAlias", "zipCodePropertyAlias", "phonePropertyAlias", "shipping_firstNamePropertyAlias", "shipping_lastNamePropertyAlias", "shipping_streetAddressPropertyAlias", "shipping_cityPropertyAlias", "shipping_zipCodePropertyAlias", "shipping_phonePropertyAlias", "testMode" };
            Dictionary <string, string> inputFields = settings.Where(i => !settingsToExclude.Contains(i.Key)).ToDictionary(i => i.Key, i => i.Value);

            inputFields["VPSProtocol"] = "2.23";

            #region Address properties

            string streetAddress = order.Properties[settings["streetAddressPropertyAlias"]];
            string city          = order.Properties[settings["cityPropertyAlias"]];
            string zipCode       = order.Properties[settings["zipCodePropertyAlias"]];

            streetAddress.MustNotBeNullOrEmpty("streetAddress");
            city.MustNotBeNullOrEmpty("city");
            zipCode.MustNotBeNullOrEmpty("zipCode");

            string shippingFirstName = settings.ContainsKey("shipping_firstNamePropertyAlias") ? order.Properties[settings["shipping_firstNamePropertyAlias"]] : "";
            if (string.IsNullOrEmpty(shippingFirstName))
            {
                shippingFirstName = order.PaymentInformation.FirstName;
            }

            string shippingLastName = settings.ContainsKey("shipping_lastNamePropertyAlias") ? order.Properties[settings["shipping_lastNamePropertyAlias"]] : "";
            if (string.IsNullOrEmpty(shippingLastName))
            {
                shippingLastName = order.PaymentInformation.LastName;
            }

            string shippingStreetAddress = settings.ContainsKey("shipping_streetAddressPropertyAlias") ? order.Properties[settings["shipping_streetAddressPropertyAlias"]] : "";
            if (string.IsNullOrEmpty(shippingStreetAddress))
            {
                shippingStreetAddress = streetAddress;
            }

            string shippingCity = settings.ContainsKey("shipping_cityPropertyAlias") ? order.Properties[settings["shipping_cityPropertyAlias"]] : "";
            if (string.IsNullOrEmpty(shippingCity))
            {
                shippingCity = city;
            }

            string shippingZipCode = settings.ContainsKey("shipping_zipCodePropertyAlias") ? order.Properties[settings["shipping_zipCodePropertyAlias"]] : "";
            if (string.IsNullOrEmpty(shippingZipCode))
            {
                shippingZipCode = zipCode;
            }

            #endregion

            if (order.CartNumber.Length > 40)
            {
                throw new Exception("Cart number of the order can not exceed 40 characters.");
            }
            inputFields["VendorTxCode"] = order.CartNumber;
            inputFields["Amount"]       = order.TotalPrice.Value.WithVat.ToString("0.00", CultureInfo.InvariantCulture);

            //Check that the Iso code exists
            Currency currency = CurrencyService.Instance.Get(order.StoreId, order.CurrencyId);
            if (!Iso4217CurrencyCodes.ContainsKey(currency.IsoCode))
            {
                throw new Exception("You must specify an ISO 4217 currency code for the " + currency.Name + " currency");
            }
            inputFields["Currency"]          = currency.IsoCode;
            inputFields["Description"]       = inputFields["Description"].Truncate(100);
            inputFields["SuccessURL"]        = teaCommerceContinueUrl;
            inputFields["FailureURL"]        = teaCommerceCancelUrl;
            inputFields["NotificationURL"]   = teaCommerceCallBackUrl;
            inputFields["BillingSurname"]    = order.PaymentInformation.LastName.Truncate(20);
            inputFields["BillingFirstnames"] = order.PaymentInformation.FirstName.Truncate(20);
            inputFields["BillingAddress1"]   = streetAddress.Truncate(100);
            inputFields["BillingCity"]       = city.Truncate(40);
            inputFields["BillingPostCode"]   = zipCode.Truncate(10);

            Country country = CountryService.Instance.Get(order.StoreId, order.PaymentInformation.CountryId);
            inputFields["BillingCountry"] = country.RegionCode;
            if (country.RegionCode.ToUpperInvariant() == "US" && order.PaymentInformation.CountryRegionId != null)
            {
                CountryRegion countryRegion = CountryRegionService.Instance.Get(order.StoreId, order.PaymentInformation.CountryRegionId.Value);
                inputFields["BillingState"] = countryRegion.RegionCode.Truncate(2);
            }
            if (settings.ContainsKey("phonePropertyAlias"))
            {
                inputFields["BillingPhone"] = order.Properties[settings["phonePropertyAlias"]].Truncate(20);
            }

            inputFields["DeliverySurname"]    = shippingLastName.Truncate(20);
            inputFields["DeliveryFirstnames"] = shippingFirstName.Truncate(20);
            inputFields["DeliveryAddress1"]   = shippingStreetAddress.Truncate(100);
            inputFields["DeliveryCity"]       = shippingCity.Truncate(40);
            inputFields["DeliveryPostCode"]   = shippingZipCode.Truncate(10);

            country = CountryService.Instance.Get(order.StoreId, order.ShipmentInformation.CountryId ?? order.PaymentInformation.CountryId);
            inputFields["DeliveryCountry"] = country.RegionCode;

            long?shippingCountryRegionId = order.ShipmentInformation.CountryId != null ? order.ShipmentInformation.CountryRegionId : order.PaymentInformation.CountryRegionId;
            if (country.RegionCode.ToUpperInvariant() == "US" && shippingCountryRegionId != null)
            {
                CountryRegion countryRegion = CountryRegionService.Instance.Get(order.StoreId, shippingCountryRegionId.Value);
                inputFields["DeliveryState"] = countryRegion.RegionCode.Truncate(2);
            }
            if (settings.ContainsKey("shipping_phonePropertyAlias"))
            {
                inputFields["DeliveryPhone"] = order.Properties[settings["shipping_phonePropertyAlias"]].Truncate(20);
            }

            if (!settings.ContainsKey("Apply3DSecure"))
            {
                inputFields["Apply3DSecure"] = "2";
            }

            IDictionary <string, string> responseFields = GetFields(MakePostRequest(GetMethodUrl("PURCHASE", settings), inputFields));
            string status = responseFields["Status"];

            if (status == "OK" || status == "OK REPEATED")
            {
                order.Properties.AddOrUpdate(new CustomProperty("securityKey", responseFields["SecurityKey"])
                {
                    ServerSideOnly = true
                });
                order.Properties.AddOrUpdate(new CustomProperty("teaCommerceContinueUrl", teaCommerceContinueUrl)
                {
                    ServerSideOnly = true
                });
                order.Properties.AddOrUpdate(new CustomProperty("teaCommerceCancelUrl", teaCommerceCancelUrl)
                {
                    ServerSideOnly = true
                });
                order.Save();
                htmlForm.Action = responseFields["NextURL"];
            }
            else
            {
                htmlForm.Action = teaCommerceCancelUrl;
                LoggingService.Instance.Warn <SagePay>("Sage Pay(" + order.CartNumber + ") - Generate html form error - status: " + status + " | status details: " + responseFields["StatusDetail"]);
            }

            return(htmlForm);
        }
Example #17
0
        public override PaymentHtmlForm GenerateHtmlForm(Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary <string, string> settings)
        {
            order.MustNotBeNull("order");
            settings.MustNotBeNull("settings");
            settings.MustContainKey("MerchantID", "settings");
            settings.MustContainKey("TransactionType", "settings");

            PaymentHtmlForm htmlForm = new PaymentHtmlForm {
                Action = "https://mms.paymentsensegateway.com/Pages/PublicPages/PaymentForm.aspx"
            };

            string[] settingsToExclude = new[] { "CancelURL", "streetAddressPropertyAlias", "cityPropertyAlias", "zipCodePropertyAlias", "PreSharedKey", "Password", "Testing" };
            htmlForm.InputFields = settings.Where(i => !settingsToExclude.Contains(i.Key)).ToDictionary(i => i.Key, i => i.Value);

            if (order.CartNumber.Length > 50)
            {
                throw new Exception("Cart number of the order can not exceed 50 characters.");
            }
            htmlForm.InputFields["OrderID"] = order.CartNumber;

            Currency currency = CurrencyService.Instance.Get(order.StoreId, order.CurrencyId);

            if (!Iso4217CurrencyCodes.ContainsKey(currency.IsoCode))
            {
                throw new Exception("You must specify an ISO 4217 currency code for the " + currency.Name + " currency");
            }
            htmlForm.InputFields["CurrencyCode"] = Iso4217CurrencyCodes[currency.IsoCode];
            htmlForm.InputFields["Amount"]       = (order.TotalPrice.Value.WithVat * 100M).ToString("0", CultureInfo.InvariantCulture);

            htmlForm.InputFields["CustomerName"] = order.PaymentInformation.FirstName + " " + order.PaymentInformation.LastName;

            if (settings.ContainsKey("streetAddressPropertyAlias"))
            {
                htmlForm.InputFields["Address1"] = order.Properties[settings["streetAddressPropertyAlias"]];
            }

            if (settings.ContainsKey("cityPropertyAlias"))
            {
                htmlForm.InputFields["City"] = order.Properties[settings["cityPropertyAlias"]];
            }

            if (order.PaymentInformation.CountryRegionId != null)
            {
                htmlForm.InputFields["State"] = CountryRegionService.Instance.Get(order.StoreId, order.PaymentInformation.CountryRegionId.Value).Name;
            }

            if (settings.ContainsKey("zipCodePropertyAlias"))
            {
                htmlForm.InputFields["PostCode"] = order.Properties[settings["zipCodePropertyAlias"]];
            }

            Country country = CountryService.Instance.Get(order.StoreId, order.PaymentInformation.CountryId);

            if (!Iso3166CountryCodes.ContainsKey(country.RegionCode))
            {
                throw new Exception("You must specify an ISO 3166 country code for the " + country.Name + " country");
            }
            htmlForm.InputFields["CountryCode"] = Iso3166CountryCodes[country.RegionCode];

            htmlForm.InputFields["EmailAddress"] = order.PaymentInformation.Email;

            htmlForm.InputFields["CallbackURL"]     = teaCommerceCallBackUrl;
            htmlForm.InputFields["ServerResultURL"] = teaCommerceCallBackUrl;

            htmlForm.InputFields["ResultDeliveryMethod"]      = "SERVER";
            htmlForm.InputFields["PaymentFormDisplaysResult"] = bool.FalseString;
            htmlForm.InputFields["TransactionDateTime"]       = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss zzz");

            List <string> keysToHash = new List <string>();

            keysToHash.Add("PreSharedKey");
            keysToHash.Add("MerchantID");
            keysToHash.Add("Password");
            keysToHash.Add("Amount");
            keysToHash.Add("CurrencyCode");
            if (htmlForm.InputFields.ContainsKey("EchoAVSCheckResult"))
            {
                keysToHash.Add("EchoAVSCheckResult");
            }
            if (htmlForm.InputFields.ContainsKey("EchoCV2CheckResult"))
            {
                keysToHash.Add("EchoCV2CheckResult");
            }
            if (htmlForm.InputFields.ContainsKey("EchoThreeDSecureAuthenticationCheckResult"))
            {
                keysToHash.Add("EchoThreeDSecureAuthenticationCheckResult");
            }
            if (htmlForm.InputFields.ContainsKey("EchoCardType"))
            {
                keysToHash.Add("EchoCardType");
            }
            if (htmlForm.InputFields.ContainsKey("AVSOverridePolicy"))
            {
                keysToHash.Add("AVSOverridePolicy");
            }
            if (htmlForm.InputFields.ContainsKey("CV2OverridePolicy"))
            {
                keysToHash.Add("CV2OverridePolicy");
            }
            if (htmlForm.InputFields.ContainsKey("ThreeDSecureOverridePolicy"))
            {
                keysToHash.Add("ThreeDSecureOverridePolicy");
            }
            keysToHash.Add("OrderID");
            keysToHash.Add("TransactionType");
            keysToHash.Add("TransactionDateTime");
            keysToHash.Add("CallbackURL");
            keysToHash.Add("OrderDescription");
            keysToHash.Add("CustomerName");
            keysToHash.Add("Address1");
            keysToHash.Add("Address2");
            keysToHash.Add("Address3");
            keysToHash.Add("Address4");
            keysToHash.Add("City");
            keysToHash.Add("State");
            keysToHash.Add("PostCode");
            keysToHash.Add("CountryCode");
            if (htmlForm.InputFields.ContainsKey("EmailAddress"))
            {
                keysToHash.Add("EmailAddress");
            }
            if (htmlForm.InputFields.ContainsKey("PhoneNumber"))
            {
                keysToHash.Add("PhoneNumber");
            }
            if (htmlForm.InputFields.ContainsKey("EmailAddressEditable"))
            {
                keysToHash.Add("EmailAddressEditable");
            }
            if (htmlForm.InputFields.ContainsKey("PhoneNumberEditable"))
            {
                keysToHash.Add("PhoneNumberEditable");
            }
            if (htmlForm.InputFields.ContainsKey("CV2Mandatory"))
            {
                keysToHash.Add("CV2Mandatory");
            }
            if (htmlForm.InputFields.ContainsKey("Address1Mandatory"))
            {
                keysToHash.Add("Address1Mandatory");
            }
            if (htmlForm.InputFields.ContainsKey("CityMandatory"))
            {
                keysToHash.Add("CityMandatory");
            }
            if (htmlForm.InputFields.ContainsKey("PostCodeMandatory"))
            {
                keysToHash.Add("PostCodeMandatory");
            }
            if (htmlForm.InputFields.ContainsKey("StateMandatory"))
            {
                keysToHash.Add("StateMandatory");
            }
            if (htmlForm.InputFields.ContainsKey("CountryMandatory"))
            {
                keysToHash.Add("CountryMandatory");
            }
            keysToHash.Add("ResultDeliveryMethod");
            if (htmlForm.InputFields.ContainsKey("ServerResultURL"))
            {
                keysToHash.Add("ServerResultURL");
            }
            if (htmlForm.InputFields.ContainsKey("PaymentFormDisplaysResult"))
            {
                keysToHash.Add("PaymentFormDisplaysResult");
            }
            if (htmlForm.InputFields.ContainsKey("ServerResultURLCookieVariables"))
            {
                keysToHash.Add("ServerResultURLCookieVariables");
            }
            if (htmlForm.InputFields.ContainsKey("ServerResultURLFormVariables"))
            {
                keysToHash.Add("ServerResultURLFormVariables");
            }
            if (htmlForm.InputFields.ContainsKey("ServerResultURLQueryStringVariables"))
            {
                keysToHash.Add("ServerResultURLQueryStringVariables");
            }

            htmlForm.InputFields["HashDigest"] = CreateHashDigest(keysToHash, settings, htmlForm.InputFields);

            return(htmlForm);
        }
Example #18
0
        public override PaymentHtmlForm GenerateHtmlForm(Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary <string, string> settings)
        {
            order.MustNotBeNull("order");
            settings.MustNotBeNull("settings");
            settings.MustContainKey("shopid", "settings");

            PaymentHtmlForm htmlForm = new PaymentHtmlForm {
                Action     = "https://betaling.wannafind.dk/paymentwindow.php",
                Attributes = { { "id", "wannafind" }, { "name", "wannafind" }, { "target", "_self" } }
            };

            string[] settingsToExclude = new[] { "md5AuthSecret", "md5CallbackSecret", "apiUser", "apiPassword", "testmode" };
            htmlForm.InputFields = settings.Where(i => !settingsToExclude.Contains(i.Key)).ToDictionary(i => i.Key, i => i.Value);

            //orderid
            string orderId = order.CartNumber.Replace(StoreService.Instance.Get(order.StoreId).OrderSettings.CartNumberPrefix, "");

            htmlForm.InputFields["orderid"] = orderId;

            //currency
            //Check that the Iso code exists
            Currency currency = CurrencyService.Instance.Get(order.StoreId, order.CurrencyId);

            if (!Iso4217CurrencyCodes.ContainsKey(currency.IsoCode))
            {
                throw new Exception("You must specify an ISO 4217 currency code for the " + currency.Name + " currency");
            }
            string currencyStr = Iso4217CurrencyCodes[currency.IsoCode];

            htmlForm.InputFields["currency"] = currencyStr;

            //amount
            string amount = (order.TotalPrice.Value.WithVat * 100M).ToString("0", CultureInfo.InvariantCulture);

            htmlForm.InputFields["amount"] = amount;

            htmlForm.InputFields["accepturl"]   = teaCommerceContinueUrl;
            htmlForm.InputFields["declineurl"]  = teaCommerceCancelUrl;
            htmlForm.InputFields["callbackurl"] = teaCommerceCallBackUrl;

            //authtype
            htmlForm.InputFields["authtype"] = "auth";

            //paytype - legacy
            if (!settings.ContainsKey("paytype"))
            {
                htmlForm.InputFields["paytype"] = "creditcard";
            }

            //cardtype
            string cardType = string.Empty;

            if (htmlForm.InputFields.ContainsKey("cardtype"))
            {
                cardType = htmlForm.InputFields["cardtype"];
                if (string.IsNullOrEmpty(cardType))
                {
                    htmlForm.InputFields.Remove("cardtype");
                }
            }

            //uniqueorderid
            htmlForm.InputFields["uniqueorderid"] = "true";

            //cardnomask
            htmlForm.InputFields["cardnomask"] = "true";

            //md5securitykey
            if (settings.ContainsKey("md5AuthSecret") && !string.IsNullOrEmpty(settings["md5AuthSecret"]))
            {
                htmlForm.InputFields["checkmd5"] = GenerateMD5Hash(currencyStr + orderId + amount + cardType + settings["md5AuthSecret"]);
            }

            //wannafind dont support to show order line information to the shopper

            return(htmlForm);
        }
Example #19
0
        public override PaymentHtmlForm GenerateHtmlForm( Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary<string, string> settings )
        {
            order.MustNotBeNull( "order" );
              settings.MustNotBeNull( "settings" );
              settings.MustContainKey( "MerchantID", "settings" );
              settings.MustContainKey( "TransactionType", "settings" );

              PaymentHtmlForm htmlForm = new PaymentHtmlForm {
            Action = "https://mms.paymentsensegateway.com/Pages/PublicPages/PaymentForm.aspx"
              };

              string[] settingsToExclude = new[] { "CancelURL", "streetAddressPropertyAlias", "cityPropertyAlias", "zipCodePropertyAlias", "PreSharedKey", "Password", "Testing" };
              htmlForm.InputFields = settings.Where( i => !settingsToExclude.Contains( i.Key ) ).ToDictionary( i => i.Key, i => i.Value );

              if ( order.CartNumber.Length > 50 ) {
            throw new Exception( "Cart number of the order can not exceed 50 characters." );
              }
              htmlForm.InputFields[ "OrderID" ] = order.CartNumber;

              Currency currency = CurrencyService.Instance.Get( order.StoreId, order.CurrencyId );
              if ( !Iso4217CurrencyCodes.ContainsKey( currency.IsoCode ) ) {
            throw new Exception( "You must specify an ISO 4217 currency code for the " + currency.Name + " currency" );
              }
              htmlForm.InputFields[ "CurrencyCode" ] = Iso4217CurrencyCodes[ currency.IsoCode ];
              htmlForm.InputFields[ "Amount" ] = ( order.TotalPrice.Value.WithVat * 100M ).ToString( "0", CultureInfo.InvariantCulture );

              htmlForm.InputFields[ "CustomerName" ] = order.PaymentInformation.FirstName + " " + order.PaymentInformation.LastName;

              if ( settings.ContainsKey( "streetAddressPropertyAlias" ) ) {
            htmlForm.InputFields[ "Address1" ] = order.Properties[ settings[ "streetAddressPropertyAlias" ] ];
              }

              if ( settings.ContainsKey( "cityPropertyAlias" ) ) {
            htmlForm.InputFields[ "City" ] = order.Properties[ settings[ "cityPropertyAlias" ] ];
              }

              if ( order.PaymentInformation.CountryRegionId != null ) {
            htmlForm.InputFields[ "State" ] = CountryRegionService.Instance.Get( order.StoreId, order.PaymentInformation.CountryRegionId.Value ).Name;
              }

              if ( settings.ContainsKey( "zipCodePropertyAlias" ) ) {
            htmlForm.InputFields[ "PostCode" ] = order.Properties[ settings[ "zipCodePropertyAlias" ] ];
              }

              Country country = CountryService.Instance.Get( order.StoreId, order.PaymentInformation.CountryId );
              if ( !Iso3166CountryCodes.ContainsKey( country.RegionCode ) ) {
            throw new Exception( "You must specify an ISO 3166 country code for the " + country.Name + " country" );
              }
              htmlForm.InputFields[ "CountryCode" ] = Iso3166CountryCodes[ country.RegionCode ];

              htmlForm.InputFields[ "EmailAddress" ] = order.PaymentInformation.Email;

              htmlForm.InputFields[ "CallbackURL" ] = teaCommerceCallBackUrl;
              htmlForm.InputFields[ "ServerResultURL" ] = teaCommerceCallBackUrl;

              htmlForm.InputFields[ "ResultDeliveryMethod" ] = "SERVER";
              htmlForm.InputFields[ "PaymentFormDisplaysResult" ] = bool.FalseString;
              htmlForm.InputFields[ "TransactionDateTime" ] = DateTime.Now.ToString( "yyyy-MM-dd HH:mm:ss zzz" );

              List<string> keysToHash = new List<string>();
              keysToHash.Add( "PreSharedKey" );
              keysToHash.Add( "MerchantID" );
              keysToHash.Add( "Password" );
              keysToHash.Add( "Amount" );
              keysToHash.Add( "CurrencyCode" );
              if ( htmlForm.InputFields.ContainsKey( "EchoAVSCheckResult" ) ) keysToHash.Add( "EchoAVSCheckResult" );
              if ( htmlForm.InputFields.ContainsKey( "EchoCV2CheckResult" ) ) keysToHash.Add( "EchoCV2CheckResult" );
              if ( htmlForm.InputFields.ContainsKey( "EchoThreeDSecureAuthenticationCheckResult" ) ) keysToHash.Add( "EchoThreeDSecureAuthenticationCheckResult" );
              if ( htmlForm.InputFields.ContainsKey( "EchoCardType" ) ) keysToHash.Add( "EchoCardType" );
              if ( htmlForm.InputFields.ContainsKey( "AVSOverridePolicy" ) ) keysToHash.Add( "AVSOverridePolicy" );
              if ( htmlForm.InputFields.ContainsKey( "CV2OverridePolicy" ) ) keysToHash.Add( "CV2OverridePolicy" );
              if ( htmlForm.InputFields.ContainsKey( "ThreeDSecureOverridePolicy" ) ) keysToHash.Add( "ThreeDSecureOverridePolicy" );
              keysToHash.Add( "OrderID" );
              keysToHash.Add( "TransactionType" );
              keysToHash.Add( "TransactionDateTime" );
              keysToHash.Add( "CallbackURL" );
              keysToHash.Add( "OrderDescription" );
              keysToHash.Add( "CustomerName" );
              keysToHash.Add( "Address1" );
              keysToHash.Add( "Address2" );
              keysToHash.Add( "Address3" );
              keysToHash.Add( "Address4" );
              keysToHash.Add( "City" );
              keysToHash.Add( "State" );
              keysToHash.Add( "PostCode" );
              keysToHash.Add( "CountryCode" );
              if ( htmlForm.InputFields.ContainsKey( "EmailAddress" ) ) keysToHash.Add( "EmailAddress" );
              if ( htmlForm.InputFields.ContainsKey( "PhoneNumber" ) ) keysToHash.Add( "PhoneNumber" );
              if ( htmlForm.InputFields.ContainsKey( "EmailAddressEditable" ) ) keysToHash.Add( "EmailAddressEditable" );
              if ( htmlForm.InputFields.ContainsKey( "PhoneNumberEditable" ) ) keysToHash.Add( "PhoneNumberEditable" );
              if ( htmlForm.InputFields.ContainsKey( "CV2Mandatory" ) ) keysToHash.Add( "CV2Mandatory" );
              if ( htmlForm.InputFields.ContainsKey( "Address1Mandatory" ) ) keysToHash.Add( "Address1Mandatory" );
              if ( htmlForm.InputFields.ContainsKey( "CityMandatory" ) ) keysToHash.Add( "CityMandatory" );
              if ( htmlForm.InputFields.ContainsKey( "PostCodeMandatory" ) ) keysToHash.Add( "PostCodeMandatory" );
              if ( htmlForm.InputFields.ContainsKey( "StateMandatory" ) ) keysToHash.Add( "StateMandatory" );
              if ( htmlForm.InputFields.ContainsKey( "CountryMandatory" ) ) keysToHash.Add( "CountryMandatory" );
              keysToHash.Add( "ResultDeliveryMethod" );
              if ( htmlForm.InputFields.ContainsKey( "ServerResultURL" ) ) keysToHash.Add( "ServerResultURL" );
              if ( htmlForm.InputFields.ContainsKey( "PaymentFormDisplaysResult" ) ) keysToHash.Add( "PaymentFormDisplaysResult" );
              if ( htmlForm.InputFields.ContainsKey( "ServerResultURLCookieVariables" ) ) keysToHash.Add( "ServerResultURLCookieVariables" );
              if ( htmlForm.InputFields.ContainsKey( "ServerResultURLFormVariables" ) ) keysToHash.Add( "ServerResultURLFormVariables" );
              if ( htmlForm.InputFields.ContainsKey( "ServerResultURLQueryStringVariables" ) ) keysToHash.Add( "ServerResultURLQueryStringVariables" );

              htmlForm.InputFields[ "HashDigest" ] = CreateHashDigest( keysToHash, settings, htmlForm.InputFields );

              return htmlForm;
        }
Example #20
0
        public override PaymentHtmlForm GenerateHtmlForm(Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary <string, string> settings)
        {
            order.MustNotBeNull("order");
            settings.MustNotBeNull("settings");
            settings.MustContainKey("accountNumber", "settings");
            settings.MustContainKey("purchaseOperation", "settings");
            settings.MustContainKey("encryptionKey", "settings");

            PaymentHtmlForm htmlForm = new PaymentHtmlForm();

            long   accountNumber     = long.Parse(settings["accountNumber"]);
            string purchaseOperation = settings["purchaseOperation"];
            int    price             = (int)Math.Round(order.TotalPrice.Value.WithVat * 100M, 0);
            string priceArgList      = string.Empty;

            //Check that the Iso code exists
            Currency currency = CurrencyService.Instance.Get(order.StoreId, order.CurrencyId);

            if (!Iso4217CurrencyCodes.ContainsKey(currency.IsoCode))
            {
                throw new Exception("You must specify an ISO 4217 currency code for the " + currency.Name + " currency");
            }

            int          vat              = (int)Math.Round(order.VatRate * 100M * 100M, 0);
            string       orderId          = order.CartNumber;
            string       productNumber    = string.Join(",", order.OrderLines.Select(ol => ol.Sku));
            string       description      = string.Join(",", order.OrderLines.Select(ol => ol.Name));
            string       clientIpAddress  = HttpContext.Current.Request.UserHostAddress;
            string       clientIdentifier = string.Empty;
            string       additionalValues = string.Empty;
            string       externalId       = string.Empty;
            string       returnUrl        = teaCommerceContinueUrl;
            const string view             = "CREDITCARD";
            string       agreementRef     = string.Empty;
            string       cancelUrl        = teaCommerceCancelUrl;
            string       clientLanguage   = string.Empty;

            string md5Hash = GenerateMD5Hash(accountNumber.ToString(CultureInfo.InvariantCulture) + purchaseOperation + price.ToString(CultureInfo.InvariantCulture) + priceArgList + currency.IsoCode + vat.ToString(CultureInfo.InvariantCulture) + orderId + productNumber + description + clientIpAddress + clientIdentifier + additionalValues + externalId + returnUrl + view + agreementRef + cancelUrl + clientLanguage + settings["encryptionKey"]);

            ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
            string xmlReturn = GetPayExServiceClient(settings).Initialize7(accountNumber, purchaseOperation, price, priceArgList, currency.IsoCode, vat, orderId, productNumber, description, clientIpAddress, clientIdentifier, additionalValues, externalId, returnUrl, view, agreementRef, cancelUrl, clientLanguage, md5Hash);

            XDocument xmlDoc    = XDocument.Parse(xmlReturn, LoadOptions.PreserveWhitespace);
            string    errorCode = xmlDoc.XPathSelectElement("//status/errorCode").Value;

            if (errorCode.Equals("OK"))
            {
                order.Properties.AddOrUpdate(new CustomProperty("orderRef", xmlDoc.XPathSelectElement("//orderRef").Value)
                {
                    ServerSideOnly = true
                });
                order.Save();
                htmlForm.Action = xmlDoc.XPathSelectElement("//redirectUrl").Value;
            }
            else
            {
                htmlForm.Action = teaCommerceCancelUrl;
                LoggingService.Instance.Warn <PayEx>("PayEx(" + order.CartNumber + ") - Generate html form error - error code: " + xmlDoc.XPathSelectElement("//status/description").Value);
            }

            return(htmlForm);
        }
Example #21
0
        public override PaymentHtmlForm GenerateHtmlForm( Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary<string, string> settings )
        {
            order.MustNotBeNull( "order" );
              settings.MustNotBeNull( "settings" );
              settings.MustContainKey( "SECURITY.SENDER", "settings" );
              settings.MustContainKey( "USER.LOGIN", "settings" );
              settings.MustContainKey( "USER.PWD", "settings" );
              settings.MustContainKey( "TRANSACTION.CHANNEL", "settings" );
              settings.MustContainKey( "PAYMENT.CODE", "settings" );
              settings.MustContainKey( "streetAddressPropertyAlias", "settings" );
              settings.MustContainKey( "cityPropertyAlias", "settings" );
              settings.MustContainKey( "zipCodePropertyAlias", "settings" );
              settings.MustContainKey( "TRANSACTION.MODE", "settings" );
              settings.MustContainKey( "SYSTEM", "settings" );
              order.Properties[ settings[ "streetAddressPropertyAlias" ] ].MustNotBeNullOrEmpty( "street address" );
              order.Properties[ settings[ "cityPropertyAlias" ] ].MustNotBeNullOrEmpty( "city" );
              order.Properties[ settings[ "zipCodePropertyAlias" ] ].MustNotBeNullOrEmpty( "zip code" );

              PaymentHtmlForm htmlForm = new PaymentHtmlForm();

              string[] settingsToExclude = new[] { "FRONTEND.RESPONSE_URL", "FRONTEND.CANCEL_URL", "streetAddressPropertyAlias", "cityPropertyAlias", "zipCodePropertyAlias", "SYSTEM" };
              Dictionary<string, string> inputFields = settings.Where( i => !settingsToExclude.Contains( i.Key ) ).ToDictionary( i => i.Key, i => i.Value );

              inputFields[ "REQUEST.VERSION" ] = "1.0";
              inputFields[ "FRONTEND.ENABLED" ] = "true";
              inputFields[ "FRONTEND.POPUP" ] = "false";

              inputFields[ "IDENTIFICATION.TRANSACTIONID" ] = order.CartNumber;

              Currency currency = CurrencyService.Instance.Get( order.StoreId, order.CurrencyId );
              if ( !Iso4217CurrencyCodes.ContainsKey( currency.IsoCode ) ) {
            throw new Exception( "You must specify an ISO 4217 currency code for the " + currency.Name + " currency" );
              }
              inputFields[ "PRESENTATION.CURRENCY" ] = currency.IsoCode;
              inputFields[ "PRESENTATION.AMOUNT" ] = ( order.TotalPrice.Value.WithVat ).ToString( "0.00", CultureInfo.InvariantCulture );

              inputFields[ "FRONTEND.RESPONSE_URL" ] = teaCommerceCallBackUrl;

              inputFields[ "NAME.GIVEN" ] = order.PaymentInformation.FirstName;
              inputFields[ "NAME.FAMILY" ] = order.PaymentInformation.LastName;

              inputFields[ "CONTACT.EMAIL" ] = order.PaymentInformation.Email;
              inputFields[ "CONTACT.IP" ] = HttpContext.Current.Request.UserHostAddress;

              inputFields[ "ADDRESS.STREET" ] = order.Properties[ settings[ "streetAddressPropertyAlias" ] ];
              inputFields[ "ADDRESS.CITY" ] = order.Properties[ settings[ "cityPropertyAlias" ] ];
              inputFields[ "ADDRESS.ZIP" ] = order.Properties[ settings[ "zipCodePropertyAlias" ] ];

              inputFields[ "ADDRESS.COUNTRY" ] = CountryService.Instance.Get( order.StoreId, order.PaymentInformation.CountryId ).RegionCode;
              if ( order.PaymentInformation.CountryRegionId != null ) {
            inputFields[ "ADDRESS.STATE" ] = CountryRegionService.Instance.Get( order.StoreId, order.PaymentInformation.CountryRegionId.Value ).RegionCode;
              }

              IDictionary<string, string> responseKvps = MakePostRequest( settings, inputFields );
              if ( responseKvps[ "POST.VALIDATION" ].Equals( "ACK" ) ) {
            htmlForm.Action = HttpContext.Current.Server.UrlDecode( responseKvps[ "FRONTEND.REDIRECT_URL" ] );
              } else {
            throw new Exception( "Generate html failed - error code: " + responseKvps[ "POST.VALIDATION" ] );
              }

              return htmlForm;
        }
Example #22
0
        public override PaymentHtmlForm GenerateHtmlForm(Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary <string, string> settings)
        {
            order.MustNotBeNull("order");
            settings.MustNotBeNull("settings");
            settings.MustContainKey("capture", "settings");
            settings.MustContainKey("mode", "settings");
            settings.MustContainKey(settings["mode"] + "_api_login_id", "settings");
            settings.MustContainKey(settings["mode"] + "_transaction_key", "settings");

            // Configure AuthorizeNet
            ConfigureAuthorizeNet(settings);

            // Create the transition request
            var transactionRequest = new transactionRequestType
            {
                transactionType = settings["capture"] == "true"
                    ? transactionTypeEnum.authCaptureTransaction.ToString()
                    : transactionTypeEnum.authOnlyTransaction.ToString(),
                amount   = ToTwoDecimalPlaces(order.TotalPrice.Value.WithVat),
                customer = new customerDataType
                {
                    id    = order.CustomerId,
                    email = order.PaymentInformation.Email
                },
                billTo = new customerAddressType
                {
                    firstName = order.PaymentInformation.FirstName,
                    lastName  = order.PaymentInformation.LastName,
                    email     = order.PaymentInformation.Email
                },
                order = new orderType
                {
                    invoiceNumber = order.CartNumber
                }
            };

            // Configure payment page settings
            var paymentSettings = new List <settingType>();

            var returnOptions = GetOptionsFromSettings(settings, "return_options_");

            if (!returnOptions.ContainsKey("url"))
            {
                returnOptions.Add("url", teaCommerceContinueUrl);
            }
            if (!returnOptions.ContainsKey("cancelUrl"))
            {
                returnOptions.Add("cancelUrl", teaCommerceCancelUrl);
            }
            if (!returnOptions.ContainsKey("showReceipt"))
            {
                returnOptions.Add("showReceipt", false);
            }
            AddOptionsToPaymentSettings(paymentSettings, settingNameEnum.hostedPaymentReturnOptions, returnOptions);

            var buttonOptions = GetOptionsFromSettings(settings, "button_options_");

            AddOptionsToPaymentSettings(paymentSettings, settingNameEnum.hostedPaymentButtonOptions, buttonOptions);

            var orderOptions = GetOptionsFromSettings(settings, "order_options_");

            if (orderOptions.ContainsKey("merchantName") && !orderOptions.ContainsKey("show"))
            {
                orderOptions.Add("show", true);
            }
            AddOptionsToPaymentSettings(paymentSettings, settingNameEnum.hostedPaymentOrderOptions, orderOptions);

            var styleOptions = GetOptionsFromSettings(settings, "style_options_");

            AddOptionsToPaymentSettings(paymentSettings, settingNameEnum.hostedPaymentStyleOptions, styleOptions);

            var paymentOptions = GetOptionsFromSettings(settings, "payment_options_");

            AddOptionsToPaymentSettings(paymentSettings, settingNameEnum.hostedPaymentPaymentOptions, paymentOptions);

            var securityOptions = GetOptionsFromSettings(settings, "security_options_");

            AddOptionsToPaymentSettings(paymentSettings, settingNameEnum.hostedPaymentSecurityOptions, securityOptions);

            var shippingAddressOptions = GetOptionsFromSettings(settings, "shipping_address_options_");

            AddOptionsToPaymentSettings(paymentSettings, settingNameEnum.hostedPaymentShippingAddressOptions, shippingAddressOptions);

            var billingAddressOptions = GetOptionsFromSettings(settings, "billing_address_options_");

            if (!billingAddressOptions.ContainsKey("show"))
            {
                billingAddressOptions.Add("show", false);
            }
            AddOptionsToPaymentSettings(paymentSettings, settingNameEnum.hostedPaymentBillingAddressOptions, billingAddressOptions);

            var customerOptions = GetOptionsFromSettings(settings, "customer_options_");

            AddOptionsToPaymentSettings(paymentSettings, settingNameEnum.hostedPaymentCustomerOptions, customerOptions);

            // Configure payment page request
            var hostedPaymentPageRequest = new getHostedPaymentPageRequest
            {
                transactionRequest    = transactionRequest,
                hostedPaymentSettings = paymentSettings.ToArray()
            };

            // Instantiate the controller that will call the service
            var hostedPaymentPageController = new getHostedPaymentPageController(hostedPaymentPageRequest);

            hostedPaymentPageController.Execute();

            // Get the response from the service (errors contained if any)
            var hostedPaymentPageResponse = hostedPaymentPageController.GetApiResponse();

            if (hostedPaymentPageResponse == null && hostedPaymentPageResponse.messages.resultCode != messageTypeEnum.Ok)
            {
                throw new ApplicationException("Unable to retrieve Authorize.NET token");
            }

            PaymentHtmlForm htmlForm = new PaymentHtmlForm
            {
                Action = settings["mode"] == "sandbox"
                    ? "https://test.authorize.net/payment/payment"
                    : "https://accept.authorize.net/payment/payment"
            };

            htmlForm.InputFields["token"] = hostedPaymentPageResponse.token;

            return(htmlForm);
        }
Example #23
0
        public override PaymentHtmlForm GenerateHtmlForm(Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary <string, string> settings)
        {
            order.MustNotBeNull("order");
            settings.MustNotBeNull("settings");
            settings.MustContainKey("customerLanguageCode", "settings");
            settings.MustContainKey("testMode", "settings");

            PaymentHtmlForm htmlForm = new PaymentHtmlForm();

            IPaynovaClient client = GetClient(settings);

            Currency currency = CurrencyService.Instance.Get(order.StoreId, order.CurrencyId);

            if (!Iso4217CurrencyCodes.ContainsKey(currency.IsoCode))
            {
                throw new Exception("You must specify an ISO 4217 currency code for the " + currency.Name + " currency");
            }
            try
            {
                //Create order request
                CreateOrderRequest createOrderRequest = new CreateOrderRequest(order.CartNumber, currency.IsoCode, order.TotalPrice.Value.WithVat)
                {
                    Customer = new Customer(),
                    BillTo   = new NameAndAddress(),
                    ShipTo   = new NameAndAddress()
                };

                #region Customer information

                createOrderRequest.Customer.EmailAddress     = order.PaymentInformation.Email;
                createOrderRequest.Customer.Name.CompanyName = createOrderRequest.BillTo.Name.CompanyName = order.Properties[settings.ContainsKey("companyPropertyAlias") && !string.IsNullOrEmpty(settings["companyPropertyAlias"]) ? settings["companyPropertyAlias"] : "company"];
                createOrderRequest.Customer.Name.Title       = createOrderRequest.BillTo.Name.Title = order.Properties[settings.ContainsKey("titlePropertyAlias") && !string.IsNullOrEmpty(settings["titlePropertyAlias"]) ? settings["titlePropertyAlias"] : "title"];
                createOrderRequest.Customer.Name.FirstName   = createOrderRequest.BillTo.Name.FirstName = order.PaymentInformation.FirstName;
                createOrderRequest.Customer.Name.MiddleNames = createOrderRequest.BillTo.Name.MiddleNames = order.Properties[settings.ContainsKey("middleNamesPropertyAlias") && !string.IsNullOrEmpty(settings["middleNamesPropertyAlias"]) ? settings["middleNamesPropertyAlias"] : "middleNames"];
                createOrderRequest.Customer.Name.LastName    = createOrderRequest.BillTo.Name.LastName = order.PaymentInformation.LastName;
                createOrderRequest.Customer.Name.Suffix      = createOrderRequest.BillTo.Name.Suffix = order.Properties[settings.ContainsKey("suffixPropertyAlias") && !string.IsNullOrEmpty(settings["suffixPropertyAlias"]) ? settings["suffixPropertyAlias"] : "suffix"];
                createOrderRequest.Customer.HomeTelephone    = order.Properties[settings.ContainsKey("homeTelephonePropertyAlias") && !string.IsNullOrEmpty(settings["homeTelephonePropertyAlias"]) ? settings["homeTelephonePropertyAlias"] : "phone"];
                createOrderRequest.Customer.WorkTelephone    = order.Properties[settings.ContainsKey("workTelephonePropertyAlias") && !string.IsNullOrEmpty(settings["workTelephonePropertyAlias"]) ? settings["workTelephonePropertyAlias"] : "workPhone"];
                createOrderRequest.Customer.MobileTelephone  = order.Properties[settings.ContainsKey("mobileTelephonePropertyAlias") && !string.IsNullOrEmpty(settings["mobileTelephonePropertyAlias"]) ? settings["mobileTelephonePropertyAlias"] : "mobile"];
                createOrderRequest.BillTo.Address.Street1    = order.Properties[settings.ContainsKey("street1PropertyAlias") && !string.IsNullOrEmpty(settings["street1PropertyAlias"]) ? settings["street1PropertyAlias"] : "streetAddress"];
                createOrderRequest.BillTo.Address.Street2    = order.Properties[settings.ContainsKey("street2PropertyAlias") && !string.IsNullOrEmpty(settings["street2PropertyAlias"]) ? settings["street2PropertyAlias"] : "streetAddress2"];
                createOrderRequest.BillTo.Address.Street3    = order.Properties[settings.ContainsKey("street3PropertyAlias") && !string.IsNullOrEmpty(settings["street3PropertyAlias"]) ? settings["street3PropertyAlias"] : "streetAddress3"];
                createOrderRequest.BillTo.Address.Street4    = order.Properties[settings.ContainsKey("street4PropertyAlias") && !string.IsNullOrEmpty(settings["street4PropertyAlias"]) ? settings["street4PropertyAlias"] : "streetAddress4"];
                createOrderRequest.BillTo.Address.City       = order.Properties[settings.ContainsKey("cityPropertyAlias") && !string.IsNullOrEmpty(settings["cityPropertyAlias"]) ? settings["cityPropertyAlias"] : "city"];
                createOrderRequest.BillTo.Address.PostalCode = order.Properties[settings.ContainsKey("postalCodePropertyAlias") && !string.IsNullOrEmpty(settings["postalCodePropertyAlias"]) ? settings["postalCodePropertyAlias"] : "zipCode"];
                if (order.PaymentInformation.CountryRegionId != null)
                {
                    createOrderRequest.BillTo.Address.RegionCode = CountryRegionService.Instance.Get(order.StoreId, order.PaymentInformation.CountryRegionId.Value).RegionCode;
                }
                createOrderRequest.BillTo.Address.CountryCode = CountryService.Instance.Get(order.StoreId, order.PaymentInformation.CountryId).RegionCode;

                createOrderRequest.ShipTo.Name.CompanyName   = order.Properties[settings.ContainsKey("shipping_companyPropertyAlias") && !string.IsNullOrEmpty(settings["shipping_companyPropertyAlias"]) ? settings["shipping_companyPropertyAlias"] : "shipping_company"];
                createOrderRequest.ShipTo.Name.Title         = order.Properties[settings.ContainsKey("shipping_titlePropertyAlias") && !string.IsNullOrEmpty(settings["shipping_titlePropertyAlias"]) ? settings["shipping_titlePropertyAlias"] : "shipping_title"];
                createOrderRequest.ShipTo.Name.FirstName     = order.Properties[settings.ContainsKey("shipping_firstNamePropertyAlias") && !string.IsNullOrEmpty(settings["shipping_firstNamePropertyAlias"]) ? settings["shipping_firstNamePropertyAlias"] : "shipping_firstName"];
                createOrderRequest.ShipTo.Name.MiddleNames   = order.Properties[settings.ContainsKey("shipping_middleNamesPropertyAlias") && !string.IsNullOrEmpty(settings["shipping_middleNamesPropertyAlias"]) ? settings["shipping_middleNamesPropertyAlias"] : "shipping_middleNames"];
                createOrderRequest.ShipTo.Name.LastName      = order.Properties[settings.ContainsKey("shipping_lastNamePropertyAlias") && !string.IsNullOrEmpty(settings["shipping_lastNamePropertyAlias"]) ? settings["shipping_lastNamePropertyAlias"] : "shipping_lastName"];
                createOrderRequest.ShipTo.Name.Suffix        = order.Properties[settings.ContainsKey("shipping_suffixPropertyAlias") && !string.IsNullOrEmpty(settings["shipping_suffixPropertyAlias"]) ? settings["shipping_suffixPropertyAlias"] : "shipping_suffix"];
                createOrderRequest.ShipTo.Address.Street1    = order.Properties[settings.ContainsKey("shipping_street1PropertyAlias") && !string.IsNullOrEmpty(settings["shipping_street1PropertyAlias"]) ? settings["shipping_street1PropertyAlias"] : "shipping_streetAddress"];
                createOrderRequest.ShipTo.Address.Street2    = order.Properties[settings.ContainsKey("shipping_street2PropertyAlias") && !string.IsNullOrEmpty(settings["shipping_street2PropertyAlias"]) ? settings["shipping_street2PropertyAlias"] : "shipping_streetAddress2"];
                createOrderRequest.ShipTo.Address.Street3    = order.Properties[settings.ContainsKey("shipping_street3PropertyAlias") && !string.IsNullOrEmpty(settings["shipping_street3PropertyAlias"]) ? settings["shipping_street3PropertyAlias"] : "shipping_streetAddress3"];
                createOrderRequest.ShipTo.Address.Street4    = order.Properties[settings.ContainsKey("shipping_street4PropertyAlias") && !string.IsNullOrEmpty(settings["shipping_street4PropertyAlias"]) ? settings["shipping_street4PropertyAlias"] : "shipping_streetAddress4"];
                createOrderRequest.ShipTo.Address.City       = order.Properties[settings.ContainsKey("shipping_cityPropertyAlias") && !string.IsNullOrEmpty(settings["shipping_cityPropertyAlias"]) ? settings["shipping_cityPropertyAlias"] : "shipping_city"];
                createOrderRequest.ShipTo.Address.PostalCode = order.Properties[settings.ContainsKey("shipping_postalCodePropertyAlias") && !string.IsNullOrEmpty(settings["shipping_postalCodePropertyAlias"]) ? settings["shipping_postalCodePropertyAlias"] : "shipping_zipCode"];
                if (order.ShipmentInformation.CountryRegionId != null)
                {
                    createOrderRequest.ShipTo.Address.RegionCode = CountryRegionService.Instance.Get(order.StoreId, order.ShipmentInformation.CountryRegionId.Value).RegionCode;
                }
                if (order.ShipmentInformation.CountryId != null)
                {
                    createOrderRequest.ShipTo.Address.CountryCode = CountryService.Instance.Get(order.StoreId, order.ShipmentInformation.CountryId.Value).RegionCode;
                }

                #endregion

                CreateOrderResponse createOrderResponse = client.CreateOrder(createOrderRequest);

                //Initialize payment request
                InterfaceOptions         interfaceOptions         = new InterfaceOptions(InterfaceId.Aero, settings["customerLanguageCode"], new Uri(teaCommerceContinueUrl), new Uri(teaCommerceCancelUrl), new Uri(teaCommerceContinueUrl));
                InitializePaymentRequest initializePaymentRequest = new InitializePaymentRequest(createOrderResponse.OrderId, order.TotalPrice.Value.WithVat, PaymentChannelId.Web, interfaceOptions);

                if (settings.ContainsKey("paymentMethods") && !string.IsNullOrEmpty(settings["paymentMethods"]))
                {
                    initializePaymentRequest.WithPaymentMethods(settings["paymentMethods"].Split(',').Select(i => PaynovaPaymentMethod.Custom(int.Parse(i))));
                }


                InitializePaymentResponse initializePaymentResponse = client.InitializePayment(initializePaymentRequest);
                htmlForm.Action = initializePaymentResponse.Url;
            }
            catch (Exception e)
            {
            }

            return(htmlForm);
        }
Example #24
0
        public override PaymentHtmlForm GenerateHtmlForm( Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary<string, string> settings )
        {
            order.MustNotBeNull( "order" );
              settings.MustNotBeNull( "settings" );
              settings.MustContainKey( "accountNumber", "settings" );
              settings.MustContainKey( "purchaseOperation", "settings" );
              settings.MustContainKey( "encryptionKey", "settings" );

              PaymentHtmlForm htmlForm = new PaymentHtmlForm();

              long accountNumber = long.Parse( settings[ "accountNumber" ] );
              string purchaseOperation = settings[ "purchaseOperation" ];
              int price = (int)Math.Round( order.TotalPrice.Value.WithVat * 100M, 0 );
              string priceArgList = string.Empty;

              //Check that the Iso code exists
              Currency currency = CurrencyService.Instance.Get( order.StoreId, order.CurrencyId );
              if ( !Iso4217CurrencyCodes.ContainsKey( currency.IsoCode ) ) {
            throw new Exception( "You must specify an ISO 4217 currency code for the " + currency.Name + " currency" );
              }

              int vat = (int)Math.Round( order.VatRate * 100M * 100M, 0 );
              string orderId = order.CartNumber;
              string productNumber = string.Join( ",", order.OrderLines.Select( ol => ol.Sku ) );
              string description = string.Join( ",", order.OrderLines.Select( ol => ol.Name ) );
              string clientIpAddress = HttpContext.Current.Request.UserHostAddress;
              string clientIdentifier = string.Empty;
              string additionalValues = string.Empty;
              string externalId = string.Empty;
              string returnUrl = teaCommerceContinueUrl;
              const string view = "CREDITCARD";
              string agreementRef = string.Empty;
              string cancelUrl = teaCommerceCancelUrl;
              string clientLanguage = string.Empty;

              string md5Hash = GenerateMD5Hash( accountNumber.ToString( CultureInfo.InvariantCulture ) + purchaseOperation + price.ToString( CultureInfo.InvariantCulture ) + priceArgList + currency.IsoCode + vat.ToString( CultureInfo.InvariantCulture ) + orderId + productNumber + description + clientIpAddress + clientIdentifier + additionalValues + externalId + returnUrl + view + agreementRef + cancelUrl + clientLanguage + settings[ "encryptionKey" ] );

              string xmlReturn = GetPayExServiceClient( settings ).Initialize7( accountNumber, purchaseOperation, price, priceArgList, currency.IsoCode, vat, orderId, productNumber, description, clientIpAddress, clientIdentifier, additionalValues, externalId, returnUrl, view, agreementRef, cancelUrl, clientLanguage, md5Hash );

              XDocument xmlDoc = XDocument.Parse( xmlReturn, LoadOptions.PreserveWhitespace );
              string errorCode = xmlDoc.XPathSelectElement( "//status/errorCode" ).Value;

              if ( errorCode.Equals( "OK" ) ) {
            order.Properties.AddOrUpdate( new CustomProperty( "orderRef", xmlDoc.XPathSelectElement( "//orderRef" ).Value ) { ServerSideOnly = true } );
            order.Save();
            htmlForm.Action = xmlDoc.XPathSelectElement( "//redirectUrl" ).Value;
              } else {
            htmlForm.Action = teaCommerceCancelUrl;
            LoggingService.Instance.Log( "PayEx(" + order.CartNumber + ") - Generate html form error - error code: " + xmlDoc.XPathSelectElement( "//status/description" ).Value );
              }

              return htmlForm;
        }
        public override PaymentHtmlForm GenerateHtmlForm(Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary <string, string> settings)
        {
            order.MustNotBeNull("order");
            settings.MustNotBeNull("settings");
            settings.MustContainKey("merchantnumber", "settings");
            settings.MustContainKey("language", "settings");

            PaymentHtmlForm htmlForm = new PaymentHtmlForm {
                Action = "https://ssl.ditonlinebetalingssystem.dk/integration/ewindow/Default.aspx"
            };

            string[] settingsToExclude = new[] { "iframeelement", "md5securitykey", "webservicepassword", "testMode" };
            htmlForm.InputFields = settings.Where(i => !settingsToExclude.Contains(i.Key)).ToDictionary(i => i.Key, i => i.Value);

            //orderid
            htmlForm.InputFields["orderid"] = order.CartNumber;

            //currency
            Currency currency = CurrencyService.Instance.Get(order.StoreId, order.CurrencyId);

            if (!Iso4217CurrencyCodes.ContainsKey(currency.IsoCode))
            {
                throw new Exception("You must specify an ISO 4217 currency code for the " + currency.Name + " currency");
            }

            htmlForm.InputFields["currency"] = Iso4217CurrencyCodes[currency.IsoCode];

            //amount
            htmlForm.InputFields["amount"] = (order.TotalPrice.Value.WithVat * 100M).ToString("0", CultureInfo.InvariantCulture);

            htmlForm.InputFields["accepturl"]   = teaCommerceContinueUrl;
            htmlForm.InputFields["cancelurl"]   = teaCommerceCancelUrl;
            htmlForm.InputFields["callbackurl"] = teaCommerceCallBackUrl;

            //instantcallback
            htmlForm.InputFields["instantcallback"] = "1";

            //instantcapture
            if (htmlForm.InputFields.ContainsKey("instantcapture") && string.IsNullOrEmpty(htmlForm.InputFields["instantcapture"]))
            {
                htmlForm.InputFields.Remove("instantcapture");
            }

            //cardtype
            if (htmlForm.InputFields.ContainsKey("paymenttype") && string.IsNullOrEmpty(htmlForm.InputFields["paymenttype"]))
            {
                htmlForm.InputFields.Remove("paymenttype");
            }

            //windowstate
            if (htmlForm.InputFields.ContainsKey("windowstate") && string.IsNullOrEmpty(htmlForm.InputFields["windowstate"]))
            {
                htmlForm.InputFields.Remove("windowstate");
            }

            htmlForm.InputFields["ownreceipt"] = "1";

            //ePay dont support to show order line information to the shopper

            //md5securitykey
            if (settings.ContainsKey("md5securitykey") && !string.IsNullOrEmpty(settings["md5securitykey"]))
            {
                htmlForm.InputFields["hash"] = GenerateMD5Hash(string.Join("", htmlForm.InputFields.Values) + settings["md5securitykey"]);
            }

            htmlForm.JavaScriptFunction = SubmitJavascriptFunction(htmlForm.InputFields, settings);

            return(htmlForm);
        }
Example #26
0
        public override PaymentHtmlForm GenerateHtmlForm( Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary<string, string> settings )
        {
            order.MustNotBeNull( "order" );
              settings.MustNotBeNull( "settings" );
              settings.MustContainKey( "merchant", "settings" );
              settings.MustContainKey( "language", "settings" );
              settings.MustContainKey( "md5secret", "settings" );

              PaymentHtmlForm htmlForm = new PaymentHtmlForm {
            Action = "https://secure.quickpay.dk/form/"
              };

              string[] settingsToExclude = new[] { "md5secret" };
              htmlForm.InputFields = settings.Where( i => !settingsToExclude.Contains( i.Key ) ).ToDictionary( i => i.Key, i => i.Value );

              htmlForm.InputFields[ "protocol" ] = "7";
              htmlForm.InputFields[ "msgtype" ] = "authorize";

              //Order name must be between 4 or 20 chars
              string orderName = order.CartNumber;
              while ( orderName.Length < 4 )
            orderName = "0" + orderName;
              if ( orderName.Length > 20 ) {
            throw new Exception( "Cart number of the order can not exceed 20 characters." );
              }
              htmlForm.InputFields[ "ordernumber" ] = orderName;
              htmlForm.InputFields[ "amount" ] = ( order.TotalPrice.Value.WithVat * 100M ).ToString( "0", CultureInfo.InvariantCulture );

              //Check that the Iso code exists
              Currency currency = CurrencyService.Instance.Get( order.StoreId, order.CurrencyId );
              if ( !Iso4217CurrencyCodes.ContainsKey( currency.IsoCode ) ) {
            throw new Exception( "You must specify an ISO 4217 currency code for the " + currency.Name + " currency" );
              }
              htmlForm.InputFields[ "currency" ] = currency.IsoCode;

              htmlForm.InputFields[ "continueurl" ] = teaCommerceContinueUrl;
              htmlForm.InputFields[ "cancelurl" ] = teaCommerceCancelUrl;
              htmlForm.InputFields[ "callbackurl" ] = teaCommerceCallBackUrl;

              //Quickpay dont support to show order line information to the shopper

              //Md5 check sum
              string[] md5CheckSumKeys = { "protocol", "msgtype", "merchant", "language", "ordernumber", "amount", "currency", "continueurl", "cancelurl", "callbackurl", "autocapture", "autofee", "cardtypelock", "description", "group", "testmode", "splitpayment", "forcemobile", "deadline", "cardhash" };
              string md5CheckValue = "";
              foreach ( string key in md5CheckSumKeys ) {
            if ( htmlForm.InputFields.ContainsKey( key ) ) {
              md5CheckValue += htmlForm.InputFields[ key ];
            }
              }
              md5CheckValue += settings[ "md5secret" ];

              htmlForm.InputFields[ "md5check" ] = GenerateMD5Hash( md5CheckValue );

              return htmlForm;
        }
Example #27
0
        public override PaymentHtmlForm GenerateHtmlForm( Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary<string, string> settings )
        {
            order.MustNotBeNull( "order" );
              settings.MustNotBeNull( "settings" );

              PaymentHtmlForm htmlForm = new PaymentHtmlForm {
            Action = "https://www.2checkout.com/checkout/spurchase"
              };

              string[] settingsToExclude = new[] { "secretWord", "streetAddressPropertyAlias", "cityPropertyAlias", "zipCodePropertyAlias", "phonePropertyAlias", "phoneExtensionPropertyAlias", "shipping_firstNamePropertyAlias", "shipping_lastNamePropertyAlias", "shipping_streetAddressPropertyAlias", "shipping_cityPropertyAlias", "shipping_zipCodePropertyAlias" };
              htmlForm.InputFields = settings.Where( i => !settingsToExclude.Contains( i.Key ) ).ToDictionary( i => i.Key, i => i.Value );

              //cartId
              htmlForm.InputFields[ "cart_order_id" ] = order.CartNumber;

              //amount
              htmlForm.InputFields[ "total" ] = order.TotalPrice.Value.WithVat.ToString( "0.00", CultureInfo.InvariantCulture );

              htmlForm.InputFields[ "x_receipt_link_url" ] = teaCommerceContinueUrl;

              //card_holder_name
              htmlForm.InputFields[ "card_holder_name" ] = order.PaymentInformation.FirstName + " " + order.PaymentInformation.LastName;

              //street_address
              if ( settings.ContainsKey( "streetAddressPropertyAlias" ) ) {
            htmlForm.InputFields[ "street_address" ] = order.Properties[ settings[ "streetAddressPropertyAlias" ] ];
              }

              //city
              if ( settings.ContainsKey( "cityPropertyAlias" ) ) {
            htmlForm.InputFields[ "city" ] = order.Properties[ settings[ "cityPropertyAlias" ] ];
              }

              //state
              if ( order.PaymentInformation.CountryRegionId != null ) {
            CountryRegion countryRegion = CountryRegionService.Instance.Get( order.StoreId, order.PaymentInformation.CountryRegionId.Value );
            htmlForm.InputFields[ "state" ] = countryRegion.Name;
              }

              //zip
              if ( settings.ContainsKey( "zipCodePropertyAlias" ) ) {
            htmlForm.InputFields[ "zip" ] = order.Properties[ settings[ "zipCodePropertyAlias" ] ];
              }

              //country
              htmlForm.InputFields[ "country" ] = CountryService.Instance.Get( order.StoreId, order.PaymentInformation.CountryId ).Name;

              //email
              htmlForm.InputFields[ "email" ] = order.PaymentInformation.Email;

              //phone
              if ( settings.ContainsKey( "phonePropertyAlias" ) ) {
            htmlForm.InputFields[ "phone" ] = order.Properties[ settings[ "phonePropertyAlias" ] ];
              }

              //phone_extension
              if ( settings.ContainsKey( "phoneExtensionPropertyAlias" ) ) {
            htmlForm.InputFields[ "phone_extension" ] = order.Properties[ settings[ "phoneExtensionPropertyAlias" ] ];
              }

              //shipping name
              if ( settings.ContainsKey( "shipping_firstNamePropertyAlias" ) && settings.ContainsKey( "shipping_lastNamePropertyAlias" ) ) {
            htmlForm.InputFields[ "ship_name" ] = order.Properties[ settings[ "shipping_firstNamePropertyAlias" ] ] + " " + order.Properties[ settings[ "shipping_lastNamePropertyAlias" ] ];
              }

              //shipping street_address
              if ( settings.ContainsKey( "shipping_streetAddressPropertyAlias" ) ) {
            htmlForm.InputFields[ "ship_street_address" ] = order.Properties[ settings[ "shipping_streetAddressPropertyAlias" ] ];
              }

              //shipping city
              if ( settings.ContainsKey( "shipping_cityPropertyAlias" ) ) {
            htmlForm.InputFields[ "ship_city" ] = order.Properties[ settings[ "shipping_cityPropertyAlias" ] ];
              }

              //shipping state
              if ( order.ShipmentInformation.CountryRegionId != null ) {
            htmlForm.InputFields[ "ship_state" ] = CountryRegionService.Instance.Get( order.StoreId, order.ShipmentInformation.CountryRegionId.Value ).Name;
              }

              //shipping zip
              if ( settings.ContainsKey( "shipping_zipCodePropertyAlias" ) ) {
            htmlForm.InputFields[ "ship_zip" ] = order.Properties[ settings[ "shipping_zipCodePropertyAlias" ] ];
              }

              //shipping country
              if ( order.ShipmentInformation.CountryId != null ) {
            htmlForm.InputFields[ "ship_country" ] = CountryService.Instance.Get( order.StoreId, order.ShipmentInformation.CountryId.Value ).Name;
              }

              //fixed
              htmlForm.InputFields[ "fixed" ] = "Y";

              //skip_landing
              htmlForm.InputFields[ "skip_landing" ] = "1";

              //Testing
              if ( htmlForm.InputFields.ContainsKey( "demo" ) && htmlForm.InputFields[ "demo" ] != "Y" )
            htmlForm.InputFields.Remove( "demo" );

              //fixed
              htmlForm.InputFields[ "id_type" ] = "1";

              return htmlForm;
        }
Example #28
0
        public override PaymentHtmlForm GenerateHtmlForm( Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary<string, string> settings )
        {
            order.MustNotBeNull( "order" );
              settings.MustNotBeNull( "settings" );
              settings.MustContainKey( "payer_agentid", "settings" );
              settings.MustContainKey( "language", "settings" );
              settings.MustContainKey( "payment_methods", "settings" );
              settings.MustContainKey( "md5Key1", "settings" );
              settings.MustContainKey( "md5Key2", "settings" );

              HttpServerUtility server = HttpContext.Current.Server;

              PaymentHtmlForm htmlForm = new PaymentHtmlForm {
            Action = "https://secure.pay-read.se/PostAPI_V1/InitPayFlow"
              };

              //Shop id
              htmlForm.InputFields[ "payer_agentid" ] = server.HtmlEncode( settings[ "payer_agentid" ] );

              //API version
              htmlForm.InputFields[ "payer_xml_writer" ] = "payread_php_0_2_v08";

              XNamespace ns = "http://www.w3.org/2001/XMLSchema-instance";
              XElement payerData = new XElement( "payread_post_api_0_2",
            new XAttribute( XNamespace.Xmlns + "xsi", "http://www.w3.org/2001/XMLSchema-instance" ),
            new XAttribute( ns + "noNamespaceSchemaLocation", "payread_post_api_0_2.xsd" )
              );

              //Seller details
              payerData.Add( new XElement( "seller_details",
            new XElement( "agent_id", server.HtmlEncode( settings[ "payer_agentid" ] ) )
              ) );

              //Buyer details
              payerData.Add( new XElement( "buyer_details",
            new XElement( "first_name", server.HtmlEncode( order.PaymentInformation.FirstName ) ),
            new XElement( "last_name", server.HtmlEncode( order.PaymentInformation.LastName ) ),
            new XElement( "address_line_1", server.HtmlEncode( string.Empty ) ),
            new XElement( "address_line_2", server.HtmlEncode( string.Empty ) ),
            new XElement( "postal_code", server.HtmlEncode( string.Empty ) ),
            new XElement( "city", server.HtmlEncode( string.Empty ) ),
            new XElement( "country_code", server.HtmlEncode( string.Empty ) ),
            new XElement( "phone_home", server.HtmlEncode( string.Empty ) ),
            new XElement( "phone_work", server.HtmlEncode( string.Empty ) ),
            new XElement( "phone_mobile", server.HtmlEncode( string.Empty ) ),
            new XElement( "email", server.HtmlEncode( order.PaymentInformation.Email ) ),
            new XElement( "organisation", server.HtmlEncode( string.Empty ) ),
            new XElement( "orgnr", server.HtmlEncode( string.Empty ) ),
            new XElement( "customer_id", server.HtmlEncode( string.Empty ) )
            //new XElement( "your_reference", server.HtmlEncode( string.Empty ) )
            //new XElement( "options", server.HtmlEncode( string.Empty ) )
              ) );

              //Purchase
              XElement purchaseList = new XElement( "purchase_list" );
              purchaseList.Add( new XElement( "freeform_purchase",
            new XElement( "line_number", 1 ),
            new XElement( "description", server.HtmlEncode( settings.ContainsKey( "totalName" ) ? settings[ "totalName" ] : "Total" ) ),
            new XElement( "item_number", server.HtmlEncode( settings.ContainsKey( "totalSku" ) ? settings[ "totalSku" ] : "0001" ) ),
            new XElement( "price_including_vat", server.HtmlEncode( order.TotalPrice.Value.WithVat.ToString( CultureInfo.InvariantCulture ) ) ),
            new XElement( "vat_percentage", server.HtmlEncode( 0M.ToString( CultureInfo.InvariantCulture ) ) ),
            new XElement( "quantity", server.HtmlEncode( 1M.ToString( CultureInfo.InvariantCulture ) ) )
              ) );

              //Check that the Iso code exists
              Currency currency = CurrencyService.Instance.Get( order.StoreId, order.CurrencyId );
              if ( !Iso4217CurrencyCodes.ContainsKey( currency.IsoCode ) ) {
            throw new Exception( "You must specify an ISO 4217 currency code for the " + currency.Name + " currency" );
              }
              payerData.Add( new XElement( "purchase",
            new XElement( "currency", server.HtmlEncode( currency.IsoCode ) ),
            new XElement( "reference_id", server.HtmlEncode( order.CartNumber ) ),
            purchaseList
              ) );

              //Processing control
              payerData.Add( new XElement( "processing_control",
            new XElement( "success_redirect_url", server.HtmlEncode( teaCommerceContinueUrl ) ),
            new XElement( "authorize_notification_url", server.HtmlEncode( teaCommerceCallBackUrl ) ),
            new XElement( "settle_notification_url", server.HtmlEncode( teaCommerceCallBackUrl ) ),
            new XElement( "redirect_back_to_shop_url", server.HtmlEncode( teaCommerceCancelUrl ) )
              ) );

              //Database overrides
              payerData.Add( new XElement( "database_overrides",
            new XElement( "accepted_payment_methods",
              settings[ "payment_methods" ].Split( new[] { "," }, StringSplitOptions.RemoveEmptyEntries ).Select( i =>
            new XElement( "payment_method", server.HtmlEncode( i ) )
              )
            ),
            new XElement( "debug_mode", server.HtmlEncode( settings.ContainsKey( "settings" ) && settings[ "test_mode" ] == "true" ? "verbose" : "silent" ) ),
            new XElement( "test_mode", server.HtmlEncode( settings.ContainsKey( "settings" ) ? settings[ "test_mode" ] : "false" ) ),
            new XElement( "language", server.HtmlEncode( settings[ "language" ] ) )
              ) );

              //Add all data to the xml document
              XDocument xmlDocument = new XDocument(
            new XDeclaration( "1.0", "ISO-8859-1", "yes" ),
            payerData
              );

              htmlForm.InputFields[ "payer_data" ] = xmlDocument.ToString().ToBase64();
              htmlForm.InputFields[ "payer_checksum" ] = GenerateMD5Hash( settings[ "md5Key1" ] + htmlForm.InputFields[ "payer_data" ] + settings[ "md5Key2" ] );

              return htmlForm;
        }
Example #29
0
        public override PaymentHtmlForm GenerateHtmlForm( Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary<string, string> settings )
        {
            order.MustNotBeNull( "order" );
              settings.MustNotBeNull( "settings" );
              settings.MustContainKey( "merchant_id", "settings" );
              settings.MustContainKey( "agreement_id", "settings" );
              settings.MustContainKey( "autocapture", "settings" );
              settings.MustContainKey( "language", "settings" );
              settings.MustContainKey( "windowApiKey", "settings" );

              PaymentHtmlForm htmlForm = new PaymentHtmlForm {
            Action = "https://payment.quickpay.net"
              };

              htmlForm.InputFields[ "version" ] = "v10";
              htmlForm.InputFields[ "merchant_id" ] = settings[ "merchant_id" ];
              htmlForm.InputFields[ "agreement_id" ] = settings[ "agreement_id" ];
              htmlForm.InputFields[ "autocapture" ] = settings[ "autocapture" ];
              htmlForm.InputFields[ "payment_methods" ] = settings[ "payment_methods" ];

              //Order name must be between 4 or 20 chars
              string orderName = order.CartNumber;
              while ( orderName.Length < 4 )
            orderName = "0" + orderName;
              if ( orderName.Length > 20 ) {
            throw new Exception( "Cart number of the order can not exceed 20 characters." );
              }
              htmlForm.InputFields[ "order_id" ] = orderName;

              htmlForm.InputFields[ "amount" ] = ( order.TotalPrice.Value.WithVat * 100M ).ToString( "0", CultureInfo.InvariantCulture );

              //Check that the Iso code exists
              Currency currency = CurrencyService.Instance.Get( order.StoreId, order.CurrencyId );
              if ( !Iso4217CurrencyCodes.ContainsKey( currency.IsoCode ) ) {
            throw new Exception( "You must specify an ISO 4217 currency code for the " + currency.Name + " currency" );
              }
              htmlForm.InputFields[ "currency" ] = currency.IsoCode;

              htmlForm.InputFields[ "continueurl" ] = teaCommerceContinueUrl;
              htmlForm.InputFields[ "cancelurl" ] = teaCommerceCancelUrl;
              htmlForm.InputFields[ "callbackurl" ] = teaCommerceCallBackUrl;

              htmlForm.InputFields[ "language" ] = settings[ "language" ];

              if ( settings.ContainsKey( "branding_id" ) ) {
            htmlForm.InputFields[ "branding_id" ] = settings[ "branding_id" ];
              }

              if ( settings.ContainsKey( "google_analytics_tracking_id" ) ) {
            htmlForm.InputFields[ "google_analytics_tracking_id" ] = settings[ "google_analytics_tracking_id" ];
              }

              if ( settings.ContainsKey( "google_analytics_client_id" ) ) {
            htmlForm.InputFields[ "google_analytics_client_id" ] = settings[ "google_analytics_client_id" ];
              }

              htmlForm.InputFields[ "checksum" ] = GetChecksum( htmlForm.InputFields, settings[ "windowApiKey" ] );

              return htmlForm;
        }
        public override PaymentHtmlForm GenerateHtmlForm(Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary <string, string> settings)
        {
            order.MustNotBeNull("order");
            settings.MustNotBeNull("settings");
            settings.MustContainKey("SECURITY.SENDER", "settings");
            settings.MustContainKey("USER.LOGIN", "settings");
            settings.MustContainKey("USER.PWD", "settings");
            settings.MustContainKey("TRANSACTION.CHANNEL", "settings");
            settings.MustContainKey("PAYMENT.CODE", "settings");
            settings.MustContainKey("streetAddressPropertyAlias", "settings");
            settings.MustContainKey("cityPropertyAlias", "settings");
            settings.MustContainKey("zipCodePropertyAlias", "settings");
            settings.MustContainKey("TRANSACTION.MODE", "settings");
            settings.MustContainKey("SYSTEM", "settings");
            order.Properties[settings["streetAddressPropertyAlias"]].MustNotBeNullOrEmpty("street address");
            order.Properties[settings["cityPropertyAlias"]].MustNotBeNullOrEmpty("city");
            order.Properties[settings["zipCodePropertyAlias"]].MustNotBeNullOrEmpty("zip code");

            PaymentHtmlForm htmlForm = new PaymentHtmlForm();

            string[] settingsToExclude = new[] { "FRONTEND.RESPONSE_URL", "FRONTEND.CANCEL_URL", "streetAddressPropertyAlias", "cityPropertyAlias", "zipCodePropertyAlias", "SYSTEM" };
            Dictionary <string, string> inputFields = settings.Where(i => !settingsToExclude.Contains(i.Key)).ToDictionary(i => i.Key, i => i.Value);

            inputFields["REQUEST.VERSION"]  = "1.0";
            inputFields["FRONTEND.ENABLED"] = "true";
            inputFields["FRONTEND.POPUP"]   = "false";

            inputFields["IDENTIFICATION.TRANSACTIONID"] = order.CartNumber;

            Currency currency = CurrencyService.Instance.Get(order.StoreId, order.CurrencyId);

            if (!Iso4217CurrencyCodes.ContainsKey(currency.IsoCode))
            {
                throw new Exception("You must specify an ISO 4217 currency code for the " + currency.Name + " currency");
            }
            inputFields["PRESENTATION.CURRENCY"] = currency.IsoCode;
            inputFields["PRESENTATION.AMOUNT"]   = (order.TotalPrice.Value.WithVat).ToString("0.00", CultureInfo.InvariantCulture);

            inputFields["FRONTEND.RESPONSE_URL"] = teaCommerceCallBackUrl;

            inputFields["NAME.GIVEN"]  = order.PaymentInformation.FirstName;
            inputFields["NAME.FAMILY"] = order.PaymentInformation.LastName;

            inputFields["CONTACT.EMAIL"] = order.PaymentInformation.Email;
            inputFields["CONTACT.IP"]    = HttpContext.Current.Request.UserHostAddress;

            inputFields["ADDRESS.STREET"] = order.Properties[settings["streetAddressPropertyAlias"]];
            inputFields["ADDRESS.CITY"]   = order.Properties[settings["cityPropertyAlias"]];
            inputFields["ADDRESS.ZIP"]    = order.Properties[settings["zipCodePropertyAlias"]];

            inputFields["ADDRESS.COUNTRY"] = CountryService.Instance.Get(order.StoreId, order.PaymentInformation.CountryId).RegionCode;
            if (order.PaymentInformation.CountryRegionId != null)
            {
                inputFields["ADDRESS.STATE"] = CountryRegionService.Instance.Get(order.StoreId, order.PaymentInformation.CountryRegionId.Value).RegionCode;
            }

            IDictionary <string, string> responseKvps = MakePostRequest(settings, inputFields);

            if (responseKvps["POST.VALIDATION"].Equals("ACK"))
            {
                htmlForm.Action = HttpContext.Current.Server.UrlDecode(responseKvps["FRONTEND.REDIRECT_URL"]);
            }
            else
            {
                throw new Exception("Generate html failed - error code: " + responseKvps["POST.VALIDATION"]);
            }

            return(htmlForm);
        }
Example #31
0
        public override PaymentHtmlForm GenerateHtmlForm( Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary<string, string> settings )
        {
            order.MustNotBeNull( "order" );
              settings.MustNotBeNull( "settings" );
              settings.MustContainKey( "md5Secret", "settings" );
              settings.MustContainKey( "instId", "settings" );
              settings.MustContainKey( "streetAddressPropertyAlias", "settings" );
              settings.MustContainKey( "cityPropertyAlias", "settings" );
              settings.MustContainKey( "zipCodePropertyAlias", "settings" );
              order.Properties[ settings[ "streetAddressPropertyAlias" ] ].MustNotBeNullOrEmpty( "street address" );
              order.Properties[ settings[ "cityPropertyAlias" ] ].MustNotBeNullOrEmpty( "city" );
              order.Properties[ settings[ "zipCodePropertyAlias" ] ].MustNotBeNullOrEmpty( "zip code" );

              PaymentHtmlForm htmlForm = new PaymentHtmlForm {
            Action = settings.ContainsKey( "testMode" ) && settings[ "testMode" ] == "100" ? "https://secure-test.worldpay.com/wcc/purchase" : "https://secure.worldpay.com/wcc/purchase"
              };

              string[] settingsToExclude = new[] { "md5Secret", "callbackPW", "streetAddressPropertyAlias", "cityPropertyAlias", "zipCodePropertyAlias" };
              htmlForm.InputFields = settings.Where( i => !settingsToExclude.Contains( i.Key ) ).ToDictionary( i => i.Key, i => i.Value );

              //cartId
              htmlForm.InputFields[ "cartId" ] = order.CartNumber;

              //currency
              Currency currency = CurrencyService.Instance.Get( order.StoreId, order.CurrencyId );
              if ( !Iso4217CurrencyCodes.ContainsKey( currency.IsoCode ) ) {
            throw new Exception( "You must specify an ISO 4217 currency code for the " + currency.Name + " currency" );
              }
              htmlForm.InputFields[ "currency" ] = currency.IsoCode;

              //amount
              string amount = order.TotalPrice.Value.WithVat.ToString( "0.00", CultureInfo.InvariantCulture );
              htmlForm.InputFields[ "amount" ] = amount;

              htmlForm.InputFields[ "successURL" ] = teaCommerceContinueUrl;
              htmlForm.InputFields[ "cancelURL" ] = teaCommerceCancelUrl;

              //name
              htmlForm.InputFields[ "name" ] = order.PaymentInformation.FirstName + " " + order.PaymentInformation.LastName;

              //email
              htmlForm.InputFields[ "email" ] = order.PaymentInformation.Email;

              //country
              Country country = CountryService.Instance.Get( order.StoreId, order.PaymentInformation.CountryId );
              htmlForm.InputFields[ "country" ] = country.RegionCode;

              //country region
              if ( order.PaymentInformation.CountryRegionId != null ) {
            CountryRegion countryRegion = CountryRegionService.Instance.Get( order.StoreId, order.PaymentInformation.CountryRegionId.Value );
            htmlForm.InputFields[ "region" ] = countryRegion.RegionCode;
              }

              //address1
              htmlForm.InputFields[ "address1" ] = order.Properties[ settings[ "streetAddressPropertyAlias" ] ];

              //town
              htmlForm.InputFields[ "town" ] = order.Properties[ settings[ "cityPropertyAlias" ] ];

              //postcode
              htmlForm.InputFields[ "postcode" ] = order.Properties[ settings[ "zipCodePropertyAlias" ] ];

              //UI settings
              htmlForm.InputFields[ "noLanguageMenu" ] = string.Empty;
              htmlForm.InputFields[ "hideCurrency" ] = string.Empty;
              htmlForm.InputFields[ "fixContact" ] = string.Empty;
              htmlForm.InputFields[ "hideContact" ] = string.Empty;

              htmlForm.InputFields[ "signatureFields" ] = "amount:currency:instId:cartId";
              htmlForm.InputFields[ "signature" ] = GenerateMD5Hash( settings[ "md5Secret" ] + ":" + amount + ":" + currency.IsoCode + ":" + settings[ "instId" ] + ":" + order.CartNumber );

              //WorldPay dont support to show order line information to the shopper

              return htmlForm;
        }
Example #32
0
        public override PaymentHtmlForm GenerateHtmlForm( Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary<string, string> settings )
        {
            order.MustNotBeNull( "order" );
              settings.MustNotBeNull( "settings" );

              PaymentHtmlForm htmlForm = new PaymentHtmlForm {
            Action = settings.ContainsKey( "isSandbox" ) && settings[ "isSandbox" ] == "1" ? "https://www.sandbox.paypal.com/cgi-bin/webscr" : "https://www.paypal.com/cgi-bin/webscr"
              };

              string[] settingsToExclude = new[] { "USER", "PWD", "SIGNATURE", "isSandbox" };
              htmlForm.InputFields = settings.Where( i => !settingsToExclude.Contains( i.Key ) ).ToDictionary( i => i.Key, i => i.Value );

              htmlForm.InputFields[ "cmd" ] = "_cart";
              htmlForm.InputFields[ "upload" ] = "1";

              //Check that the Iso code exists
              Currency currency = CurrencyService.Instance.Get( order.StoreId, order.CurrencyId );
              if ( !Iso4217CurrencyCodes.ContainsKey( currency.IsoCode ) ) {
            throw new Exception( "You must specify an ISO 4217 currency code for the " + currency.Name + " currency" );
              }
              htmlForm.InputFields[ "currency_code" ] = currency.IsoCode;

              htmlForm.InputFields[ "invoice" ] = order.CartNumber;

              htmlForm.InputFields[ "return" ] = teaCommerceContinueUrl;
              htmlForm.InputFields[ "rm" ] = "2";
              htmlForm.InputFields[ "cancel_return" ] = teaCommerceCancelUrl;
              htmlForm.InputFields[ "notify_url" ] = teaCommerceCallBackUrl;

              htmlForm.InputFields[ "item_name_1" ] = settings.ContainsKey( "totalName" ) ? settings[ "totalName" ] : "Total";
              htmlForm.InputFields[ "item_number_1" ] = settings.ContainsKey( "totalSku" ) ? settings[ "totalSku" ] : "0001";
              htmlForm.InputFields[ "amount_1" ] = order.TotalPrice.Value.WithVat.ToString( "0.00", CultureInfo.InvariantCulture );
              htmlForm.InputFields[ "quantity_1" ] = 1M.ToString( "0", CultureInfo.InvariantCulture );

              return htmlForm;
        }
Example #33
0
        public override PaymentHtmlForm GenerateHtmlForm(Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary <string, string> settings)
        {
            order.MustNotBeNull("order");
            settings.MustNotBeNull("settings");
            settings.MustContainKey("merchant", "settings");
            settings.MustContainKey("md5k1", "settings");
            settings.MustContainKey("md5k2", "settings");

            PaymentHtmlForm htmlForm = new PaymentHtmlForm {
                Action = "https://payment.architrade.com/paymentweb/start.action"
            };

            string[] settingsToExclude = new[] { "md5k1", "md5k2", "apiusername", "apipassword" };
            htmlForm.InputFields = settings.Where(i => !settingsToExclude.Contains(i.Key)).ToDictionary(i => i.Key, i => i.Value);

            htmlForm.InputFields["orderid"] = order.CartNumber;

            string strAmount = (order.TotalPrice.Value.WithVat * 100M).ToString("0", CultureInfo.InvariantCulture);

            htmlForm.InputFields["amount"] = strAmount;

            Currency currency = CurrencyService.Instance.Get(order.StoreId, order.CurrencyId);

            if (!Iso4217CurrencyCodes.ContainsKey(currency.IsoCode))
            {
                throw new Exception("You must specify an ISO 4217 currency code for the " + currency.Name + " currency");
            }
            string currencyStr = Iso4217CurrencyCodes[currency.IsoCode];

            htmlForm.InputFields["currency"] = currencyStr;

            htmlForm.InputFields["accepturl"]   = teaCommerceContinueUrl;
            htmlForm.InputFields["cancelurl"]   = teaCommerceCancelUrl;
            htmlForm.InputFields["callbackurl"] = teaCommerceCallBackUrl;

            if (htmlForm.InputFields.ContainsKey("capturenow") && htmlForm.InputFields["capturenow"] != "1")
            {
                htmlForm.InputFields.Remove("capturenow");
            }

            if (htmlForm.InputFields.ContainsKey("calcfee") && htmlForm.InputFields["calcfee"] != "1")
            {
                htmlForm.InputFields.Remove("calcfee");
            }

            htmlForm.InputFields["uniqueoid"] = string.Empty;

            if (htmlForm.InputFields.ContainsKey("test") && htmlForm.InputFields["test"] != "1")
            {
                htmlForm.InputFields.Remove("test");
            }

            //DIBS dont support to show order line information to the shopper

            //MD5(key2 + MD5(key1 + “merchant=<merchant>&orderid=<orderid> &currency=<cur>&amount=<amount>))
            string md5CheckValue = string.Empty;

            md5CheckValue += settings["md5k1"];
            md5CheckValue += "merchant=" + settings["merchant"];
            md5CheckValue += "&orderid=" + order.CartNumber;
            md5CheckValue += "&currency=" + currencyStr;
            md5CheckValue += "&amount=" + strAmount;

            htmlForm.InputFields["md5key"] = GenerateMD5Hash(settings["md5k2"] + GenerateMD5Hash(md5CheckValue));

            return(htmlForm);
        }
Example #34
0
        public override PaymentHtmlForm GenerateHtmlForm( Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary<string, string> settings )
        {
            order.MustNotBeNull( "order" );
              settings.MustNotBeNull( "settings" );
              settings.MustContainKey( "merchantId", "settings" );

              PaymentHtmlForm htmlForm = new PaymentHtmlForm();

              string[] settingsToExclude = new[] { "accepturl", "cancelurl", "instantcapture", "testMode" };
              htmlForm.InputFields = settings.Where( i => !settingsToExclude.Contains( i.Key ) ).ToDictionary( i => i.Key, i => i.Value );

              //orderNumber
              htmlForm.InputFields[ "orderNumber" ] = order.CartNumber;

              //currencyCode
              Currency currency = CurrencyService.Instance.Get( order.StoreId, order.CurrencyId );
              if ( !Iso4217CurrencyCodes.ContainsKey( currency.IsoCode ) ) {
            throw new Exception( "You must specify an ISO 4217 currency code for the " + currency.Name + " currency" );
              }
              htmlForm.InputFields[ "currencyCode" ] = currency.IsoCode;

              //amount
              htmlForm.InputFields[ "amount" ] = ( order.TotalPrice.Value.WithVat * 100M ).ToString( "0", CultureInfo.InvariantCulture );

              //redirectUrl
              htmlForm.InputFields[ "redirectUrl" ] = teaCommerceCallBackUrl;

              //redirectOnError
              htmlForm.InputFields[ "redirectOnError" ] = "false";

              //paymentMethodList
              if ( htmlForm.InputFields.ContainsKey( "paymentMethodList" ) && string.IsNullOrEmpty( htmlForm.InputFields[ "paymentMethodList" ] ) )
            htmlForm.InputFields.Remove( "paymentMethodList" );

              XDocument xmlResponse = XDocument.Parse( MakePostRequest( settings.ContainsKey( "testMode" ) && settings[ "testMode" ] == "1" ? "https://epayment-test.bbs.no/Netaxept/Register.aspx" : "https://epayment.bbs.no/Netaxept/Register.aspx", htmlForm.InputFields ), LoadOptions.PreserveWhitespace );
              if ( xmlResponse.XPathSelectElement( "//RegisterResponse" ) != null ) {
            //Save the Tea Commerce continue and cancel url so we have access to them in the "Callback"
            order.Properties.AddOrUpdate( new CustomProperty( "teaCommerceContinueUrl", teaCommerceContinueUrl ) { ServerSideOnly = true } );
            order.Properties.AddOrUpdate( new CustomProperty( "teaCommerceCancelUrl", teaCommerceCancelUrl ) { ServerSideOnly = true } );
            order.Save();

            htmlForm.Action = ( settings.ContainsKey( "testMode" ) && settings[ "testMode" ] == "1" ? "https://epayment-test.bbs.no/Terminal/default.aspx" : "https://epayment.bbs.no/Terminal/default.aspx" ) + "?merchantId=" + settings[ "merchantId" ] + "&transactionId=" + xmlResponse.XPathSelectElement( "//TransactionId" ).Value;
              } else {
            throw new Exception( "Generate html failed - error message: " + xmlResponse.XPathSelectElement( "//Error/Message" ).Value );
              }

              return htmlForm;
        }
Example #35
0
        public override PaymentHtmlForm GenerateHtmlForm( Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary<string, string> settings )
        {
            order.MustNotBeNull( "order" );
              settings.MustNotBeNull( "settings" );
              settings.MustContainKey( "shopid", "settings" );

              PaymentHtmlForm htmlForm = new PaymentHtmlForm {
            Action = "https://betaling.wannafind.dk/paymentwindow.php",
            Attributes = { { "id", "wannafind" }, { "name", "wannafind" }, { "target", "_self" } }
              };

              string[] settingsToExclude = new[] { "md5AuthSecret", "md5CallbackSecret", "apiUser", "apiPassword", "testmode" };
              htmlForm.InputFields = settings.Where( i => !settingsToExclude.Contains( i.Key ) ).ToDictionary( i => i.Key, i => i.Value );

              //orderid
              string orderId = order.CartNumber.Replace( StoreService.Instance.Get( order.StoreId ).OrderSettings.CartNumberPrefix, "" );
              htmlForm.InputFields[ "orderid" ] = orderId;

              //currency
              //Check that the Iso code exists
              Currency currency = CurrencyService.Instance.Get( order.StoreId, order.CurrencyId );
              if ( !Iso4217CurrencyCodes.ContainsKey( currency.IsoCode ) ) {
            throw new Exception( "You must specify an ISO 4217 currency code for the " + currency.Name + " currency" );
              }
              string currencyStr = Iso4217CurrencyCodes[ currency.IsoCode ];
              htmlForm.InputFields[ "currency" ] = currencyStr;

              //amount
              string amount = ( order.TotalPrice.Value.WithVat * 100M ).ToString( "0", CultureInfo.InvariantCulture );
              htmlForm.InputFields[ "amount" ] = amount;

              htmlForm.InputFields[ "accepturl" ] = teaCommerceContinueUrl;
              htmlForm.InputFields[ "declineurl" ] = teaCommerceCancelUrl;
              htmlForm.InputFields[ "callbackurl" ] = teaCommerceCallBackUrl;

              //authtype
              htmlForm.InputFields[ "authtype" ] = "auth";

              //paytype
              htmlForm.InputFields[ "paytype" ] = "creditcard";

              //cardtype
              string cardType = string.Empty;
              if ( htmlForm.InputFields.ContainsKey( "cardtype" ) ) {
            cardType = htmlForm.InputFields[ "cardtype" ];
            if ( string.IsNullOrEmpty( cardType ) )
              htmlForm.InputFields.Remove( "cardtype" );
              }

              //uniqueorderid
              htmlForm.InputFields[ "uniqueorderid" ] = "true";

              //cardnomask
              htmlForm.InputFields[ "cardnomask" ] = "true";

              //md5securitykey
              if ( settings.ContainsKey( "md5AuthSecret" ) && !string.IsNullOrEmpty( settings[ "md5AuthSecret" ] ) )
            htmlForm.InputFields[ "checkmd5" ] = GenerateMD5Hash( currencyStr + orderId + amount + cardType + settings[ "md5AuthSecret" ] );

              //wannafind dont support to show order line information to the shopper

              return htmlForm;
        }
Example #36
0
        public override PaymentHtmlForm GenerateHtmlForm( Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary<string, string> settings )
        {
            order.MustNotBeNull( "order" );
              settings.MustNotBeNull( "settings" );
              settings.MustContainKey( "form_url", "settings" );
              settings.MustContainKey( "mode", "settings" );
              settings.MustContainKey( settings[ "mode" ] + "_public_key", "settings" );

              PaymentHtmlForm htmlForm = new PaymentHtmlForm {
            Action = settings[ "form_url" ]
              };

              string[] settingsToExclude = new[] { "form_url", "capture", "test_secret_key", "test_public_key", "live_secret_key", "live_public_key", "mode" };
              htmlForm.InputFields = settings.Where( i => !settingsToExclude.Contains( i.Key ) ).ToDictionary( i => i.Key, i => i.Value );

              htmlForm.InputFields[ "api_key" ] = settings[ settings[ "mode" ] + "_public_key" ];
              htmlForm.InputFields[ "continue_url" ] = teaCommerceContinueUrl;
              htmlForm.InputFields[ "cancel_url" ] = teaCommerceCancelUrl;

              return htmlForm;
        }
Example #37
0
        public override PaymentHtmlForm GenerateHtmlForm( Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary<string, string> settings )
        {
            order.MustNotBeNull( "order" );
              settings.MustNotBeNull( "settings" );
              settings.MustContainKey( "merchantnumber", "settings" );
              settings.MustContainKey( "language", "settings" );

              PaymentHtmlForm htmlForm = new PaymentHtmlForm {
            Action = "https://ssl.ditonlinebetalingssystem.dk/integration/ewindow/Default.aspx"
              };

              string[] settingsToExclude = new[] { "iframeelement", "md5securitykey", "webservicepassword", "testMode" };
              htmlForm.InputFields = settings.Where( i => !settingsToExclude.Contains( i.Key ) ).ToDictionary( i => i.Key, i => i.Value );

              //orderid
              htmlForm.InputFields[ "orderid" ] = order.CartNumber;

              //currency
              Currency currency = CurrencyService.Instance.Get( order.StoreId, order.CurrencyId );
              if ( !Iso4217CurrencyCodes.ContainsKey( currency.IsoCode ) ) {
            throw new Exception( "You must specify an ISO 4217 currency code for the " + currency.Name + " currency" );
              }

              htmlForm.InputFields[ "currency" ] = Iso4217CurrencyCodes[ currency.IsoCode ];

              //amount
              htmlForm.InputFields[ "amount" ] = ( order.TotalPrice.Value.WithVat * 100M ).ToString( "0", CultureInfo.InvariantCulture );

              htmlForm.InputFields[ "accepturl" ] = teaCommerceContinueUrl;
              htmlForm.InputFields[ "cancelurl" ] = teaCommerceCancelUrl;
              htmlForm.InputFields[ "callbackurl" ] = teaCommerceCallBackUrl;

              //instantcallback
              htmlForm.InputFields[ "instantcallback" ] = "1";

              //instantcapture
              if ( htmlForm.InputFields.ContainsKey( "instantcapture" ) && string.IsNullOrEmpty( htmlForm.InputFields[ "instantcapture" ] ) )
            htmlForm.InputFields.Remove( "instantcapture" );

              //cardtype
              if ( htmlForm.InputFields.ContainsKey( "paymenttype" ) && string.IsNullOrEmpty( htmlForm.InputFields[ "paymenttype" ] ) )
            htmlForm.InputFields.Remove( "paymenttype" );

              //windowstate
              if ( htmlForm.InputFields.ContainsKey( "windowstate" ) && string.IsNullOrEmpty( htmlForm.InputFields[ "windowstate" ] ) )
            htmlForm.InputFields.Remove( "windowstate" );

              htmlForm.InputFields[ "ownreceipt" ] = "1";

              //ePay dont support to show order line information to the shopper

              //md5securitykey
              if ( settings.ContainsKey( "md5securitykey" ) && !string.IsNullOrEmpty( settings[ "md5securitykey" ] ) ) {
            htmlForm.InputFields[ "hash" ] = GenerateMD5Hash( string.Join( "", htmlForm.InputFields.Values ) + settings[ "md5securitykey" ] );
              }

              htmlForm.JavaScriptFunction = SubmitJavascriptFunction( htmlForm.InputFields, settings );

              return htmlForm;
        }
        public override PaymentHtmlForm GenerateHtmlForm(Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary <string, string> settings)
        {
            order.MustNotBeNull("order");
            settings.MustNotBeNull("settings");
            settings.MustContainKey("return_url", "settings");

            PaymentHtmlForm htmlForm = new PaymentHtmlForm
            {
                Action = GetHtmlMethodUrl(settings)
            };

            string[] settingsToExclude = new[] { "secret_key", "return_url", "return_cancel_url", "payment_description", "test_mode", "awaiting_transfer_statusid", "awaiting_transfer_update",
                                                 "streetPropertyAlias", "houseNumberPropertyAlias", "postalCodePropertyAlias", "cityPropertyAlias", "shippingStreetPropertyAlias",
                                                 "shippingHouseNumberPropertyAlias", "shippingPostalCodePropertyAlias", "shippingCityPropertyAlias", "sexeAlias", "birthdateAlias", "ibanAlias", "phoneNumberAlias" };



            htmlForm.InputFields = settings.Where(i => !settingsToExclude.Contains(i.Key) && !string.IsNullOrEmpty(i.Value)).ToDictionary(i => i.Key, i => i.Value);

            // Amount
            Currency currency = CurrencyService.Instance.Get(order.StoreId, order.CurrencyId);

            if (!Iso4217CurrencyCodes.ContainsKey(currency.IsoCode))
            {
                throw new Exception("You must specify an ISO 4217 currency code for the " + currency.Name + " currency");
            }
            htmlForm.InputFields["brq_currency"] = currency.IsoCode;
            htmlForm.InputFields["brq_amount"]   = order.TotalPrice.Value.WithVat.ToString("0.00", CultureInfo.InvariantCulture);

            // Reference to order
            htmlForm.InputFields["brq_invoicenumber"] = order.CartNumber;
            htmlForm.InputFields["add_cartnumber"]    = order.CartNumber;

            //Show a nice description when customer arrives in Buckaroo
            if (settings.ContainsKey("payment_description") && settings["payment_description"] != "")
            {
                string paymentDescription = settings["payment_description"];
                if (order.Properties[paymentDescription] != null)
                {
                    htmlForm.InputFields["brq_description"] = order.Properties[paymentDescription];
                }
            }

            // WARN: this gets the URL of the current path as a base path. So you can use relative URL's to the language node of the site.
            string path    = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority);
            string baseUrl = path + String.Concat(HttpContext.Current.Request.Url.Segments.Take(2));

            teaCommerceContinueUrl = GetAbsoluteUrl(baseUrl, settings["return_url"]);
            teaCommerceCancelUrl   = GetAbsoluteUrl(baseUrl, settings["return_cancel_url"]);

            // Interactions
            htmlForm.InputFields["brq_return"]       = teaCommerceContinueUrl;
            htmlForm.InputFields["brq_returncancel"] = teaCommerceCancelUrl;
            htmlForm.InputFields["brq_returnerror"]  = teaCommerceCancelUrl;
            htmlForm.InputFields["brq_returnreject"] = teaCommerceCancelUrl;
            htmlForm.InputFields["brq_push"]         = teaCommerceCallBackUrl;
            htmlForm.InputFields["brq_pushfailure"]  = teaCommerceCallBackUrl;

            // Module info for Buckaroo
            htmlForm.InputFields["brq_module_name"]      = "Tea Commerce Payment Provider for Buckaroo Payments";
            htmlForm.InputFields["brq_module_supplier"]  = "Kresco";
            htmlForm.InputFields["brq_module_version"]   = "1";
            htmlForm.InputFields["brq_platform_name"]    = "Umbraco CMS";
            htmlForm.InputFields["brq_platform_version"] = "6";

            if (settings["brq_payment_method"].Equals("ideal", StringComparison.InvariantCultureIgnoreCase))
            {
                string idealIssuer = order.Properties["ideal_issuer"];
                htmlForm.InputFields["brq_service_ideal_issuer"] = idealIssuer;
            }

            if (settings["brq_requestedservices"].Contains("paymentguarantee"))
            {
                // Information for AfterPay
                htmlForm.InputFields["brq_culture"] = currency.CultureName;
                htmlForm.InputFields["brq_service_paymentguarantee_action"] = "PaymentInvitation"; // Default
                string customerId = order.CustomerId.ToString();
                // Generate random guid for anonymous customers
                if (String.IsNullOrWhiteSpace(customerId))
                {
                    customerId = Guid.NewGuid().ToString();
                }

                htmlForm.InputFields["brq_service_paymentguarantee_CustomerCode"]      = customerId;
                htmlForm.InputFields["brq_service_paymentguarantee_CustomerGender"]    = order.Properties[settings["sexeAlias"]]; // Value, 1 = Male, 2 = Female
                htmlForm.InputFields["brq_service_paymentguarantee_CustomerFirstName"] = order.PaymentInformation.FirstName;
                htmlForm.InputFields["brq_service_paymentguarantee_CustomerBirthDate"] = order.Properties[settings["birthdateAlias"]];
                htmlForm.InputFields["brq_service_paymentguarantee_CustomerLastName"]  = order.PaymentInformation.LastName;
                htmlForm.InputFields["brq_service_paymentguarantee_AmountVat"]         = order.TotalPrice.Value.Vat.ToString("0.00", CultureInfo.InvariantCulture);
                htmlForm.InputFields["brq_service_paymentguarantee_CustomerInitials"]  = order.PaymentInformation.FirstName.Substring(0, 1);
                htmlForm.InputFields["brq_service_paymentguarantee_DateDue"]           = string.Format("{0:yyyy-MM-dd}", DateTime.Now.AddDays(14));
                htmlForm.InputFields["brq_service_paymentguarantee_CustomerIban"]      = order.Properties[settings["ibanAlias"]];
                htmlForm.InputFields["brq_service_paymentguarantee_CustomerEmail"]     = order.Properties["email"];


                // Determine type
                var phonenumber = order.Properties[settings["phoneNumberAlias"]];
                if (phonenumber.StartsWith("06"))
                {
                    htmlForm.InputFields["brq_service_paymentguarantee_MobilePhoneNumber"] = phonenumber;
                }
                else
                {
                    htmlForm.InputFields["brq_service_paymentguarantee_PhoneNumber"] = phonenumber;
                }


                htmlForm.InputFields["brq_service_paymentguarantee_address_AddressType_1"] = "INVOICE";
                htmlForm.InputFields["brq_service_paymentguarantee_address_Street_1"]      = order.Properties[settings["streetPropertyAlias"]];
                htmlForm.InputFields["brq_service_paymentguarantee_address_HouseNumber_1"] = order.Properties[settings["houseNumberPropertyAlias"]];
                // Suffix?
                htmlForm.InputFields["brq_service_paymentguarantee_address_HouseNumberSuffix_1"] = string.Empty;
                htmlForm.InputFields["brq_service_paymentguarantee_address_ZipCode_1"]           = order.Properties[settings["postalCodePropertyAlias"]];
                htmlForm.InputFields["brq_service_paymentguarantee_address_City_1"] = order.Properties[settings["cityPropertyAlias"]];

                Country currentPaymentCountry = CountryService.Instance.Get(order.StoreId, order.PaymentInformation.CountryId);
                htmlForm.InputFields["brq_service_paymentguarantee_address_Country_1"] = currentPaymentCountry.RegionCode;

                htmlForm.InputFields["brq_service_paymentguarantee_address_AddressType_2"] = "SHIPPING";
                if (!String.IsNullOrWhiteSpace(order.Properties[settings["shippingStreetPropertyAlias"]]))
                {
                    htmlForm.InputFields["brq_service_paymentguarantee_address_Street_2"]      = order.Properties[settings["shippingStreetPropertyAlias"]];
                    htmlForm.InputFields["brq_service_paymentguarantee_address_HouseNumber_2"] = order.Properties[settings["shippingHouseNumberPropertyAlias"]];
                    // Suffix?
                    htmlForm.InputFields["brq_service_paymentguarantee_address_HouseNumberSuffix_2"] = string.Empty;
                    htmlForm.InputFields["brq_service_paymentguarantee_address_ZipCode_2"]           = order.Properties[settings["shippingPostalCodePropertyAlias"]];
                    htmlForm.InputFields["brq_service_paymentguarantee_address_City_2"] = order.Properties[settings["shippingCityPropertyAlias"]];

                    Country currentShippingCountry = CountryService.Instance.Get(order.StoreId, order.ShipmentInformation.CountryId.Value);
                    htmlForm.InputFields["brq_service_paymentguarantee_address_Country_2"] = currentShippingCountry.RegionCode;
                }
                else
                {
                    htmlForm.InputFields["brq_service_paymentguarantee_address_Street_2"]      = order.Properties[settings["streetPropertyAlias"]];
                    htmlForm.InputFields["brq_service_paymentguarantee_address_HouseNumber_2"] = order.Properties[settings["houseNumberPropertyAlias"]];
                    // Suffix?
                    htmlForm.InputFields["brq_service_paymentguarantee_address_ZipCode_2"] = order.Properties[settings["postalCodePropertyAlias"]];
                    htmlForm.InputFields["brq_service_paymentguarantee_address_City_2"]    = order.Properties[settings["cityPropertyAlias"]];
                    htmlForm.InputFields["brq_service_paymentguarantee_address_Country_2"] = currentPaymentCountry.RegionCode;
                }
            }

            // Finally generate signature
            htmlForm.InputFields["brq_signature"] = GenerateBuckarooSignature(htmlForm.InputFields, settings);

            return(htmlForm);
        }
Example #39
0
        public override PaymentHtmlForm GenerateHtmlForm(Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary <string, string> settings)
        {
            order.MustNotBeNull("order");
            settings.MustNotBeNull("settings");
            string action    = string.Empty;
            string encrypted = string.Empty;

            try {
                int bvCount = 0;

                IDictionary <string, string> inputFields = PrepareApiPostRequest("BMCreateButton", settings);

                inputFields.Add("BUTTONCODE", "ENCRYPTED");
                inputFields.Add("BUTTONTYPE", "BUYNOW");
                inputFields.Add("BUTTONSUBTYPE", "PRODUCTS");

                bvCount++;
                inputFields.Add($"L_BUTTONVAR{bvCount}", "business=" + (settings.ContainsKey("business") ? settings["business"] : string.Empty).Trim());
                bvCount++;
                inputFields.Add($"L_BUTTONVAR{bvCount}", "lc=" + (settings.ContainsKey("lc") ? settings["lc"] : string.Empty).Trim());
                bvCount++;
                inputFields.Add($"L_BUTTONVAR{bvCount}", "button_subtype=PRODUCTS");

                // Check that the Iso code exists
                Currency currency = CurrencyService.Instance.Get(order.StoreId, order.CurrencyId);
                if (!Iso4217CurrencyCodes.ContainsKey(currency.IsoCode))
                {
                    throw new Exception("You must specify an ISO 4217 currency code for the " + currency.Name + " currency");
                }

                bvCount++;
                inputFields.Add($"L_BUTTONVAR{bvCount}", "currency_code=" + currency.IsoCode);

                bvCount++;
                inputFields.Add($"L_BUTTONVAR{bvCount}", "invoice=" + order.CartNumber);
                bvCount++;
                inputFields.Add($"L_BUTTONVAR{bvCount}", "item_name=" + (settings.ContainsKey("totalName") ? settings["totalName"] : "Total").Trim());
                bvCount++;
                inputFields.Add($"L_BUTTONVAR{bvCount}", "item_number=" + (settings.ContainsKey("totalSku") ? settings["totalSku"] : "0001").Trim());
                bvCount++;
                inputFields.Add($"L_BUTTONVAR{bvCount}", "amount=" + order.TotalPrice.Value.WithVat.ToString("0.00", CultureInfo.InvariantCulture));
                bvCount++;
                inputFields.Add($"L_BUTTONVAR{bvCount}", "quantity=" + 1M.ToString("0", CultureInfo.InvariantCulture));

                bvCount++;
                inputFields.Add($"L_BUTTONVAR{bvCount}", "return=" + teaCommerceContinueUrl);
                bvCount++;
                inputFields.Add($"L_BUTTONVAR{bvCount}", "rm=2");
                bvCount++;
                inputFields.Add($"L_BUTTONVAR{bvCount}", "cancel_return=" + teaCommerceCancelUrl);
                bvCount++;
                inputFields.Add($"L_BUTTONVAR{bvCount}", "notify_url=" + teaCommerceCallBackUrl);

                ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
                string response = MakePostRequest(settings.ContainsKey("isSandbox") && settings["isSandbox"] == "1" ? "https://api-3t.sandbox.paypal.com/nvp" : "https://api-3t.paypal.com/nvp", inputFields);
                IDictionary <string, string> responseKvp = GetApiResponseKvp(response);
                if (responseKvp["ACK"] == "Success" || responseKvp["ACK"] == "SuccessWithWarning")
                {
                    string input = responseKvp["WEBSITECODE"];
                    using (XmlReader reader = XmlReader.Create(new StringReader(input))) {
                        reader.ReadToFollowing("form");
                        reader.MoveToAttribute("action");
                        action = reader.Value.Trim();

                        while (reader.ReadToFollowing("input"))
                        {
                            reader.MoveToAttribute("name");
                            string name = reader.Value.Trim();
                            if (name != "encrypted")
                            {
                                continue;
                            }

                            reader.MoveToAttribute("value");
                            encrypted = reader.Value.Trim();
                            break;
                        }
                    }
                }
                else
                {
                    LoggingService.Instance.Warn <PayPal>("PayPal(" + order.OrderNumber + ") - Error making API request - error code: " + responseKvp["L_ERRORCODE0"]);
                }
            }
            catch (Exception exp) {
                LoggingService.Instance.Error <PayPal>("PayPal(" + order.OrderNumber + ") - GenerateHtmlForm payment", exp);
            }

            PaymentHtmlForm htmlForm = new PaymentHtmlForm {
                Action      = action,
                InputFields = new Dictionary <string, string> {
                    { "cmd", "_s-xclick" },
                    { "encrypted", encrypted }
                }
            };

            return(htmlForm);
        }
Example #40
0
        public override PaymentHtmlForm GenerateHtmlForm(Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary <string, string> settings)
        {
            order.MustNotBeNull("order");
            settings.MustNotBeNull("settings");
            settings.MustContainKey("merchantId", "settings");

            PaymentHtmlForm htmlForm = new PaymentHtmlForm();

            string[] settingsToExclude = new[] { "accepturl", "cancelurl", "instantcapture", "testMode" };
            htmlForm.InputFields = settings.Where(i => !settingsToExclude.Contains(i.Key)).ToDictionary(i => i.Key, i => i.Value);

            //orderNumber
            htmlForm.InputFields["orderNumber"] = order.CartNumber;

            //currencyCode
            Currency currency = CurrencyService.Instance.Get(order.StoreId, order.CurrencyId);

            if (!Iso4217CurrencyCodes.ContainsKey(currency.IsoCode))
            {
                throw new Exception("You must specify an ISO 4217 currency code for the " + currency.Name + " currency");
            }
            htmlForm.InputFields["currencyCode"] = currency.IsoCode;

            //amount
            htmlForm.InputFields["amount"] = (order.TotalPrice.Value.WithVat * 100M).ToString("0", CultureInfo.InvariantCulture);

            //redirectUrl
            htmlForm.InputFields["redirectUrl"] = teaCommerceCallBackUrl;

            //redirectOnError
            htmlForm.InputFields["redirectOnError"] = "false";

            //paymentMethodList
            if (htmlForm.InputFields.ContainsKey("paymentMethodList") && string.IsNullOrEmpty(htmlForm.InputFields["paymentMethodList"]))
            {
                htmlForm.InputFields.Remove("paymentMethodList");
            }

            XDocument xmlResponse = XDocument.Parse(MakePostRequest(settings.ContainsKey("testMode") && settings["testMode"] == "1" ? "https://epayment-test.bbs.no/Netaxept/Register.aspx" : "https://epayment.bbs.no/Netaxept/Register.aspx", htmlForm.InputFields), LoadOptions.PreserveWhitespace);

            if (xmlResponse.XPathSelectElement("//RegisterResponse") != null)
            {
                //Save the Tea Commerce continue and cancel url so we have access to them in the "Callback"
                order.Properties.AddOrUpdate(new CustomProperty("teaCommerceContinueUrl", teaCommerceContinueUrl)
                {
                    ServerSideOnly = true
                });
                order.Properties.AddOrUpdate(new CustomProperty("teaCommerceCancelUrl", teaCommerceCancelUrl)
                {
                    ServerSideOnly = true
                });
                order.Save();

                htmlForm.Action = (settings.ContainsKey("testMode") && settings["testMode"] == "1" ? "https://epayment-test.bbs.no/Terminal/default.aspx" : "https://epayment.bbs.no/Terminal/default.aspx") + "?merchantId=" + settings["merchantId"] + "&transactionId=" + xmlResponse.XPathSelectElement("//TransactionId").Value;
            }
            else
            {
                throw new Exception("Generate html failed - error message: " + xmlResponse.XPathSelectElement("//Error/Message").Value);
            }

            return(htmlForm);
        }
Example #41
0
        public override PaymentHtmlForm GenerateHtmlForm( Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary<string, string> settings )
        {
            order.MustNotBeNull( "order" );
              settings.MustNotBeNull( "settings" );
              settings.MustContainKey( "streetAddressPropertyAlias", "settings" );
              settings.MustContainKey( "cityPropertyAlias", "settings" );
              settings.MustContainKey( "zipCodePropertyAlias", "settings" );
              settings.MustContainKey( "Description", "settings" );

              PaymentHtmlForm htmlForm = new PaymentHtmlForm();

              string[] settingsToExclude = new[] { "streetAddressPropertyAlias", "cityPropertyAlias", "zipCodePropertyAlias", "phonePropertyAlias", "shipping_firstNamePropertyAlias", "shipping_lastNamePropertyAlias", "shipping_streetAddressPropertyAlias", "shipping_cityPropertyAlias", "shipping_zipCodePropertyAlias", "shipping_phonePropertyAlias", "testMode" };
              Dictionary<string, string> inputFields = settings.Where( i => !settingsToExclude.Contains( i.Key ) ).ToDictionary( i => i.Key, i => i.Value );

              inputFields[ "VPSProtocol" ] = "2.23";

              #region Address properties

              string streetAddress = order.Properties[ settings[ "streetAddressPropertyAlias" ] ];
              string city = order.Properties[ settings[ "cityPropertyAlias" ] ];
              string zipCode = order.Properties[ settings[ "zipCodePropertyAlias" ] ];

              streetAddress.MustNotBeNullOrEmpty( "streetAddress" );
              city.MustNotBeNullOrEmpty( "city" );
              zipCode.MustNotBeNullOrEmpty( "zipCode" );

              string shippingFirstName = settings.ContainsKey( "shipping_firstNamePropertyAlias" ) ? order.Properties[ settings[ "shipping_firstNamePropertyAlias" ] ] : "";
              if ( string.IsNullOrEmpty( shippingFirstName ) ) {
            shippingFirstName = order.PaymentInformation.FirstName;
              }

              string shippingLastName = settings.ContainsKey( "shipping_lastNamePropertyAlias" ) ? order.Properties[ settings[ "shipping_lastNamePropertyAlias" ] ] : "";
              if ( string.IsNullOrEmpty( shippingLastName ) ) {
            shippingLastName = order.PaymentInformation.LastName;
              }

              string shippingStreetAddress = settings.ContainsKey( "shipping_streetAddressPropertyAlias" ) ? order.Properties[ settings[ "shipping_streetAddressPropertyAlias" ] ] : "";
              if ( string.IsNullOrEmpty( shippingStreetAddress ) ) {
            shippingStreetAddress = streetAddress;
              }

              string shippingCity = settings.ContainsKey( "shipping_cityPropertyAlias" ) ? order.Properties[ settings[ "shipping_cityPropertyAlias" ] ] : "";
              if ( string.IsNullOrEmpty( shippingCity ) ) {
            shippingCity = city;
              }

              string shippingZipCode = settings.ContainsKey( "shipping_zipCodePropertyAlias" ) ? order.Properties[ settings[ "shipping_zipCodePropertyAlias" ] ] : "";
              if ( string.IsNullOrEmpty( shippingZipCode ) ) {
            shippingZipCode = zipCode;
              }

              #endregion

              if ( order.CartNumber.Length > 40 ) {
            throw new Exception( "Cart number of the order can not exceed 40 characters." );
              }
              inputFields[ "VendorTxCode" ] = order.CartNumber;
              inputFields[ "Amount" ] = order.TotalPrice.Value.WithVat.ToString( "0.00", CultureInfo.InvariantCulture );

              //Check that the Iso code exists
              Currency currency = CurrencyService.Instance.Get( order.StoreId, order.CurrencyId );
              if ( !Iso4217CurrencyCodes.ContainsKey( currency.IsoCode ) ) {
            throw new Exception( "You must specify an ISO 4217 currency code for the " + currency.Name + " currency" );
              }
              inputFields[ "Currency" ] = currency.IsoCode;
              inputFields[ "Description" ] = inputFields[ "Description" ].Truncate( 100 );
              inputFields[ "SuccessURL" ] = teaCommerceContinueUrl;
              inputFields[ "FailureURL" ] = teaCommerceCancelUrl;
              inputFields[ "NotificationURL" ] = teaCommerceCallBackUrl;
              inputFields[ "BillingSurname" ] = order.PaymentInformation.LastName.Truncate( 20 );
              inputFields[ "BillingFirstnames" ] = order.PaymentInformation.FirstName.Truncate( 20 );
              inputFields[ "BillingAddress1" ] = streetAddress.Truncate( 100 );
              inputFields[ "BillingCity" ] = city.Truncate( 40 );
              inputFields[ "BillingPostCode" ] = zipCode.Truncate( 10 );

              Country country = CountryService.Instance.Get( order.StoreId, order.PaymentInformation.CountryId );
              inputFields[ "BillingCountry" ] = country.RegionCode;
              if ( country.RegionCode.ToUpperInvariant() == "US" && order.PaymentInformation.CountryRegionId != null ) {
            CountryRegion countryRegion = CountryRegionService.Instance.Get( order.StoreId, order.PaymentInformation.CountryRegionId.Value );
            inputFields[ "BillingState" ] = countryRegion.RegionCode.Truncate( 2 );
              }
              if ( settings.ContainsKey( "phonePropertyAlias" ) ) {
            inputFields[ "BillingPhone" ] = order.Properties[ settings[ "phonePropertyAlias" ] ].Truncate( 20 );
              }

              inputFields[ "DeliverySurname" ] = shippingLastName.Truncate( 20 );
              inputFields[ "DeliveryFirstnames" ] = shippingFirstName.Truncate( 20 );
              inputFields[ "DeliveryAddress1" ] = shippingStreetAddress.Truncate( 100 );
              inputFields[ "DeliveryCity" ] = shippingCity.Truncate( 40 );
              inputFields[ "DeliveryPostCode" ] = shippingZipCode.Truncate( 10 );

              country = CountryService.Instance.Get( order.StoreId, order.ShipmentInformation.CountryId ?? order.PaymentInformation.CountryId );
              inputFields[ "DeliveryCountry" ] = country.RegionCode;

              long? shippingCountryRegionId = order.ShipmentInformation.CountryId != null ? order.ShipmentInformation.CountryRegionId : order.PaymentInformation.CountryRegionId;
              if ( country.RegionCode.ToUpperInvariant() == "US" && shippingCountryRegionId != null ) {
            CountryRegion countryRegion = CountryRegionService.Instance.Get( order.StoreId, shippingCountryRegionId.Value );
            inputFields[ "DeliveryState" ] = countryRegion.RegionCode.Truncate( 2 );
              }
              if ( settings.ContainsKey( "shipping_phonePropertyAlias" ) ) {
            inputFields[ "DeliveryPhone" ] = order.Properties[ settings[ "shipping_phonePropertyAlias" ] ].Truncate( 20 );
              }

              inputFields[ "Apply3DSecure" ] = "2";

              IDictionary<string, string> responseFields = GetFields( MakePostRequest( GetMethodUrl( "PURCHASE", settings ), inputFields ) );
              string status = responseFields[ "Status" ];

              if ( status == "OK" || status == "OK REPEATED" ) {
            order.Properties.AddOrUpdate( new CustomProperty( "securityKey", responseFields[ "SecurityKey" ] ) { ServerSideOnly = true } );
            order.Properties.AddOrUpdate( new CustomProperty( "teaCommerceContinueUrl", teaCommerceContinueUrl ) { ServerSideOnly = true } );
            order.Properties.AddOrUpdate( new CustomProperty( "teaCommerceCancelUrl", teaCommerceCancelUrl ) { ServerSideOnly = true } );
            order.Save();
            htmlForm.Action = responseFields[ "NextURL" ];
              } else {
            htmlForm.Action = teaCommerceCancelUrl;
            LoggingService.Instance.Log( "Sage Pay(" + order.CartNumber + ") - Generate html form error - status: " + status + " | status details: " + responseFields[ "StatusDetail" ] );
              }

              return htmlForm;
        }
Example #42
0
        public override PaymentHtmlForm GenerateHtmlForm(Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary <string, string> settings)
        {
            order.MustNotBeNull("order");
            settings.MustNotBeNull("settings");
            settings.MustContainKey("merchant", "settings");
            settings.MustContainKey("language", "settings");
            settings.MustContainKey("md5secret", "settings");

            PaymentHtmlForm htmlForm = new PaymentHtmlForm {
                Action = "https://secure.quickpay.dk/form/"
            };

            string[] settingsToExclude = new[] { "md5secret" };
            htmlForm.InputFields = settings.Where(i => !settingsToExclude.Contains(i.Key)).ToDictionary(i => i.Key, i => i.Value);

            htmlForm.InputFields["protocol"] = "7";
            htmlForm.InputFields["msgtype"]  = "authorize";

            //Order name must be between 4 or 20 chars
            string orderName = order.CartNumber;

            while (orderName.Length < 4)
            {
                orderName = "0" + orderName;
            }
            if (orderName.Length > 20)
            {
                throw new Exception("Cart number of the order can not exceed 20 characters.");
            }
            htmlForm.InputFields["ordernumber"] = orderName;
            htmlForm.InputFields["amount"]      = (order.TotalPrice.Value.WithVat * 100M).ToString("0", CultureInfo.InvariantCulture);

            //Check that the Iso code exists
            Currency currency = CurrencyService.Instance.Get(order.StoreId, order.CurrencyId);

            if (!Iso4217CurrencyCodes.ContainsKey(currency.IsoCode))
            {
                throw new Exception("You must specify an ISO 4217 currency code for the " + currency.Name + " currency");
            }
            htmlForm.InputFields["currency"] = currency.IsoCode;

            htmlForm.InputFields["continueurl"] = teaCommerceContinueUrl;
            htmlForm.InputFields["cancelurl"]   = teaCommerceCancelUrl;
            htmlForm.InputFields["callbackurl"] = teaCommerceCallBackUrl;

            //Quickpay dont support to show order line information to the shopper

            //Md5 check sum
            string[] md5CheckSumKeys = { "protocol", "msgtype", "merchant", "language", "ordernumber", "amount", "currency", "continueurl", "cancelurl", "callbackurl", "autocapture", "autofee", "cardtypelock", "description", "group", "testmode", "splitpayment", "forcemobile", "deadline", "cardhash" };
            string   md5CheckValue   = "";

            foreach (string key in md5CheckSumKeys)
            {
                if (htmlForm.InputFields.ContainsKey(key))
                {
                    md5CheckValue += htmlForm.InputFields[key];
                }
            }
            md5CheckValue += settings["md5secret"];

            htmlForm.InputFields["md5check"] = GenerateMD5Hash(md5CheckValue);

            return(htmlForm);
        }
Example #43
0
        public override PaymentHtmlForm GenerateHtmlForm( Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary<string, string> settings )
        {
            order.MustNotBeNull( "order" );
              settings.MustNotBeNull( "settings" );
              settings.MustContainKey( "SHAINPASSPHRASE", "settings" );

              PaymentHtmlForm htmlForm = new PaymentHtmlForm {
            Action = GetMethodUrl( "GENERATEFORM", settings )
              };

              string[] settingsToExclude = new[] { "SHAINPASSPHRASE", "SHAOUTPASSPHRASE", "APIUSERID", "APIPASSWORD", "TESTMODE" };
              htmlForm.InputFields = settings.Where( i => !settingsToExclude.Contains( i.Key ) && !string.IsNullOrEmpty( i.Value ) ).ToDictionary( i => i.Key.ToUpperInvariant(), i => i.Value );

              htmlForm.InputFields[ "ORDERID" ] = order.CartNumber;
              htmlForm.InputFields[ "AMOUNT" ] = ( order.TotalPrice.Value.WithVat * 100M ).ToString( "0", CultureInfo.InvariantCulture );

              //Check that the Iso code exists
              Currency currency = CurrencyService.Instance.Get( order.StoreId, order.CurrencyId );
              if ( !Iso4217CurrencyCodes.ContainsKey( currency.IsoCode ) ) {
            throw new Exception( "You must specify an ISO 4217 currency code for the " + currency.Name + " currency" );
              }
              htmlForm.InputFields[ "CURRENCY" ] = currency.IsoCode;

              htmlForm.InputFields[ "CN" ] = order.PaymentInformation.FirstName + " " + order.PaymentInformation.LastName;
              htmlForm.InputFields[ "EMAIL" ] = order.PaymentInformation.Email;
              htmlForm.InputFields[ "ACCEPTURL" ] = teaCommerceContinueUrl;
              htmlForm.InputFields[ "DECLINEURL" ] = teaCommerceCancelUrl;
              htmlForm.InputFields[ "EXCEPTIONURL" ] = teaCommerceCancelUrl;
              htmlForm.InputFields[ "CANCELURL" ] = teaCommerceCancelUrl;

              //Ogone dont support to show order line information to the shopper

              string strToHash = string.Join( "", htmlForm.InputFields.OrderBy( i => i.Key ).Select( i => i.Key + "=" + i.Value + settings[ "SHAINPASSPHRASE" ] ) );
              htmlForm.InputFields[ "SHASIGN" ] = new SHA512Managed().ComputeHash( Encoding.UTF8.GetBytes( strToHash ) ).ToHex();

              return htmlForm;
        }
        public override PaymentHtmlForm GenerateHtmlForm(Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary <string, string> settings)
        {
            order.MustNotBeNull("order");
            settings.MustNotBeNull("settings");

            PaymentHtmlForm htmlForm = new PaymentHtmlForm {
                Action = "https://www.2checkout.com/checkout/spurchase"
            };

            string[] settingsToExclude = new[] { "secretWord", "streetAddressPropertyAlias", "cityPropertyAlias", "zipCodePropertyAlias", "phonePropertyAlias", "phoneExtensionPropertyAlias", "shipping_firstNamePropertyAlias", "shipping_lastNamePropertyAlias", "shipping_streetAddressPropertyAlias", "shipping_cityPropertyAlias", "shipping_zipCodePropertyAlias" };
            htmlForm.InputFields = settings.Where(i => !settingsToExclude.Contains(i.Key)).ToDictionary(i => i.Key, i => i.Value);

            //cartId
            htmlForm.InputFields["cart_order_id"] = order.CartNumber;

            //amount
            htmlForm.InputFields["total"] = order.TotalPrice.Value.WithVat.ToString("0.00", CultureInfo.InvariantCulture);

            htmlForm.InputFields["x_receipt_link_url"] = teaCommerceContinueUrl;

            //card_holder_name
            htmlForm.InputFields["card_holder_name"] = order.PaymentInformation.FirstName + " " + order.PaymentInformation.LastName;

            //street_address
            if (settings.ContainsKey("streetAddressPropertyAlias"))
            {
                htmlForm.InputFields["street_address"] = order.Properties[settings["streetAddressPropertyAlias"]];
            }

            //city
            if (settings.ContainsKey("cityPropertyAlias"))
            {
                htmlForm.InputFields["city"] = order.Properties[settings["cityPropertyAlias"]];
            }

            //state
            if (order.PaymentInformation.CountryRegionId != null)
            {
                CountryRegion countryRegion = CountryRegionService.Instance.Get(order.StoreId, order.PaymentInformation.CountryRegionId.Value);
                htmlForm.InputFields["state"] = countryRegion.Name;
            }

            //zip
            if (settings.ContainsKey("zipCodePropertyAlias"))
            {
                htmlForm.InputFields["zip"] = order.Properties[settings["zipCodePropertyAlias"]];
            }

            //country
            htmlForm.InputFields["country"] = CountryService.Instance.Get(order.StoreId, order.PaymentInformation.CountryId).Name;

            //email
            htmlForm.InputFields["email"] = order.PaymentInformation.Email;

            //phone
            if (settings.ContainsKey("phonePropertyAlias"))
            {
                htmlForm.InputFields["phone"] = order.Properties[settings["phonePropertyAlias"]];
            }

            //phone_extension
            if (settings.ContainsKey("phoneExtensionPropertyAlias"))
            {
                htmlForm.InputFields["phone_extension"] = order.Properties[settings["phoneExtensionPropertyAlias"]];
            }

            //shipping name
            if (settings.ContainsKey("shipping_firstNamePropertyAlias") && settings.ContainsKey("shipping_lastNamePropertyAlias"))
            {
                htmlForm.InputFields["ship_name"] = order.Properties[settings["shipping_firstNamePropertyAlias"]] + " " + order.Properties[settings["shipping_lastNamePropertyAlias"]];
            }

            //shipping street_address
            if (settings.ContainsKey("shipping_streetAddressPropertyAlias"))
            {
                htmlForm.InputFields["ship_street_address"] = order.Properties[settings["shipping_streetAddressPropertyAlias"]];
            }

            //shipping city
            if (settings.ContainsKey("shipping_cityPropertyAlias"))
            {
                htmlForm.InputFields["ship_city"] = order.Properties[settings["shipping_cityPropertyAlias"]];
            }

            //shipping state
            if (order.ShipmentInformation.CountryRegionId != null)
            {
                htmlForm.InputFields["ship_state"] = CountryRegionService.Instance.Get(order.StoreId, order.ShipmentInformation.CountryRegionId.Value).Name;
            }

            //shipping zip
            if (settings.ContainsKey("shipping_zipCodePropertyAlias"))
            {
                htmlForm.InputFields["ship_zip"] = order.Properties[settings["shipping_zipCodePropertyAlias"]];
            }

            //shipping country
            if (order.ShipmentInformation.CountryId != null)
            {
                htmlForm.InputFields["ship_country"] = CountryService.Instance.Get(order.StoreId, order.ShipmentInformation.CountryId.Value).Name;
            }

            //fixed
            htmlForm.InputFields["fixed"] = "Y";

            //skip_landing
            htmlForm.InputFields["skip_landing"] = "1";

            //Testing
            if (htmlForm.InputFields.ContainsKey("demo") && htmlForm.InputFields["demo"] != "Y")
            {
                htmlForm.InputFields.Remove("demo");
            }

            //fixed
            htmlForm.InputFields["id_type"] = "1";

            return(htmlForm);
        }
        public override PaymentHtmlForm GenerateHtmlForm(Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary <string, string> settings)
        {
            order.MustNotBeNull("order");
            settings.MustNotBeNull("settings");
            settings.MustContainKey("payer_agentid", "settings");
            settings.MustContainKey("language", "settings");
            settings.MustContainKey("payment_methods", "settings");
            settings.MustContainKey("md5Key1", "settings");
            settings.MustContainKey("md5Key2", "settings");

            HttpServerUtility server = HttpContext.Current.Server;

            PaymentHtmlForm htmlForm = new PaymentHtmlForm
            {
                Action = "https://secure.pay-read.se/PostAPI_V1/InitPayFlow"
            };

            //Shop id
            htmlForm.InputFields["payer_agentid"] = server.HtmlEncode(settings["payer_agentid"]);

            //API version
            htmlForm.InputFields["payer_xml_writer"] = "payread_php_0_2_v08";

            XNamespace ns        = "http://www.w3.org/2001/XMLSchema-instance";
            XElement   payerData = new XElement("payread_post_api_0_2",
                                                new XAttribute(XNamespace.Xmlns + "xsi", "http://www.w3.org/2001/XMLSchema-instance"),
                                                new XAttribute(ns + "noNamespaceSchemaLocation", "payread_post_api_0_2.xsd")
                                                );

            //Seller details
            payerData.Add(new XElement("seller_details",
                                       new XElement("agent_id", server.HtmlEncode(settings["payer_agentid"]))
                                       ));

            //Buyer details
            payerData.Add(new XElement("buyer_details",
                                       new XElement("first_name", server.HtmlEncode(order.PaymentInformation.FirstName)),
                                       new XElement("last_name", server.HtmlEncode(order.PaymentInformation.LastName)),
                                       new XElement("address_line_1", server.HtmlEncode(string.Empty)),
                                       new XElement("address_line_2", server.HtmlEncode(string.Empty)),
                                       new XElement("postal_code", server.HtmlEncode(string.Empty)),
                                       new XElement("city", server.HtmlEncode(string.Empty)),
                                       new XElement("country_code", server.HtmlEncode(string.Empty)),
                                       new XElement("phone_home", server.HtmlEncode(string.Empty)),
                                       new XElement("phone_work", server.HtmlEncode(string.Empty)),
                                       new XElement("phone_mobile", server.HtmlEncode(string.Empty)),
                                       new XElement("email", server.HtmlEncode(order.PaymentInformation.Email)),
                                       new XElement("organisation", server.HtmlEncode(string.Empty)),
                                       new XElement("orgnr", server.HtmlEncode(string.Empty)),
                                       new XElement("customer_id", server.HtmlEncode(string.Empty))
                                       //new XElement( "your_reference", server.HtmlEncode( string.Empty ) )
                                       //new XElement( "options", server.HtmlEncode( string.Empty ) )
                                       ));

            //Purchase
            XElement purchaseList = new XElement("purchase_list");

            purchaseList.Add(new XElement("freeform_purchase",
                                          new XElement("line_number", 1),
                                          new XElement("description", server.HtmlEncode(settings.ContainsKey("totalName") ? settings["totalName"] : "Total")),
                                          new XElement("item_number", server.HtmlEncode(settings.ContainsKey("totalSku") ? settings["totalSku"] : "0001")),
                                          new XElement("price_including_vat", server.HtmlEncode(order.TotalPrice.Value.WithVat.ToString(CultureInfo.InvariantCulture))),
                                          new XElement("vat_percentage", server.HtmlEncode(0M.ToString(CultureInfo.InvariantCulture))),
                                          new XElement("quantity", server.HtmlEncode(1M.ToString(CultureInfo.InvariantCulture)))
                                          ));

            //Check that the Iso code exists
            Currency currency = CurrencyService.Instance.Get(order.StoreId, order.CurrencyId);

            if (!Iso4217CurrencyCodes.ContainsKey(currency.IsoCode))
            {
                throw new Exception("You must specify an ISO 4217 currency code for the " + currency.Name + " currency");
            }
            payerData.Add(new XElement("purchase",
                                       new XElement("currency", server.HtmlEncode(currency.IsoCode)),
                                       new XElement("reference_id", server.HtmlEncode(order.CartNumber)),
                                       purchaseList
                                       ));

            //Processing control
            payerData.Add(new XElement("processing_control",
                                       new XElement("success_redirect_url", server.HtmlEncode(teaCommerceContinueUrl)),
                                       new XElement("authorize_notification_url", server.HtmlEncode(teaCommerceCallBackUrl)),
                                       new XElement("settle_notification_url", server.HtmlEncode(teaCommerceCallBackUrl)),
                                       new XElement("redirect_back_to_shop_url", server.HtmlEncode(teaCommerceCancelUrl))
                                       ));

            //Database overrides
            payerData.Add(new XElement("database_overrides",
                                       new XElement("accepted_payment_methods",
                                                    settings["payment_methods"].Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(i =>
                                                                                                                                                   new XElement("payment_method", server.HtmlEncode(i))
                                                                                                                                                   )
                                                    ),
                                       new XElement("debug_mode", server.HtmlEncode(settings.ContainsKey("settings") && settings["test_mode"] == "true" ? "verbose" : "silent")),
                                       new XElement("test_mode", server.HtmlEncode(settings.ContainsKey("settings") ? settings["test_mode"] : "false")),
                                       new XElement("language", server.HtmlEncode(settings["language"]))
                                       ));

            //Add all data to the xml document
            XDocument xmlDocument = new XDocument(
                new XDeclaration("1.0", "ISO-8859-1", "yes"),
                payerData
                );

            htmlForm.InputFields["payer_data"]     = xmlDocument.ToString().ToBase64();
            htmlForm.InputFields["payer_checksum"] = GenerateMD5Hash(settings["md5Key1"] + htmlForm.InputFields["payer_data"] + settings["md5Key2"]);

            return(htmlForm);
        }
Example #46
0
        public override PaymentHtmlForm GenerateHtmlForm( Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary<string, string> settings )
        {
            order.MustNotBeNull( "order" );
              settings.MustNotBeNull( "settings" );
              settings.MustContainKey( "customerLanguageCode", "settings" );
              settings.MustContainKey( "testMode", "settings" );

              PaymentHtmlForm htmlForm = new PaymentHtmlForm();

              IPaynovaClient client = GetClient( settings );

              Currency currency = CurrencyService.Instance.Get( order.StoreId, order.CurrencyId );
              if ( !Iso4217CurrencyCodes.ContainsKey( currency.IsoCode ) ) {
            throw new Exception( "You must specify an ISO 4217 currency code for the " + currency.Name + " currency" );
              }
              try {
            //Create order request
            CreateOrderRequest createOrderRequest = new CreateOrderRequest( order.CartNumber, currency.IsoCode, order.TotalPrice.Value.WithVat ) {
              Customer = new Customer(),
              BillTo = new NameAndAddress(),
              ShipTo = new NameAndAddress()
            };

            #region Customer information

            createOrderRequest.Customer.EmailAddress = order.PaymentInformation.Email;
            createOrderRequest.Customer.Name.CompanyName = createOrderRequest.BillTo.Name.CompanyName = order.Properties[ settings.ContainsKey( "companyPropertyAlias" ) && !string.IsNullOrEmpty( settings[ "companyPropertyAlias" ] ) ? settings[ "companyPropertyAlias" ] : "company" ];
            createOrderRequest.Customer.Name.Title = createOrderRequest.BillTo.Name.Title = order.Properties[ settings.ContainsKey( "titlePropertyAlias" ) && !string.IsNullOrEmpty( settings[ "titlePropertyAlias" ] ) ? settings[ "titlePropertyAlias" ] : "title" ];
            createOrderRequest.Customer.Name.FirstName = createOrderRequest.BillTo.Name.FirstName = order.PaymentInformation.FirstName;
            createOrderRequest.Customer.Name.MiddleNames = createOrderRequest.BillTo.Name.MiddleNames = order.Properties[ settings.ContainsKey( "middleNamesPropertyAlias" ) && !string.IsNullOrEmpty( settings[ "middleNamesPropertyAlias" ] ) ? settings[ "middleNamesPropertyAlias" ] : "middleNames" ];
            createOrderRequest.Customer.Name.LastName = createOrderRequest.BillTo.Name.LastName = order.PaymentInformation.LastName;
            createOrderRequest.Customer.Name.Suffix = createOrderRequest.BillTo.Name.Suffix = order.Properties[ settings.ContainsKey( "suffixPropertyAlias" ) && !string.IsNullOrEmpty( settings[ "suffixPropertyAlias" ] ) ? settings[ "suffixPropertyAlias" ] : "suffix" ];
            createOrderRequest.Customer.HomeTelephone = order.Properties[ settings.ContainsKey( "homeTelephonePropertyAlias" ) && !string.IsNullOrEmpty( settings[ "homeTelephonePropertyAlias" ] ) ? settings[ "homeTelephonePropertyAlias" ] : "phone" ];
            createOrderRequest.Customer.WorkTelephone = order.Properties[ settings.ContainsKey( "workTelephonePropertyAlias" ) && !string.IsNullOrEmpty( settings[ "workTelephonePropertyAlias" ] ) ? settings[ "workTelephonePropertyAlias" ] : "workPhone" ];
            createOrderRequest.Customer.MobileTelephone = order.Properties[ settings.ContainsKey( "mobileTelephonePropertyAlias" ) && !string.IsNullOrEmpty( settings[ "mobileTelephonePropertyAlias" ] ) ? settings[ "mobileTelephonePropertyAlias" ] : "mobile" ];
            createOrderRequest.BillTo.Address.Street1 = order.Properties[ settings.ContainsKey( "street1PropertyAlias" ) && !string.IsNullOrEmpty( settings[ "street1PropertyAlias" ] ) ? settings[ "street1PropertyAlias" ] : "streetAddress" ];
            createOrderRequest.BillTo.Address.Street2 = order.Properties[ settings.ContainsKey( "street2PropertyAlias" ) && !string.IsNullOrEmpty( settings[ "street2PropertyAlias" ] ) ? settings[ "street2PropertyAlias" ] : "streetAddress2" ];
            createOrderRequest.BillTo.Address.Street3 = order.Properties[ settings.ContainsKey( "street3PropertyAlias" ) && !string.IsNullOrEmpty( settings[ "street3PropertyAlias" ] ) ? settings[ "street3PropertyAlias" ] : "streetAddress3" ];
            createOrderRequest.BillTo.Address.Street4 = order.Properties[ settings.ContainsKey( "street4PropertyAlias" ) && !string.IsNullOrEmpty( settings[ "street4PropertyAlias" ] ) ? settings[ "street4PropertyAlias" ] : "streetAddress4" ];
            createOrderRequest.BillTo.Address.City = order.Properties[ settings.ContainsKey( "cityPropertyAlias" ) && !string.IsNullOrEmpty( settings[ "cityPropertyAlias" ] ) ? settings[ "cityPropertyAlias" ] : "city" ];
            createOrderRequest.BillTo.Address.PostalCode = order.Properties[ settings.ContainsKey( "postalCodePropertyAlias" ) && !string.IsNullOrEmpty( settings[ "postalCodePropertyAlias" ] ) ? settings[ "postalCodePropertyAlias" ] : "zipCode" ];
            if ( order.PaymentInformation.CountryRegionId != null ) {
              createOrderRequest.BillTo.Address.RegionCode = CountryRegionService.Instance.Get( order.StoreId, order.PaymentInformation.CountryRegionId.Value ).RegionCode;
            }
            createOrderRequest.BillTo.Address.CountryCode = CountryService.Instance.Get( order.StoreId, order.PaymentInformation.CountryId ).RegionCode;

            createOrderRequest.ShipTo.Name.CompanyName = order.Properties[ settings.ContainsKey( "shipping_companyPropertyAlias" ) && !string.IsNullOrEmpty( settings[ "shipping_companyPropertyAlias" ] ) ? settings[ "shipping_companyPropertyAlias" ] : "shipping_company" ];
            createOrderRequest.ShipTo.Name.Title = order.Properties[ settings.ContainsKey( "shipping_titlePropertyAlias" ) && !string.IsNullOrEmpty( settings[ "shipping_titlePropertyAlias" ] ) ? settings[ "shipping_titlePropertyAlias" ] : "shipping_title" ];
            createOrderRequest.ShipTo.Name.FirstName = order.Properties[ settings.ContainsKey( "shipping_firstNamePropertyAlias" ) && !string.IsNullOrEmpty( settings[ "shipping_firstNamePropertyAlias" ] ) ? settings[ "shipping_firstNamePropertyAlias" ] : "shipping_firstName" ];
            createOrderRequest.ShipTo.Name.MiddleNames = order.Properties[ settings.ContainsKey( "shipping_middleNamesPropertyAlias" ) && !string.IsNullOrEmpty( settings[ "shipping_middleNamesPropertyAlias" ] ) ? settings[ "shipping_middleNamesPropertyAlias" ] : "shipping_middleNames" ];
            createOrderRequest.ShipTo.Name.LastName = order.Properties[ settings.ContainsKey( "shipping_lastNamePropertyAlias" ) && !string.IsNullOrEmpty( settings[ "shipping_lastNamePropertyAlias" ] ) ? settings[ "shipping_lastNamePropertyAlias" ] : "shipping_lastName" ];
            createOrderRequest.ShipTo.Name.Suffix = order.Properties[ settings.ContainsKey( "shipping_suffixPropertyAlias" ) && !string.IsNullOrEmpty( settings[ "shipping_suffixPropertyAlias" ] ) ? settings[ "shipping_suffixPropertyAlias" ] : "shipping_suffix" ];
            createOrderRequest.ShipTo.Address.Street1 = order.Properties[ settings.ContainsKey( "shipping_street1PropertyAlias" ) && !string.IsNullOrEmpty( settings[ "shipping_street1PropertyAlias" ] ) ? settings[ "shipping_street1PropertyAlias" ] : "shipping_streetAddress" ];
            createOrderRequest.ShipTo.Address.Street2 = order.Properties[ settings.ContainsKey( "shipping_street2PropertyAlias" ) && !string.IsNullOrEmpty( settings[ "shipping_street2PropertyAlias" ] ) ? settings[ "shipping_street2PropertyAlias" ] : "shipping_streetAddress2" ];
            createOrderRequest.ShipTo.Address.Street3 = order.Properties[ settings.ContainsKey( "shipping_street3PropertyAlias" ) && !string.IsNullOrEmpty( settings[ "shipping_street3PropertyAlias" ] ) ? settings[ "shipping_street3PropertyAlias" ] : "shipping_streetAddress3" ];
            createOrderRequest.ShipTo.Address.Street4 = order.Properties[ settings.ContainsKey( "shipping_street4PropertyAlias" ) && !string.IsNullOrEmpty( settings[ "shipping_street4PropertyAlias" ] ) ? settings[ "shipping_street4PropertyAlias" ] : "shipping_streetAddress4" ];
            createOrderRequest.ShipTo.Address.City = order.Properties[ settings.ContainsKey( "shipping_cityPropertyAlias" ) && !string.IsNullOrEmpty( settings[ "shipping_cityPropertyAlias" ] ) ? settings[ "shipping_cityPropertyAlias" ] : "shipping_city" ];
            createOrderRequest.ShipTo.Address.PostalCode = order.Properties[ settings.ContainsKey( "shipping_postalCodePropertyAlias" ) && !string.IsNullOrEmpty( settings[ "shipping_postalCodePropertyAlias" ] ) ? settings[ "shipping_postalCodePropertyAlias" ] : "shipping_zipCode" ];
            if ( order.ShipmentInformation.CountryRegionId != null ) {
              createOrderRequest.ShipTo.Address.RegionCode = CountryRegionService.Instance.Get( order.StoreId, order.ShipmentInformation.CountryRegionId.Value ).RegionCode;
            }
            if ( order.ShipmentInformation.CountryId != null ) {
              createOrderRequest.ShipTo.Address.CountryCode = CountryService.Instance.Get( order.StoreId, order.ShipmentInformation.CountryId.Value ).RegionCode;
            }

            #endregion

            CreateOrderResponse createOrderResponse = client.CreateOrder( createOrderRequest );

            //Initialize payment request
            InterfaceOptions interfaceOptions = new InterfaceOptions( InterfaceId.Aero, settings[ "customerLanguageCode" ], new Uri( teaCommerceContinueUrl ), new Uri( teaCommerceCancelUrl ), new Uri( teaCommerceContinueUrl ) );
            InitializePaymentRequest initializePaymentRequest = new InitializePaymentRequest( createOrderResponse.OrderId, order.TotalPrice.Value.WithVat, PaymentChannelId.Web, interfaceOptions );

            if ( settings.ContainsKey( "paymentMethods" ) && !string.IsNullOrEmpty( settings[ "paymentMethods" ] ) ) {
              initializePaymentRequest.WithPaymentMethods( settings[ "paymentMethods" ].Split( ',' ).Select( i => PaynovaPaymentMethod.Custom( int.Parse( i ) ) ) );
            }

            InitializePaymentResponse initializePaymentResponse = client.InitializePayment( initializePaymentRequest );
            htmlForm.Action = initializePaymentResponse.Url;
              } catch ( Exception e ) {

              }

              return htmlForm;
        }